Fix unhandled exception with port check function

This commit is contained in:
Zedifus 2021-09-24 22:20:13 +01:00
parent 3e84df601f
commit d93038a70d

View File

@ -87,13 +87,16 @@ class Helpers:
@staticmethod
def check_port(server_port):
host_public = get('https://api.ipify.org').text
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((host_public ,server_port))
sock.close()
if result == 0:
return True
else:
try:
host_public = get('https://api.ipify.org').text
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((host_public ,server_port))
sock.close()
if result == 0:
return True
else:
return False
except Exception as err:
return False