diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/admin_windows.go | 36 | ||||
-rw-r--r-- | conf/config.go | 10 |
2 files changed, 45 insertions, 1 deletions
diff --git a/conf/admin_windows.go b/conf/admin_windows.go new file mode 100644 index 00000000..2f97f4da --- /dev/null +++ b/conf/admin_windows.go @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2020 WireGuard LLC. All Rights Reserved. + */ + +package conf + +import "golang.org/x/sys/windows/registry" + +const adminRegKey = `Software\WireGuard` + +var adminKey registry.Key + +func openAdminKey() (registry.Key, error) { + if adminKey != 0 { + return adminKey, nil + } + var err error + adminKey, err = registry.OpenKey(registry.LOCAL_MACHINE, adminRegKey, registry.QUERY_VALUE) + if err != nil { + return 0, err + } + return adminKey, nil +} + +func AdminBool(name string) bool { + key, err := openAdminKey() + if err != nil { + return false + } + val, _, err := key.GetIntegerValue(name) + if err != nil { + return false + } + return val != 0 +} diff --git a/conf/config.go b/conf/config.go index f5f25add..1ce1988d 100644 --- a/conf/config.go +++ b/conf/config.go @@ -84,7 +84,7 @@ func (r *IPCidr) IPNet() net.IPNet { func (r *IPCidr) MaskSelf() { bits := int(r.Bits()) mask := net.CIDRMask(int(r.Cidr), bits) - for i := 0; i < bits / 8; i++ { + for i := 0; i < bits/8; i++ { r.IP[i] &= mask[i] } } @@ -238,3 +238,11 @@ func (conf *Config) DeduplicateNetworkEntries() { peer.AllowedIPs = peer.AllowedIPs[:i] } } + +func (conf *Config) Redact() { + conf.Interface.PrivateKey = Key{} + for i := range conf.Peers { + conf.Peers[i].PublicKey = Key{} + conf.Peers[i].PresharedKey = Key{} + } +} |