dtorrent_task_v2 0.4.2
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 #
- BEP 0003 The BitTorrent Protocol Specification
- BEP 0005 DHT Protocol
- BEP 0006 Fast Extension
- BEP 0010 Extension Protocol
- BEP 0011 Peer Exchange (PEX)
- BEP 0014 Local Service Discovery
- BEP 0015 UDP Tracker Protocol
- BEP 0029 uTorrent transport protocol
- BEP 0055 Holepunch extension
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