From 6ae56b6931d6493920207f8329dd10c25836989c Mon Sep 17 00:00:00 2001 From: canoziia Date: Thu, 8 Jun 2023 17:33:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 3bdbea71f..74486636e 100644 --- a/server.js +++ b/server.js @@ -202,7 +202,7 @@ class Server extends EventEmitter { return html } - if (req.method === 'GET' && (req.url === '/stats' || req.url === '/stats.json')) { + if (req.method === 'GET' && (req.url === '/stats' || req.url === '/stats.json' || req.url === '/torrents.json' || req.url === '/peers.json')) { infoHashes.forEach(infoHash => { const peers = this.torrents[infoHash].peers const keys = peers.keys @@ -273,6 +273,12 @@ class Server extends EventEmitter {

Clients:

${printClients(stats.clients)} `.replace(/^\s+/gm, '')) // trim left + } else if (req.url === '/torrents.json') { + res.setHeader('Content-Type', 'application/json') + res.end(JSON.stringify(this.torrents)) + } else if (req.url === '/peers.json') { + res.setHeader('Content-Type', 'application/json') + res.end(JSON.stringify(allPeers)) } } }) @@ -507,8 +513,8 @@ class Server extends EventEmitter { response.info_hash = common.hexToBinary(params.info_hash) - // WebSocket tracker should have a shorter interval – default: 2 minutes - response.interval = Math.ceil(this.intervalMs / 1000 / 5) + // WebSocket tracker should have a shorter interval – default: 12 seconds + response.interval = Math.ceil(this.intervalMs / 1000 / 50) } // Skip sending update back for 'answer' announce messages – not needed From eba2cd303faf19de648e93bcc270b2902e949fb9 Mon Sep 17 00:00:00 2001 From: canoziia Date: Fri, 9 Jun 2023 16:07:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?bugfix:=20=E9=98=B2=E6=AD=A2=E6=81=B6?= =?UTF-8?q?=E6=84=8F=E7=AB=AF=E5=8F=A3=E6=94=BB=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/server/swarm.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/server/swarm.js b/lib/server/swarm.js index c3602133f..bb0249a2f 100644 --- a/lib/server/swarm.js +++ b/lib/server/swarm.js @@ -153,6 +153,8 @@ class Swarm { if (!peer) continue if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself if ((isWebRTC && peer.type !== 'ws') || (!isWebRTC && peer.type === 'ws')) continue // send proper peer type + // 如果端口号不是0-65535, continue + if (peer.port > 65535 || peer.port < 0) continue peers.push(peer) } return peers From 90d06087141bcb6881a753ed920121aed9e8d837 Mon Sep 17 00:00:00 2001 From: canoziia Date: Fri, 9 Jun 2023 17:17:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?10min=E5=AF=B9=E5=BA=946s,20min=E5=AF=B9?= =?UTF-8?q?=E5=BA=9412s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 74486636e..41af8ef58 100644 --- a/server.js +++ b/server.js @@ -514,7 +514,7 @@ class Server extends EventEmitter { response.info_hash = common.hexToBinary(params.info_hash) // WebSocket tracker should have a shorter interval – default: 12 seconds - response.interval = Math.ceil(this.intervalMs / 1000 / 50) + response.interval = Math.ceil(this.intervalMs / 1000 / 100) } // Skip sending update back for 'answer' announce messages – not needed