简体   繁体   English

连接到洪流跟踪器/同行

[英]Connecting to torrent trackers / peers

I'm currently trying to implement a minimal torrent client, in nodeJS. 我目前正在尝试在nodeJS中实现一个最小的torrent客户端。

I'm reading through this specification: https://wiki.theory.org/index.php/BitTorrentSpecification 我正在阅读这个规范: https//wiki.theory.org/index.php/BitTorrentSpecification

I've got 2 magnet URIs: 我有2个磁铁URI:

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

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? 我如何实际进行此连接?

The specification has nothing on magnet links, and states that trackers can be used via the HTTP(S) protocols, but these are clearly UDP. 该规范在磁链路上没有任何内容,并指出跟踪器可以通过HTTP(S)协议使用,但这些显然是UDP。

I gave a stab at this: 我对此嗤之以鼻:

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. 显然,这不起作用,但我找不到任何文档可以提供帮助。

The inofficial Wiki.theory.org/BitTorrentSpecification is without doubt the very best place to start learning about the BitTorrent protocol, but it is incomplete. 非官方的Wiki.theory.org/BitTorrentSpecification无疑是开始学习BitTorrent协议的最佳场所,但它不完整。 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. 这就是为什么你找不到你需要的所有信息的原因。

Since 2008 the official* documentation of the protocol can be found at BitTorrent.org . 自2008年以来,可以在BitTorrent.org上找到该协议的官方*文档。
The official version of the base protocol is the terse and dense BEP3 - The BitTorrent Protocol Specification . 基本协议的官方版本是简洁而密集的BEP3 - BitTorrent协议规范

Magnet links is covered in BEP9 - Extension for Peers to Send Metadata Files . 磁带链接包含在BEP9 - 用于发送元数据文件的对等扩展中
There can you read: 你能读到:

If no tracker is specified, the client SHOULD use the DHT to acquire peers. 如果没有指定跟踪器,客户端应该使用DHT来获取对等体。

The DHT is specified in BEP5 - DHT Protocol . DHT在BEP5-DHT协议中规定

As you have noticed, trackers nowadays use UDP, that is specified in BEP15 - UDP Tracker Protocol . 正如您所注意到的,跟踪器现在使用UDP,这是在BEP15-UDP跟踪器协议中指定的。


footnote: * Official only means that it's run by BitTorrentInc, not that it's superior or the only source to use. 脚注:* 官方仅表示它由BitTorrentInc运行,而不是它是优越的或唯一使用的源。 The BitTorrent protocol is not governed by authority. BitTorrent协议不受权限管辖。 None client has pledged allegiance to BEP. 没有客户承诺效忠BEP。 The protocol is formed by consensus from what clients in the real do. 该协议是由真实客户的共识形成的。

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

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