Skip to content

Commit fa57a93

Browse files
intra/tcp.go: don't create TCP endpoint before Dial() returns
1 parent c646f0c commit fa57a93

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

intra/tcp.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,6 @@ func (h *tcpHandler) Proxy(gconn *netstack.GTCPConn, src, target netip.AddrPort)
186186
return deny
187187
}
188188

189-
// handshake; since we assume a duplex-stream from here on
190-
if open, err = gconn.Establish(); !open {
191-
log.E("tcp: %s connect err %v; %s => %s for %s", cid, err, src, target, uid)
192-
clos(gconn)
193-
h.queueSummary(smm.done(err))
194-
return deny // == !open
195-
}
196-
197189
if isAnyBasePid(pids) { // see udp.go:Connect
198190
if h.dnsOverride(gconn, target, uid) {
199191
// SocketSummary not sent; x.DNSSummary supercedes it
@@ -270,6 +262,11 @@ func (h *tcpHandler) handle(px ipn.Proxy, src net.Conn, boundSrc, target netip.A
270262
return err
271263
}
272264

265+
gconn := src.(*netstack.GTCPConn)
266+
if open, err := gconn.Establish(); !open {
267+
return err
268+
}
269+
273270
core.Go("tcp.forward."+smm.ID, func() {
274271
h.forward(src, rwext{dst, tcptimeout}, smm) // src always *gonet.TCPConn
275272
})

0 commit comments

Comments
 (0)