5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-12-28 14:05:42 +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 socktype = socket.AF_UNIX
sockaddr = "/var/run/yggdrasil/yggdrasil.sock" 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): def doRequest(req):
try: try:
ygg = socket.socket(socktype, socket.SOCK_STREAM) ygg = socket.socket(socktype, socket.SOCK_STREAM)
ygg.connect(sockaddr) ygg.connect(sockaddr)
ygg.send(req) ygg.send(req)
data = json.loads(ygg.recv(1048576)) data = json.loads(readall(ygg))
return data return data
except: except:
return None return None