连接到洪流跟踪器/同行

时间:2017-06-02 15:44:48

标签: node.js udp bittorrent

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

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

我有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

根据我的阅读,跟踪器用于查找从中下载数据的对等项。那么如何下载第一个洪流呢?它没有跟踪器。

我如何实际进行此连接?

规范中没有磁链接,并声明跟踪器可以通过HTTP(S)协议使用,但这些显然是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);

});

显然,这不起作用,但我找不到任何文件可以提供帮助。

1 个答案:

答案 0 :(得分:0)

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

自2008年以来,该协议的官方*文件可在BitTorrent.org找到 基本协议的官方版本是简洁而密集的BEP3 - The BitTorrent Protocol Specification

BEP9 - Extension for Peers to Send Metadata Files中包含磁铁链接 你可以阅读:

  

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

DHT在BEP5 - DHT Protocol中指定。

正如您所注意到的,现在跟踪器使用的是BEP15 - UDP Tracker Protocol中指定的UDP。

脚注:* 官方仅表示它由BitTorrentInc运行,而不是它是优越的或唯一使用的源。 BitTorrent协议不受权限管辖。没有客户承诺效忠BEP。该协议是由真实客户的共识形成的。

相关问题