resolvconf

package
v1.4.2-0...-3d9cbf0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

README

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

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

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

func FilterResolvDns

func FilterResolvDns(resolvConf []byte, ipv6Enabled bool) ([]byte, bool)

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

It returns a boolean to notify the caller if changes were made at all

func Get

func Get() ([]byte, error)

Get returns the contents of /etc/resolv.conf

func GetIfChanged

func GetIfChanged() ([]byte, string, 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

func GetLastModified() ([]byte, string)

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

func GetNameservers

func GetNameservers(resolvConf []byte) []string

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

func GetNameserversAsCIDR

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 GetSearchDomains

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 IsLocalhost

func IsLocalhost(ip string) bool

IsLocalhost returns true if ip matches the localhost IP regular expression. Used for determining if nameserver settings are being passed which are localhost addresses

Types

This section is empty.

Jump to

Keyboard shortcuts

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