连接到 torrent 跟踪器/对等点 [英] Connecting to torrent trackers / peers

查看:47
本文介绍了连接到 torrent 跟踪器/对等点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在 nodeJS 中实现一个最小的 Torrent 客户端.

I'm currently trying to implement a minimal torrent client, in nodeJS.

我正在阅读本规范:https://wiki.theory.org/index.php/BitTorrent 规范

我有 2 个磁铁 URI:

I've got 2 magnet URIs:

magnet:?xt=urn:btih:633ab5b0cc27218bca2f9fec9b68ae4f7cbf0c5f&dn=dmb2017-05-31.dpa4021.flac16


xt=urn:btih:633ab5b0cc27218bca2f9fec9b68ae4f7cbf0c5f
dn=dmb2017-05-31.dpa4021.flac16

<小时>

magnet:?xt=urn:btih:9f9165d9a281a9b8e782cd5176bbcc8256fd1871&dn=Ubuntu+16.04.1+LTS+Desktop+64-bit&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969

xt=urn:btih:9f9165d9a281a9b8e782cd5176bbcc8256fd1871
dn=Ubuntu+16.04.1+LTS+Desktop+64-bit
tr=udp://tracker.leechers-paradise.org:6969
tr=udp://zer0day.ch:1337
tr=udp://open.demonii.com:1337
tr=udp://tracker.coppersurfer.tk:6969
tr=udp://exodus.desync.com:6969

据我所知,跟踪器用于查找对等点,从中下载数据.那么如何下载第一个 torrent 呢?它没有跟踪器.

From what I've read, the tracker is used to find peers, from which data is downloaded. How would one download the first torrent then? It has no tracker.

我实际上如何进行这种连接?

How do I actually do conduct this connection?

该规范没有关于磁力链接的内容,并声明可以通过 HTTP(S) 协议使用跟踪器,但这些显然是 UDP.

The specification has nothing on magnet links, and states that trackers can be used via the HTTP(S) protocols, but these are clearly UDP.

我试了一下:

var PORT = 6969 ;
var HOST = 'tracker.leechers-paradise.org';

var dgram = require('dgram');
var message = new Buffer("xt=urn:btih:9f9165d9a281a9b8e782cd5176bbcc8256fd1871");

var client = dgram.createSocket('udp4');

client.on('listening', function () {
    var address = client.address();
    console.log('UDP Server listening on ' + address.address + ":" + address.port);
});

client.on('message', function (message, remote) {

    console.log(remote.address + ':' + remote.port +' - ' + message);

});

client.send(message, 0, message.length, PORT, HOST, function(err, bytes) {

    if (err) throw err;
    console.log('UDP message sent to ' + HOST +':'+ PORT);
    console.log(bytes);

});

显然,这行不通,但我找不到任何帮助文档.

Obviously, this doesn't work, but I can't find any documentation to help.

推荐答案

非官方的 Wiki.theory.org/BitTorrentSpecification 无疑是开始了解 BitTorrent 协议的最佳场所,但它并不完整.它只涵盖了早期开发的基础协议和扩展.这就是为什么您无法在那里找到您需要的所有信息的原因.

The inofficial Wiki.theory.org/BitTorrentSpecification is without doubt the very best place to start learning about the BitTorrent protocol, but it is incomplete. It only covers the base protocol and the extensions that was developed in the early years. That's why you can't find all the information you need there.

自 2008 年以来,可以在 BitTorrent.org.
基础协议的官方版本是简洁而密集的 BEP3 - BitTorrent 协议规范.

Since 2008 the official* documentation of the protocol can be found at BitTorrent.org.
The official version of the base protocol is the terse and dense BEP3 - The BitTorrent Protocol Specification.

磁力链接包含在 BEP9 - 对等方发送元数据文件的扩展.
你可以在那里阅读:

Magnet links is covered in BEP9 - Extension for Peers to Send Metadata Files.
There can you read:

如果没有指定跟踪器,客户端应该使用 DHT 来获取对等点.

If no tracker is specified, the client SHOULD use the DHT to acquire peers.

DHT 在中指定BEP5 - DHT 协议.

正如您所注意到的,现在跟踪器使用 UDP,这在 BEP15 - UDP 跟踪协议.

As you have noticed, trackers nowadays use UDP, that is specified in BEP15 - UDP Tracker Protocol.

footnote: * Official 仅表示它由 BitTorrentInc 运行,而不是它的优越性或唯一可用的来源.BitTorrent 协议不受权限管理.没有客户承诺效忠 BEP.该协议是根据真实客户所做的共识形成的.

footnote: * Official only means that it's run by BitTorrentInc, not that it's superior or the only source to use. The BitTorrent protocol is not governed by authority. None client has pledged allegiance to BEP. The protocol is formed by consensus from what clients in the real do.

这篇关于连接到 torrent 跟踪器/对等点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆