network

package
v0.0.0-...-f662469 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PairMask        = 30
	GatewayReserved = 2
)

Variables

View Source
var (
	ErrNotEnoughAvailableIPsInHostCIDR      = errors.New("not enough available IPs in host CIDR")
	ErrNotEnoughAvailableIPsInNamespaceCIDR = errors.New("not enough available IPs in namespace CIDR")
	ErrAllNamespacesClaimed                 = errors.New("all namespaces claimed")
)
View Source
var (
	ErrInvalidCIDRSize = errors.New("invalid cidr size")
)

Functions

func CreateNAT

func CreateNAT(hostInterface string) error

func RemoveNAT

func RemoveNAT(hostInterface string) error

Types

type Daemon

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

func NewDaemon

func NewDaemon(
	hostInterface string,

	hostVethCIDR string,
	namespaceVethCIDR string,

	namespaceInterface string,
	namespaceInterfaceGateway string,
	namespaceInterfaceNetmask uint32,
	namespaceInterfaceIP string,
	namespaceInterfaceMAC string,

	namespacePrefix string,

	onBeforeCreateNamespace func(id string) error,
	onBeforeRemoveNamespace func(id string) error,
) *Daemon

func (*Daemon) ClaimNamespace

func (d *Daemon) ClaimNamespace() (string, error)

func (*Daemon) Close

func (d *Daemon) Close(ctx context.Context) error

func (*Daemon) Open

func (d *Daemon) Open(ctx context.Context) error

func (*Daemon) ReleaseNamespace

func (d *Daemon) ReleaseNamespace(namespace string) error

type IP

type IP struct {
	*ipam.IP
}

func NewIP

func NewIP(ip *ipam.IP) *IP

func (*IP) String

func (i *IP) String() string

type IPPair

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

func NewIPPair

func NewIPPair(
	firstIP *IP,
	secondIP *IP,

	prefix *ipam.Prefix,
	ipTable *IPTable,
) *IPPair

func (*IPPair) GetFirstIP

func (p *IPPair) GetFirstIP() *IP

func (*IPPair) GetSecondIP

func (p *IPPair) GetSecondIP() *IP

type IPTable

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

func NewIPTable

func NewIPTable(cidr string) *IPTable

func (*IPTable) AvailableIPs

func (t *IPTable) AvailableIPs() uint64

func (*IPTable) AvailablePairs

func (t *IPTable) AvailablePairs() uint64

func (*IPTable) GetIP

func (t *IPTable) GetIP(ctx context.Context) (*IP, error)

func (*IPTable) GetPair

func (t *IPTable) GetPair(ctx context.Context) (*IPPair, error)

func (*IPTable) Open

func (t *IPTable) Open(ctx context.Context) error

func (*IPTable) ReleaseIP

func (t *IPTable) ReleaseIP(ctx context.Context, ip *IP) error

func (*IPTable) ReleasePair

func (i *IPTable) ReleasePair(ctx context.Context, ipPair *IPPair) error

type Namespace

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

func NewNamespace

func NewNamespace(
	id string,

	hostInterface string,
	namespaceInterface string,

	namespaceInterfaceGateway string,
	namespaceInterfaceNetmask uint32,

	hostVethInternalIP string,
	hostVethExternalIP string,

	namespaceInterfaceIP string,
	namespaceVethIP string,

	blockedSubnet string,

	namespaceInterfaceMAC string,
) *Namespace

func (*Namespace) Close

func (n *Namespace) Close() error

func (*Namespace) GetID

func (n *Namespace) GetID() string

func (*Namespace) Open

func (n *Namespace) Open() error

Jump to

Keyboard shortcuts

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