From f2882279aba25e92d296ccc843b2d091531611c3 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Mon, 14 May 2018 18:58:10 +0800 Subject: [PATCH] fix(announce): update peer ip & port when changed than old peer record --- .../controllers/announces.server.controller.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/announce/server/controllers/announces.server.controller.js b/modules/announce/server/controllers/announces.server.controller.js index d9afc940..477d5a52 100644 --- a/modules/announce/server/controllers/announces.server.controller.js +++ b/modules/announce/server/controllers/announces.server.controller.js @@ -489,7 +489,7 @@ exports.announce = function (req, res) { getCurrentPeer(function () { mtDebug.debugRed('req.currentPeer.isNewCreated = ' + req.currentPeer.isNewCreated, 'ANNOUNCE', true, req.passkeyuser); - mtDebug.debugRed(req.currentPeer._id.toString(), 'ANNOUNCE', true, req.passkeyuser); + mtDebug.debugRed('req.currentPeer._id = ' + req.currentPeer._id.toString(), 'ANNOUNCE', true, req.passkeyuser); done(null); }); }, @@ -948,6 +948,19 @@ exports.announce = function (req, res) { req.currentPeer.torrent = req.torrent; req.currentPeer.isNewCreated = false; + //if find peer_id, but some time some client (like qbittorrent 4.1.0) the ip or port is changed, update it + if (req.currentPeer.peer_ip !== req.cf_ip || req.currentPeer.peer_port !== query.port) { + req.currentPeer.peer_ip = req.cf_ip; + req.currentPeer.peer_port = query.port; + + req.currentPeer.update({ + $set: { + peer_ip: req.cf_ip, + peer_port: query.port + } + }).exec(); + } + if (req.seeder && req.currentPeer.peer_status !== PEERSTATE_SEEDER && event(query.event) !== EVENT_COMPLETED) { mtDebug.debugGreen('---------------PEER STATUS CHANGED: Seeder----------------', 'ANNOUNCE', true, req.passkeyuser); doCompleteEvent(function () {