Skip to content

v0.9.0

Choose a tag to compare

@github-actions github-actions released this 27 Sep 13:50
· 40 commits to main since this release
4a1a6d4

mtorrent v0.9.0

This release adds a seeding mode and lets you stop a download instantly with a separate cancel signal. It also fixes a uTP reconnection bug and reworks how the DHT limits and tracks its queries. It includes breaking API changes in the mtorrent and mtorrent-dht library crates.

Highlights

Seeding mode (--seed)

  • CLI: the new --seed flag keeps uploading to peers after the download is complete, until you press Ctrl+C.
  • Library: the new app::main::Mode setting in app::main::Config:
    • Mode::Leech (the default) exits once the download is complete and every active leech has received some data.
    • Mode::Seeder keeps uploading until cancelled.

Immediate cancellation

  • Stopping a download: single_torrent() now takes a cancel future. The download stops as soon as that future resolves, instead of waiting for the next state snapshot.
  • Saving progress: progress is written to disk every few seconds, only when it has changed, and once more before returning. This no longer depends on the listener's snapshot interval.
  • CLI: Ctrl+C now takes effect immediately, and the CLI logs a state snapshot every 10 seconds.

Full piece bitfield in state snapshots

PiecesSnapshot now has a bitfield field listing which pieces have been downloaded. It is serialized as a string of 0s and 1s. The snapshot types also implement Debug now.

Breaking changes

mtorrent

  • app::main::single_torrent:
    • It takes a new cancel: impl Future<Output = ()> argument, placed between listener and cfg.
    • It returns io::Result<Outcome> instead of io::Result<()>. Outcome is either Finished or Cancelled.
    • Don't stop a download by dropping the returned future. Background tasks would then be aborted instead of shut down cleanly, and UPnP port mappings would not be removed. Resolve cancel and wait for the future to complete instead.
  • utils::listener::StateListener::on_snapshot:
    • It now returns () instead of ControlFlow<()>. Listeners can no longer stop the download; use cancel for that.
    • It is called as soon as each stage (metadata, then content) starts, and then every INTERVAL.
  • app::main::Config has a new mode field.
  • utils::listener::PiecesSnapshot has a new public bitfield field.

mtorrent-dht

  • Concurrency limit: the limit on outstanding outbound queries now applies to each operation (for example, each search) instead of globally.
    • It moved from dht::setup_queries(...) to dht::Processor::new(config_dir, outbound_queries, max_concurrent_queries).
    • setup_queries now takes (outgoing_msgs_sink, incoming_msgs_source, query_timeout).
  • Renamed values: the values returned by setup_queries were renamed from client, server to outbound_queries, inbound_queries, and the README and crate docs use the new names.
  • dht_node binary: --parallel-queries now sets the limit per operation. 0 runs the node as a passive server.

Improvements

  • DHT node tracking: the DHT now remembers every recently probed node, not only the ones that answered well. It uses a bounded set of 128K entries, so the same nodes aren't probed over and over.
  • DHT bootstrap addresses: bootstrap nodes that resolve to disallowed remote IP addresses are now skipped.
  • Documentation: the mtorrent crate is now fully documented, and CI fails if a public item has no docs.

Bug fixes

  • uTP reconnect between stages: after the metadata download, mtorrent reconnects to the same peer over uTP. A late FIN packet from the old connection could be mistaken for the reply to the new connection request. The new connection then failed and the download hung. The handshake now ignores packets that belong to the old connection.
  • uTP connect errors: failed uTP connection attempts now return meaningful io::ErrorKind values:
    • ConnectionReset when the peer answers with RESET.
    • UnexpectedEof when it answers with FIN.
    • InvalidData for any other unexpected packet (previously a generic Other error).

Internal

  • Integration tests: a test could connect to peers left over from another test; this is fixed.
  • Dependencies: tokio-util default features are off across the workspace. Only mtorrent-dht enables the time feature.

To see every change, run git log v0.8.0..v0.9.0.

Full Changelog

v0.8.0...v0.9.0