mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-28 09:58:06 +03:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user