net/portmapper: add NAT-PMP client, move port mapping service probing

* move probing out of netcheck into new net/portmapper package
* use PCP ANNOUNCE op codes for PCP discovery, rather than causing
  short-lived (sub-second) side effects with a 1-second-expiring map +
  delete.
* track when we heard things from the router so we can be less wasteful
  in querying the router's port mapping services in the future
* use portmapper from magicsock to map a public port

Fixes #1298
Fixes #1080
Fixes #1001
Updates #864

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2021-02-19 22:15:41 -08:00
committed by Brad Fitzpatrick
parent d038a5295d
commit c64bd587ae
9 changed files with 721 additions and 104 deletions

9
types/pad32/pad32.go Normal file
View File

@@ -0,0 +1,9 @@
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package pad32 defines padding types that have width on only 32-bit platforms.
package pad32
// Four is 4 bytes of padding on 32-bit machines, else 0 bytes.
type Four [4 * (1 - ((^uint(0))>>32)&1)]byte