forked from I2P_Developers/i2p.i2p
i2psnark: display peer version when available
This commit is contained in:
@ -42,7 +42,7 @@ import org.klomp.snark.bencode.InvalidBEncodingException;
|
|||||||
* and the PeerID is not required.
|
* and the PeerID is not required.
|
||||||
* Equality is now determined solely by the dest hash.
|
* Equality is now determined solely by the dest hash.
|
||||||
*/
|
*/
|
||||||
class PeerID implements Comparable<PeerID>
|
public class PeerID implements Comparable<PeerID>
|
||||||
{
|
{
|
||||||
private byte[] id;
|
private byte[] id;
|
||||||
private Destination address;
|
private Destination address;
|
||||||
|
@ -32,6 +32,7 @@ import org.klomp.snark.I2PSnarkUtil;
|
|||||||
import org.klomp.snark.MagnetURI;
|
import org.klomp.snark.MagnetURI;
|
||||||
import org.klomp.snark.MetaInfo;
|
import org.klomp.snark.MetaInfo;
|
||||||
import org.klomp.snark.Peer;
|
import org.klomp.snark.Peer;
|
||||||
|
import org.klomp.snark.PeerID;
|
||||||
import org.klomp.snark.Snark;
|
import org.klomp.snark.Snark;
|
||||||
import org.klomp.snark.SnarkManager;
|
import org.klomp.snark.SnarkManager;
|
||||||
import org.klomp.snark.Storage;
|
import org.klomp.snark.Storage;
|
||||||
@ -1478,7 +1479,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
continue;
|
continue;
|
||||||
out.write("<tr class=\"" + rowClass + "\"><td></td>");
|
out.write("<tr class=\"" + rowClass + "\"><td></td>");
|
||||||
out.write("<td colspan=\"4\" align=\"right\">");
|
out.write("<td colspan=\"4\" align=\"right\">");
|
||||||
String ch = peer.toString().substring(0, 4);
|
PeerID pid = peer.getPeerID();
|
||||||
|
String ch = pid != null ? pid.toString().substring(0, 4) : "????";
|
||||||
String client;
|
String client;
|
||||||
if ("AwMD".equals(ch))
|
if ("AwMD".equals(ch))
|
||||||
client = _("I2PSnark");
|
client = _("I2PSnark");
|
||||||
@ -1487,15 +1489,15 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
else if ("TTMt".equals(ch))
|
else if ("TTMt".equals(ch))
|
||||||
client = "I2P-BT";
|
client = "I2P-BT";
|
||||||
else if ("LUFa".equals(ch))
|
else if ("LUFa".equals(ch))
|
||||||
client = "Azureus";
|
client = "Vuze" + getAzVersion(pid.getID());
|
||||||
else if ("CwsL".equals(ch))
|
else if ("CwsL".equals(ch))
|
||||||
client = "I2PSnarkXL";
|
client = "I2PSnarkXL";
|
||||||
else if ("ZV".equals(ch.substring(2,4)) || "VUZP".equals(ch))
|
else if ("ZV".equals(ch.substring(2,4)) || "VUZP".equals(ch))
|
||||||
client = "Robert";
|
client = "Robert" + getRobtVersion(pid.getID());
|
||||||
else if (ch.startsWith("LV")) // LVCS 1.0.2?; LVRS 1.0.4
|
else if (ch.startsWith("LV")) // LVCS 1.0.2?; LVRS 1.0.4
|
||||||
client = "Transmission";
|
client = "Transmission" + getAzVersion(pid.getID());
|
||||||
else if ("LUtU".equals(ch))
|
else if ("LUtU".equals(ch))
|
||||||
client = "KTorrent";
|
client = "KTorrent" + getAzVersion(pid.getID());
|
||||||
else
|
else
|
||||||
client = _("Unknown") + " (" + ch + ')';
|
client = _("Unknown") + " (" + ch + ')';
|
||||||
out.write(client + " <tt>" + peer.toString().substring(5, 9)+ "</tt>");
|
out.write(client + " <tt>" + peer.toString().substring(5, 9)+ "</tt>");
|
||||||
@ -1569,6 +1571,50 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get version from bytes 3-6
|
||||||
|
* @return " w.x.y.z" or ""
|
||||||
|
* @since 0.9.14
|
||||||
|
*/
|
||||||
|
private static String getAzVersion(byte[] id) {
|
||||||
|
if (id[7] != '-')
|
||||||
|
return "";
|
||||||
|
StringBuilder buf = new StringBuilder(16);
|
||||||
|
buf.append(' ');
|
||||||
|
for (int i = 3; i <= 6; i++) {
|
||||||
|
int val = id[i] - '0';
|
||||||
|
if (val < 0)
|
||||||
|
return "";
|
||||||
|
if (val > 9)
|
||||||
|
val = id[i] - 'A';
|
||||||
|
if (i != 6 || val != 0) {
|
||||||
|
if (i != 3)
|
||||||
|
buf.append('.');
|
||||||
|
buf.append(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get version from bytes 3-5
|
||||||
|
* @return " w.x.y" or ""
|
||||||
|
* @since 0.9.14
|
||||||
|
*/
|
||||||
|
private static String getRobtVersion(byte[] id) {
|
||||||
|
StringBuilder buf = new StringBuilder(8);
|
||||||
|
buf.append(' ');
|
||||||
|
for (int i = 3; i <= 5; i++) {
|
||||||
|
int val = id[i];
|
||||||
|
if (val < 0)
|
||||||
|
return "";
|
||||||
|
if (i != 3)
|
||||||
|
buf.append('.');
|
||||||
|
buf.append(val);
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/** @since 0.8.2 */
|
/** @since 0.8.2 */
|
||||||
private static String thinsp(boolean disable) {
|
private static String thinsp(boolean disable) {
|
||||||
|
Reference in New Issue
Block a user