From 5ad210b7e12866390d8577b3698699e107e511fd Mon Sep 17 00:00:00 2001 From: daiyu Date: Mon, 23 Apr 2018 23:09:57 +0800 Subject: [PATCH 1/2] Fix filter function --- server.js | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/server.js b/server.js index 8d9fc65..8779b75 100644 --- a/server.js +++ b/server.js @@ -659,32 +659,27 @@ Server.prototype._onAnnounce = function (params, cb) { self.getSwarm(params.info_hash, function (err, swarm) { if (err) return cb(err) - if (swarm) { - announce(swarm) - } else { - createSwarm() - } - }) - function createSwarm () { if (self._filter) { self._filter(params.info_hash, params, function (err) { - // Precense of err means that this info_hash is disallowed - if (err) { - cb(err) - } else { - self.createSwarm(params.info_hash, function (err, swarm) { - if (err) return cb(err) - announce(swarm) - }) + // Precense of err means that this torrent or user is disallowd + if (err) cb(err) + else { + if (swarm) announce(swarm) + else createSwarm() } }) } else { - self.createSwarm(params.info_hash, function (err, swarm) { - if (err) return cb(err) - announce(swarm) - }) + if (swarm) announce(swarm) + else createSwarm() } + }) + + function createSwarm() { + self.createSwarm(params.info_hash, function (err, swarm) { + if (err) return cb(err) + announce(swarm) + }) } function announce (swarm) { From 2ba6946f1761e6ebf413e3d831fd7a9fd29b30dd Mon Sep 17 00:00:00 2001 From: daiyu Date: Tue, 24 Apr 2018 13:12:34 +0800 Subject: [PATCH 2/2] standard --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 8779b75..15ec93d 100644 --- a/server.js +++ b/server.js @@ -675,7 +675,7 @@ Server.prototype._onAnnounce = function (params, cb) { } }) - function createSwarm() { + function createSwarm () { self.createSwarm(params.info_hash, function (err, swarm) { if (err) return cb(err) announce(swarm)