Add default DnsMode function for non-linux platforms

Signed-off-by: Ghvstcode <impoissants@gmail.com>
This commit is contained in:
Ghvstcode 2024-01-05 11:27:43 +01:00
parent fbfae42811
commit 3451d9ea4c
2 changed files with 14 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import (
"sync"
"time"
"github.com/godbus/dbus/v5"
"tailscale.com/health"
"tailscale.com/net/netaddr"
"tailscale.com/types/logger"
@ -31,8 +32,8 @@ func (kv kv) String() string {
var publishOnce sync.Once
var (
dnsMode string
dnsModeMutex sync.RWMutex
globalDnsMode string
dnsModeMutex sync.RWMutex
)
func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurator, err error) {
@ -437,12 +438,12 @@ func dbusReadString(name, objectPath, iface, member string) (string, error) {
func setGlobalDnsMode(mode string) {
dnsModeMutex.Lock()
defer dnsModeMutex.Unlock()
dnsMode = mode
globalDnsMode = mode
}
// GetGlobalDnsMode safely returns the global DNS mode variable
func GetGlobalDnsMode() string {
dnsModeMutex.RLock()
defer dnsModeMutex.RUnlock()
return dnsMode
return globalDnsMode
}

View File

@ -0,0 +1,9 @@
//go:build !linux
package dns
// GetGlobalDnsMode exists to make the build happy on non-linux platforms.
// The actual implementation is in manager_linux.go & in there it safely returns the current resolv.conf mode
func GetGlobalDnsMode() string {
return ""
}