2021-04-02 08:39:52 +00:00
|
|
|
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package dns
|
|
|
|
|
2021-04-05 20:05:47 +00:00
|
|
|
import "inet.af/netaddr"
|
2021-04-02 08:39:52 +00:00
|
|
|
|
|
|
|
// An OSConfigurator applies DNS settings to the operating system.
|
|
|
|
type OSConfigurator interface {
|
2021-04-03 03:15:54 +00:00
|
|
|
// SetDNS updates the OS's DNS configuration to match cfg.
|
2021-04-03 01:44:02 +00:00
|
|
|
// If cfg is the zero value, all Tailscale-related DNS
|
2021-04-02 08:39:52 +00:00
|
|
|
// configuration is removed.
|
2021-04-03 03:15:54 +00:00
|
|
|
// SetDNS must not be called after Close.
|
|
|
|
SetDNS(cfg OSConfig) error
|
2021-04-05 20:05:47 +00:00
|
|
|
// SupportsSplitDNS reports whether the configurator is capable of
|
|
|
|
// installing a resolver only for specific DNS suffixes. If false,
|
|
|
|
// the configurator can only set a global resolver.
|
|
|
|
SupportsSplitDNS() bool
|
2021-04-02 08:39:52 +00:00
|
|
|
// Close removes Tailscale-related DNS configuration from the OS.
|
|
|
|
Close() error
|
|
|
|
}
|
2021-04-05 20:05:47 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|