2017-06-02 60 views
1

我目前正在尝试在nodeJS中实现一个最小的洪流客户端。连接到洪流跟踪器/同行

我读通过这个规格: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); 

}); 

显然,这是不行的,但我无法找到任何文件,以帮助。

回答

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中指定。

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


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

+0

那么,还有HTTP跟踪器吗?这很酷,我可以使用浏览器客户端。感谢您的额外信息! – Tobiq

+0

是否有单个DHT?我在哪里连接?这一切都令人困惑 – Tobiq

+1

公共HTTP跟踪器在受欢迎时往往会死亡,因为与UDP跟踪器相比,HTTP跟踪器占用的资源要多得多。无论如何,你可以在这里找到一个列表:https://github.com/ngosang/trackerslist只有浏览器的bittorrent客户端是不可能的,因为你需要通过原始TCP或uTP/UDP连接到其他对等端。webtorrent假装是一个真正的bittorrent客户端,但它不是,因为它不能连接到任何以前存在的客户端。 – Encombe