mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix unhandled exception with port check function
This commit is contained in:
parent
3e84df601f
commit
d93038a70d
@ -87,13 +87,16 @@ class Helpers:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_port(server_port):
|
def check_port(server_port):
|
||||||
host_public = get('https://api.ipify.org').text
|
try:
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
host_public = get('https://api.ipify.org').text
|
||||||
result = sock.connect_ex((host_public ,server_port))
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
sock.close()
|
result = sock.connect_ex((host_public ,server_port))
|
||||||
if result == 0:
|
sock.close()
|
||||||
return True
|
if result == 0:
|
||||||
else:
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
except Exception as err:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user