natmap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package natmap provides optional NAT helpers (Phase 2b: UPnP IGD port mapping). TURN and other relays are out of scope until Phase 3+.

IPv6 note: UPnP IGD is an IPv4 NAT mechanism. Nodes with a globally routable IPv6 address are directly reachable without any port mapping and do not use this package. UPnP mapping is only attempted when the node's public address is obtained via STUN or natsense and the socket is behind an IPv4 NAT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalIPv4ForUPnP

func LocalIPv4ForUPnP() string

LocalIPv4ForUPnP returns an IPv4 address suitable as IGD "internal client" (typically the LAN address used for outbound UDP).

func MapUDPPort

func MapUDPPort(ctx context.Context, internalPort int, internalClient string) (externalIP string, externalPort int, cleanup func(), err error)

MapUDPPort asks the LAN IGD to forward UDP externalPort -> internalClient:internalPort using the same port number on the WAN side (required for predictable QUIC URLs). Returns cleanup (DeletePortMapping). Errors if no gateway or mapping is rejected.

func QUICURL

func QUICURL(host string, port int) string

QUICURL builds a quic:// URL for an endpoint string (host + port).

Types

This section is empty.

Jump to

Keyboard shortcuts

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