bittorrent_dht 0.0.12 copy "bittorrent_dht: ^0.0.12" to clipboard
bittorrent_dht: ^0.0.12 copied to clipboard

A DHT protocal implemented by Dart. This package implemented BEP-0005 for torrent client

About #

Bittorrent DHT by Dart.

Support:

Usage #

A simple usage example:

import 'package:bittorrent_dht/bittorrent_dht.dart';

main() {
  var dht = DHT();
  dht.announce(infohashStr, port);
  await dht.bootstrap();
}

The method announce can invoke after DHT bootstrap. But I suggest that invoking it before DHT startted;

Onece DHT startted , it will check if there is ant announce , if it has , each new DHT node added , it will try to announce the local peer to the new node.

Before send announce_peer query , it should send get_peers query to get the token first , so when user invoke announce method , it will fire get_peers query automatically and return the result. In other word , if user isn't downloading any resource , he will not to announce local peer and he dont need any related peers also. However, user can invoke requestPeers method to request the peers:

  dht.requestPeers(infoHashStr);

When DHT found any new peer , it will notify the listener:

  dht.onNewPeer((address, port, infoHash) {
    // found new peer for InfoHash
  });

User can add a listener to get error from other nodes:

  dht.onError((code, msg) {
    log('An error occurred', error: '[$code]$msg');
  });

To stop DHT , invoke stop method:

  dht.stop();

Once DHT stopped , each hanlder will be removed and nothing will be save. If user start DHT after it stopped , everything will be fresh.

1
likes
150
pub points
6%
popularity

Publisher

unverified uploader

A DHT protocal implemented by Dart. This package implemented BEP-0005 for torrent client

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

b_encode_decode, collection, dtorrent_common, events_emitter2, logging, meta

More

Packages that depend on bittorrent_dht