fix: (native conn.go) closeMatch logic should really close all matching conns; closes PacketConn also (#248)

This commit is contained in:
Shun Zi 2024-07-30 13:26:57 +08:00 committed by GitHub
parent 65bfd8a132
commit 143c84d47b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,20 +12,17 @@ func CloseAllConnections() {
})
}
func closeMatch(filter func(conn C.Conn) bool) {
func closeMatch(filter func(conn C.Connection) bool) {
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
if cc, ok := c.(C.Conn); ok {
if filter(cc) {
_ = cc.Close()
return true
}
if filter(c) {
_ = c.Close()
}
return false
return true
})
}
func closeConnByGroup(name string) {
closeMatch(func(conn C.Conn) bool {
closeMatch(func(conn C.Connection) bool {
for _, c := range conn.Chains() {
if c == name {
return true