mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-03 08:22:00 +01:00
Thanks for the report, @Need-an-AwP! Fixes #17681 Updates #9394 Change-Id: I2e0b722ef9b460bd7e79499192d1a315504ca84c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
41 lines
1008 B
Go
41 lines
1008 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/feature"
|
|
"tailscale.com/net/netmon"
|
|
"tailscale.com/net/portmapper"
|
|
"tailscale.com/net/portmapper/portmappertype"
|
|
"tailscale.com/types/logger"
|
|
"tailscale.com/util/eventbus"
|
|
)
|
|
|
|
func init() {
|
|
feature.Register("portmapper")
|
|
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
|
|
}
|