mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-02-23 21:59:03 +00:00
Check if peer is undefined
This commit is contained in:
parent
8f2e21798c
commit
ebf117242c
@ -198,6 +198,11 @@ function Server (opts) {
|
|||||||
if (keys.length > 0) activeTorrents++
|
if (keys.length > 0) activeTorrents++
|
||||||
|
|
||||||
keys.forEach(function (peerId) {
|
keys.forEach(function (peerId) {
|
||||||
|
// Don't mark the peer as most recently used for stats
|
||||||
|
var peer = peers.peek(peerId)
|
||||||
|
|
||||||
|
// The peer could be evicted at this point
|
||||||
|
if (typeof peer !== 'undefined') {
|
||||||
if (!allPeers.hasOwnProperty(peerId)) {
|
if (!allPeers.hasOwnProperty(peerId)) {
|
||||||
allPeers[peerId] = {
|
allPeers[peerId] = {
|
||||||
ipv4: false,
|
ipv4: false,
|
||||||
@ -206,8 +211,7 @@ function Server (opts) {
|
|||||||
leecher: false
|
leecher: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Don't mark the peer as most recently used for stats
|
|
||||||
var peer = peers.peek(peerId)
|
|
||||||
if (peer.ip.indexOf(':') >= 0) {
|
if (peer.ip.indexOf(':') >= 0) {
|
||||||
allPeers[peerId].ipv6 = true
|
allPeers[peerId].ipv6 = true
|
||||||
} else {
|
} else {
|
||||||
@ -220,6 +224,7 @@ function Server (opts) {
|
|||||||
}
|
}
|
||||||
allPeers[peerId].peerId = peer.peerId
|
allPeers[peerId].peerId = peer.peerId
|
||||||
allPeers[peerId].client = peerid(peer.peerId)
|
allPeers[peerId].client = peerid(peer.peerId)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user