Skip to content

Commit b0efe65

Browse files
Merge pull request webtorrent#319 from alxhotel/validate-port
Add validation for tracker port
2 parents 24d9422 + 5c90b2b commit b0efe65

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

client.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ class Client extends EventEmitter {
8585

8686
this._trackers = announce
8787
.map(announceUrl => {
88-
const protocol = url.parse(announceUrl).protocol
88+
const parsedUrl = url.parse(announceUrl)
89+
const port = parsedUrl.port
90+
if (port < 0 || port > 65535) {
91+
nextTickWarn(new Error(`Invalid tracker port: ${announceUrl}`))
92+
return null
93+
}
94+
95+
const protocol = parsedUrl.protocol
8996
if ((protocol === 'http:' || protocol === 'https:') &&
9097
typeof HTTPTracker === 'function') {
9198
return new HTTPTracker(this, announceUrl)

0 commit comments

Comments
 (0)