mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 03:46:02 +08:00
added iot check in mq message handlers
This commit is contained in:
parent
bcbe355281
commit
11daff3f1c
2 changed files with 23 additions and 0 deletions
|
@ -7,6 +7,21 @@ import (
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"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
|
// WIREGUARD_INTERFACE name of wireguard interface
|
||||||
const WIREGUARD_INTERFACE = "netmaker"
|
const WIREGUARD_INTERFACE = "netmaker"
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func decryptMsgWithHost(host *models.Host, msg []byte) ([]byte, error) {
|
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
|
trafficKey, trafficErr := logic.RetrievePrivateTrafficKey() // get server private key
|
||||||
if trafficErr != nil {
|
if trafficErr != nil {
|
||||||
return nil, trafficErr
|
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) {
|
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
|
// fetch server public key to be certain hasn't changed in transit
|
||||||
trafficKey, trafficErr := logic.RetrievePrivateTrafficKey()
|
trafficKey, trafficErr := logic.RetrievePrivateTrafficKey()
|
||||||
if trafficErr != nil {
|
if trafficErr != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue