mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-19 23:11:29 +02:00
Adds missing WGPort config
This commit is contained in:
@@ -691,6 +691,17 @@ func (config *Config) applyMDMPolicy(policy *mdm.Policy) {
|
||||
if v, ok := policy.GetBool(mdm.KeyRosenpassPermissive); ok {
|
||||
config.RosenpassPermissive = v
|
||||
}
|
||||
|
||||
if v, ok := policy.GetInt(mdm.KeyWireguardPort); ok {
|
||||
// REG_DWORD is 32-bit; UDP port range is 1-65535. Clamp at the
|
||||
// upper bound and reject obviously-invalid values to avoid the
|
||||
// engine binding to an unusable port if the admin pushes garbage.
|
||||
if v >= 1 && v <= 65535 {
|
||||
config.WgPort = int(v)
|
||||
} else {
|
||||
log.Warnf("MDM wireguard port %d out of range [1,65535]; keeping previous value", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// parseURL parses and validates a service URL
|
||||
|
||||
@@ -10,6 +10,7 @@ package mdm
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -32,6 +33,7 @@ const (
|
||||
KeyPreSharedKey = "preSharedKey"
|
||||
KeyRosenpassEnabled = "rosenpassEnabled"
|
||||
KeyRosenpassPermissive = "rosenpassPermissive"
|
||||
KeyWireguardPort = "wireguardPort"
|
||||
KeySplitTunnelAllowApps = "splitTunnelAllowApps"
|
||||
KeySplitTunnelDisallowApps = "splitTunnelDisallowApps"
|
||||
)
|
||||
@@ -53,6 +55,7 @@ var AllKeys = []string{
|
||||
KeyPreSharedKey,
|
||||
KeyRosenpassEnabled,
|
||||
KeyRosenpassPermissive,
|
||||
KeyWireguardPort,
|
||||
KeySplitTunnelAllowApps,
|
||||
KeySplitTunnelDisallowApps,
|
||||
}
|
||||
@@ -171,6 +174,36 @@ func (p *Policy) GetBool(key string) (bool, bool) {
|
||||
return false, false
|
||||
}
|
||||
|
||||
// GetInt returns the managed value for key as int64, and whether the key
|
||||
// was set. Accepts native int / int64 (as produced by the Windows registry
|
||||
// loader for REG_DWORD/REG_QWORD) and numeric strings (decimal).
|
||||
func (p *Policy) GetInt(key string) (int64, bool) {
|
||||
if p == nil {
|
||||
return 0, false
|
||||
}
|
||||
v, ok := p.values[key]
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
switch t := v.(type) {
|
||||
case int64:
|
||||
return t, true
|
||||
case int:
|
||||
return int64(t), true
|
||||
case int32:
|
||||
return int64(t), true
|
||||
case uint64:
|
||||
return int64(t), true
|
||||
case float64:
|
||||
return int64(t), true
|
||||
case string:
|
||||
if n, err := strconv.ParseInt(t, 10, 64); err == nil {
|
||||
return n, true
|
||||
}
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// GetStringSlice returns the managed value for key as []string, and whether
|
||||
// the key was set. Accepts []string, []any (of strings), and a single string
|
||||
// (treated as a one-element list).
|
||||
|
||||
@@ -49,6 +49,9 @@ func requestedMDMManagedKeys(msg *proto.SetConfigRequest) []string {
|
||||
if msg.BlockInbound != nil {
|
||||
keys = append(keys, mdm.KeyBlockInbound)
|
||||
}
|
||||
if msg.WireguardPort != nil {
|
||||
keys = append(keys, mdm.KeyWireguardPort)
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user