You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/net/portmapper
Andrew Dunham bac4890467 net/portmapper: be smarter about selecting a UPnP device
Previously, we would select the first WANIPConnection2 (and related)
client from the root device, without any additional checks. However,
some routers expose multiple UPnP devices in various states, and simply
picking the first available one can result in attempting to perform a
portmap with a device that isn't functional.

Instead, mimic what the miniupnpc code does, and prefer devices that are
(a) reporting as Connected, and (b) have a valid external IP address.
For our use-case, we additionally prefer devices that have an external
IP address that's a public address, to increase the likelihood that we
can obtain a direct connection from peers.

Finally, we split out fetching the root device (getUPnPRootDevice) from
selecting the best service within that root device (selectBestService),
and add some extensive tests for various UPnP server behaviours.

RELNOTE=Improve UPnP portmapping when multiple UPnP services exist

Updates #8364

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I71795cd80be6214dfcef0fe83115a5e3fe4b8753
11 months ago
..
disabled_stubs.go all: update copyright and license headers 2 years ago
igd_test.go net/portmapper: fall back to permanent UPnP leases if necessary 1 year ago
pcp.go all: update tools that manage copyright headers 2 years ago
pcp_test.go all: update copyright and license headers 2 years ago
pcpresultcode_string.go all: update copyright and license headers 2 years ago
pmpresultcode_string.go all: update copyright and license headers 2 years ago
portmapper.go net/portmapper: be smarter about selecting a UPnP device 11 months ago
portmapper_test.go net/portmapper: fix invalid UPnP metric name 1 year ago
select_test.go net/portmapper: be smarter about selecting a UPnP device 11 months ago
upnp.go net/portmapper: be smarter about selecting a UPnP device 11 months ago
upnp_test.go net/portmapper: be smarter about selecting a UPnP device 11 months ago