network

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PairMask        = 30
	GatewayReserved = 2
)

Variables

View Source
var (
	ErrInvalidCIDRSize            = errors.New("invalid CIDR size")
	ErrCouldNotParseCIDR          = errors.New("could not parse CIDR")
	ErrCouldNotCreateNewPrefix    = errors.New("could not create new prefix")
	ErrCouldNotAcquireIP          = errors.New("could not acquire IP")
	ErrCouldNotReleaseIP          = errors.New("could not release IP")
	ErrCouldNotAcquireChildPrefix = errors.New("could not acquire child prefix")
	ErrCouldNotReleaseChildPrefix = errors.New("could not release child prefix")
)
View Source
var (
	ErrCouldNotGetOriginalNamespace    = errors.New("could not get original namespace")
	ErrCouldNotNewNamespace            = errors.New("could not create new namespace")
	ErrCouldNotAddTapInterface         = errors.New("could not add tap interface")
	ErrCouldNotParseGatewaySubnet      = errors.New("could not parse gateway subnet")
	ErrCouldNotAddAddressToInterface   = errors.New("could not add address to interface")
	ErrCouldNotParseMACAddress         = errors.New("could not parse MAC address")
	ErrCouldNotSetHardwareAddress      = errors.New("could not set hardware address")
	ErrCouldNotSetLinkUp               = errors.New("could not set link up")
	ErrCouldNotAddVethInterface        = errors.New("could not add veth interface")
	ErrCouldNotGetVethInterface        = errors.New("could not get veth interface")
	ErrCouldNotSetNamespacePid         = errors.New("could not set namespace pid")
	ErrCouldNotParseInternalVethSubnet = errors.New("could not parse internal veth subnet")
	ErrCouldNotSetOriginalNamespace    = errors.New("could not set original namespace")
	ErrCouldNotParseExternalVethSubnet = errors.New("could not parse external veth subnet")
	ErrCouldNotParseDefaultAddress     = errors.New("could not parse default address")
	ErrCouldNotAddRoute                = errors.New("could not add route")
	ErrCouldNotNewIPTable              = errors.New("could not create new iptables instance")
	ErrCouldNotAppendIPTableRule       = errors.New("could not append iptables rule")
	ErrCouldNotDeleteIPTableRule       = errors.New("could not delete iptables rule")
	ErrCouldNotDeleteRoute             = errors.New("could not delete route")
	ErrCouldNotDeleteLink              = errors.New("could not delete link")
	ErrCouldNotSetLinkDown             = errors.New("could not set link down")
	ErrCouldNotDeleteNamespace         = errors.New("could not delete namespace")
)
View Source
var (
	ErrCouldNotWriteIPForwarding      = errors.New("could not enable IP forwarding")
	ErrCouldNotCreateIPTablesInstance = errors.New("could not create iptables instance")
	ErrCouldNotAppendPostRoutingRule  = errors.New("could not append POSTROUTING rule to nat table")
	ErrCouldNotAppendForwardRule      = errors.New("could not append FORWARD rule to filter table")
	ErrCouldNotDeleteForwardRule      = errors.New("could not delete FORWARD rule from filter table")
	ErrCouldNotDeletePostRoutingRule  = errors.New("could not delete POSTROUTING rule from nat table")
)

Functions

func CreateNAT

func CreateNAT(hostInterface string) error

func RemoveNAT

func RemoveNAT(hostInterface string) error

Types

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, ctx context.Context) *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,

	allowIncomingTraffic bool,
) *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