From 994075cce1b9925b38671a8ce76629bfab2aab62 Mon Sep 17 00:00:00 2001
From: Per Qvarforth <per@qvarforth.se>
Date: Sun, 9 Oct 2022 13:47:35 +0000
Subject: [PATCH] frequency limit per packet type

---
 server/trackdirect/parser/AprsISConnection.py | 20 +++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/server/trackdirect/parser/AprsISConnection.py b/server/trackdirect/parser/AprsISConnection.py
index b5afe62..3cfad1c 100644
--- a/server/trackdirect/parser/AprsISConnection.py
+++ b/server/trackdirect/parser/AprsISConnection.py
@@ -94,6 +94,18 @@ class AprsISConnection(aprslib.IS):
             except:
                 return False
 
+            # Divide into body and head
+            try:
+                (head, body) = other.split(':', 1)
+            except:
+                return False
+
+            if len(body) == 0:
+                return False
+
+            packetType = body[0]
+            body = body[1:]
+
             # Try to find turn rate and reduce frequency limit if high turn rate
             frequencyLimitToApply = int(self.frequencyLimit)
             if (self.sourceId == 5) :
@@ -106,13 +118,13 @@ class AprsISConnection(aprslib.IS):
                     pass
 
             latestTimestampOnMap = 0
-            if (name in self.stationHashTimestamps):
-                latestTimestampOnMap = self.stationHashTimestamps[name]
+            if (name + packetType in self.stationHashTimestamps):
+                latestTimestampOnMap = self.stationHashTimestamps[name + packetType]
 
                 if (((int(time.time()) - 1) - frequencyLimitToApply) < latestTimestampOnMap):
                     # This sender is sending faster than config limit
                     return True
-            self.stationHashTimestamps[name] = int(time.time()) - 1
+            self.stationHashTimestamps[name + packetType] = int(time.time()) - 1
             self._cacheMaintenance()
         return False
 
@@ -125,4 +137,4 @@ class AprsISConnection(aprslib.IS):
             try:
                 self.stationHashTimestamps.popitem(last=False)
             except (KeyError, StopIteration) as e:
-                pass
\ No newline at end of file
+                pass
-- 
GitLab