Help us shape the future of Go! Take the 2026 Go Developer Survey

network

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package network provides network configuration helpers for Apple Virtualization virtual machines.

It covers the common network attachment modes used by vzkit's high-level VM builders and exposes lower-level attachment constructors for callers that need more control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAttachment

func CreateAttachment(cfg Config) (vz.VZNetworkDeviceAttachment, error)

CreateAttachment creates a network device attachment based on cfg.

func CreateBridgedAttachment

func CreateBridgedAttachment(identifier string, macNAT bool) (vz.VZNetworkDeviceAttachment, error)

CreateBridgedAttachment creates a bridged attachment for the named interface.

func CreateDevice

CreateDevice creates a Virtio network device with a random MAC address.

func CreateHostOnlyNetworkAttachment

func CreateHostOnlyNetworkAttachment() (vz.VZNetworkDeviceAttachment, error)

CreateHostOnlyNetworkAttachment creates a host-only attachment.

func CreateNATAttachment

func CreateNATAttachment(isolate bool) (vz.VZNetworkDeviceAttachment, error)

CreateNATAttachment creates a NAT attachment.

func CreateRandomMACAddress added in v0.6.11

func CreateRandomMACAddress(path string) error

CreateRandomMACAddress creates and saves a random locally administered MAC address.

func CreateVhostUserNetworkAttachment

func CreateVhostUserNetworkAttachment(cfg VhostUserConfig) (vz.VZNetworkDeviceAttachment, error)

CreateVhostUserNetworkAttachment creates a private vhost-user attachment.

func LookupBridgedNetworkInterface

func LookupBridgedNetworkInterface(identifier string) (vz.VZBridgedNetworkInterface, error)

LookupBridgedNetworkInterface resolves a bridged interface by identifier.

Types

type Config

type Config struct {
	Mode      Mode
	Interface string
}

Config describes a VM network device configuration.

func Parse

func Parse(s string) (Config, error)

Parse parses a network mode string.

type Mode

type Mode string

Mode describes a network attachment mode.

const (
	ModeNAT      Mode = "nat"
	ModeBridged  Mode = "bridged"
	ModeHostOnly Mode = "host-only"
	ModeVMNet    Mode = "vmnet"
	ModeNone     Mode = "none"
)

type VhostUserConfig

type VhostUserConfig struct {
	Interface                   string
	XPCService                  int64
	MaximumTransmissionUnit     int64
	HostChecksumOffload         int64
	GuestChecksumOffload        int64
	HostTCPSegmentationOffload  int64
	GuestTCPSegmentationOffload int64
}

VhostUserConfig describes a private vhost-user network attachment.

func DefaultVhostUserConfig

func DefaultVhostUserConfig(interfaceName string) VhostUserConfig

DefaultVhostUserConfig returns a config populated with framework defaults.

Jump to

Keyboard shortcuts

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