dtorrent_task_v2 0.4.2 copy "dtorrent_task_v2: ^0.4.2" to clipboard
dtorrent_task_v2: ^0.4.2 copied to clipboard

BitTorrent download client package written by pure Dart language.

About #

Dart library for implementing BitTorrent client.

The Dart Torrent client consists of several parts:

This package implements the regular BitTorrent Protocol and manages the above packages to work together for downloading.

BEP Support #

Developing:

Other support will come soon.

How to use #

This package requires dependency dtorrent_parser:

dependencies:
  dtorrent_parser: ^1.0.8
  dtorrent_task_v2: ^0.4.2

Download from: DTORRENT_TASK_V2

Import the library:

import 'package:dtorrent_task_v2/dtorrent_task_v2.dart';

First, create a Torrent model from a .torrent file:

  var model = await Torrent.parse('some.torrent');

Second, create a Torrent Task and start it:

  var task = TorrentTask.newTask(model, 'savepath');
  await task.start();

You can add event listeners to monitor TorrentTask execution:

  EventsListener<TaskEvent> listener = task.createListener();
  listener
    ..on<TaskCompleted>((event) {
      print('Download completed!');
    })
    ..on<TaskFileCompleted>((event) {
      print('File completed: ${event.file.originalFileName}');
    })
    ..on<TaskStopped>((event) {
      print('Task stopped');
    });

And there are methods to control the TorrentTask:

   // Stop task:
   await task.stop();
   // Pause task:
   task.pause();
   // Resume task:
   task.resume();

Monitoring and Error Tracking #

The library includes comprehensive error tracking for uTP protocol stability:

import 'package:dtorrent_task_v2/src/peer/protocol/peer.dart';

// Check RangeError metrics
if (Peer.rangeErrorCount > 0) {
  print('Total RangeErrors: ${Peer.rangeErrorCount}');
  print('uTP RangeErrors: ${Peer.utpRangeErrorCount}');
  print('Errors by reason: ${Peer.rangeErrorByReason}');
}

// Reset metrics for new monitoring period
Peer.resetRangeErrorMetrics();

These metrics help monitor uTP protocol stability and debug RangeError crashes, particularly those related to selective ACK processing and buffer handling.

Features #

Stability Improvements #

  • uTP RangeError Protection: Comprehensive protection against RangeError crashes in uTP protocol with:
    • Buffer bounds validation before all operations
    • Message length validation (negative, oversized, and overflow protection)
    • Integer overflow protection in calculations
    • Detailed error tracking and metrics
    • Extensive test coverage (stress tests, reordering, extreme values, long sessions)

Protocol Support #

  • Full BitTorrent protocol implementation
  • uTP (uTorrent transport protocol) support with enhanced stability
  • TCP fallback support
  • Multiple extension protocols (PEX, LSD, Holepunch, Metadata Exchange)

Performance #

  • Efficient piece management and selection
  • Memory-optimized file handling
  • Streaming support for media files
  • Congestion control for uTP connections
2
likes
0
points
147
downloads

Publisher

unverified uploader

Weekly Downloads

BitTorrent download client package written by pure Dart language.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, b_encode_decode, bittorrent_dht, collection, crypto, dart_ipify, dtorrent_common, dtorrent_parser, dtorrent_tracker, events_emitter2, logging, mime, utp_protocol

More

Packages that depend on dtorrent_task_v2