Documentation
¶
Index ¶
- func DeleteRecord(recordEnsurer recordEnsurer, hostsfileReader hostsfileReaderFunc, host string) (string, error)
- func EnsureRecords(content string, newRecords map[string]string, deletedRecords map[string]bool) error
- func ForceReloadDNSMasqProcess() error
- func ReadContents(ctx context.Context, executor executor.IExecCommander) (string, error)
- func ReadHostsToHostMap(ctx context.Context, executor executor.IExecCommander) (map[string]string, error)
- func ReadHostsToIPMap(ctx context.Context, executor executor.IExecCommander) (map[string]string, error)
- func SetDNSFileContent(content string) error
- func UpdateRecord(ctx context.Context, host string, addr string) (string, error)
- type IPToHostnameResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteRecord ¶
func DeleteRecord(recordEnsurer recordEnsurer, hostsfileReader hostsfileReaderFunc, host string) (string, error)
DeleteRecord removes an addr, host pairing from the /etc/hosts file if it is present and returns the original contents before modification, to allow its caller to undo the modification.
func EnsureRecords ¶
func EnsureRecords( content string, newRecords map[string]string, deletedRecords map[string]bool, ) error
EnsureRecords ensures that the given DNS records in question are up to date with respect to a map mapping hostnames to addresses.
func ForceReloadDNSMasqProcess ¶
func ForceReloadDNSMasqProcess() error
ForceReloadDNSMasqProcess sends the hangup signal to the dnsmasq process inside the dns container and forces it to reload its config.
func ReadContents ¶
ReadContents gets the content of a DNS file. If the DNS file does not exist, replace it with an empty container.
func ReadHostsToHostMap ¶
func ReadHostsToHostMap( ctx context.Context, executor executor.IExecCommander, ) (map[string]string, error)
ReadHostsToHostMap read the hosts file to get the host IP mapping
func ReadHostsToIPMap ¶
func ReadHostsToIPMap( ctx context.Context, executor executor.IExecCommander, ) (map[string]string, error)
ReadHostsToIPMap read the hosts file to get the IP host mapping
func SetDNSFileContent ¶
SetDNSFileContent set the content of the DNS file.
func UpdateRecord ¶
UpdateRecord ensures that the contents of the /etc/hosts file in the dns container are up to date with a given host and address. UpdateRecord returns the original contents before modification, to allow its caller to undo the modification.
Types ¶
type IPToHostnameResult ¶
type IPToHostnameResult struct { // Hostnames contains the hostname that we can // convert the IP address to hostname Hostnames []string // InvalidAddresses contains the invalid IP address // that we can not convert it InvalidAddresses []string }
func IPToHostname ¶
func IPToHostname(ctx context.Context, executor executor.IExecCommander, addresses []string) (*IPToHostnameResult, error)
IPToHostname convert the IP addresses to the hostnames it returns the result that contains two parts. Valid (hostname), if we can convert the IP address to the hostname. Invalid (IP address), if we can not convert the IP address to the hostname