2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-07-14 14:12:00 +01:00
|
|
|
|
2021-08-05 23:42:39 +01:00
|
|
|
//go:build linux
|
2020-07-14 14:12:00 +01:00
|
|
|
|
2020-07-31 21:27:09 +01:00
|
|
|
package dns
|
2020-07-14 14:12:00 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
2021-05-10 23:05:29 +01:00
|
|
|
"net"
|
2021-11-16 20:24:40 +00:00
|
|
|
"strings"
|
2022-07-22 20:49:18 +01:00
|
|
|
"time"
|
2020-07-14 14:12:00 +01:00
|
|
|
|
|
|
|
"github.com/godbus/dbus/v5"
|
|
|
|
"golang.org/x/sys/unix"
|
2021-11-18 23:52:21 +00:00
|
|
|
"tailscale.com/health"
|
2022-07-25 04:08:42 +01:00
|
|
|
"tailscale.com/logtail/backoff"
|
|
|
|
"tailscale.com/net/netaddr"
|
2021-04-12 04:52:05 +01:00
|
|
|
"tailscale.com/types/logger"
|
2021-04-12 02:12:24 +01:00
|
|
|
"tailscale.com/util/dnsname"
|
2020-07-14 14:12:00 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// resolvedListenAddr is the listen address of the resolved stub resolver.
|
|
|
|
//
|
|
|
|
// We only consider resolved to be the system resolver if the stub resolver is;
|
|
|
|
// that is, if this address is the sole nameserver in /etc/resolved.conf.
|
2020-07-31 21:27:09 +01:00
|
|
|
// In other cases, resolved may be managing the system DNS configuration directly.
|
2020-07-14 14:12:00 +01:00
|
|
|
// Then the nameserver list will be a concatenation of those for all
|
|
|
|
// the interfaces that register their interest in being a default resolver with
|
2022-08-02 17:33:46 +01:00
|
|
|
//
|
|
|
|
// SetLinkDomains([]{{"~.", true}, ...})
|
|
|
|
//
|
2020-07-14 14:12:00 +01:00
|
|
|
// which includes at least the interface with the default route, i.e. not us.
|
|
|
|
// This does not work for us: there is a possibility of getting NXDOMAIN
|
|
|
|
// from the other nameservers before we are asked or get a chance to respond.
|
|
|
|
// We consider this case as lacking resolved support and fall through to dnsDirect.
|
|
|
|
//
|
|
|
|
// While it may seem that we need to read a config option to get at this,
|
|
|
|
// this address is, in fact, hard-coded into resolved.
|
|
|
|
var resolvedListenAddr = netaddr.IPv4(127, 0, 0, 53)
|
|
|
|
|
|
|
|
var errNotReady = errors.New("interface not ready")
|
|
|
|
|
2021-11-19 01:18:11 +00:00
|
|
|
// DBus entities we talk to.
|
|
|
|
//
|
|
|
|
// DBus is an RPC bus. In particular, the bus we're talking to is the
|
|
|
|
// system-wide bus (there is also a per-user session bus for
|
|
|
|
// user-specific applications).
|
|
|
|
//
|
|
|
|
// Daemons connect to the bus, and advertise themselves under a
|
|
|
|
// well-known object name. That object exposes paths, and each path
|
|
|
|
// implements one or more interfaces that contain methods, properties,
|
|
|
|
// and signals.
|
|
|
|
//
|
|
|
|
// Clients connect to the bus and walk that same hierarchy to invoke
|
|
|
|
// RPCs, get/set properties, or listen for signals.
|
|
|
|
const (
|
|
|
|
dbusResolvedObject = "org.freedesktop.resolve1"
|
|
|
|
dbusResolvedPath dbus.ObjectPath = "/org/freedesktop/resolve1"
|
|
|
|
dbusResolvedInterface = "org.freedesktop.resolve1.Manager"
|
|
|
|
dbusPath dbus.ObjectPath = "/org/freedesktop/DBus"
|
|
|
|
dbusInterface = "org.freedesktop.DBus"
|
|
|
|
dbusOwnerSignal = "NameOwnerChanged" // broadcast when a well-known name's owning process changes.
|
|
|
|
)
|
|
|
|
|
2020-07-14 14:12:00 +01:00
|
|
|
type resolvedLinkNameserver struct {
|
|
|
|
Family int32
|
|
|
|
Address []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
type resolvedLinkDomain struct {
|
|
|
|
Domain string
|
|
|
|
RoutingOnly bool
|
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
// changeRequest tracks latest OSConfig and related error responses to update.
|
|
|
|
type changeRequest struct {
|
|
|
|
config OSConfig // configs OSConfigs, one per each SetDNS call
|
2022-07-25 04:08:42 +01:00
|
|
|
res chan<- error // response channel
|
2022-07-22 20:49:18 +01:00
|
|
|
}
|
|
|
|
|
2021-06-25 15:02:10 +01:00
|
|
|
// resolvedManager is an OSConfigurator which uses the systemd-resolved DBus API.
|
2021-04-12 04:52:05 +01:00
|
|
|
type resolvedManager struct {
|
2022-07-22 20:49:18 +01:00
|
|
|
ctx context.Context
|
|
|
|
cancel func() // terminate the context, for close
|
|
|
|
|
2021-11-18 23:28:46 +00:00
|
|
|
logf logger.Logf
|
|
|
|
ifidx int
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
configCR chan changeRequest // tracks OSConfigs changes and error responses
|
2021-04-12 04:52:05 +01:00
|
|
|
}
|
2020-07-31 21:27:09 +01:00
|
|
|
|
2021-05-10 23:05:29 +01:00
|
|
|
func newResolvedManager(logf logger.Logf, interfaceName string) (*resolvedManager, error) {
|
|
|
|
iface, err := net.InterfaceByName(interfaceName)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-11-18 23:28:46 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
2022-07-22 20:49:18 +01:00
|
|
|
logf = logger.WithPrefix(logf, "dns: ")
|
2021-11-18 23:28:46 +00:00
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
mgr := &resolvedManager{
|
|
|
|
ctx: ctx,
|
|
|
|
cancel: cancel,
|
|
|
|
|
|
|
|
logf: logf,
|
|
|
|
ifidx: iface.Index,
|
|
|
|
|
|
|
|
configCR: make(chan changeRequest),
|
2021-11-18 23:28:46 +00:00
|
|
|
}
|
2022-07-22 20:49:18 +01:00
|
|
|
|
|
|
|
go mgr.run(ctx)
|
|
|
|
|
|
|
|
return mgr, nil
|
2020-07-31 21:27:09 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 02:03:34 +01:00
|
|
|
func (m *resolvedManager) SetDNS(config OSConfig) error {
|
2023-03-24 16:43:37 +00:00
|
|
|
// NOTE: don't close this channel, since it's possible that the SetDNS
|
|
|
|
// call will time out and return before the run loop answers, at which
|
|
|
|
// point it will send on the now-closed channel.
|
2022-07-22 20:49:18 +01:00
|
|
|
errc := make(chan error, 1)
|
2021-11-18 23:28:46 +00:00
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
select {
|
|
|
|
case <-m.ctx.Done():
|
|
|
|
return m.ctx.Err()
|
|
|
|
case m.configCR <- changeRequest{config, errc}:
|
|
|
|
}
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-m.ctx.Done():
|
|
|
|
return m.ctx.Err()
|
|
|
|
case err := <-errc:
|
|
|
|
if err != nil {
|
|
|
|
m.logf("failed to configure resolved: %v", err)
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
2021-11-18 23:28:46 +00:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
func (m *resolvedManager) run(ctx context.Context) {
|
|
|
|
var (
|
2022-07-25 04:08:42 +01:00
|
|
|
conn *dbus.Conn
|
|
|
|
signals chan *dbus.Signal
|
2022-07-22 20:49:18 +01:00
|
|
|
rManager dbus.BusObject // rManager is the Resolved DBus connection
|
|
|
|
)
|
|
|
|
bo := backoff.NewBackoff("resolved-dbus", m.logf, 30*time.Second)
|
|
|
|
needsReconnect := make(chan bool, 1)
|
|
|
|
defer func() {
|
|
|
|
if conn != nil {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// Reconnect the systemBus if disconnected.
|
|
|
|
reconnect := func() error {
|
|
|
|
var err error
|
|
|
|
signals = make(chan *dbus.Signal, 16)
|
|
|
|
conn, err = dbus.SystemBus()
|
|
|
|
if err != nil {
|
|
|
|
m.logf("dbus connection error: %v", err)
|
|
|
|
} else {
|
|
|
|
m.logf("[v1] dbus connected")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
// Backoff increases time between reconnect attempts.
|
|
|
|
go func() {
|
|
|
|
bo.BackOff(ctx, err)
|
|
|
|
needsReconnect <- true
|
|
|
|
}()
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
rManager = conn.Object(dbusResolvedObject, dbus.ObjectPath(dbusResolvedPath))
|
|
|
|
|
|
|
|
// Only receive the DBus signals we need to resync our config on
|
|
|
|
// resolved restart. Failure to set filters isn't a fatal error,
|
|
|
|
// we'll just receive all broadcast signals and have to ignore
|
|
|
|
// them on our end.
|
|
|
|
if err = conn.AddMatchSignal(dbus.WithMatchObjectPath(dbusPath), dbus.WithMatchInterface(dbusInterface), dbus.WithMatchMember(dbusOwnerSignal), dbus.WithMatchArg(0, dbusResolvedObject)); err != nil {
|
|
|
|
m.logf("[v1] Setting DBus signal filter failed: %v", err)
|
|
|
|
}
|
|
|
|
conn.Signal(signals)
|
|
|
|
|
|
|
|
// Reset backoff and SetNSOSHealth after successful on reconnect.
|
|
|
|
bo.BackOff(ctx, nil)
|
|
|
|
health.SetDNSOSHealth(nil)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create initial systemBus connection.
|
|
|
|
reconnect()
|
|
|
|
|
|
|
|
lastConfig := OSConfig{}
|
|
|
|
|
2021-11-18 23:28:46 +00:00
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
2022-07-22 20:49:18 +01:00
|
|
|
if rManager == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// RevertLink resets all per-interface settings on systemd-resolved to defaults.
|
|
|
|
// When ctx goes away systemd-resolved auto reverts.
|
|
|
|
// Keeping for potential use in future refactor.
|
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".RevertLink", 0, m.ifidx); call.Err != nil {
|
2022-09-14 00:24:38 +01:00
|
|
|
m.logf("[v1] RevertLink: %v", call.Err)
|
2022-07-22 20:49:18 +01:00
|
|
|
return
|
|
|
|
}
|
2021-11-18 23:28:46 +00:00
|
|
|
return
|
2022-07-22 20:49:18 +01:00
|
|
|
case configCR := <-m.configCR:
|
|
|
|
// Track and update sync with latest config change.
|
|
|
|
lastConfig = configCR.config
|
|
|
|
|
|
|
|
if rManager == nil {
|
|
|
|
configCR.res <- fmt.Errorf("resolved DBus does not have a connection")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
err := m.setConfigOverDBus(ctx, rManager, configCR.config)
|
|
|
|
configCR.res <- err
|
|
|
|
case <-needsReconnect:
|
|
|
|
if err := reconnect(); err != nil {
|
|
|
|
m.logf("[v1] SystemBus reconnect error %T", err)
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
case signal, ok := <-signals:
|
|
|
|
// If signal ends and is nil then program tries to reconnect.
|
|
|
|
if !ok {
|
|
|
|
if err := reconnect(); err != nil {
|
|
|
|
m.logf("[v1] SystemBus reconnect error %T", err)
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
2021-11-18 23:28:46 +00:00
|
|
|
// In theory the signal was filtered by DBus, but if
|
|
|
|
// AddMatchSignal in the constructor failed, we may be
|
|
|
|
// getting other spam.
|
2021-11-19 01:18:11 +00:00
|
|
|
if signal.Path != dbusPath || signal.Name != dbusInterface+"."+dbusOwnerSignal {
|
2021-11-18 23:28:46 +00:00
|
|
|
continue
|
|
|
|
}
|
2022-07-22 20:49:18 +01:00
|
|
|
if lastConfig.IsZero() {
|
|
|
|
continue
|
|
|
|
}
|
2022-03-16 23:27:57 +00:00
|
|
|
// signal.Body is a []any of 3 strings: bus name, previous owner, new owner.
|
2021-11-18 23:28:46 +00:00
|
|
|
if len(signal.Body) != 3 {
|
2022-07-22 20:49:18 +01:00
|
|
|
m.logf("[unexpected] DBus NameOwnerChanged len(Body) = %d, want 3")
|
2021-11-18 23:28:46 +00:00
|
|
|
}
|
2021-11-19 01:18:11 +00:00
|
|
|
if name, ok := signal.Body[0].(string); !ok || name != dbusResolvedObject {
|
2021-11-18 23:28:46 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
newOwner, ok := signal.Body[2].(string)
|
|
|
|
if !ok {
|
|
|
|
m.logf("[unexpected] DBus NameOwnerChanged.new_owner is a %T, not a string", signal.Body[2])
|
|
|
|
}
|
|
|
|
if newOwner == "" {
|
|
|
|
// systemd-resolved left the bus, no current owner,
|
|
|
|
// nothing to do.
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// The resolved bus name has a new owner, meaning resolved
|
|
|
|
// restarted. Reprogram current config.
|
|
|
|
m.logf("systemd-resolved restarted, syncing DNS config")
|
2022-07-22 20:49:18 +01:00
|
|
|
err := m.setConfigOverDBus(ctx, rManager, lastConfig)
|
2021-11-18 23:52:21 +00:00
|
|
|
// Set health while holding the lock, because this will
|
|
|
|
// graciously serialize the resync's health outcome with a
|
|
|
|
// concurrent SetDNS call.
|
|
|
|
health.SetDNSOSHealth(err)
|
2021-11-18 23:28:46 +00:00
|
|
|
if err != nil {
|
|
|
|
m.logf("failed to configure systemd-resolved: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
// setConfigOverDBus updates resolved DBus config and is only called from the run goroutine.
|
|
|
|
func (m *resolvedManager) setConfigOverDBus(ctx context.Context, rManager dbus.BusObject, config OSConfig) error {
|
2021-11-18 23:28:46 +00:00
|
|
|
ctx, cancel := context.WithTimeout(ctx, reconfigTimeout)
|
2020-07-14 14:12:00 +01:00
|
|
|
defer cancel()
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
var linkNameservers = make([]resolvedLinkNameserver, len(config.Nameservers))
|
|
|
|
for i, server := range config.Nameservers {
|
2020-07-14 14:12:00 +01:00
|
|
|
ip := server.As16()
|
|
|
|
if server.Is4() {
|
|
|
|
linkNameservers[i] = resolvedLinkNameserver{
|
|
|
|
Family: unix.AF_INET,
|
|
|
|
Address: ip[12:],
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
linkNameservers[i] = resolvedLinkNameserver{
|
|
|
|
Family: unix.AF_INET6,
|
|
|
|
Address: ip[:],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-22 20:49:18 +01:00
|
|
|
err := rManager.CallWithContext(
|
2021-11-19 01:18:11 +00:00
|
|
|
ctx, dbusResolvedInterface+".SetLinkDNS", 0,
|
2021-05-10 23:05:29 +01:00
|
|
|
m.ifidx, linkNameservers,
|
2020-07-14 14:12:00 +01:00
|
|
|
).Store()
|
|
|
|
if err != nil {
|
2020-07-31 21:27:09 +01:00
|
|
|
return fmt.Errorf("setLinkDNS: %w", err)
|
2020-07-14 14:12:00 +01:00
|
|
|
}
|
2022-07-22 20:49:18 +01:00
|
|
|
linkDomains := make([]resolvedLinkDomain, 0, len(config.SearchDomains)+len(config.MatchDomains))
|
2021-04-12 02:12:24 +01:00
|
|
|
seenDomains := map[dnsname.FQDN]bool{}
|
2022-07-22 20:49:18 +01:00
|
|
|
for _, domain := range config.SearchDomains {
|
2021-04-12 02:12:24 +01:00
|
|
|
if seenDomains[domain] {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
seenDomains[domain] = true
|
|
|
|
linkDomains = append(linkDomains, resolvedLinkDomain{
|
|
|
|
Domain: domain.WithTrailingDot(),
|
2020-07-14 14:12:00 +01:00
|
|
|
RoutingOnly: false,
|
2021-04-12 02:12:24 +01:00
|
|
|
})
|
|
|
|
}
|
2022-07-22 20:49:18 +01:00
|
|
|
for _, domain := range config.MatchDomains {
|
2021-04-12 02:12:24 +01:00
|
|
|
if seenDomains[domain] {
|
|
|
|
// Search domains act as both search and match in
|
|
|
|
// resolved, so it's correct to skip.
|
|
|
|
continue
|
2020-07-14 14:12:00 +01:00
|
|
|
}
|
2021-04-12 02:12:24 +01:00
|
|
|
seenDomains[domain] = true
|
|
|
|
linkDomains = append(linkDomains, resolvedLinkDomain{
|
|
|
|
Domain: domain.WithTrailingDot(),
|
|
|
|
RoutingOnly: true,
|
|
|
|
})
|
|
|
|
}
|
2022-07-22 20:49:18 +01:00
|
|
|
if len(config.MatchDomains) == 0 && len(config.Nameservers) > 0 {
|
2021-04-12 02:12:24 +01:00
|
|
|
// Caller requested full DNS interception, install a
|
|
|
|
// routing-only root domain.
|
|
|
|
linkDomains = append(linkDomains, resolvedLinkDomain{
|
|
|
|
Domain: ".",
|
|
|
|
RoutingOnly: true,
|
|
|
|
})
|
2020-07-14 14:12:00 +01:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
err = rManager.CallWithContext(
|
2021-11-19 01:18:11 +00:00
|
|
|
ctx, dbusResolvedInterface+".SetLinkDomains", 0,
|
2021-05-10 23:05:29 +01:00
|
|
|
m.ifidx, linkDomains,
|
2020-07-14 14:12:00 +01:00
|
|
|
).Store()
|
2021-11-16 20:24:40 +00:00
|
|
|
if err != nil && err.Error() == "Argument list too long" { // TODO: better error match
|
|
|
|
// Issue 3188: older systemd-resolved had argument length limits.
|
|
|
|
// Trim out the *.arpa. entries and try again.
|
2022-07-22 20:49:18 +01:00
|
|
|
err = rManager.CallWithContext(
|
2021-11-19 01:18:11 +00:00
|
|
|
ctx, dbusResolvedInterface+".SetLinkDomains", 0,
|
2021-11-16 20:24:40 +00:00
|
|
|
m.ifidx, linkDomainsWithoutReverseDNS(linkDomains),
|
|
|
|
).Store()
|
|
|
|
}
|
2020-07-14 14:12:00 +01:00
|
|
|
if err != nil {
|
2020-07-31 21:27:09 +01:00
|
|
|
return fmt.Errorf("setLinkDomains: %w", err)
|
2020-07-14 14:12:00 +01:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".SetLinkDefaultRoute", 0, m.ifidx, len(config.MatchDomains) == 0); call.Err != nil {
|
2021-10-19 15:02:35 +01:00
|
|
|
if dbusErr, ok := call.Err.(dbus.Error); ok && dbusErr.Name == dbus.ErrMsgUnknownMethod.Name {
|
|
|
|
// on some older systems like Kubuntu 18.04.6 with systemd 237 method SetLinkDefaultRoute is absent,
|
|
|
|
// but otherwise it's working good
|
|
|
|
m.logf("[v1] failed to set SetLinkDefaultRoute: %v", call.Err)
|
|
|
|
} else {
|
|
|
|
return fmt.Errorf("setLinkDefaultRoute: %w", call.Err)
|
|
|
|
}
|
2021-04-12 04:52:14 +01:00
|
|
|
}
|
|
|
|
|
2021-04-12 02:12:24 +01:00
|
|
|
// Some best-effort setting of things, but resolved should do the
|
|
|
|
// right thing if these fail (e.g. a really old resolved version
|
|
|
|
// or something).
|
|
|
|
|
|
|
|
// Disable LLMNR, we don't do multicast.
|
2022-07-22 20:49:18 +01:00
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".SetLinkLLMNR", 0, m.ifidx, "no"); call.Err != nil {
|
2021-04-12 04:52:05 +01:00
|
|
|
m.logf("[v1] failed to disable LLMNR: %v", call.Err)
|
2021-04-12 02:12:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable mdns.
|
2022-07-22 20:49:18 +01:00
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".SetLinkMulticastDNS", 0, m.ifidx, "no"); call.Err != nil {
|
2021-04-12 04:52:05 +01:00
|
|
|
m.logf("[v1] failed to disable mdns: %v", call.Err)
|
2021-04-12 02:12:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// We don't support dnssec consistently right now, force it off to
|
|
|
|
// avoid partial failures when we split DNS internally.
|
2022-07-22 20:49:18 +01:00
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".SetLinkDNSSEC", 0, m.ifidx, "no"); call.Err != nil {
|
2021-04-12 04:52:05 +01:00
|
|
|
m.logf("[v1] failed to disable DNSSEC: %v", call.Err)
|
2021-04-12 02:12:24 +01:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".SetLinkDNSOverTLS", 0, m.ifidx, "no"); call.Err != nil {
|
2021-04-12 04:52:05 +01:00
|
|
|
m.logf("[v1] failed to disable DoT: %v", call.Err)
|
2021-04-12 02:12:24 +01:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:49:18 +01:00
|
|
|
if call := rManager.CallWithContext(ctx, dbusResolvedInterface+".FlushCaches", 0); call.Err != nil {
|
2021-04-12 04:52:05 +01:00
|
|
|
m.logf("failed to flush resolved DNS cache: %v", call.Err)
|
2021-04-12 02:12:24 +01:00
|
|
|
}
|
2020-07-14 14:12:00 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-13 02:03:34 +01:00
|
|
|
func (m *resolvedManager) SupportsSplitDNS() bool {
|
2021-04-12 02:12:24 +01:00
|
|
|
return true
|
2021-04-02 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 02:03:34 +01:00
|
|
|
func (m *resolvedManager) GetBaseConfig() (OSConfig, error) {
|
2021-04-07 23:39:26 +01:00
|
|
|
return OSConfig{}, ErrGetBaseConfigNotSupported
|
2021-04-07 08:31:31 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 02:03:34 +01:00
|
|
|
func (m *resolvedManager) Close() error {
|
2022-07-22 20:49:18 +01:00
|
|
|
m.cancel() // stops the 'run' method goroutine
|
2020-07-14 14:12:00 +01:00
|
|
|
return nil
|
|
|
|
}
|
2021-11-16 20:24:40 +00:00
|
|
|
|
|
|
|
// linkDomainsWithoutReverseDNS returns a copy of v without
|
|
|
|
// *.arpa. entries.
|
|
|
|
func linkDomainsWithoutReverseDNS(v []resolvedLinkDomain) (ret []resolvedLinkDomain) {
|
|
|
|
for _, d := range v {
|
|
|
|
if strings.HasSuffix(d.Domain, ".arpa.") {
|
|
|
|
// Oh well. At least the rest will work.
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
ret = append(ret, d)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|