Skip to content

Commit e73737d

Browse files
committed
trackers must start with http:// or udp://
1 parent 6414587 commit e73737d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

client.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ function Client (peerId, port, torrent, opts) {
5252

5353
if (typeof torrent.announce === 'string') {
5454
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
55-
torrent.announce = [torrent.announce]
55+
torrent.announce = [ torrent.announce ]
5656
}
57-
self._trackers = torrent.announce.map(function (announceUrl) {
58-
return new Tracker(self, announceUrl, self._opts)
59-
})
57+
self._trackers = torrent.announce
58+
.filter(function (announceUrl) {
59+
return announceUrl.indexOf('udp://') === 0 || announceUrl.indexOf('http://') === 0
60+
})
61+
.map(function (announceUrl) {
62+
return new Tracker(self, announceUrl, self._opts)
63+
})
6064
}
6165

6266
/**
@@ -150,9 +154,9 @@ function Tracker (client, announceUrl, opts) {
150154
self._intervalMs = self.client._intervalMs // use client interval initially
151155
self._interval = null
152156

153-
if (self._announceUrl.indexOf('udp:') === 0) {
157+
if (self._announceUrl.indexOf('udp://') === 0) {
154158
self._requestImpl = self._requestUdp
155-
} else {
159+
} else if (self._announceUrl.indexOf('http://') === 0) {
156160
self._requestImpl = self._requestHttp
157161
}
158162
}

0 commit comments

Comments
 (0)