Search code examples
bittorrentdhttorrent

Download the extended handshake response from peers failed by bep10


before download the metadata from peers ,I must get extend message data, like this:

{
e: 0,
ipv4: xxx,
ipv6: xxx,
complete_ago: 1,
m:
{
    upload_only: 3,
    lt_donthave: 7,
    ut_holepunch: 4,
    ut_metadata: 2,
    ut_pex: 1,
    ut_comment: 6
},
matadata_size: 45377,
p: 33733,
reqq: 255,
v: BitTorrent 7.9.3
yp: 19616,
yourip: xxx
}

I got Handshake and Extended Bitfield and Have Piece ok, but no extension data message.

wireshark

wireshark dump data

Need help in resolving this issue, thanks!


Solution

  • One of your handshakes from the pcap:

    BitTorrent Protocol Name Length: 19 Protocol Name: BitTorrent protocol Reserved Extension Bytes: 0000000000000000 SHA1 Hash of info dictionary: 7dd228be16c64d996be7a1bd7355cc416284d6dc Peer ID: 0401832c018f1ef9f25632c1b3d65d593113edc6 0000 13 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 .BitTorrent prot 0010 6f 63 6f 6c 00 00 00 00 00 00 00 00 7d d2 28 be ocol........}.(. 0020 16 c6 4d 99 6b e7 a1 bd 73 55 cc 41 62 84 d6 dc ..M.k...sU.Ab... 0030 04 01 83 2c 01 8f 1e f9 f2 56 32 c1 b3 d6 5d 59 ...,.....V2...]Y 0040 31 13 ed c6 1...

    The problem is that the bit for the extension handshake is not set in the reserved extension bytes. This will cause that the other peer will close the connection when it receives the unexpected extension handshake.

    It should be:

    Reserved Extension Bytes: 0000000000100000