From 754f73fe8a54b59155f1eb372fa91fffd8865eef Mon Sep 17 00:00:00 2001 From: root <165865819+brianshea2@users.noreply.github.com> Date: Sat, 9 Nov 2024 18:34:47 +0000 Subject: [PATCH] add optional Accept function --- internal/meshtastic/mqtt.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/meshtastic/mqtt.go b/internal/meshtastic/mqtt.go index 01c414d..f6020a6 100644 --- a/internal/meshtastic/mqtt.go +++ b/internal/meshtastic/mqtt.go @@ -33,6 +33,7 @@ func NewBlockCipher(key []byte) cipher.Block { type MQTTClient struct { TopicRegex *regexp.Regexp + Accept func(from uint32) bool BlockCipher cipher.Block MessageHandler func(from uint32, topic string, portNum generated.PortNum, payload []byte) topics []string @@ -105,6 +106,10 @@ func (c *MQTTClient) handleMessage(_ mqtt.Client, msg mqtt.Message) { log.Printf("[warn] skipping MeshPacket from unknown on %v", topic) return } + // check sender + if c.Accept != nil && !c.Accept(from) { + return + } // get Data, try decoded first data := packet.GetDecoded() if data == nil {