0 purchases
dtorrent tracker
About #
Dart implementation of a BitTorrent Http/Https and UDP tracker/scrape client
Support #
BEP 0003 HTTP/HTTPS Tracker/Scrape
BEP 0015 UDP Tracker/Scrape
BEP 0007 IPv6 Tracker Extension
How to use it #
Tracker #
To create the TorrentAnnounceTracker instance, the parameter AnnounceOptionProvider should be provided.
Howerver, there is not any implements , user have to implement it manually:
class SimpleProvider implements AnnounceOptionsProvider {
SimpleProvider(this.torrent, this.peerId, this.port);
String peerId;
int port;
String infoHash;
Torrent torrent;
int compact = 1;
int numwant = 50;
@override
Future<Map<String, dynamic>> getOptions(Uri uri, String infoHash) {
return Future.value({
'downloaded': 0,
'uploaded': 0,
'left': torrent.length,
'compact': compact,// it should be 1
'numwant': numwant, // max is 50
'peerId': peerId,
'port': port
});
}
}
copied to clipboard
When we have the AnnounceOptionsProvider instance, we can create a TorrentAnnounceTracker like this:
var torrentTracker = TorrentAnnounceTracker(SimpleProvider(....));
copied to clipboard
TorrentAnnounceTracker have some methods to run started,stopped,completed announce event:
torrentTracker.runTracker(url,infohash,event:'started');
copied to clipboard
We can add some listener on the torrentTracker to get the announce result:
torrentTracker.onAnnounceError((source, error) {
log('announce error:', error: error);
});
torrentTracker.onPeerEvent((source, event) {
print('${source.announceUrl} peer event: $event');
});
torrentTracker.onAnnounceOver((source, time) {
print('${source.announceUrl} announce over!: $time');
source.dispose();
});
copied to clipboard
Scrape #
Create a TorrentScrapeTracker instance:
var scrapeTracker = TorrentScrapeTracker();
copied to clipboard
Then add the scrape url (same with the announce tracker url, TorrentScrapeTracker will transform it) and infohash buffer to create a Scrape:
scrapeTracker.addScrapes(torrent.announces, torrent.infoHashBuffer);
copied to clipboard
NOTE: The Scrape can add more than one infoHashbuffer , because it can "scrape" multiple torrent informations at one time, so if user invoke addScrapes or addScrape with same url but different infohashbuffer , it will return the same Scrape instance.
To get the scrape result:
scrapeTracker.scrape(torrent.infoHashBuffer).listen((event) {
print(event);
});
copied to clipboard
The method scrape need a infoHashbuffer as the parameter and return a Stream , user can listen the Stream event to get the result.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.