I'm looking to build a bittorrrent client in python. Here is my code to find peers. It only returns none. How do I fix it?
bencodepy is a simple BEncode library
import bencodepy
import hashlib
import btdht
import binascii
from time import sleep
f = open("debian.torrent","rb")
decoded = bencodepy.decode(f.read())
info = bencodepy.encode(dict(decoded.get(b"info")))
info_hash = hashlib.sha1(info).hexdigest()
dht = btdht.DHT()
dht.start()
sleep(15) # wait for the DHT to build
while True:
print(dht.get_peers(info_hash.encode()))
sleep(1)