TUN inbound: Only close the UDP connection that actually finished (#6814)

https://github.com/XTLS/Xray-core/pull/6814#pullrequestreview-5324536423

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Artem Lytkin
2026-09-27 21:06:19 +00:00
committed by GitHub
co-authored by 风扇滑翔翼
parent 5dda894e29
commit 7b8ade3ec5
+5 -5
View File
@@ -78,11 +78,11 @@ func (u *udpConnectionHandler) HandlePacket(src net.Destination, dst net.Destina
}
}
func (u *udpConnectionHandler) connectionFinished(src net.Destination) {
func (u *udpConnectionHandler) connectionFinished(conn *udpConn) {
u.Lock()
conn, found := u.udpConns[src]
if found {
delete(u.udpConns, src)
// Close runs twice per flow; a newer conn may already own this src.
if u.udpConns[conn.src] == conn {
delete(u.udpConns, conn.src)
close(conn.egress)
}
u.Unlock()
@@ -161,7 +161,7 @@ func (c *udpConn) Write(p []byte) (int, error) {
}
func (c *udpConn) Close() error {
c.handler.connectionFinished(c.src)
c.handler.connectionFinished(c)
return nil
}