From 455197dd91bca752e575c139edae44e588d59207 Mon Sep 17 00:00:00 2001 From: Fangliding Date: Tue, 23 Jun 2026 18:46:05 +0800 Subject: [PATCH] Fix TUN nil addr --- proxy/tun/handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/proxy/tun/handler.go b/proxy/tun/handler.go index d552eca53..b5e748532 100644 --- a/proxy/tun/handler.go +++ b/proxy/tun/handler.go @@ -143,7 +143,14 @@ func (t *Handler) HandleConnection(conn net.Conn, destination net.Destination) { defer cancel() ctx = c.ContextWithID(ctx, session.NewID()) - source := net.DestinationFromAddr(conn.RemoteAddr()) + // if the connection is already closed, conn.RemoteAddr() will be nil + // due to gvisor weird behavior + remote := conn.RemoteAddr() + if remote == nil { + errors.LogInfo(t.ctx, "dropped quick close connection") + return + } + source := net.DestinationFromAddr(remote) inbound := session.Inbound{ Name: "tun", Tag: t.tag,