docker: github.com/docker/docker/vendor/github.com/docker/libnetwork/resolvconf Index | Files | Directories

package resolvconf

import "github.com/docker/docker/vendor/github.com/docker/libnetwork/resolvconf"

Package resolvconf provides utility code to query and update DNS configuration in /etc/resolv.conf

Index

Package Files

resolvconf.go

func GetNameservers Uses

func GetNameservers(resolvConf []byte, kind int) []string

GetNameservers returns nameservers (if any) listed in /etc/resolv.conf

func GetNameserversAsCIDR Uses

func GetNameserversAsCIDR(resolvConf []byte) []string

GetNameserversAsCIDR returns nameservers (if any) listed in /etc/resolv.conf as CIDR blocks (e.g., "1.2.3.4/32") This function's output is intended for net.ParseCIDR

func GetOptions Uses

func GetOptions(resolvConf []byte) []string

GetOptions returns options (if any) listed in /etc/resolv.conf If more than one options line is encountered, only the contents of the last one is returned.

func GetSearchDomains Uses

func GetSearchDomains(resolvConf []byte) []string

GetSearchDomains returns search domains (if any) listed in /etc/resolv.conf If more than one search line is encountered, only the contents of the last one is returned.

func Path Uses

func Path() string

Path returns the path to the resolv.conf file that libnetwork should use.

When /etc/resolv.conf contains 127.0.0.53 as the only nameserver, then it is assumed systemd-resolved manages DNS. Because inside the container 127.0.0.53 is not a valid DNS server, Path() returns /run/systemd/resolve/resolv.conf which is the resolv.conf that systemd-resolved generates and manages. Otherwise Path() returns /etc/resolv.conf.

Errors are silenced as they will inevitably resurface at future open/read calls.

More information at https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html#/etc/resolv.conf

type File Uses

type File struct {
    Content []byte
    Hash    string
}

File contains the resolv.conf content and its hash

func Build Uses

func Build(path string, dns, dnsSearch, dnsOptions []string) (*File, error)

Build writes a configuration file to path containing a "nameserver" entry for every element in dns, a "search" entry for every element in dnsSearch, and an "options" entry for every element in dnsOptions.

func FilterResolvDNS Uses

func FilterResolvDNS(resolvConf []byte, ipv6Enabled bool) (*File, error)

FilterResolvDNS cleans up the config in resolvConf. It has two main jobs: 1. It looks for localhost (127.*|::1) entries in the provided

resolv.conf, removing local nameserver entries, and, if the resulting
cleaned config has no defined nameservers left, adds default DNS entries

2. Given the caller provides the enable/disable state of IPv6, the filter

code will remove all IPv6 nameservers if it is not enabled for containers

func Get Uses

func Get() (*File, error)

Get returns the contents of /etc/resolv.conf and its hash

func GetIfChanged Uses

func GetIfChanged() (*File, error)

GetIfChanged retrieves the host /etc/resolv.conf file, checks against the last hash and, if modified since last check, returns the bytes and new hash. This feature is used by the resolv.conf updater for containers

func GetLastModified Uses

func GetLastModified() *File

GetLastModified retrieves the last used contents and hash of the host resolv.conf. Used by containers updating on restart

func GetSpecific Uses

func GetSpecific(path string) (*File, error)

GetSpecific returns the contents of the user specified resolv.conf file and its hash

Directories

PathSynopsis
dns

Package resolvconf imports 9 packages (graph). Updated 2019-06-15. Refresh now. Tools for package owners.