diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 6f08f622..3f5bb8cc 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -97,12 +97,16 @@ class Helpers: @staticmethod def check_port(server_port): - try: - host_public = get('https://api.ipify.org').text - tn = telnetlib.Telnet(host_public, server_port, 10) - telnetlib.close() + a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + ip = get('https://api.ipify.org').content.decode('utf8') + + location = (ip, server_port) + result_of_check = a_socket.connect_ex(location) + + if result_of_check == 0: return True - except Exception as err: + else: return False @staticmethod