【发布时间】:2019-07-05 23:45:30
【问题描述】:
我有一个 torrent 文件。它的 info_hash 值为87bebe2a6dfa25c8d8075893c4c6e05878cccb4a。
我需要从 UDP tracker 中获取 peers,但是在 UDP Tracker Protocol 中,info_hash 的大小应该是 20。那么如何转换呢?
我使用 bitcomet 下载并使用wireshark 捕获消息。
这是我得到的东西:
0000 80 f6 2e cd a7 81 8c ec 4b 6d 8f 0f 08 00 45 00 .ö.ͧ..ìKm....E.
0010 00 7e 41 a9 00 00 80 11 00 00 c0 a8 29 49 6d 4a .~A©......À¨)ImJ
0020 46 bc 41 cd 4c 3e 00 6a 9e 73 64 31 3a 61 64 32 F¼AÍL>.j.sd1:ad2
0030 3a 69 64 32 30 3a f7 66 44 1b 73 41 09 0d 1b 10 :id20:÷fD.sA....
0040 84 1d a6 7f 47 e8 4c b7 63 86 36 3a 74 61 72 67 ..¦.GèL·c.6:targ
0050 65 74 32 30 3a 08 99 bb e4 8c be f6 f2 e4 ef 7b et20:..»ä.¾öòäï{
0060 e2 59 80 b8 17 b3 48 9c 78 65 31 3a 71 39 3a 66 âY.¸.³H.xe1:q9:f
0070 69 6e 64 5f 6e 6f 64 65 31 3a 74 38 3a 0f ea 8a ind_node1:t8:.ê.
0080 c2 86 ff 4c 37 31 3a 79 31 3a 71 65 Â.ÿL71:y1:qe
根据UDP Tracker Protocol,我捕获的info_hash是7341090d1b10841da67f47e84cb76386363a7461。它与87bebe2a6dfa25c8d8075893c4c6e05878cccb4a 的实际值完全不同。我错了吗?我确信消息的目的地是 UDP 跟踪器,因为它的长度是 98。
我尝试使用 Java 进行转换。代码如下:
public static String IHToString(String v) throws Exception{
byte[] b=new byte[20];
for(int i=0;i<b.length;i++) {
String n=v.substring(i*2, i*2+2);
int j=(byte)Integer.parseInt(n, 16) & 0xff;
b[i]=(byte)j;
}
return new String(b,"ASCII");
}
String s1=IHToString("87bebe2a6dfa25c8d8075893c4c6e05878cccb4a");
byte[] b1=s1.getByte("ASCII");
显然错了。
结果既不是7341090d1b1084 1da67f47e84cb76386363a7461 也不是87bebe2a6dfa25c8d8075893c4c6e05878cccb4a。我真的很累。请帮我。 -_-
【问题讨论】:
-
BT 信息哈希似乎是用于受版权保护的电影...
-
Wireshark 捕获的是 DHT 消息。
-
我捕获了一些 len 为 101 的 udp 消息。这些消息包含正确的 info_hash。但它应该是 DHT 消息,而不是 UDP 跟踪器。真的很累
标签: java udp p2p bittorrent dht