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.0.tar.gz (580.0 kB view details)

Uploaded Source

Built Distributions

btdht-0.3.0-cp35-cp35m-win_amd64.whl (962.3 kB view details)

Uploaded CPython 3.5m Windows x86-64

btdht-0.3.0-cp35-cp35m-win32.whl (928.0 kB view details)

Uploaded CPython 3.5m Windows x86

btdht-0.3.0-cp27-cp27m-win_amd64.whl (992.3 kB view details)

Uploaded CPython 2.7m Windows x86-64

btdht-0.3.0-cp27-cp27m-win32.whl (934.6 kB view details)

Uploaded CPython 2.7m Windows x86

File details

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

File metadata

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

File hashes

Hashes for btdht-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5a157c43704b462573402808e2e75464e2f9a5d433d3f6e5b54489eb11fc63b7
MD5 1c05e9c2682575e9058c573e870bf379
BLAKE2b-256 37c0d923fef89ae99cc511a914ccbca4dfb6e8b0ff1bcebb59b6dcd793c8aa30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for btdht-0.3.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 84e4e475a15ff4c7835cd029b6f88b4778259be44c91bbfca0cdf12532832d8a
MD5 e5758ba64a8f80d252187431995c083d
BLAKE2b-256 f6e6b95bd4e64707f0e23c349852ce5d37b338984601d605b6cf34ca9f45c5d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for btdht-0.3.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 20f7e272ef9455bc9d4895706a7a1f974c85430064aa8c2a2a000d3bf41a6671
MD5 7b5341ef0e7562ac2407f24319946b7d
BLAKE2b-256 e2aa049d250230871d7afc94f2990d847e867746a335acd6b5ba5f0f755dc4fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for btdht-0.3.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 781ece97f73e0b80961d5b8940d34ae0268da5ded54d6a353645f8376bcf6d8f
MD5 f4d335a099791452c54e65e753e4b50d
BLAKE2b-256 0a216d27ee824a2a274592aa8336eb0433ec1e4f9b8a709a4532d1b1e2555e77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for btdht-0.3.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 fa9931a7f5812fe3c2c519ddc7411b8bbfdd5af946f09dbea60b82d5d667ed57
MD5 3d4def69dc70fb0664aac58c480bfdb9
BLAKE2b-256 ffb430175771f5d4a569a33b28b13a437d460fc117c40c259a83ab552c1c5296

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