[bittorrent] DHT: How to reply to get_peers when I have neither any peers nor closer nodes?

Josef Drexler jd284 at cornell.edu
Wed Nov 15 14:24:05 EST 2006


I'm writing DHT support for libTorrent/rTorrent 
(http://libtorrent.rakshasa.no/), and the DHT specs on bittorrent.org aren't 
clear how one should handle the case of a get_peers query while having 
neither any peers for the given info hash yet, nor any closer nodes. 
Currently I'm replying with a "nodes" key holding an empty string:

d1:rd2:id20:O%8F%E9(...)5:nodes0:5:token8:A%D0:%AE4%C2%E9ne1:t1:L1:y1:re
(%xx meaning byte with hex code xx)

However, I never get any valid announce_peer messages.  I do occasionally 
get some with a zero-length token, however:

d1:ad2:id20:x(...)9:info_hash20:O%8F%FA(...):porti7101e5:token0:e1:q13:
announce_peer1:t8:u%CB6%E4.%E1I%FE1:y1:qe
(this was in reply to the above response)

I'm not sure if that means the client is broken, or my get_peers reply is 
malformed.  Somehow the transaction is an eight-byte string too instead of 
the required single character string, so it's probably a broken client.

Still, that does not explain why I never see any valid announce_peer 
queries, even if for testing I set my own node ID close to a very active 
torrent, for which I do receive lots of get_peers queries.

So the question is, how should I reply in the case that I have neither any 
peers yet nor any closer nodes,  but I am willing to track the torrent?

-- 
Josef Drexler



More information about the BitTorrent mailing list