5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-12-27 21:55:39 +00:00

readall for crawler

This commit is contained in:
Arceliar 2023-11-04 13:52:07 -05:00
parent ca64c31ca9
commit da1bbfc8e3

View File

@ -15,6 +15,17 @@ else:
socktype = socket.AF_UNIX
sockaddr = "/var/run/yggdrasil/yggdrasil.sock"
def readall(sock):
data = []
sock.settimeout(1)
while True:
try:
frag = sock.recv(4096)
data.append(frag)
except:
break
return "".join(data)
def getPeersRequest(key):
return '{{"keepalive":true, "request":"debug_remoteGetPeers", "arguments": {{"key":"{}"}}}}'.format(key)
@ -23,7 +34,7 @@ def doRequest(req):
ygg = socket.socket(socktype, socket.SOCK_STREAM)
ygg.connect(sockaddr)
ygg.send(req)
data = json.loads(ygg.recv(1048576))
data = json.loads(readall(ygg))
return data
except:
return None