@@ -223,6 +223,57 @@ server.torrents[infoHash].peers
223223
224224The http server will handle requests for the following paths: ` /announce ` , ` /scrape ` . Requests for other paths will not be handled.
225225
226+ ## Using HTTPS and WSS
227+
228+ ```
229+ var Server = require('bittorrent-tracker').Server
230+ var fs = require('fs')
231+
232+ var privateKey = fs.readFileSync('ssl-cert/privkey.pem');
233+ var certificate = fs.readFileSync('ssl-cert/fullchain.pem');
234+
235+ var server = new Server({
236+ udp: true, // enable udp server? [default=true]
237+ http: true, // enable http server? [default=true]
238+ ws: true, // enable websocket server? [default=true]
239+ ssl: {
240+ key: privateKey,
241+ cert: certificate
242+ },
243+ stats: true, // enable web-based statistics? [default=true]
244+ filter: function (infoHash, params, cb) {
245+ // Blacklist/whitelist function for allowing/disallowing torrents. If this option is
246+ // omitted, all torrents are allowed. It is possible to interface with a database or
247+ // external system before deciding to allow/deny, because this function is async.
248+
249+ // It is possible to block by peer id (whitelisting torrent clients) or by secret
250+ // key (private trackers). Full access to the original HTTP/UDP request parameters
251+ // are available in `params`.
252+
253+ // This example only allows one torrent.
254+
255+ var allowed = (infoHash === 'aaa67059ed6bd08362da625b3ae77f6f4a075aaa')
256+ if (allowed) {
257+ // If the callback is passed `null`, the torrent will be allowed.
258+ cb(null)
259+ } else {
260+ // If the callback is passed an `Error` object, the torrent will be disallowed
261+ // and the error's `message` property will be given as the reason.
262+ cb(new Error('disallowed torrent'))
263+ }
264+ }
265+ })
266+
267+ server.on('listening', function () {
268+ // fired when all requested servers are listening
269+ console.log('listening on https port:' + server.http.address().port)
270+ console.log('listening on wss port:' + server.ws.address().port)
271+ console.log('listening on udp port:' + server.udp.address().port)
272+ })
273+ ```
274+
275+ The tracker will load with https:// and wss://, but no with http:// and ws://.
276+
226277## multi scrape
227278
228279Scraping multiple torrent info is possible with a static ` Client.scrape ` method:
0 commit comments