network

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// DefaultContainerInterface is the default container interface.
	DefaultContainerInterface = "eth0"
	// DefaultPortPrefix is the default port prefix.
	DefaultPortPrefix = "netnsv0"
)

Variables

View Source
var (

	// ErrBridgeNameEmpty holds the error for when the bridge name is empty.
	ErrBridgeNameEmpty = errors.New("bridge name cannot be empty")
	// ErrStateDirPathEmpty holds the error for when the state directory path
	// is empty.
	ErrStateDirPathEmpty = errors.New("state directory path cannot be empty")
	// ErrDatabaseDoesNotExist holds the error for when the database does not
	// exit.
	ErrDatabaseDoesNotExist = errors.New("database does not exist")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the object used for interacting with networks.

func New

func New(opt Opt) (*Client, error)

New creates a new Client for interacting with networks.

func (*Client) AllocateIP

func (c *Client) AllocateIP(pid int) (ip net.IP, err error)

AllocateIP returns an unused IP for a specific process ID and saves it in the database.

func (*Client) Create

func (c *Client) Create(hook configs.HookState, brOpt bridge.Opt, staticip string) (net.IP, error)

Create returns a container IP that was created with the given bridge name, the settings from the HookState passed, and the bridge options.

func (*Client) List

func (c *Client) List() ([]Network, error)

List returns the ip addresses being used from the database for the networks with the specified bridge name.

type Network

type Network struct {
	VethPair *netlink.Veth
	IP       net.IP
	PID      int
	Status   string
	FD       netns.NsHandle
}

Network holds information about a network.

type Opt

type Opt struct {
	StateDir           string
	ContainerInterface string
	PortPrefix         string
	BridgeName         string
}

Opt holds the options for holding networks state, etc.

Jump to

Keyboard shortcuts

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