mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-23 01:11:40 +00:00
net/dns: add a Primary field to OSConfig.
Currently ignored. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
b2a597b288
commit
de6dc4c510
@ -35,11 +35,3 @@ type Config struct {
|
|||||||
// return NXDOMAIN.
|
// return NXDOMAIN.
|
||||||
AuthoritativeSuffixes []string
|
AuthoritativeSuffixes []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
|
@ -159,8 +159,8 @@ func (m directManager) SetDNS(config OSConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m directManager) RoutingMode() RoutingMode {
|
func (m directManager) SupportsSplitDNS() bool {
|
||||||
return RoutingModeNone
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m directManager) Close() error {
|
func (m directManager) Close() error {
|
||||||
|
@ -113,8 +113,8 @@ func (m windowsManager) SetDNS(config OSConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m windowsManager) RoutingMode() RoutingMode {
|
func (m windowsManager) SupportsSplitDNS() bool {
|
||||||
return RoutingModeNone
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m windowsManager) Close() error {
|
func (m windowsManager) Close() error {
|
||||||
|
@ -200,7 +200,7 @@ func (m nmManager) SetDNS(config OSConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m nmManager) RoutingMode() RoutingMode { return RoutingModeNone }
|
func (m nmManager) SupportsSplitDNS() bool { return false }
|
||||||
|
|
||||||
func (m nmManager) Close() error {
|
func (m nmManager) Close() error {
|
||||||
return m.SetDNS(OSConfig{})
|
return m.SetDNS(OSConfig{})
|
||||||
|
@ -7,7 +7,7 @@ package dns
|
|||||||
type noopManager struct{}
|
type noopManager struct{}
|
||||||
|
|
||||||
func (m noopManager) SetDNS(OSConfig) error { return nil }
|
func (m noopManager) SetDNS(OSConfig) error { return nil }
|
||||||
func (m noopManager) RoutingMode() RoutingMode { return RoutingModeNone }
|
func (m noopManager) SupportsSplitDNS() bool { return false }
|
||||||
func (m noopManager) Close() error { return nil }
|
func (m noopManager) Close() error { return nil }
|
||||||
|
|
||||||
func NewNoopManager() noopManager {
|
func NewNoopManager() noopManager {
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
@ -138,8 +138,8 @@ func (m resolvconfManager) SetDNS(config OSConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m resolvconfManager) RoutingMode() RoutingMode {
|
func (m resolvconfManager) SupportsSplitDNS() bool {
|
||||||
return RoutingModeNone
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m resolvconfManager) Close() error {
|
func (m resolvconfManager) Close() error {
|
||||||
|
@ -153,8 +153,8 @@ func (m resolvedManager) SetDNS(config OSConfig) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m resolvedManager) RoutingMode() RoutingMode {
|
func (m resolvedManager) SupportsSplitDNS() bool {
|
||||||
return RoutingModeNone
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m resolvedManager) Close() error {
|
func (m resolvedManager) Close() error {
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
// DNS configuration simultaneously (iOS, android).
|
// DNS configuration simultaneously (iOS, android).
|
||||||
type CallbackRouter struct {
|
type CallbackRouter struct {
|
||||||
SetBoth func(rcfg *Config, dcfg *dns.OSConfig) error
|
SetBoth func(rcfg *Config, dcfg *dns.OSConfig) error
|
||||||
DNSMode dns.RoutingMode
|
SplitDNS bool
|
||||||
|
|
||||||
mu sync.Mutex // protects all the following
|
mu sync.Mutex // protects all the following
|
||||||
rcfg *Config // last applied router config
|
rcfg *Config // last applied router config
|
||||||
@ -44,9 +44,9 @@ func (r *CallbackRouter) SetDNS(dcfg dns.OSConfig) error {
|
|||||||
return r.SetBoth(r.rcfg, r.dcfg)
|
return r.SetBoth(r.rcfg, r.dcfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoutingMode implements dns.OSConfigurator.
|
// SupportsSplitDNS implements dns.OSConfigurator.
|
||||||
func (r *CallbackRouter) RoutingMode() dns.RoutingMode {
|
func (r *CallbackRouter) SupportsSplitDNS() bool {
|
||||||
return r.DNSMode
|
return r.SplitDNS
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CallbackRouter) Close() error {
|
func (r *CallbackRouter) Close() error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user