Skip to content

Commit b2ff218

Browse files
committed
Merge pull request webtorrent#128 from DiegoRBaquero/patch-2
Don't add non-secure trackers on a https site
2 parents 4b62a41 + 0133c96 commit b2ff218

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

client.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ function Client (peerId, port, torrent, opts) {
8787
} else if (protocol === 'udp:' && typeof UDPTracker === 'function') {
8888
return new UDPTracker(self, announceUrl)
8989
} 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)