netplane

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netplane connects the emulator process to the container networks it creates (Section 3.3). Every container the emulator runs is attached to an internal "services" network on which the emulator's own endpoints (gateway, metadata, DNS, registry, ...) are reachable at the network's gateway address through forwarders, and optionally to an "external" network that provides internet egress (public IPs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(cidr, ip string) bool

Contains reports whether ip lies inside cidr.

func HostPort

func HostPort(addr string) (string, int)

HostPort splits "ip:port" into its parts with a numeric port.

func ListenUDP added in v0.4.0

func ListenUDP(ctx context.Context, host, port string) (net.PacketConn, error)

ListenUDP binds a UDP socket for DNS: the emulator's server and its forwarder on the services network. Port 5353 is also the mDNS port: avahi-daemon, systemd-resolved and browsers hold UDP 0.0.0.0:5353 with SO_REUSEADDR on most Linux desktops, so a plain bind of 127.0.0.1:5353 (or of the services gateway) fails with "address already in use". Setting SO_REUSEADDR on our socket lets it coexist; unicast queries to the specific bind address reach our socket while multicast mDNS traffic keeps going to the wildcard sockets. On a wildcard bind we would share (and steal) mDNS traffic, so reuse is only enabled for specific addresses. The TCP listener on the same port is bound first without reuse, so a second emulator instance still fails cleanly.

Types

type Net

type Net struct {
	// Name is the runtime network name.
	Name string
	// Subnet is the IPv4 CIDR.
	Subnet string
	// Gateway is the host-side address on the network.
	Gateway string
}

Net describes a container network.

type Plane

type Plane struct {
	// contains filtered or unexported fields
}

Plane manages the services and external networks of one instance.

func New

func New(rt *runtime.Manager, endpoints func() map[string]string, log *slog.Logger) *Plane

New returns a plane. endpoints returns the current host endpoint map (name → host:port), as recorded by emu.Endpoints.

func (*Plane) Addr

func (p *Plane) Addr(ctx context.Context, name string) (string, error)

Addr returns the address at which containers on the services network reach the named emulator endpoint ("gateway", "metadata", "dns", "ar", ...), starting a forwarder on the services gateway if needed. The port is the same as the host endpoint's when it is free.

func (*Plane) Close

func (p *Plane) Close()

Close stops all forwarders. Networks are left to runtime cleanup.

func (*Plane) External

func (p *Plane) External(ctx context.Context) (Net, error)

External returns the external (egress-capable) network, creating it on first use.

func (*Plane) Runtime

func (p *Plane) Runtime() *runtime.Manager

Runtime returns the runtime manager.

func (*Plane) Services

func (p *Plane) Services(ctx context.Context) (Net, error)

Services returns the internal services network, creating it on first use.

Jump to

Keyboard shortcuts

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