From 3d84d44abc3a8c5d460bd1a52159f72c4c11f72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Tue, 15 Mar 2016 00:16:25 -0300 Subject: [PATCH] Don't add insecure trackers on a https site https://github.com/feross/webtorrent/issues/67#issuecomment-189853184 --- client.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client.js b/client.js index 650a4ca..e27564c 100644 --- a/client.js +++ b/client.js @@ -86,7 +86,15 @@ function Client (peerId, port, torrent, opts) { return new HTTPTracker(self, announceUrl) } else if (protocol === 'udp:' && typeof UDPTracker === 'function') { return new UDPTracker(self, announceUrl) - } else if ((protocol === 'ws:' || protocol === 'wss:') && webrtcSupport) { + } else if (((protocol === 'ws:') || protocol === 'wss:') && webrtcSupport) { + // Don't try to add http tracker on an https website + if (protocol === 'ws:' && location && location.protocol && location.protocol === 'https:') { + process.nextTick(function () { + var err = new Error('unsupported http tracker on https: ' + announceUrl) + self.emit('warning', err) + }) + return null + } return new WebSocketTracker(self, announceUrl) } else { process.nextTick(function () {