diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e3929f3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: python +sudo: false +python: + - "2.7" + - "3.3" + - "3.4" + - "3.5" + - "pypy" +before_install: + - pip install codecov + - pip install 'coverage<4' +script: + - coverage run -a bencode.py + - coverage run -a crc32c.py + - coverage run -a krpc.py + - coverage run -a dht.py +after_success: + - codecov diff --git a/README.md b/README.md index 6d687bd..5d02f27 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Build Status](https://travis-ci.org/FredStober/tinyBT.svg?branch=master)](https://travis-ci.org/FredStober/tinyBT) +[![Coverage](https://codecov.io/github/FredStober/tinyBT/coverage.svg?branch=master)](https://codecov.io/github/FredStober/tinyBT?branch=master) + tiny Bittorrent client ====================== @@ -55,11 +58,15 @@ a user specified timeout: The final three functions are used to start and shutdown the local DHT Peer and allow access to the discovered external connection infos: + - __init__(listen_connection, bootstrap_connection = ('router.bittorrent.com', 6881), - setup = {'report_t': 10, 'check_t': 30, 'check_N': 10, 'discover_t': 180}) + user_setup = {}, user_router = None) The constructor needs to know what address and port to listen on and which node to use as a bootstrap node. The run interval and some other parameters of the maintainance - threads can be configured as well. + threads can be configured as well via the user_setup parameter. The default values are: + {'discover_t': 180, 'check_t': 30, 'check_N': 10}. + It is possible to provide a user implemntation for the DHT node router with the user_router + parameter - shutdown() Start shutdown of the local DHT peer and all associated maintainance threads. - get_external_connection() diff --git a/bencode.py b/bencode.py index ebc699d..d125859 100644 --- a/bencode.py +++ b/bencode.py @@ -28,7 +28,7 @@ class BTFailure(Exception): # Encoding functions ############################################## import sys -if sys.version_info.major >= 3: +if sys.version_info[0] >= 3: str_to_bytes = lambda x: x.encode('ascii') else: str_to_bytes = lambda x: x diff --git a/dht.py b/dht.py index ba7543d..6a60082 100644 --- a/dht.py +++ b/dht.py @@ -468,7 +468,7 @@ if __name__ == '__main__': break import binascii - info_hash = binascii.unhexlify('cb84ccc10f296df72d6c40ba7a07c178a4323a14') # Ubuntu 14.04 info hash + info_hash = binascii.unhexlify('ae3fa25614b753118931373f8feae64f3c75f5cd') # Ubuntu 15.10 info hash log.critical('starting "get_peers" test') for idx, peer in enumerate(dht5.dht_get_peers(info_hash)):