mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-19 04:31:36 +00:00
Merge pull request #319 from alxhotel/validate-port
Add validation for tracker port
This commit is contained in:
commit
b0efe653fb
@ -85,7 +85,14 @@ class Client extends EventEmitter {
|
|||||||
|
|
||||||
this._trackers = announce
|
this._trackers = announce
|
||||||
.map(announceUrl => {
|
.map(announceUrl => {
|
||||||
const protocol = url.parse(announceUrl).protocol
|
const parsedUrl = url.parse(announceUrl)
|
||||||
|
const port = parsedUrl.port
|
||||||
|
if (port < 0 || port > 65535) {
|
||||||
|
nextTickWarn(new Error(`Invalid tracker port: ${announceUrl}`))
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const protocol = parsedUrl.protocol
|
||||||
if ((protocol === 'http:' || protocol === 'https:') &&
|
if ((protocol === 'http:' || protocol === 'https:') &&
|
||||||
typeof HTTPTracker === 'function') {
|
typeof HTTPTracker === 'function') {
|
||||||
return new HTTPTracker(this, announceUrl)
|
return new HTTPTracker(this, announceUrl)
|
||||||
|
Loading…
Reference in New Issue
Block a user