Documentation ¶
Overview ¶
Package dns is responsible for configuring dns on various Linux distros.
Index ¶
Constants ¶
const (
HostsFilePath = "/etc/hosts"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultSetter ¶
type DefaultSetter struct {
// contains filtered or unexported fields
}
DefaultSetter handleds DNS in this order:
1. If systemd-resolve command is available and systemd-resolved.service is running, systemd-resolve DBUS API is used.
2. In case of systemd-resolve is not accessible, resolvectl (which is part of systemd-resolve package) command line utility is used.
3. In absence of systemd-resolve, resolvconf command line utility is used, which modifies /etc/resolv.conf by adding or removing lines.
4. In case the resolvconf command line utility fails, /etc/resolv.conf is backed up and modified directly by NordVPN.
func (*DefaultSetter) Set ¶
func (d *DefaultSetter) Set(iface string, nameservers []string) error
Set DNS for a given iface if the system supports per interface DNS settings. Also, backup current DNS settings (only in case of direct resolv.conf edit). Backup is not overridden, so its safe to call this function multiple times in a row.
func (*DefaultSetter) Unset ¶
func (d *DefaultSetter) Unset(iface string) error
Unset DNS for network interface, restore DNS from a backup, if backup is available, and remove the backup on success.
type HostnameSetter ¶
Add hostname interface
type HostsFileSetter ¶
type HostsFileSetter struct {
// contains filtered or unexported fields
}
HostsFileSetter modifies the hosts file in order to add custom DNS
func NewHostsFileSetter ¶
func NewHostsFileSetter(filePath string) *HostsFileSetter
func (*HostsFileSetter) SetHosts ¶
func (s *HostsFileSetter) SetHosts(hosts Hosts) error
func (*HostsFileSetter) UnsetHosts ¶
func (s *HostsFileSetter) UnsetHosts() error
type Method ¶
type Method interface { Set(iface string, nameservers []string) error Unset(iface string) error IsAvailable() bool Name() string }
Method is abstraction of DNS handling method
type NameServers ¶
type NameServers struct {
// contains filtered or unexported fields
}
func NewNameServers ¶
func NewNameServers(servers []string) *NameServers
type ResolvConfFile ¶
type ResolvConfFile struct{}
Direct file resolv.conf editing based DNS handling method. This is last fallback method if others are not available
func (*ResolvConfFile) IsAvailable ¶
func (m *ResolvConfFile) IsAvailable() bool
func (*ResolvConfFile) Name ¶
func (m *ResolvConfFile) Name() string
func (*ResolvConfFile) Unset ¶
func (m *ResolvConfFile) Unset(iface string) error
type Resolvconf ¶
type Resolvconf struct{}
Resolvconf based DNS handling method
func (*Resolvconf) IsAvailable ¶
func (m *Resolvconf) IsAvailable() bool
func (*Resolvconf) Name ¶
func (m *Resolvconf) Name() string
func (*Resolvconf) Unset ¶
func (m *Resolvconf) Unset(iface string) error
type Resolvectl ¶
type Resolvectl struct{}
Systemd-resolved and resolvectl based DNS handling method
func (*Resolvectl) IsAvailable ¶
func (m *Resolvectl) IsAvailable() bool
func (*Resolvectl) Name ¶
func (m *Resolvectl) Name() string
func (*Resolvectl) Unset ¶
func (m *Resolvectl) Unset(iface string) error
type Resolved ¶
type Resolved struct{}
Systemd-resolved DBUS API based DNS handling method