diff options
| author | Brad Fitzpatrick <bradfitz@tailscale.com> | 2021-05-13 20:57:41 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@tailscale.com> | 2021-05-13 20:57:41 -0700 |
| commit | 3579452856e0dfea1717de92626ca2f09ba06163 (patch) | |
| tree | 7fc3b09fbc30a776a7f5bafab6f961f9df4d63a1 | |
| parent | 6f62bbae7921452db4a7bb8e73e98abfe5db6ffd (diff) | |
| download | tailscale-bradfitz/netstack_port_map.tar.xz tailscale-bradfitz/netstack_port_map.zip | |
wgengine/netstack: add netstack port rewriting mechanismbradfitz/netstack_port_map
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
| -rw-r--r-- | wgengine/netstack/netstack.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/wgengine/netstack/netstack.go b/wgengine/netstack/netstack.go index a8c9aa6bd..cbd78495a 100644 --- a/wgengine/netstack/netstack.go +++ b/wgengine/netstack/netstack.go @@ -12,6 +12,7 @@ import ( "io" "log" "net" + "os" "strconv" "strings" "sync" @@ -452,6 +453,9 @@ func (ns *Impl) acceptTCP(r *tcp.ForwarderRequest) { func (ns *Impl) forwardTCP(client *gonet.TCPConn, wq *waiter.Queue, dialAddr tcpip.Address, dialPort uint16) { defer client.Close() dialAddrStr := net.JoinHostPort(dialAddr.String(), strconv.Itoa(int(dialPort))) + if alt := os.Getenv(fmt.Sprintf("TAILSCALE_INCOMING_REMAP_%s_%d", dialAddr, dialPort)); alt != "" { + dialAddrStr = alt + } ns.logf("[v2] netstack: forwarding incoming connection to %s", dialAddrStr) ctx, cancel := context.WithCancel(context.Background()) defer cancel() |
