network

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOF = iota
	LITERAL
	NUMBER
)
View Source
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

View Source
const DefaultLXCBridge = "lxcbr0"

DefaultLXCBridge is the bridge that gets used for LXC containers

View Source
const DefaultLXDBridge = "lxdbr0"

DefaultLXDBridge is the bridge that gets used for LXD containers

View Source
const UnknownId = ""

UnknownId can be used whenever an Id is needed but not known.

Variables

View Source
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.

View Source
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

func NaturallySortDeviceNames(names ...string) []string

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

func QuoteSpaceSet(vals set.Strings) string

QuoteSpaceSet is the same as QuoteSpaces, but ensures that a set.Strings gets sorted values output.

func QuoteSpaces

func QuoteSpaces(vals []string) string

QuoteSpaces takes a slice of space names, and returns a nicely formatted form so they show up legible in log messages, etc.

func SubnetInAnyRange

func SubnetInAnyRange(cidrs []*net.IPNet, subnet *net.IPNet) bool

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

func DefaultEtcNetworkInterfacesBridger(timeout time.Duration, filename string) (Bridger, error)

DefaultEtcNetworkInterfacesBridger returns a Bridger instance that can parse an interfaces(5) to transform existing devices into bridged devices.

func DefaultNetplanBridger

func DefaultNetplanBridger(timeout time.Duration, directory string) (Bridger, error)

DefaultNetplanBridger returns a Bridger instance that can parse a set of netplan yaml files 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.

type ScriptResult

type ScriptResult struct {
	Stdout   []byte
	Stderr   []byte
	Code     int
	TimedOut bool
}

Directories

Path Synopsis
ssh

Jump to

Keyboard shortcuts

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