network

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSandboxNotFound = errors.New("sandbox not found")
)

Functions

func NewBadgerStorage

func NewBadgerStorage(db *badger.DB) goipam.Storage

NewBadgerStorage creates a new goipam.Storage instance backed by BadgerDB.

Types

type BadgerStorage

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

BadgerStorage implements the goipam.Storage interface using BadgerDB as the backend.

func (*BadgerStorage) Close

func (b *BadgerStorage) Close() error

Close closes the underlying BadgerDB instance.

func (*BadgerStorage) CreateNamespace

func (b *BadgerStorage) CreateNamespace(ctx context.Context, namespace string) error

CreateNamespace creates a new namespace. Returns error if namespace already exists.

func (*BadgerStorage) CreatePrefix

func (b *BadgerStorage) CreatePrefix(ctx context.Context, prefix goipam.Prefix, namespace string) (goipam.Prefix, error)

CreatePrefix creates a new prefix in the given namespace. Returns error if prefix already exists.

func (*BadgerStorage) DeleteAllPrefixes

func (b *BadgerStorage) DeleteAllPrefixes(ctx context.Context, namespace string) error

DeleteAllPrefixes removes all prefixes from the given namespace.

func (*BadgerStorage) DeleteNamespace

func (b *BadgerStorage) DeleteNamespace(ctx context.Context, namespace string) error

DeleteNamespace removes a namespace and all its prefixes.

func (*BadgerStorage) DeletePrefix

func (b *BadgerStorage) DeletePrefix(ctx context.Context, prefix goipam.Prefix, namespace string) (goipam.Prefix, error)

DeletePrefix removes a prefix from the given namespace.

func (*BadgerStorage) ListNamespaces

func (b *BadgerStorage) ListNamespaces(ctx context.Context) ([]string, error)

ListNamespaces returns all existing namespaces.

func (*BadgerStorage) Name

func (b *BadgerStorage) Name() string

Name returns the storage backend name.

func (*BadgerStorage) ReadAllPrefixCidrs

func (b *BadgerStorage) ReadAllPrefixCidrs(ctx context.Context, namespace string) ([]string, error)

ReadAllPrefixCidrs returns all prefix CIDRs from the given namespace.

func (*BadgerStorage) ReadAllPrefixes

func (b *BadgerStorage) ReadAllPrefixes(ctx context.Context, namespace string) (goipam.Prefixes, error)

ReadAllPrefixes returns all prefixes from the given namespace.

func (*BadgerStorage) ReadPrefix

func (b *BadgerStorage) ReadPrefix(ctx context.Context, prefix string, namespace string) (goipam.Prefix, error)

ReadPrefix retrieves a prefix from the given namespace.

func (*BadgerStorage) UpdatePrefix

func (b *BadgerStorage) UpdatePrefix(ctx context.Context, prefix goipam.Prefix, namespace string) (goipam.Prefix, error)

UpdatePrefix updates an existing prefix in the given namespace.

type Network

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

Network represents an execution container network.

func NewNetwork

func NewNetwork(opts ...Option) *Network

NewNetwork creates a new network.

func (*Network) Down

func (n *Network) Down(ctx context.Context, cid string) error

Down tears down the network for the given container.

func (*Network) Init

func (n *Network) Init(ctx context.Context) error

Init performs the network initialization. Must be called before any other method

func (*Network) Status

func (n *Network) Status(ctx context.Context, cid string) (*SandboxInfo, error)

func (*Network) String

func (n *Network) String() string

func (*Network) Up

func (n *Network) Up(ctx context.Context, cid string) error

Up sets up the network for the given container.

type Option

type Option func(*Network)

func WithCIDR

func WithCIDR(cidr string) Option

WithCIDR sets the cidr of the network.

func WithExtIfc

func WithExtIfc(name string) Option

WithExtIfc sets the external interface name.

func WithIpamDBPath

func WithIpamDBPath(path string) Option

func WithSubnetPrefixSize

func WithSubnetPrefixSize(prefixSize int) Option

WithSubnetPrefixSize sets the prefix size of the network.

type SandboxInfo

type SandboxInfo struct {
	ID     string         `json:"id"`
	Veth   string         `json:"veth"`
	Cidr   netip.Prefix   `json:"cidr"`
	GW     netip.Addr     `json:"gw"`
	IP     netip.Addr     `json:"ip"`
	Routes []SandboxRoute `json:"routes"`
}

SandboxInfo contains information about a network sandbox.

type SandboxRoute

type SandboxRoute struct {
	Dst   string `json:"dst"`
	Table int    `json:"table"`
}

SandboxRoute represents a route in a network sandbox.

Directories

Path Synopsis
Package iptables container useful routines for manipulating iptables rules.
Package iptables container useful routines for manipulating iptables rules.

Jump to

Keyboard shortcuts

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