https://github.com/elektito/pybtracker
UDP BitTorrent tracker written in Python 3.5 using co-routines and asyncio.
https://github.com/elektito/pybtracker
asyncio bittorrent bittorrent-tracker python tracker
Last synced: 6 months ago
JSON representation
UDP BitTorrent tracker written in Python 3.5 using co-routines and asyncio.
- Host: GitHub
- URL: https://github.com/elektito/pybtracker
- Owner: elektito
- License: mit
- Created: 2016-01-24T10:18:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-01-03T15:52:48.000Z (over 4 years ago)
- Last Synced: 2025-09-24T23:56:18.733Z (10 months ago)
- Topics: asyncio, bittorrent, bittorrent-tracker, python, tracker
- Language: Python
- Size: 24.4 KB
- Stars: 61
- Watchers: 2
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
pybtracker
==========
pybtracker is a UDP BitTorrent tracker written in Python 3.5 using
co-routines and the ``asyncio`` module. You can use the tracker in a
script like this:
::
import asyncio
from pybtracker import TrackerServer
loop = asyncio.get_event_loop()
tracker = TrackerServer(local_addr=('127.0.0.1', 8000), loop=loop)
asyncio.ensure_future(tracker.start())
try:
loop.run_forever()
except KeyboardInterrupt:
loop.run_until_complete(tracker.stop())
It also includes a UDP tracker client:
::
import asyncio
from pybtracker import TrackerClient
async def announce():
client = TrackerClient(announce_uri='udp://127.0.0.1:8000', loop=loop)
await client.start()
peers = await client.announce(
b'01234567890123456789', # infohash
10000, # downloaded
40000, # left
5000, # uploaded
0, # event (0=none)
120 # number of peers wanted
)
print(peers)
loop = asyncio.get_event_loop()
loop.run_until_complete(announce())
You can run the server independently by running:
::
$ python -m pybtracker.server -b 127.0.0.1:8000 -O
The client can also be run independently and it provides you with a
shell to interact with the server:
::
$ python -m pybtracker.client udp://127.0.0.1:8000
BitTorrent tracker client. Type help or ? to list commands.
(btrc) help
Documented commands (type help ):
========================================
EOF announce connect help quit
(btrc) quit
$
If you have installed pybtracker using pip or setup.py, you can also
run ``pybtracker`` and ``pybtracker-client`` instead of using ``python
-m``.