mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-02-20 20:29:02 +00:00
Fixes for PR #128
This commit is contained in:
parent
5d4cf75e0a
commit
ede2119f78
23
client.js
23
client.js
@ -87,24 +87,25 @@ function Client (peerId, port, torrent, opts) {
|
||||
} else if (protocol === 'udp:' && typeof UDPTracker === 'function') {
|
||||
return new UDPTracker(self, announceUrl)
|
||||
} 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)
|
||||
})
|
||||
// Skip ws:// trackers on https:// sites because they throw SecurityError
|
||||
if (protocol === 'ws:' && typeof window !== 'undefined' &&
|
||||
window.location.protocol === 'https:') {
|
||||
nextTickWarn(new Error('Unsupported tracker protocol: ' + announceUrl))
|
||||
return null
|
||||
}
|
||||
return new WebSocketTracker(self, announceUrl)
|
||||
} else {
|
||||
process.nextTick(function () {
|
||||
var err = new Error('unsupported tracker protocol for ' + announceUrl)
|
||||
self.emit('warning', err)
|
||||
})
|
||||
nextTickWarn(new Error('Unsupported tracker protocol: ' + announceUrl))
|
||||
return null
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter(Boolean)
|
||||
|
||||
function nextTickWarn (err) {
|
||||
process.nextTick(function () {
|
||||
self.emit('warning', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user