mirror of
https://github.com/tailscale/tailscale.git
synced 2025-09-21 13:41:46 +02:00
Starting at a minimal binary and adding one feature back... tailscaled tailscale combined (linux/amd64) 30073135 17451704 31543692 omitting everything + 480302 + 10258 + 493896 .. add debugportmapper + 475317 + 151943 + 467660 .. add portmapper + 500086 + 162873 + 510511 .. add portmapper+debugportmapper Fixes #17148 Change-Id: I90bd0e9d1bd8cbe64fa2e885e9afef8fb5ee74b1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
39 lines
951 B
Go
39 lines
951 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Package portmapper registers support for NAT-PMP, PCP, and UPnP port
|
|
// mapping protocols to help get direction connections through NATs.
|
|
package portmapper
|
|
|
|
import (
|
|
"tailscale.com/net/netmon"
|
|
"tailscale.com/net/portmapper"
|
|
"tailscale.com/net/portmapper/portmappertype"
|
|
"tailscale.com/types/logger"
|
|
"tailscale.com/util/eventbus"
|
|
)
|
|
|
|
func init() {
|
|
portmappertype.HookNewPortMapper.Set(newPortMapper)
|
|
}
|
|
|
|
func newPortMapper(
|
|
logf logger.Logf,
|
|
bus *eventbus.Bus,
|
|
netMon *netmon.Monitor,
|
|
disableUPnPOrNil func() bool,
|
|
onlyTCP443OrNil func() bool) portmappertype.Client {
|
|
|
|
pm := portmapper.NewClient(portmapper.Config{
|
|
EventBus: bus,
|
|
Logf: logf,
|
|
NetMon: netMon,
|
|
DebugKnobs: &portmapper.DebugKnobs{
|
|
DisableAll: onlyTCP443OrNil,
|
|
DisableUPnPFunc: disableUPnPOrNil,
|
|
},
|
|
})
|
|
pm.SetGatewayLookupFunc(netMon.GatewayAndSelfIP)
|
|
return pm
|
|
}
|