Skip to main content

efficent full implementation of the bittorent mainline dht

Project description

github_version pypi_version licence doc

The aim of btdht is to provide a powerful implementation of the Bittorrent mainline DHT easily extended to build application over the DHT. The author currently uses it to crawl the dht and has been able to retrieve more than 200.000 torrents files a day.

The implementation is fully compliant with the BEP5 and the kademlia paper [1] (with a predominance of the BEP5 over the paper) For example, this implementation uses a bucket-based approach for the routing table.

Dependencies

Build dependencies

  • A C compiler

  • cython

  • python header files

Installation

The recommended installation mode is to use a virtualenv.

To Install btdht using the last published release, run:

$ pip install btdht

Alternatively if you want to use the version of the git repository, you can clone it:

$ git clone https://github.com/nitmir/btdht
$ cd btdht
$ pip install -r requirements-dev.txt

Then, run make install to compile the sources and create a python package and install it with pip.

For installing or building on linux and unix systems, you will need a C compiler and the python headers (installing the packages build-essential and python-dev should be enough on debian like systems, you’ll probably gonna need make, gcc, python2-devel and redhat-rpm-config on centos like systems).

On windows systems, we provide pre-builded releases for python 2.7 and 3.5 so just running pip install btdht should be fine. If you want to build from the sources of the repository or, for another python version, you will also need a C compiler.

Usage examples

Search for the peers announcing the torrent 0403fb4728bd788fbcb67e87d6feb241ef38c75a (Ubuntu 16.10 Desktop (64-bit))

>>> import btdht
>>> import binascii
>>> dht = btdht.DHT()
>>> dht.start()  # now wait at least 15s for the dht to boostrap
init socket for 4c323257aa6c4c5c6ccae118db93ccce5bb05d92
Bootstraping
>>> dht.get_peers(binascii.a2b_hex("0403fb4728bd788fbcb67e87d6feb241ef38c75a"))
[
    ('81.171.107.75', 17744),
    ('94.242.250.86', 3813),
    ('88.175.164.228', 32428),
    ('82.224.107.213', 61667),
    ('85.56.118.178', 6881),
    ('78.196.28.4', 38379),
    ('82.251.140.70', 32529),
    ('78.198.108.3', 10088),
    ('78.235.153.136', 10619),
    ('88.189.113.32', 33192),
    ('81.57.9.183', 5514),
    ('82.251.17.155', 14721),
    ('88.168.207.178', 31466),
    ('82.238.89.236', 32970),
    ('78.226.209.88', 2881),
    ('5.164.219.48', 6881),
    ('78.225.252.39', 31002)
]

Subsequent calls to get_peers may return more peers.

You may also inherit btdht.DHT_BASE and overload some of the on_`msg`_(query|response) functions. See the doc for a full overview of the btdht API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

btdht-0.3.1.tar.gz (605.6 kB view details)

Uploaded Source

Built Distributions

btdht-0.3.1-cp35-cp35m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.5m Windows x86-64

btdht-0.3.1-cp35-cp35m-win32.whl (1.0 MB view details)

Uploaded CPython 3.5m Windows x86

btdht-0.3.1-cp27-cp27m-win_amd64.whl (1.1 MB view details)

Uploaded CPython 2.7m Windows x86-64

btdht-0.3.1-cp27-cp27m-win32.whl (1.0 MB view details)

Uploaded CPython 2.7m Windows x86

File details

Details for the file btdht-0.3.1.tar.gz.

File metadata

  • Download URL: btdht-0.3.1.tar.gz
  • Upload date:
  • Size: 605.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for btdht-0.3.1.tar.gz
Algorithm Hash digest
SHA256 639253291b99ce1d752b307d2f49474f191539aca0902a0f6cad1df3417cbd09
MD5 2efafde1b136455d947a0b6e543c506f
BLAKE2b-256 86427f553bef69cc5e8df6410f1674d611d23eb60962195c4d93c6c23bb688a6

See more details on using hashes here.

File details

Details for the file btdht-0.3.1-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for btdht-0.3.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 c0631835ac45956337da7456ebf251b3e81528398417a54afb1e57101f11c432
MD5 e29cc6d4d030d14dc9fdbb61e99c6d38
BLAKE2b-256 3cd9556447eecc5ed15b9971b49e161bc11850eb728b3a6bfc8ab27a6ab57160

See more details on using hashes here.

File details

Details for the file btdht-0.3.1-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for btdht-0.3.1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 edb7e2a245db300aed0c4e9215ad1b8d42d9234e0c18faf3a39ee0994ef35bf5
MD5 3bd907c1ea633f7ff778f4180f72907f
BLAKE2b-256 7464366b9ed6b01f37435b898e5e65d4f058d765ff35f9ce68d774586ed62499

See more details on using hashes here.

File details

Details for the file btdht-0.3.1-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for btdht-0.3.1-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 883215f31050619d28bc01fa2c5a3693e6ec230508ada3845557462c8a8a9ba3
MD5 837307b1553fc37e65f6992b79ebc52d
BLAKE2b-256 69380b36ed4c3ffcf48ed15bf4747230ecce0346b580fcbb7521884ffb9fd45e

See more details on using hashes here.

File details

Details for the file btdht-0.3.1-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for btdht-0.3.1-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 368394e5826250eb78c11c950e77626fbd72a5e6019da7e6cb44be202ffd3c15
MD5 744f29066a1647bb40b00d123e4cd793
BLAKE2b-256 6443b928888675395c21a5d0bb601986cf4c68ca86f35afb308102bbc0fe9d1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page