This commit is contained in:
Feross Aboukhadijeh 2019-07-05 13:12:24 -07:00
parent 85e7a606a6
commit db4a06d97f

View File

@ -15,6 +15,8 @@ const parseHttpRequest = require('./lib/server/parse-http')
const parseUdpRequest = require('./lib/server/parse-udp')
const parseWebSocketRequest = require('./lib/server/parse-websocket')
const hasOwnProperty = Object.prototype.hasOwnProperty
/**
* BitTorrent tracker server.
*
@ -147,7 +149,7 @@ class Server extends EventEmitter {
let key
for (key in allPeers) {
if (allPeers.hasOwnProperty(key) && filterFunction(allPeers[key])) {
if (hasOwnProperty.call(allPeers, key) && filterFunction(allPeers[key])) {
count++
}
}
@ -158,7 +160,7 @@ class Server extends EventEmitter {
function groupByClient () {
const clients = {}
for (const key in allPeers) {
if (allPeers.hasOwnProperty(key)) {
if (hasOwnProperty.call(allPeers, key)) {
const peer = allPeers[key]
if (!clients[peer.client.client]) {
@ -179,10 +181,10 @@ class Server extends EventEmitter {
function printClients (clients) {
let html = '<ul>\n'
for (const name in clients) {
if (clients.hasOwnProperty(name)) {
if (hasOwnProperty.call(clients, name)) {
const client = clients[name]
for (const version in client) {
if (client.hasOwnProperty(version)) {
if (hasOwnProperty.call(client, version)) {
html += `<li><strong>${name}</strong> ${version} : ${client[version]}</li>\n`
}
}
@ -203,7 +205,7 @@ class Server extends EventEmitter {
const peer = peers.peek(peerId)
if (peer == null) return // peers.peek() can evict the peer
if (!allPeers.hasOwnProperty(peerId)) {
if (!hasOwnProperty.call(allPeers, peerId)) {
allPeers[peerId] = {
ipv4: false,
ipv6: false,