add port checking stuff

This commit is contained in:
Andrew 2021-12-21 17:39:24 -05:00
parent c9908a3e0f
commit 5d6cbf6a4f

View File

@ -97,12 +97,16 @@ class Helpers:
@staticmethod @staticmethod
def check_port(server_port): def check_port(server_port):
try: a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host_public = get('https://api.ipify.org').text
tn = telnetlib.Telnet(host_public, server_port, 10) ip = get('https://api.ipify.org').content.decode('utf8')
telnetlib.close()
location = (ip, server_port)
result_of_check = a_socket.connect_ex(location)
if result_of_check == 0:
return True return True
except Exception as err: else:
return False return False
@staticmethod @staticmethod