bittorrent-tracker/examples/express-embed/server.js

29 lines
737 B
JavaScript
Raw Normal View History

2014-12-12 15:51:37 +00:00
#!/usr/bin/env node
var Server = require('../..').Server
var express = require('express')
var app = express()
// https://wiki.theory.org/BitTorrentSpecification#peer_id
var whitelist = {
UT: true // uTorrent
}
2014-12-12 15:51:37 +00:00
var server = new Server({
http: false, // we do our own
2018-02-18 01:13:56 +00:00
udp: false, // not interested
ws: false, // not interested
filter: function (params) {
// black/whitelist for disallowing/allowing specific clients [default=allow all]
// this example only allows the uTorrent client
var client = params.peer_id[1] + params.peer_id[2]
return whitelist[client]
}
2014-12-12 15:51:37 +00:00
})
var onHttpRequest = server.onHttpRequest.bind(server)
2014-12-12 15:51:37 +00:00
app.get('/announce', onHttpRequest)
app.get('/scrape', onHttpRequest)
app.listen(8080)