add timeout
This commit is contained in:
@@ -48,6 +48,7 @@ def version_to_string(version):
|
|||||||
def query_server(host, port=34197):
|
def query_server(host, port=34197):
|
||||||
global info
|
global info
|
||||||
s = socket.socket(type=socket.SOCK_DGRAM)
|
s = socket.socket(type=socket.SOCK_DGRAM)
|
||||||
|
s.settimeout(5)
|
||||||
s.sendto(bytes.fromhex("30"), (host, port))
|
s.sendto(bytes.fromhex("30"), (host, port))
|
||||||
info = s.recvfrom(512)[0]
|
info = s.recvfrom(512)[0]
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
query_server(args.host, args.port)
|
query_server(args.host, args.port)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"CRITICAL:{e}")
|
print(f"CRITICAL: {e}")
|
||||||
exit(2)
|
exit(2)
|
||||||
|
|
||||||
s = decode_packet()
|
s = decode_packet()
|
||||||
|
|||||||
Reference in New Issue
Block a user