handle case where server returns ip in square brackets

This commit is contained in:
Feross Aboukhadijeh 2014-11-26 20:18:44 +08:00
parent b079bad35a
commit d7c4af4ce8

View File

@ -513,9 +513,9 @@ Tracker.prototype._handleResponse = function (requestUrl, data) {
} else if (Array.isArray(data.peers6)) { } else if (Array.isArray(data.peers6)) {
// tracker returned normal response // tracker returned normal response
data.peers.forEach(function (peer) { data.peers.forEach(function (peer) {
var ip = /:/.test(peer.ip) ? var ip = /^\[/.test(peer.ip)
'[' + peer.ip + ']' : ? peer.ip
peer.ip : '[' + peer.ip + ']'
self.client.emit('peer', ip + ':' + peer.port) self.client.emit('peer', ip + ':' + peer.port)
}) })
} }