net/dns: rename Config to OSConfig.

Making way for a new higher level config struct.

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/1652/head
David Anderson 3 years ago committed by Dave Anderson
parent fcfc0d3a08
commit 8af9d770cf

@ -46,7 +46,7 @@ func getVal() []interface{} {
},
},
&router.Config{
DNS: dns.Config{
DNS: dns.OSConfig{
Nameservers: []netaddr.IP{netaddr.IPv4(8, 8, 8, 8)},
Domains: []string{"tailscale.net"},
},

@ -1449,7 +1449,7 @@ func (b *LocalBackend) authReconfig() {
b.logf("[unexpected] dns proxied but no nameservers")
proxied = false
}
rcfg.DNS = dns.Config{
rcfg.DNS = dns.OSConfig{
Nameservers: nm.DNS.Nameservers,
Domains: nm.DNS.Domains,
Proxied: proxied,

@ -8,9 +8,8 @@ import (
"inet.af/netaddr"
)
// Config is the set of parameters that uniquely determine
// the state to which a manager should bring system DNS settings.
type Config struct {
// 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.
@ -22,7 +21,7 @@ type Config struct {
// Equal determines whether its argument and receiver
// represent equivalent DNS configurations (then DNS reconfig is a no-op).
func (lhs Config) Equal(rhs Config) bool {
func (lhs OSConfig) Equal(rhs OSConfig) bool {
if lhs.Proxied != rhs.Proxied {
return false
}

@ -48,8 +48,8 @@ func writeResolvConf(w io.Writer, servers []netaddr.IP, domains []string) {
}
// readResolvConf reads DNS configuration from /etc/resolv.conf.
func readResolvConf() (Config, error) {
var config Config
func readResolvConf() (OSConfig, error) {
var config OSConfig
f, err := os.Open("/etc/resolv.conf")
if err != nil {
@ -115,7 +115,7 @@ func newDirectManager() managerImpl {
}
// Up implements managerImpl.
func (m directManager) Up(config Config) error {
func (m directManager) Up(config OSConfig) error {
// Write the tsConf file.
buf := new(bytes.Buffer)
writeResolvConf(buf, config.Nameservers, config.Domains)

@ -25,7 +25,7 @@ const reconfigTimeout = time.Second
type managerImpl interface {
// Up updates system DNS settings to match the given configuration.
Up(Config) error
Up(OSConfig) error
// Down undoes the effects of Up.
// It is idempotent and performs no action if Up has never been called.
Down() error
@ -37,7 +37,7 @@ type Manager struct {
impl managerImpl
config Config
config OSConfig
}
// NewManagers created a new manager from the given config.
@ -52,7 +52,7 @@ func NewManager(logf logger.Logf, interfaceName string) *Manager {
return m
}
func (m *Manager) Set(config Config) error {
func (m *Manager) Set(config OSConfig) error {
if config.Equal(m.config) {
return nil
}

@ -64,7 +64,7 @@ func (m windowsManager) setDomains(basePath string, domains []string) error {
return setRegistryString(path, "SearchList", value)
}
func (m windowsManager) Up(config Config) error {
func (m windowsManager) Up(config OSConfig) error {
var ipsv4 []string
var ipsv6 []string
@ -114,5 +114,5 @@ func (m windowsManager) Up(config Config) error {
}
func (m windowsManager) Down() error {
return m.Up(Config{Nameservers: nil, Domains: nil})
return m.Up(OSConfig{Nameservers: nil, Domains: nil})
}

@ -62,7 +62,7 @@ func newNMManager(interfaceName string) managerImpl {
type nmConnectionSettings map[string]map[string]dbus.Variant
// Up implements managerImpl.
func (m nmManager) Up(config Config) error {
func (m nmManager) Up(config OSConfig) error {
ctx, cancel := context.WithTimeout(context.Background(), reconfigTimeout)
defer cancel()
@ -201,5 +201,5 @@ func (m nmManager) Up(config Config) error {
// Down implements managerImpl.
func (m nmManager) Down() error {
return m.Up(Config{Nameservers: nil, Domains: nil})
return m.Up(OSConfig{Nameservers: nil, Domains: nil})
}

@ -9,7 +9,7 @@ package dns
type noopManager struct{}
// Up implements managerImpl.
func (m noopManager) Up(Config) error { return nil }
func (m noopManager) Up(OSConfig) error { return nil }
// Down implements managerImpl.
func (m noopManager) Down() error { return nil }

@ -116,7 +116,7 @@ func newResolvconfManager(logf logger.Logf) managerImpl {
const resolvconfConfigName = "tun-tailscale.inet"
// Up implements managerImpl.
func (m resolvconfManager) Up(config Config) error {
func (m resolvconfManager) Up(config OSConfig) error {
stdin := new(bytes.Buffer)
writeResolvConf(stdin, config.Nameservers, config.Domains) // dns_direct.go

@ -82,7 +82,7 @@ func newResolvedManager() managerImpl {
}
// Up implements managerImpl.
func (m resolvedManager) Up(config Config) error {
func (m resolvedManager) Up(config OSConfig) error {
ctx, cancel := context.WithTimeout(context.Background(), reconfigTimeout)
defer cancel()

@ -58,7 +58,7 @@ type Config struct {
// this node has chosen to use.
Routes []netaddr.IPPrefix
DNS dns.Config
DNS dns.OSConfig
// Linux-only things below, ignored on other platforms.

Loading…
Cancel
Save