ping a bittorent dht bootstrap 节点无法得到答案
ping a bittorent dht bootstrap node could not get a answer
当发送find_node到router.utorrent.com时没有回应
像这样的代码
import bencode
import random
import socket
# Generate a 160-bit (20-byte) random node ID.
my_id = ''.join([chr(random.randint(0, 255)) for _ in range(20)])
ping_query = {'y': 'q',
't': '0f',
'q': 'ping',
'a': {'id': my_id}}
ping_query_bencoded = bencode.bencode(ping_query)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(ping_query_bencoded,
(socket.gethostbyname('router.bittorrent.com'), 6881))
r = s.recvfrom(1024)
ping_response = bencode.bdecode(r[0])
print(ping_response)
我 运行 你的例子,它运行良好。您的防火墙似乎阻止了 UDP 响应。
当发送find_node到router.utorrent.com时没有回应 像这样的代码
import bencode
import random
import socket
# Generate a 160-bit (20-byte) random node ID.
my_id = ''.join([chr(random.randint(0, 255)) for _ in range(20)])
ping_query = {'y': 'q',
't': '0f',
'q': 'ping',
'a': {'id': my_id}}
ping_query_bencoded = bencode.bencode(ping_query)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(ping_query_bencoded,
(socket.gethostbyname('router.bittorrent.com'), 6881))
r = s.recvfrom(1024)
ping_response = bencode.bdecode(r[0])
print(ping_response)
我 运行 你的例子,它运行良好。您的防火墙似乎阻止了 UDP 响应。