Documentation
¶
Index ¶
- func AttachTAP(tapName, bridgeName string) error
- func CreateBridge(cfg BridgeConfig) error
- func CreateTAPDevice(name string) error
- func DeleteTAPDevice(name string) error
- func DestroyBridge(name string) error
- func DetachTAP(tapName string) error
- func EnsureBridge(cfg BridgeConfig) error
- type BridgeConfig
- type Forwarder
- type Network
- type PortForward
- type Store
- func (s *Store) AllocateIP(name string) (net.IP, error)
- func (s *Store) Create(name, subnet, driver string) (*Network, error)
- func (s *Store) Get(name string) (*Network, error)
- func (s *Store) List() ([]*Network, error)
- func (s *Store) ReleaseIP(name string, ip string) error
- func (s *Store) Remove(name string) error
- type TAP
- type TAPConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBridge ¶
func CreateBridge(cfg BridgeConfig) error
CreateBridge creates a Linux bridge, assigns the gateway IP, and brings it up. Requires CAP_NET_ADMIN.
func CreateTAPDevice ¶
CreateTAPDevice creates a persistent TAP device by name. It is idempotent: a device that already exists is treated as success. Firecracker requires the tap to exist before it opens it; unlike QEMU it does not create taps itself.
func DeleteTAPDevice ¶
DeleteTAPDevice removes a persistent TAP device created by CreateTAPDevice.
func DestroyBridge ¶
DestroyBridge removes a Linux bridge interface.
func EnsureBridge ¶
func EnsureBridge(cfg BridgeConfig) error
EnsureBridge creates the bridge if it does not already exist, assigning the gateway IP and bringing it up. Unlike CreateBridge it is idempotent, so it is safe to call for a bridge shared by multiple VMs.
Types ¶
type BridgeConfig ¶
type BridgeConfig struct {
// Name is the bridge interface name (e.g. "jerboa-br0").
Name string
// CIDR is the gateway IP with CIDR mask (e.g. "10.0.0.1/24").
CIDR string
}
BridgeConfig holds the parameters for a Linux bridge interface.
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder publishes guest ports on the host by proxying real listening sockets to the guest over the bridge.
It replaces iptables DNAT, which never worked for host-local access (the PREROUTING rule matched the wrong direction) and is invisible to WSL2's localhost forwarding (a DNAT rule opens no listening socket, so a Windows host cannot reach it). A userspace listener is a normal socket: reachable from the host itself and mirrored by WSL2 to the Windows side.
func StartForwarder ¶
func StartForwarder(guestIP string, ports []PortForward) (*Forwarder, error)
StartForwarder opens a TCP listener for each TCP port map and proxies accepted connections to guestIP. UDP maps are not yet supported and are skipped with a warning. The returned Forwarder must be closed when the VM stops.
type PortForward ¶
PortForward describes a single host-to-guest port forwarding rule.