Documentation ¶
Index ¶
- Constants
- Variables
- func FilterBridgeAddresses(addresses corenetwork.ProviderAddresses) 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
Constants ¶
const ( EOF = iota LITERAL NUMBER )
const DefaultDockerBridge = "docker0"
DefaultDockerBridge is the bridge that is set up by Docker.
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 AddressesForInterfaceName = func(name string) ([]string, error) { iface, err := net.InterfaceByName(name) if err != nil { return nil, errors.Trace(err) } addrs, err := iface.Addrs() if err != nil { return nil, errors.Trace(err) } res := make([]string, len(addrs)) for i, addr := range addrs { res[i] = addr.String() } return res, nil }
AddressesForInterfaceName returns the addresses in string form for the given interface name. It's exported to facilitate cross-package testing.
Functions ¶
func FilterBridgeAddresses ¶
func FilterBridgeAddresses(addresses corenetwork.ProviderAddresses) 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. This includes addresses used by the local Fan network.
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 { // Bridge turns existing devices into bridged devices. 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.