network

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 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(s *specs.State, brOpt bridge.Opt, staticip string, configure bool) (net.IP, error)

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

func (*Client) Delete added in v0.6.0

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

Delete the virtual network interface from the configured bridge

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