Skip to content

Commit 3d84d44

Browse files
committed
Don't add insecure trackers on a https site
webtorrent/webtorrent#67 (comment)
1 parent 7daf7ec commit 3d84d44

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

client.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ function Client (peerId, port, torrent, opts) {
8686
return new HTTPTracker(self, announceUrl)
8787
} else if (protocol === 'udp:' && typeof UDPTracker === 'function') {
8888
return new UDPTracker(self, announceUrl)
89-
} else if ((protocol === 'ws:' || protocol === 'wss:') && webrtcSupport) {
89+
} else if (((protocol === 'ws:') || protocol === 'wss:') && webrtcSupport) {
90+
// Don't try to add http tracker on an https website
91+
if (protocol === 'ws:' && location && location.protocol && location.protocol === 'https:') {
92+
process.nextTick(function () {
93+
var err = new Error('unsupported http tracker on https: ' + announceUrl)
94+
self.emit('warning', err)
95+
})
96+
return null
97+
}
9098
return new WebSocketTracker(self, announceUrl)
9199
} else {
92100
process.nextTick(function () {

0 commit comments

Comments
 (0)