BitTorrent Client with DHT support written in Java using Eclipse Vert.x.
- Leeching
- Seeding
- Single-file torrents
- Multi-file torrents
- Optimistic Unchoking
- Endgame
- DHT
- DHT Storage
- UDP Tracker
- Magnet Links
- BEP 0003 (BitTorrent Protocol)
- BEP 0005 (Distributed Hash Table)
- BEP 0007 (IPv6 Tracker Extension)
- BEP 0044 (DHT Data Storage)
The application can be started using the run
script with a path(s) to torrent file(s) as an argument:
./run <torrent_file> [<torrent_file2> ...]
The script will build the application using gradle installDist
.
To trigger a rebuild with the script, gradle clean
needs to be run to delete the build files.
Alternatively the gradle run task can be used:
gradle run --args="<torrent_file> [<torrent_file2> ...]"
Using DHT requires that an entrypoint is specified.
This can be set with the environment variable DHT_BOOTSTRAP_NODE
or parameter --dht-bootstrap-node
for example to 87.98.162.88:6881
(dht.transmissionbt.com
).
DHT_BOOTSTRAP_NODE=87.98.162.88:6881 ./run <torrent_file> [<torrent_file2> ...]
./run <torrent_file> [<torrent_file2> ...] --dht-bootstrap-node 87.98.162.88:6881
The routing table will be saved to dht.json
.
To build a distributable application:
./gradlew clean build
This will create a zip file at build/distributions/vertx-bittorrent-*.zip
.
The archive includes the jar files and start scripts for Windows and Unix systems.
Vert.x works in a reactive way using an event loop. Therefore multiple sockets can be managed with the same single thread in contrast to a concurrent model where each connection is handled by a new thread. The advantage is that no synchronization needs to happen between threads since there is only one thread. This makes it easy to work with data from multiple connections without running into race conditions.
And BitTorrent requires to connect to many other peers and creating a new thread for each peer would also be expensive (this applies to OS threads, not virtual threads).