mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-08 07:11:35 +00:00
e6d3189edf
BREAKING CHANGE: ESM only * feat: esm * fix: linter oops
29 lines
737 B
JavaScript
Executable File
29 lines
737 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import { Server } from '../../index.js'
|
|
import express from '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)
|