Fix filter function

This commit is contained in:
daiyu 2018-04-23 23:09:57 +08:00
parent 58a1c5d879
commit 5ad210b7e1

View File

@ -659,33 +659,28 @@ Server.prototype._onAnnounce = function (params, cb) {
self.getSwarm(params.info_hash, function (err, swarm) {
if (err) return cb(err)
if (swarm) {
announce(swarm)
if (self._filter) {
self._filter(params.info_hash, params, function (err) {
// Precense of err means that this torrent or user is disallowd
if (err) cb(err)
else {
if (swarm) announce(swarm)
else createSwarm()
}
})
} else {
createSwarm()
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)
})
}
})
} else {
self.createSwarm(params.info_hash, function (err, swarm) {
if (err) return cb(err)
announce(swarm)
})
}
}
function announce (swarm) {
if (!params.event || params.event === 'empty') params.event = 'update'