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 ListenUDP ¶ added in v0.4.0
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 ¶
New returns a plane. endpoints returns the current host endpoint map (name → host:port), as recorded by emu.Endpoints.
func (*Plane) Addr ¶
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 ¶
External returns the external (egress-capable) network, creating it on first use.