Fixed error reporting in tracker tests
parent
cbf1ad9fcf
commit
f2fac6948e
|
@ -87,5 +87,5 @@ either 'started', 'stopped', 'completed' or 'empty' (for regular queries).
|
|||
uploaded = 0, downloaded = 0, left = 0, event = 'started')
|
||||
- udp_get_peers(tracker_url, info_hash, peer_id, ip = '0.0.0.0', port = 0,
|
||||
uploaded = 0, downloaded = 0, left = 0, event = 'started', num_want = -1, key = 0)
|
||||
With num_want it is possible to tell the tracker who many peers should be sent. The parameter key
|
||||
With num_want it is possible to tell the tracker how many peers should be sent. The parameter key
|
||||
should be a unique key that is randomized by the client.
|
||||
|
|
12
tracker.py
12
tracker.py
|
@ -129,8 +129,14 @@ def http_get_peers(tracker_url, info_hash, peer_id, ip = '0.0.0.0', port = 0,
|
|||
return list(decode_connections(decoded[b'peers']))
|
||||
|
||||
if __name__ == '__main__':
|
||||
import os, binascii
|
||||
import os, binascii, logging
|
||||
peer_id = os.urandom(20)
|
||||
info_hash = binascii.unhexlify('ae3fa25614b753118931373f8feae64f3c75f5cd') # Ubuntu 15.10 info hash
|
||||
print(http_get_peers('http://torrent.ubuntu.com:6969/announce', info_hash, peer_id))
|
||||
print(udp_get_peers('udp://tracker.openbittorrent.com:80', info_hash, peer_id))
|
||||
try:
|
||||
print(http_get_peers('http://torrent.ubuntu.com:6969/announce', info_hash, peer_id))
|
||||
except Exception:
|
||||
logging.exception('Exception during http query')
|
||||
try:
|
||||
print(udp_get_peers('udp://tracker.coppersurfer.tk:6969', info_hash, peer_id))
|
||||
except Exception:
|
||||
logging.exception('Exception during udp query')
|
||||
|
|
Loading…
Reference in New Issue