A Tracker which will "chuang" you
A high-performance BitTorrent Tracker implemented in Go. Using Hertz from cloudwego, with observability.
This tracker is hosted as https://btn-prod.ghostchu-services.top/announce
For benchmark, please refer to the Benchmark section.
./build.sh
cd output
./bootstrap.sh
or
docker pull gaojianli2333/trunker:latest
- BEP-0003
- BEP-0007 (IPv6 Tracker Extension)
- BEP-0023 (Compact Peer Lists)
- BEP-0024 (External IP)
- BEP-0031 (Failure Retry Extension)
- BEP-0048 (Scrape)
- LT-Extension (complete,incomplete)
- Full-Memory Mode
- Load from Persist
- MySQL Mode
Name | Description | Default |
---|---|---|
ttl | The time of a peer announce next time. | 3600s |
invervalTask | The interval of the task to clean the expired peers. | 600s |
useDB | Use the database to store the data. (currently no usable) | false |
enablePersist | Save the peers to the disk and load them while launching. | true |
maxPeersPerTorrent | The max number of peers per torrent. | 100 |
shard | The number of shards. More shards will improve response time, by cost more memory. | 16 |
useUnixSocket | Use Unix Socket instead tcp | false |
hostPorts | The host and port of the server, For unix socket mode, this is the file name of the sock file. | 127.0.0.1:8888 |
useAnnounceIP | Allow peer to announce its IP in the query string. | true |
enableEventProducer | Send peer event to the mq. Caution: This will produce tons of message. | false |
JSON config is also supported with env TRUNKER_CONFIG
.
Trunker provides a simple admin interface to check the status of the tracker. Before using the admin interface, you need to set the ADMIN_KEY
env.
Header: Authorization: Bearer ${ADMIN_KEY}
Method | Path | Description |
---|---|---|
GET | /admin/statistic |
Get the statistic of the tracker. |
You can ban some torrent or peer by using the following endpoints.
Method | Path | Description |
---|---|---|
PUT | /admin/ban/info_hash |
Ban a torrent by info_hash. |
DELETE | /admin/ban/info_hash |
Clear all info_hash ban list. |
PUT | /ban/peer |
Ban a peer by peer_id. |
DELETE | /ban/peer |
Clear all peer ban list. |
Method | Path | Description |
---|---|---|
GET | /admin/info_hash/:infoHash/peers |
Get all peers of a info_hash. The response may be very large |
DELETE | /admin/info_hash/:infoHash |
Delete a info_hash |
Currently trunker is serving a prometheus handler at :9091
by default. With 2 paths:
/metrics
Providing metrics about http request, including latency and QPS./pprof
Providing golang runtime pprof info.
CPU: 4 Cores ARM64 Oracle Cloud
Average response time: 600μs when 30K torrents and 27K peers are online.
QPS: 700~ (can be higher but we don't have such many peers connect to our tracker)
Memory Cost: 348MB.