trackers must start with http:// or udp://

This commit is contained in:
Feross Aboukhadijeh 2014-08-02 14:09:44 -07:00
parent 6414587a35
commit e73737dac7

View File

@ -54,7 +54,11 @@ function Client (peerId, port, torrent, opts) {
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
torrent.announce = [ torrent.announce ]
}
self._trackers = torrent.announce.map(function (announceUrl) {
self._trackers = torrent.announce
.filter(function (announceUrl) {
return announceUrl.indexOf('udp://') === 0 || announceUrl.indexOf('http://') === 0
})
.map(function (announceUrl) {
return new Tracker(self, announceUrl, self._opts)
})
}
@ -150,9 +154,9 @@ function Tracker (client, announceUrl, opts) {
self._intervalMs = self.client._intervalMs // use client interval initially
self._interval = null
if (self._announceUrl.indexOf('udp:') === 0) {
if (self._announceUrl.indexOf('udp://') === 0) {
self._requestImpl = self._requestUdp
} else {
} else if (self._announceUrl.indexOf('http://') === 0) {
self._requestImpl = self._requestHttp
}
}