From 3ed304c3784907692ff90cc71c8da2adff760687 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 21 Dec 2021 15:58:48 -0500 Subject: [PATCH] Add fix for port checker. We'll see if this works this time. --- app/classes/shared/helpers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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