[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:

(%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:

(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