Documentation
¶
Overview ¶
copied from gokrazy
Functions for setting up resolv.conf ¶
https://go.dev/src/net/dnsconfig_unix.go
on initramfs systems /etc/resolv.conf is memory based. no need to safewrite/copy and fsync tricks
this is only way how resolv.conf is edited
Index ¶
- Constants
- func Carrier(interfacename string) (bool, error)
- func GetDhcpLease(ifi *net.Interface, hostname string) (*dhcp4.Lease, error)
- func GetInterfaceByName(interfacename string, timeout time.Duration) (*net.Interface, error)
- func HaveInterface(interfacename string) (bool, error)
- func Link(interfacename string) (bool, error)
- func ListInterfaceNames() ([]string, error)
- func PrintoutNetInterface(interfacename string) string
- func SetAddress(interfName string, addrWithMask string) error
- func SetLinkUp(interfacename string, up bool) error
- func SetRoute(interfacename string, gatewayIp net.IP, priority int) error
- func WaitCarrier(interfacename string, timeout time.Duration, interval time.Duration) error
- func WaitInterface(interfacename string, timeout time.Duration, interval time.Duration) error
- type IpSettings
- type ResolvConf
Constants ¶
View Source
const RESOLVCONFFILE = "/etc/resolv.conf"
Variables ¶
This section is empty.
Functions ¶
func GetInterfaceByName ¶
func HaveInterface ¶
func ListInterfaceNames ¶
func SetAddress ¶
func WaitCarrier ¶
WaitCarrier, helper function for polling carrier
Types ¶
type IpSettings ¶
type IpSettings struct {
Gateway net.IP //Goes to route
Address string
DnsServers []net.IP
LeaseTime time.Duration //Stays same
Expire time.Time //If leased from DHCP
}
func (*IpSettings) ApplyToInterface ¶
func (p *IpSettings) ApplyToInterface(interfacename string, priority int) error
func (IpSettings) String ¶
func (a IpSettings) String() string
type ResolvConf ¶
type ResolvConf struct {
CommentTitle string //One supported
Nameserver []netip.Addr // netip.IP is more modern, https://www.papercall.io/speakers/mdlayher/speaker_talks/222197-net-netip-introducing-go-s-new-ip-address-package
Domain string
Search string
Unparsed []string //Extra options etc... pack at end of file
}
Resolv.conf parsing. Better than https://go.dev/src/net/dnsconfig.go Only supported features
func ReadResolvConf ¶
func ReadResolvConf(fname string) (ResolvConf, error)
ReadResolvConf if file does not exist then return default resolv conf
func (*ResolvConf) AddNameservers ¶
func (p *ResolvConf) AddNameservers(iplist []net.IP) error
AddNameservers adds nameservers without duplicates
func (ResolvConf) Save ¶
func (a ResolvConf) Save(fname string) error
func (ResolvConf) String ¶
func (a ResolvConf) String() string
Click to show internal directories.
Click to hide internal directories.