将 DHT 和 Torrent Client 拼接在一起

Stitching DHT and Torrent Client together

我有两个 java 库。 一个连接到 DHT 并可以成功下载 torrent 文件。 另一个下载与种子相关的实际数据。

torrent 客户端库需要 torrent 中的 announce 或 announce-list 部分,但不理解 'nodes' 条目。

问题是如何更改 Torrent 客户端代码以理解 Torrent 文件的 'nodes' 部分。 要么 我如何从一组 ip:port 个 DHT 对等地址计算跟踪器 URL?

我可以通过猜测端口号并在其上附加 /announce 来猜测 url。但这肯定不对吗?

有人知道这是怎么回事吗?

对于仅 DHT 操作,您不需要公告 URL。如果库本身需要一个你可以插入一个虚拟 url,格式 dht://<infohash in hex> 是常见的,但没关系,因为它不会被使用。

另一方面,DHT 部分不需要 nodes 来执行查找,它只是根据 torrent 的 infohash 进行操作。节点可以 可选地 注入 dht 客户端进行引导,例如通过对它们执行 ping 命令,但如果它已经被引导,则不需要这样做。 一旦 DHT 客户端完成了 get_peersannounce 查找,就可以将对等列表注入回 torrent 客户端。

因为您正在使用我的库:您可以使用 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 命令包含如何使用第一部分的示例。 还有 utility methods 应涵盖常见用例。

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