From 878ab683ed7849693b70eafdf036e7a5a2210ab6 Mon Sep 17 00:00:00 2001 From: Dave Behnke <916775+dbehnke@users.noreply.github.com> Date: Thu, 1 Jan 2026 15:09:34 -0500 Subject: [PATCH] feat(reflector): rate limit late entry warnings to once per minute --- reflector/DMRMMDVMProtocol.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/reflector/DMRMMDVMProtocol.cpp b/reflector/DMRMMDVMProtocol.cpp index c36c921..eebc20f 100644 --- a/reflector/DMRMMDVMProtocol.cpp +++ b/reflector/DMRMMDVMProtocol.cpp @@ -19,6 +19,10 @@ #include +#include +#include +#include +#include #include "Global.h" #include "DMRMMDVMClient.h" #include "DMRMMDVMProtocol.h" @@ -677,7 +681,16 @@ bool CDmrmmdvmProtocol::IsValidDvFramePacket(const CIp &Ip, const CBuffer &Buffe if ( !stream ) { std::cout << std::showbase << std::hex; - std::cout << "Late entry DMR voice frame, creating DMR header for DMR stream ID " << ntohl(uiStreamId) << std::noshowbase << std::dec << " on " << Ip << std::endl; + static std::map last_late_entry; + std::time_t now = std::time(nullptr); + uint32_t sid = ntohl(uiStreamId); + + if (last_late_entry.find(sid) == last_late_entry.end() || (now - last_late_entry[sid]) > 60) { + std::cout << "Late entry DMR voice frame, creating DMR header for DMR stream ID " << std::hex << std::showbase << sid + << std::noshowbase << std::dec << " on " << Ip + << " (Suppressed for 60s)" << std::endl; + last_late_entry[sid] = now; + } std::cout << std::noshowbase << std::dec; uint8_t cmd;