From bd198d7c67fe72b4fd318c4c21603ca851ff2135 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sun, 20 Nov 2022 18:19:56 +0100 Subject: [PATCH] disallow disconnect when disconnected, disconnecting, failed #289 --- tnc/sock.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tnc/sock.py b/tnc/sock.py index 915f4770..fc9ab0a5 100644 --- a/tnc/sock.py +++ b/tnc/sock.py @@ -360,11 +360,19 @@ def process_tnc_commands(data): # DISCONNECT ---------------------------------------------------------- if received_json["type"] == "arq" and received_json["command"] == "disconnect": try: - DATA_QUEUE_TRANSMIT.put(["DISCONNECT"]) + if not static.ARQ_SESSION_STATE in ["disconnecting", "disconnected", "failed"]: + DATA_QUEUE_TRANSMIT.put(["DISCONNECT"]) - # set early disconnecting state so we can interrupt connection attempts - static.ARQ_SESSION_STATE = "disconnecting" - command_response("disconnect", True) + # set early disconnecting state so we can interrupt connection attempts + static.ARQ_SESSION_STATE = "disconnecting" + command_response("disconnect", True) + else: + command_response("disconnect", False) + log.warning( + "[SCK] Disconnect command not possible", + state=static.ARQ_SESSION_STATE, + command=received_json, + ) except Exception as err: command_response("disconnect", False) log.warning(