net/dns: fix staticcheck errors.

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/1691/head
David Anderson 4 years ago
parent 79109f4965
commit cca230cc23

@ -9,7 +9,7 @@ import "tailscale.com/types/logger"
func NewOSConfigurator(logf logger.Logf, interfaceName string) OSConfigurator { func NewOSConfigurator(logf logger.Logf, interfaceName string) OSConfigurator {
switch { switch {
case isResolvedActive(): case isResolvedActive():
return newResolvedManager() return newResolvedManager(logf)
case isNMActive(): case isNMActive():
return newNMManager(interfaceName) return newNMManager(interfaceName)
case isResolvconfActive(): case isResolvconfActive():

@ -5,7 +5,6 @@
// +build linux // +build linux
//lint:file-ignore U1000 refactoring, temporarily unused code. //lint:file-ignore U1000 refactoring, temporarily unused code.
//lint:file-ignore SA9003 WIP code
package dns package dns
@ -18,6 +17,7 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"inet.af/netaddr" "inet.af/netaddr"
"tailscale.com/net/interfaces" "tailscale.com/net/interfaces"
"tailscale.com/types/logger"
"tailscale.com/util/dnsname" "tailscale.com/util/dnsname"
) )
@ -83,10 +83,14 @@ func isResolvedActive() bool {
} }
// resolvedManager uses the systemd-resolved DBus API. // resolvedManager uses the systemd-resolved DBus API.
type resolvedManager struct{} type resolvedManager struct {
logf logger.Logf
}
func newResolvedManager() resolvedManager { func newResolvedManager(logf logger.Logf) resolvedManager {
return resolvedManager{} return resolvedManager{
logf: logf,
}
} }
// Up implements managerImpl. // Up implements managerImpl.
@ -187,28 +191,26 @@ func (m resolvedManager) SetDNS(config OSConfig) error {
// Disable LLMNR, we don't do multicast. // Disable LLMNR, we don't do multicast.
if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkLLMNR", 0, iface.Index, "no"); call.Err != nil { if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkLLMNR", 0, iface.Index, "no"); call.Err != nil {
// TODO: log m.logf("[v1] failed to disable LLMNR: %v", call.Err)
} }
// Disable mdns. // Disable mdns.
if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkMulticastDNS", 0, iface.Index, "no"); call.Err != nil { if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkMulticastDNS", 0, iface.Index, "no"); call.Err != nil {
// TODO: log m.logf("[v1] failed to disable mdns: %v", call.Err)
} }
// We don't support dnssec consistently right now, force it off to // We don't support dnssec consistently right now, force it off to
// avoid partial failures when we split DNS internally. // avoid partial failures when we split DNS internally.
if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkDNSSEC", 0, iface.Index, "no"); call.Err != nil { if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkDNSSEC", 0, iface.Index, "no"); call.Err != nil {
// TODO: log m.logf("[v1] failed to disable DNSSEC: %v", call.Err)
} }
if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkDNSOverTLS", 0, iface.Index, "no"); call.Err != nil { if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.SetLinkDNSOverTLS", 0, iface.Index, "no"); call.Err != nil {
// TODO: log m.logf("[v1] failed to disable DoT: %v", call.Err)
} }
err = resolved.CallWithContext( if call := resolved.CallWithContext(ctx, "org.freedesktop.resolve1.Manager.FlushCaches", 0); call.Err != nil {
ctx, "org.freedesktop.resolve1.Manager.FlushCaches", 0).Store() m.logf("failed to flush resolved DNS cache: %v", call.Err)
if err != nil {
// TODO: log
} }
return nil return nil

Loading…
Cancel
Save