diff --git a/server.py b/server.py index e68db5c..526e85f 100644 --- a/server.py +++ b/server.py @@ -754,7 +754,7 @@ def tcp_session(sock): print("Waiting for connection...") connection, client = sock.accept() ip_to = restrict_ip - threading.Thread(target=session, daemon=True, args=[connection, client, ip_to]).start() + threading.Thread(target=session, daemon=True, args=[context.wrap_socket(connection, client, ip_to]).start() except: print("Something went wrong...") print(traceback.format_exc()) @@ -762,13 +762,12 @@ def ssl_session(sock2): while True: try: while opened: - context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) - context.load_cert_chain(ssl_cert, keyfile=ssl_pkey) - with context.wrap_socket(sock2, server_side=True) as sock: - print("Waiting for connection...") - connection, client = sock.accept() - ip_to = restrict_ip - threading.Thread(target=session, daemon=True, args=[connection, client, ip_to, True]).start() + context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + context.load_cert_chain(ssl_cert, keyfile=ssl_pkey) + print("Waiting for connection...") + connection, client = sock.accept() + ip_to = restrict_ip + threading.Thread(target=session, daemon=True, args=[context.wrap_socket(connection, server_side=True), client, ip_to, True]).start() except: print("Something went wrong...") print(traceback.format_exc())