dns

package
v0.0.0-...-f4b31ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

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

func ReadContents(ctx context.Context, executor executor.IExecCommander) (string, error)

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

func SetDNSFileContent(content string) error

SetDNSFileContent set the content of the DNS file.

func UpdateRecord

func UpdateRecord(ctx context.Context, host string, addr string) (string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL