Documentation ¶
Index ¶
- func DoInNetNS(ns netns.NsHandle, run func() error) error
- func GenerateEtcHostsContent(ctx context.Context, hostname string) string
- func GenerateResolvConfContent(ctx context.Context, searches, servers, options []string) (_ string, err error)
- func InstanceIDToName(ctx context.Context, id string, vpciAssigned bool) (_ string, err error)
- func MergeValues(first, second []string) []string
- func MoveInterfaceToNS(ifStr string, pid int) error
- func NetNSConfig(ctx context.Context, ifStr string, nsPid int, adapter *prot.NetworkAdapter) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoInNetNS ¶
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 ¶
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 ¶
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 ¶
MergeValues merges `first` and `second` maintaining order `first, second`.
func MoveInterfaceToNS ¶
MoveInterfaceToNS moves the adapter with interface name `ifStr` to the network namespace of `pid`.
func NetNSConfig ¶
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.