mafintosh / torrent-stream

The low level streaming torrent engine that peerflix uses
MIT License
1.94k stars 228 forks source link

External trackers list support, info-dictionary receiving speedup for magnet links by early trackers client init #46

Closed arestov closed 10 years ago

arestov commented 10 years ago

Now we can use manual trackers list to speedup peers finding. Which accelerates start of downloading and with early trackers client init info-dictionary receiving.

engine('magnet://...', 
    {trackers: [
        'udp://tracker.openbittorrent.com:80',
        'udp://tracker.ccc.de:80',
        'udp://tracker.istole.it:80',
        'udp://tracker.publicbt.com:80'
    ]});
arestov commented 10 years ago

@asapach done

asapach commented 10 years ago

I'd like to preserve existing behavior: if opts.tracker: false, no trackers should be used, regardless of opts.trackers option.

arestov commented 10 years ago

in suggested code we can do

{
  tracker: false,
  trackers: null
}

to disable trackers completely.

And we can

{
  tracker: false,
  trackers: [...]
}

to use own list of trackers instead of list from torrent file.

But if tracker disables trackers how we can use own list of trackers instead of list form torrent file. I thought that this way is more flexible and better for API. What do you think?

BastienClement commented 10 years ago

Seems like a good point for me.

asapach commented 10 years ago

I'm merging this PR into the trackers branch: https://github.com/mafintosh/torrent-stream/tree/trackers I've added a couple of tests and they are failing at the moment.

asapach commented 10 years ago

Ran into an issue with bittorent-tracker: feross/bittorrent-tracker#19, tests still failing.

arestov commented 10 years ago

Now tests pass. And if we call .listen immediately after engine instance has been created we do not recreate tracker. (With process.nextTick help)

asapach commented 10 years ago

@arestov, I'm trying to test this on public trackers (TPB, openbittorent, etc.), but always get connection refused (might be my ISP). Does it work for you?

arestov commented 10 years ago

Following code works for me

var Eng = require('./index');
var eng = Eng('magnet:?xt=urn:btih:2e0ba00b6ae7d68d03a61e682fe85e6964796b27&dn=Duck%20Sauce%20%E2%80%93%20NRG', {
    dht: false,
    trackers: [
        'udp://tracker.openbittorrent.com:80',
        'udp://tracker.ccc.de:80',
        'udp://tracker.istole.it:80',
        'udp://tracker.publicbt.com:80'
    ]
});
eng.on('ready', function() {
    console.log('done')
});
asapach commented 10 years ago

This PR has been merged into #50. Let's continue discussion there.