dnsmasq

package
v0.0.0-...-49f7de5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigMutex sync.Mutex

ConfigMutex used to coordinate access to the dnsmasq config files.

Functions

func DHCPAllocatedIPs

func DHCPAllocatedIPs(network string) (map[[4]byte]DHCPAllocation, map[[16]byte]DHCPAllocation, error)

DHCPAllocatedIPs returns a map of IPs currently allocated (statically and dynamically) in dnsmasq for a specific network. The returned map is keyed by a 16 byte array representing the net.IP format. The value of each map item is a DHCPAllocation struct containing at least whether the allocation was static or dynamic and optionally container name or MAC address. MAC addresses are only included for dynamic IPv4 allocations (where name is not reliable). Static allocations are not overridden by dynamic allocations, allowing for container name to be included for static IPv6 allocations. IPv6 addresses that are dynamically assigned cannot be reliably linked to containers using either name or MAC because dnsmasq does not record the MAC address for these records, and the recorded host name can be set by the container if the dns.mode for the network is set to "dynamic" and so cannot be trusted, so in this case we do not return any identifying info.

func DHCPStaticIPs

func DHCPStaticIPs(network, projectName, instanceName string) (DHCPAllocation, DHCPAllocation, error)

DHCPStaticIPs retrieves the dnsmasq statically allocated IPs for a container. Returns IPv4 and IPv6 DHCPAllocation structs respectively.

func GetVersion

func GetVersion() (*version.DottedVersion, error)

GetVersion returns the version of dnsmasq.

func Kill

func Kill(name string, reload bool) error

Kill kills dnsmasq for a particular network (or optionally reloads it).

func RemoveStaticEntry

func RemoveStaticEntry(network string, projectName string, instanceName string) error

RemoveStaticEntry removes a single dhcp-host line for a network/instance combination.

func UpdateStaticEntry

func UpdateStaticEntry(network string, projectName string, instanceName string, netConfig map[string]string, hwaddr string, ipv4Address string, ipv6Address string) error

UpdateStaticEntry writes a single dhcp-host line for a network/instance combination.

Types

type DHCPAllocation

type DHCPAllocation struct {
	IP     net.IP
	Name   string
	MAC    net.HardwareAddr
	Static bool
}

DHCPAllocation represents an IP allocation from dnsmasq.

Jump to

Keyboard shortcuts

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