mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2024-11-12 16:44:19 -08:00
add optional Accept function
This commit is contained in:
parent
98cb8c734c
commit
754f73fe8a
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue