ipn/ipnlocal: add start of handling TCP proxying
Updates tailscale/corp#7515 Change-Id: I82d19b5864674b2169f25ec8e429f60a543e0c57 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
4bccc02413
commit
b683921b87
@ -784,6 +784,8 @@ func (ns *Impl) acceptTCP(r *tcp.ForwarderRequest) {
|
||||
r.Complete(true) // sends a RST
|
||||
return
|
||||
}
|
||||
clientRemotePort := reqDetails.RemotePort
|
||||
clientRemoteAddrPort := netip.AddrPortFrom(clientRemoteIP, clientRemotePort)
|
||||
|
||||
dialIP := netaddrIPFromNetstackIP(reqDetails.LocalAddress)
|
||||
isTailscaleIP := tsaddr.IsTailscaleIP(dialIP)
|
||||
@ -894,11 +896,14 @@ func (ns *Impl) acceptTCP(r *tcp.ForwarderRequest) {
|
||||
return
|
||||
}
|
||||
if ns.lb.ShouldInterceptTCPPort(reqDetails.LocalPort) && ns.isLocalIP(dialIP) {
|
||||
c := createConn()
|
||||
if c == nil {
|
||||
return
|
||||
getTCPConn := func() (_ net.Conn, ok bool) {
|
||||
c := createConn()
|
||||
return c, c != nil
|
||||
}
|
||||
ns.lb.HandleInterceptedTCPConn(c)
|
||||
sendRST := func() {
|
||||
r.Complete(true)
|
||||
}
|
||||
ns.lb.HandleInterceptedTCPConn(reqDetails.LocalPort, clientRemoteAddrPort, getTCPConn, sendRST)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user