network

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoInNetNS

func DoInNetNS(ns netns.NsHandle, run func() error) error

DoInNetNS is a utility to run a function `run` inside of a specific network namespace `ns`. This is accomplished by locking the current goroutines thread to prevent the goroutine from being scheduled to a new thread during execution of `run`. The threads original network namespace will be rejoined on exit.

func GenerateEtcHostsContent

func GenerateEtcHostsContent(ctx context.Context, hostname string) string

GenerateEtcHostsContent generates a /etc/hosts file based on `hostname`.

func GenerateResolvConfContent

func GenerateResolvConfContent(ctx context.Context, searches, servers, options []string) (_ string, err error)

GenerateResolvConfContent generates the resolv.conf file content based on `searches`, `servers`, and `options`.

func InstanceIDToName

func InstanceIDToName(ctx context.Context, id string, vpciAssigned bool) (_ string, err error)

InstanceIDToName converts from the given instance ID (a GUID generated on the Windows host) to its corresponding interface name (e.g. "eth0").

Will retry the operation until `ctx` is exceeded or canceled.

func MergeValues

func MergeValues(first, second []string) []string

MergeValues merges `first` and `second` maintaining order `first, second`.

func MoveInterfaceToNS

func MoveInterfaceToNS(ifStr string, pid int) error

MoveInterfaceToNS moves the adapter with interface name `ifStr` to the network namespace of `pid`.

func NetNSConfig

func NetNSConfig(ctx context.Context, ifStr string, nsPid int, adapter *prot.NetworkAdapter) error

NetNSConfig moves a network interface into a network namespace and configures it.

This function MUST be used in tandem with `DoInNetNS` or some other means that ensures that the goroutine executing this code stays on the same thread.

Types

This section is empty.

Jump to

Keyboard shortcuts

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