mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 10:31:36 +00:00
client IPv6 support [BEP-7]
This commit is contained in:
parent
54b8d7112a
commit
1ca387f2fe
21
client.js
21
client.js
@ -499,6 +499,27 @@ Tracker.prototype._handleResponse = function (requestUrl, data) {
|
||||
self.client.emit('peer', peer.ip + ':' + peer.port)
|
||||
})
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(data.peers6)) {
|
||||
// tracker returned compact response
|
||||
var addrs
|
||||
try {
|
||||
addrs = compact2string.multi6(data.peers6)
|
||||
} catch (err) {
|
||||
return self.client.emit('warning', err)
|
||||
}
|
||||
addrs.forEach(function (addr) {
|
||||
self.client.emit('peer', addr)
|
||||
})
|
||||
} else if (Array.isArray(data.peers6)) {
|
||||
// tracker returned normal response
|
||||
data.peers.forEach(function (peer) {
|
||||
var ip = /:/.test(peer.ip) ?
|
||||
'[' + peer.ip + ']' :
|
||||
peer.ip
|
||||
self.client.emit('peer', ip + ':' + peer.port)
|
||||
})
|
||||
}
|
||||
} else if (requestUrl === self._scrapeUrl) {
|
||||
// NOTE: the unofficial spec says to use the 'files' key but i've seen 'host' in practice
|
||||
data = data.files || data.host || {}
|
||||
|
Loading…
Reference in New Issue
Block a user