Skip to content
This repository was archived by the owner on Jun 6, 2022. It is now read-only.

Commit bdc7ede

Browse files
committed
preserve backwards compatibility
1 parent de19b61 commit bdc7ede

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,14 @@ var Server = require('bittorrent-tracker').Server
111111
var server = new Server({
112112
udp: true, // enable udp server? [default=true]
113113
http: true, // enable http server? [default=true]
114-
filter: function (params) {
114+
filter: function (infoHash, params) {
115115
// black/whitelist for disallowing/allowing torrents [default=allow all]
116116
// this example only allows this one torrent
117-
return params.info_hash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa'
118-
117+
return infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa'
118+
119119
// you can also block by peer id (whitelisting torrent clients) or by
120-
// secret key, as you get full access to the original http request
120+
// secret key, as you get full access to the original http GET
121+
// request parameters in `params`
121122
})
122123
})
123124

server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ Server.prototype.close = function (cb) {
111111

112112
Server.prototype.getSwarm = function (infoHash, params) {
113113
var self = this
114-
if (Buffer.isBuffer(infoHash)) infoHash = params.info_hash = infoHash.toString('hex')
115-
if (self._filter && !self._filter(params)) return null
114+
if (!params) params = {}
115+
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex')
116+
if (self._filter && !self._filter(infoHash, params)) return null
116117
var swarm = self.torrents[infoHash]
117118
if (!swarm) swarm = self.torrents[infoHash] = new Swarm(infoHash, this)
118119
return swarm

0 commit comments

Comments
 (0)