forked from webtorrent/bittorrent-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·28 lines (23 loc) · 741 Bytes
/
server.js
File metadata and controls
executable file
·28 lines (23 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
const Server = require('../..').Server
const express = require('express')
const app = express()
// https://wiki.theory.org/BitTorrentSpecification#peer_id
const whitelist = {
UT: true // uTorrent
}
const server = new Server({
http: false, // we do our own
udp: false, // not interested
ws: false, // not interested
filter (params) {
// black/whitelist for disallowing/allowing specific clients [default=allow all]
// this example only allows the uTorrent client
const client = params.peer_id[1] + params.peer_id[2]
return whitelist[client]
}
})
const onHttpRequest = server.onHttpRequest.bind(server)
app.get('/announce', onHttpRequest)
app.get('/scrape', onHttpRequest)
app.listen(8080)