From 11daff3f1c2d37ec43943c0a93693e7436fe4f50 Mon Sep 17 00:00:00 2001 From: 0xdcarns Date: Tue, 14 Mar 2023 10:46:12 -0400 Subject: [PATCH] added iot check in mq message handlers --- models/host.go | 15 +++++++++++++++ mq/util.go | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/models/host.go b/models/host.go index 86991198..b27b75da 100644 --- a/models/host.go +++ b/models/host.go @@ -7,6 +7,21 @@ import ( "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) +// OS_Types - list of OS types Netmaker cares about +var OS_Types = struct { + Linux string + Windows string + Mac string + FreeBSD string + IoT string +}{ + Linux: "linux", + Windows: "windows", + Mac: "darwin", + FreeBSD: "freebsd", + IoT: "iot", +} + // WIREGUARD_INTERFACE name of wireguard interface const WIREGUARD_INTERFACE = "netmaker" diff --git a/mq/util.go b/mq/util.go index 0ab59ee9..fb7688de 100644 --- a/mq/util.go +++ b/mq/util.go @@ -12,6 +12,10 @@ import ( ) func decryptMsgWithHost(host *models.Host, msg []byte) ([]byte, error) { + if host.OS == models.OS_Types.IoT { // just pass along IoT messages + return msg, nil + } + trafficKey, trafficErr := logic.RetrievePrivateTrafficKey() // get server private key if trafficErr != nil { return nil, trafficErr @@ -41,6 +45,10 @@ func decryptMsg(node *models.Node, msg []byte) ([]byte, error) { } func encryptMsg(host *models.Host, msg []byte) ([]byte, error) { + if host.OS == models.OS_Types.IoT { + return msg, nil + } + // fetch server public key to be certain hasn't changed in transit trafficKey, trafficErr := logic.RetrievePrivateTrafficKey() if trafficErr != nil {