|
|
@ -4,22 +4,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
package dns
|
|
|
|
package dns
|
|
|
|
|
|
|
|
|
|
|
|
// DNSRoutingMode describes the type of per-domain DNS routing that
|
|
|
|
import "inet.af/netaddr"
|
|
|
|
// the OS is capable of.
|
|
|
|
|
|
|
|
type RoutingMode int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
// RoutingModeNone means the OS only supports setting a single
|
|
|
|
|
|
|
|
// primary set of DNS resolvers.
|
|
|
|
|
|
|
|
RoutingModeNone RoutingMode = iota
|
|
|
|
|
|
|
|
// RoutingModeSingle means the OS supports a set of
|
|
|
|
|
|
|
|
// primary resolvers, as well as one set of additional per-suffix
|
|
|
|
|
|
|
|
// resolvers per network interface.
|
|
|
|
|
|
|
|
RoutingModeSingle
|
|
|
|
|
|
|
|
// RoutingModeMulti means the OS supports a set of primary
|
|
|
|
|
|
|
|
// resolvers, as well as an arbitrary overlay of DNS routes.
|
|
|
|
|
|
|
|
RoutingModeMulti
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// An OSConfigurator applies DNS settings to the operating system.
|
|
|
|
// An OSConfigurator applies DNS settings to the operating system.
|
|
|
|
type OSConfigurator interface {
|
|
|
|
type OSConfigurator interface {
|
|
|
@ -28,9 +13,25 @@ type OSConfigurator interface {
|
|
|
|
// configuration is removed.
|
|
|
|
// configuration is removed.
|
|
|
|
// SetDNS must not be called after Close.
|
|
|
|
// SetDNS must not be called after Close.
|
|
|
|
SetDNS(cfg OSConfig) error
|
|
|
|
SetDNS(cfg OSConfig) error
|
|
|
|
// DNSRoutingMode reports the DNS routing capabilities of this OS
|
|
|
|
// SupportsSplitDNS reports whether the configurator is capable of
|
|
|
|
// configurator.
|
|
|
|
// installing a resolver only for specific DNS suffixes. If false,
|
|
|
|
RoutingMode() RoutingMode
|
|
|
|
// the configurator can only set a global resolver.
|
|
|
|
|
|
|
|
SupportsSplitDNS() bool
|
|
|
|
// Close removes Tailscale-related DNS configuration from the OS.
|
|
|
|
// Close removes Tailscale-related DNS configuration from the OS.
|
|
|
|
Close() error
|
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OSConfig is an OS DNS configuration.
|
|
|
|
|
|
|
|
type OSConfig struct {
|
|
|
|
|
|
|
|
// Nameservers are the IP addresses of the nameservers to use.
|
|
|
|
|
|
|
|
Nameservers []netaddr.IP
|
|
|
|
|
|
|
|
// Domains are the search domains to use.
|
|
|
|
|
|
|
|
Domains []string
|
|
|
|
|
|
|
|
// Primary indicates whether to set Nameservers as the
|
|
|
|
|
|
|
|
// primary/"default" resolvers for the system.
|
|
|
|
|
|
|
|
// If false, Nameservers will be set as resolvers for Domains
|
|
|
|
|
|
|
|
// only.
|
|
|
|
|
|
|
|
// Primary=false is only allowed for OSConfigurators that report
|
|
|
|
|
|
|
|
// SupportsSplitDNS.
|
|
|
|
|
|
|
|
Primary bool
|
|
|
|
|
|
|
|
}
|
|
|
|