mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-19 04:31:36 +00:00
preserve backwards compatibility
This commit is contained in:
parent
de19b61c52
commit
bdc7edea70
@ -111,13 +111,14 @@ var Server = require('bittorrent-tracker').Server
|
|||||||
var server = new Server({
|
var server = new Server({
|
||||||
udp: true, // enable udp server? [default=true]
|
udp: true, // enable udp server? [default=true]
|
||||||
http: true, // enable http server? [default=true]
|
http: true, // enable http server? [default=true]
|
||||||
filter: function (params) {
|
filter: function (infoHash, params) {
|
||||||
// black/whitelist for disallowing/allowing torrents [default=allow all]
|
// black/whitelist for disallowing/allowing torrents [default=allow all]
|
||||||
// this example only allows this one torrent
|
// this example only allows this one torrent
|
||||||
return params.info_hash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa'
|
return infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa'
|
||||||
|
|
||||||
// you can also block by peer id (whitelisting torrent clients) or by
|
// you can also block by peer id (whitelisting torrent clients) or by
|
||||||
// secret key, as you get full access to the original http request
|
// secret key, as you get full access to the original http GET
|
||||||
|
// request parameters in `params`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -111,8 +111,9 @@ Server.prototype.close = function (cb) {
|
|||||||
|
|
||||||
Server.prototype.getSwarm = function (infoHash, params) {
|
Server.prototype.getSwarm = function (infoHash, params) {
|
||||||
var self = this
|
var self = this
|
||||||
if (Buffer.isBuffer(infoHash)) infoHash = params.info_hash = infoHash.toString('hex')
|
if (!params) params = {}
|
||||||
if (self._filter && !self._filter(params)) return null
|
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex')
|
||||||
|
if (self._filter && !self._filter(infoHash, params)) return null
|
||||||
var swarm = self.torrents[infoHash]
|
var swarm = self.torrents[infoHash]
|
||||||
if (!swarm) swarm = self.torrents[infoHash] = new Swarm(infoHash, this)
|
if (!swarm) swarm = self.torrents[infoHash] = new Swarm(infoHash, this)
|
||||||
return swarm
|
return swarm
|
||||||
|
Loading…
Reference in New Issue
Block a user