Compare commits

...

1 Commits

Author SHA1 Message Date
Brad Fitzpatrick 3579452856 wgengine/netstack: add netstack port rewriting mechanism
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-13 20:57:41 -07:00
1 changed files with 4 additions and 0 deletions

View File

@ -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()