1
votes

I have two java libraries. One connects to DHT and can successfully download torrent files. And the other which downloads the actual data associated with the torrent.

The torrent client library expects an announce or announce-list section in the torrent, and does't understand the 'nodes' entry.

The question is how do I alter the torrent client code to understand the 'nodes' section of a torrent file. OR How do I calculate a tracker URL from a set of ip:port DHT peer addresses?

I could just guess the url by guessing a port number and appending /announce onto it.. but this surely isn't right?

Does anyone know how this works?

2

2 Answers

2
votes

For DHT-only operation you do not need an announce URL. If the library itself expects one you can insert a dummy url, the format dht://<infohash in hex> is common, but it does not matter, as it won't be used.

The DHT part on the other hand does not require the nodes to perform a lookup, it simply operates based on the infohash of the torrent. The nodes can optionally be injected into a dht client for bootstrapping, e.g. by executing a ping on them, but that should not be needed if it already is bootstrapped. Once the DHT client has done its get_peers and announce lookups the peer lists can be injected back into the torrent client.

Since you're using my library: You can use PeerLookupTask to read a torrent peer list from the DHT and AnnounceTask to add your torrent port to the list. The obtained IP and Ports have to be passed to the torrent client. The GetPeers CLI command contains an example how to use the first part. There also are utility methods that should cover common use cases.

1
votes

For an alternative I may recommend you to see Bt, which is a Java 8 BitTorrent client and already integrates with the8472's mldht: https://github.com/atomashpolskiy/bt