Documentation ¶
Index ¶
- Constants
- Variables
- func FilterBridgeAddresses(addresses []corenetwork.ProviderAddress) corenetwork.ProviderAddresses
- func NaturallySortDeviceNames(names ...string) []string
- func QuoteSpaceSet(vals set.Strings) string
- func QuoteSpaces(vals []string) string
- func SubnetInAnyRange(cidrs []*net.IPNet, subnet *net.IPNet) bool
- func SupportsIPv6() bool
- type Bridger
- type DeviceToBridge
- type ScriptResult
Constants ¶
const ( EOF = iota LITERAL NUMBER )
const DefaultKVMBridge = "virbr0"
DefaultKVMBridge is the bridge that is set up by installing libvirt-bin Note: we don't import this from 'container' to avoid import loops
const DefaultLXCBridge = "lxcbr0"
DefaultLXCBridge is the bridge that gets used for LXC containers
const DefaultLXDBridge = "lxdbr0"
DefaultLXDBridge is the bridge that gets used for LXD containers
const UnknownId = ""
UnknownId can be used whenever an Id is needed but not known.
Variables ¶
var InterfaceByNameAddrs = func(name string) ([]net.Addr, error) { iface, err := net.InterfaceByName(name) if err != nil { return nil, err } return iface.Addrs() }
InterfaceByNameAddrs returns the addresses for the given interface name. It's exported to facilitate cross-package testing.
var LXCNetDefaultConfig = "/etc/default/lxc-net"
LXCNetDefaultConfig is the location of the default network config of the lxc package. It's exported to allow cross-package testing.
Functions ¶
func FilterBridgeAddresses ¶
func FilterBridgeAddresses(addresses []corenetwork.ProviderAddress) corenetwork.ProviderAddresses
FilterBridgeAddresses removes addresses seen as a Bridge address (the IP address used only to connect to local containers), rather than a remote accessible address.
func NaturallySortDeviceNames ¶
NaturallySortDeviceNames returns an ordered list of names based on a natural ordering where 'natural' is an ordering of the string value in alphabetical order, execept that multi-digit numbers are ordered as a single character.
For example, sorting:
[ br-eth10 br-eth1 br-eth2 ]
would sort as:
[ br-eth1 br-eth2 br-eth10 ]
In purely alphabetical sorting "br-eth10" would be sorted before "br-eth2" because "1" is sorted as smaller than "2", while in natural sorting "br-eth2" is sorted before "br-eth10" because "2" is sorted as smaller than "10".
This also extends to multiply repeated numbers (e.g., VLANs).
For example, sorting:
[ br-eth2 br-eth10.10 br-eth200.0 br-eth1.0 br-eth2.0 ]
would sort as:
[ br-eth1.0 br-eth2 br-eth2.0 br-eth10.10 br-eth200.0 ]
func QuoteSpaceSet ¶
QuoteSpaceSet is the same as QuoteSpaces, but ensures that a set.Strings gets sorted values output.
func QuoteSpaces ¶
QuoteSpaces takes a slice of space names, and returns a nicely formatted form so they show up legible in log messages, etc.
func SubnetInAnyRange ¶
SubnetInAnyRange returns true if the subnet's address range is fully contained in any of the specified subnet blocks.
func SupportsIPv6 ¶
func SupportsIPv6() bool
SupportsIPv6 reports whether the platform supports IPv6 networking functionality.
Source: https://github.com/golang/net/blob/master/internal/nettest/stack.go
Types ¶
type Bridger ¶
type Bridger interface { // Turns existing devices into bridged devices. // TODO(frobware) - we may want a different type to encompass // and reflect how bridging should be done vis-a-vis what // needs to be bridged. Bridge(devices []DeviceToBridge, reconfigureDelay int) error }
Bridger creates network bridges to support addressable containers.
func DefaultEtcNetworkInterfacesBridger ¶
DefaultEtcNetworkInterfacesBridger returns a Bridger instance that can parse an interfaces(5) to transform existing devices into bridged devices.
type DeviceToBridge ¶
type DeviceToBridge struct { // DeviceName is the name of the device on the machine that should // be bridged. DeviceName string // BridgeName is the name of the bridge that we want created. BridgeName string // MACAddress is the MAC address of the device to be bridged MACAddress string }
DeviceToBridge gives the information about a particular device that should be bridged.