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