netops

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPrefix = netip.MustParsePrefix("0.0.0.0/0")

Functions

func CreateNamedNamespace

func CreateNamedNamespace(name string) (string, error)

CreateNamedNamespace creates a new named network namespace, and returns its path

func DeleteNamedNamespace

func DeleteNamedNamespace(name string) error

DeleteNamedNamespace deletes a named NS

Types

type Bridge

type Bridge struct{}

type Device

type Device interface {
	// contains filtered or unexported methods
}
type Link interface {
	Name() string
	Namespace() Namespace
	Type() string
	Delete() error

	GetAddr() ([]netip.Prefix, error)
	AddAddr(prefix netip.Prefix) error
	GetHardwareAddr() (string, error)
	SetHardwareAddr(hwAddr string) error
	GetMTU() (int, error)
	SetMTU(mtu int) error

	SetMaster(master Link) error
	SetNamespace(target Namespace) error
	SetName(name string) error
	SetUp() error
}

type Namespace

type Namespace interface {
	Close() error
	LinkAdd(name string, device Device) (Link, error)
	LinkFind(name string) (Link, error)
	LinkList() ([]Link, error)
	Path() string
	RedirectAdd(src, dst string) error
	RedirectDel(src string) error
	RouteAdd(route *Route) error
	RouteDel(route *Route) error
	RouteList(filters ...*Route) ([]*Route, error)
	RuleAdd(rule *Rule) error
	RuleDel(rule *Rule) error
	RuleList(rule *Rule) ([]*Rule, error)
	Run(fn func() error) error
}

func OpenCurrentNamespace

func OpenCurrentNamespace() (Namespace, error)

OpenCurrentNamespace returns the current network namespace

func OpenNamespace

func OpenNamespace(nsPath string) (Namespace, error)

OpenNamespace returns a namespace specified by a path

type Route

type Route struct {
	Destination netip.Prefix
	Source      netip.Addr
	Gateway     netip.Addr
	Device      string
	Priority    int
	Table       int
	Type        int
	Protocol    int
	Onlink      bool
}

type Rule

type Rule struct {
	Src      netip.Prefix
	IifName  string
	Priority int
	Table    int
}

type VEth

type VEth struct {
	PeerName      string
	PeerNamespace Namespace
}

type VRF

type VRF struct {
	Table uint32
}

type VXLAN

type VXLAN struct {
	Group netip.Addr
	ID    int
	Port  int
}

Jump to

Keyboard shortcuts

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