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:
1 parent
5dda894e29
commit
7b8ade3ec5
1 file changed
+5
-5
@@ -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()
|
u.Lock()
|
||||||
conn, found := u.udpConns[src]
|
// Close runs twice per flow; a newer conn may already own this src.
|
||||||
if found {
|
if u.udpConns[conn.src] == conn {
|
||||||
delete(u.udpConns, src)
|
delete(u.udpConns, conn.src)
|
||||||
close(conn.egress)
|
close(conn.egress)
|
||||||
}
|
}
|
||||||
u.Unlock()
|
u.Unlock()
|
||||||
@@ -161,7 +161,7 @@ func (c *udpConn) Write(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *udpConn) Close() error {
|
func (c *udpConn) Close() error {
|
||||||
c.handler.connectionFinished(c.src)
|
c.handler.connectionFinished(c)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user