From 6e62ac14b8cca193faf6c73464eb47e54efd7abe Mon Sep 17 00:00:00 2001
From: Hemna <waboring@hemna.com>
Date: Wed, 6 Nov 2024 17:59:10 -0500
Subject: [PATCH] Allow disabling sending all AckPackets

This patch adds a new config option 'enable_sending_ack_packets', which
is by default set to True.  This allows the admin to disable sending Ack
Packets for MessagePackets entirely.
---
 aprsd/conf/common.py | 6 ++++++
 aprsd/threads/rx.py  | 5 +++++
 aprsd/threads/tx.py  | 5 ++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/aprsd/conf/common.py b/aprsd/conf/common.py
index 07d69cc..256c730 100644
--- a/aprsd/conf/common.py
+++ b/aprsd/conf/common.py
@@ -136,6 +136,12 @@ aprsd_opts = [
         default=True,
         help="Set this to False, to disable logging of packets to the log file.",
     ),
+    cfg.BoolOpt(
+        "enable_sending_ack_packets",
+        default=True,
+        help="Set this to False, to disable sending of ack packets. This will entirely stop"
+             "APRSD from sending ack packets.",
+    ),
 ]
 
 watch_list_opts = [
diff --git a/aprsd/threads/rx.py b/aprsd/threads/rx.py
index 3c88958..c770096 100644
--- a/aprsd/threads/rx.py
+++ b/aprsd/threads/rx.py
@@ -151,6 +151,11 @@ class APRSDProcessPacketThread(APRSDThread):
     def __init__(self, packet_queue):
         self.packet_queue = packet_queue
         super().__init__("ProcessPKT")
+        if not CONF.enable_sending_ack_packets:
+            LOG.warning(
+                "Sending ack packets is disabled, messages "
+                "will not be acknowledged.",
+            )
 
     def process_ack_packet(self, packet):
         """We got an ack for a message, no need to resend it."""
diff --git a/aprsd/threads/tx.py b/aprsd/threads/tx.py
index b7ed45b..83ab140 100644
--- a/aprsd/threads/tx.py
+++ b/aprsd/threads/tx.py
@@ -53,7 +53,10 @@ def send(packet: core.Packet, direct=False, aprs_client=None):
     # After prepare, as prepare assigns the msgNo
     collector.PacketCollector().tx(packet)
     if isinstance(packet, core.AckPacket):
-        _send_ack(packet, direct=direct, aprs_client=aprs_client)
+        if CONF.enable_sending_ack_packets:
+            _send_ack(packet, direct=direct, aprs_client=aprs_client)
+        else:
+            LOG.info("Sending ack packets is disabled. Not sending AckPacket.")
     else:
         _send_packet(packet, direct=direct, aprs_client=aprs_client)