From e2366da77e7b415c7c54f3b3bb7afdea4ef23815 Mon Sep 17 00:00:00 2001
From: swee <meow@swee.codes>
Date: Wed, 5 Feb 2025 12:35:30 -0800
Subject: [PATCH] Update server.py

---
 server.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/server.py b/server.py
index de662af..cf5bd59 100644
--- a/server.py
+++ b/server.py
@@ -241,6 +241,8 @@ def session(connection, client, ip, isssl=False):
     pendingCommands = "" # list of commands that were executed before verification
     unfinished = False
     textt = ""
+    nonlocal last_ping
+    nonlocal ping_pending
     last_ping = time.time()
     ping_pending = False
     pendingSend = "" # Text that should be sent to the client
@@ -863,9 +865,9 @@ def ssl_session(sock):
                 ctx.use_privatekey_file(ssl_pkey)
                 ctx.use_certificate_chain_file(ssl_cert)
                 conn = SSL.Connection(ctx, connection)
-                conn.settimeout(5)
                 conn.set_accept_state()
                 conn.do_handshake()
+                conn.settimeout(5)
                 threading.Thread(target=session, daemon=True, args=[conn, client, ip_to, True]).start()
         except:
             print("Something went wrong...")