Expand description
UPnP/IGD method — ask the local Internet Gateway Device (via UPnP SSDP discovery + SOAP) to add a port mapping so inbound peer dials reach this node.
Unlike NAT-PMP/PCP, UPnP/IGD is a large protocol (SSDP multicast discovery + SOAP over HTTP), so
we do NOT hand-roll it — we use the maintained igd-next crate for
the live gateway call. It sits behind the same TraversalMethod trait as the other methods, so
the ordering/fallback strategy is exercised with mock methods in tests and the live IGD call is
covered only by an opt-in integration test (it needs a real UPnP gateway on the LAN).
Testability: the gateway interaction is abstracted behind the IgdGateway trait so the
method’s own logic (map → yield dial address, or fail → fall through) is unit-tested with a fake
gateway. RealIgd is the production implementation delegating to igd-next.
Structs§
- RealIgd
- Production
IgdGatewaybacked byigd-next(async tokio). Discovers the gateway via SSDP and adds a UDP mapping. Kept thin so the one real network call is isolated. - Upnp
Method - The UPnP/IGD traversal method. Adds a mapping via
IgdGateway, then yields a dial address for the peer. Generic over the gateway so tests inject a fake.
Traits§
- IgdGateway
- Abstraction over “add a port mapping on the local IGD”. Real impl talks to
igd-next; tests use a fake so the method logic is verified with no network + no gateway.
Functions§
- local_
ipv6 - Best-effort GLOBAL (routable) local IPv6 address of this host, if any.
- select_
global_ ipv6 - Select the best IPv6 address to ADVERTISE from a set of the host’s candidate addresses: a
global-unicast address is preferred; link-local (
fe80::/10), ULA (fc00::/7), loopback, and unspecified addresses are rejected because they are not reachable by peers across the internet. IPv4 candidates are ignored. Returns the first global-unicast IPv6 candidate, orNone.
Type Aliases§
- Real
Upnp Method - The production UPnP method (real IGD discovery).