Merge pull request #272 from qqdaiyu55/master

Fix filter function
This commit is contained in:
Feross Aboukhadijeh 2018-04-29 20:50:48 -07:00 committed by GitHub
commit c98c40abe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -659,32 +659,27 @@ Server.prototype._onAnnounce = function (params, cb) {
self.getSwarm(params.info_hash, function (err, swarm) { self.getSwarm(params.info_hash, function (err, swarm) {
if (err) return cb(err) 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 { } else {
createSwarm() if (swarm) announce(swarm)
else createSwarm()
} }
}) })
function createSwarm () { function createSwarm () {
if (self._filter) { self.createSwarm(params.info_hash, function (err, swarm) {
self._filter(params.info_hash, params, function (err) { if (err) return cb(err)
// Precense of err means that this info_hash is disallowed announce(swarm)
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) { function announce (swarm) {