network

package
v0.15.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 23 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 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 *guestresource.LCOWNetworkAdapter) 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.

func ValidateHostname

func ValidateHostname(hostname string) error

Check that the hostname is safe. This function is less strict than technically allowed, but ensures that when the hostname is inserted to /etc/hosts, it cannot lead to injection attacks.

Types

This section is empty.

Jump to

Keyboard shortcuts

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