简体   繁体   English

将DHT和Torrent客户端拼接在一起

[英]Stitching DHT and Torrent Client together

I have two java libraries. 我有两个java库。 One connects to DHT and can successfully download torrent files. 一个连接到DHT,可以成功下载torrent文件。 And the other which downloads the actual data associated with the torrent. 另一个下载与torrent相关的实际数据。

The torrent client library expects an announce or announce-list section in the torrent, and does't understand the 'nodes' entry. torrent客户端库需要torrent中的announce或announce-list部分,并且不理解'nodes'条目。

The question is how do I alter the torrent client code to understand the 'nodes' section of a torrent file. 问题是如何更改torrent客户端代码以理解torrent文件的“节点”部分。 OR How do I calculate a tracker URL from a set of ip:port DHT peer addresses? 或者如何从一组ip:port DHT对等地址计算跟踪器URL?

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? 有谁知道这是如何工作的?

For DHT-only operation you do not need an announce URL. 对于仅DHT操作,您不需要通知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. 如果库本身需要一个你可以插入一个虚拟URL,格式为dht://<infohash in hex>很常见,但没关系,因为它不会被使用。

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. 另一方面,DHT部分不需要nodes执行查找,它只是根据torrent的infohash进行操作。 The nodes can optionally be injected into a dht client for bootstrapping, eg by executing a ping on them, but that should not be needed if it already is bootstrapped. 可以选择将节点注入到dht客户端以进行引导,例如通过对它们执行ping操作,但如果已经引导,则不需要这些节点。 Once the DHT client has done its get_peers and announce lookups the peer lists can be injected back into the torrent client. 一旦DHT客户端完成了get_peersannounce查找,就可以将对等列表注入到torrent客户端。

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. 由于您正在使用我的库:您可以使用PeerLookupTask从DHT和AnnounceTask读取torrent对等列表,以将您的torrent端口添加到列表中。 The obtained IP and Ports have to be passed to the torrent client. 获得的IP和端口必须传递给torrent客户端。 The GetPeers CLI command contains an example how to use the first part. GetPeers CLI命令包含如何使用第一部分的示例。 There also are utility methods that should cover common use cases. 还有一些实用方法应涵盖常见用例。

作为替代方案,我可能会建议您查看Bt,这是一个Java 8 BitTorrent客户端,并且已经与8472的mldht集成: https//github.com/atomashpolskiy/bt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM