5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-12-27 20:45:40 +00:00

read all of the response in the python getcurrent script

This commit is contained in:
Arceliar 2023-10-29 03:43:09 -05:00
parent cae7a9d13a
commit ca64c31ca9

View File

@ -15,12 +15,24 @@ 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 doRequest(req):
try:
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