Bt   java bittorrent done right

Release 1.3

Release 1.3 was published to Maven Central on July 29th, 2017. It includes two major updates:

Officially called BEP-9: Extension for Peers to Send Metadata Files, this feature is highly important for any modern BitTorrent client. It allows the participants of a BitTorrent network to exchange torrent metadata without the need for downloading a .torrent file.

New methods in the client builder make using a magnet link in Bt very straight-forward:

// create a streaming torrent from a magnet link
BtClient client = Bt.client()
                    .storage(new FileSystemStorage(new File("~/Downloads")))
                    .selector(SequentialSelector.sequential())
                    .magnet("magnet:?xt=urn:btih:B5A725522B0B4DB73AD2491BA1AD58F13D853315")
                    .build();

Some magnet links also contain “bootstrapping” tracker and peer addresses, which can be used to quickly connect to the swarm. Of course, these are fully supported as well. For convenience, there’s also an overloaded version of builder method: bt.BaseClientBuilder#magnet(bt.magnet.MagnetUri), that accepts a programmatically created magnet link.

CLI launcher has also been updated to accommodate this new feature. E.g. streaming a media file is now as easy as copying the magnet link from browser and providing it to the launcher via -m parameter and adding an -S flag to download in sequential order:

$ java -jar bt-launcher.jar -m "magnet:?xt=urn:btih:B5A725522B0B4DB73AD2491BA1AD58F13D853315" -d ~/Downloads -S

DHT module is now available in Maven Central

Bt has had DHT support for nearly half a year already, but only now it’s become possible to publish the bt-dht module to Maven Central, removing the need to build it manually from source. It’s all thanks to the authors and maintainers of Bittorrent Mainline DHT implementation in Java, who have agreed to change the license from GPL 2.0 to a more permissive Mozilla License 2.0, which is compatible with Apache License 2.0, used by Bt. My personal thanks to The8472, who currently maintains mldht and have coordinated this change.


As usual, here’s the complete list of what has been done:

Official BEPs:

  • BEP-9: Extension for Peers to Send Metadata Files

Changes/New Features:

  • Added ByteRange for working with binary ranges based on byte arrays and byte buffers
  • Support creating torrents from binary representation of info dictionary

Bug Fixes/Improvements:

  • Introduced notion of torrent processing chain
  • Fixed bug in extended protocol (invalid message type id mapping for peers) that sometimes prevented peers from receiving extended messages from Bt
  • Reduced dependency on the presence of a torrent; using torrent ID where possible
  • Perform peers lookup for active torrents only
  • Support HTTPS trackers
  • Configurable list of bootstrap DHT nodes
  • Configurable MSE private key size
  • Headless mode in CLI client (Windows compatibility)
  • Fix for occasional UI crashes in CLI client
  • Allow to specify the desired log level in CLI client (normal, verbose, trace)