1
0
mirror of https://github.com/MetaCubeX/mihomo.git synced 2026-10-10 04:03:11 +08:00

fix: close connection after error handling in kcptun

This commit is contained in:
wwqgtxx
2026-09-14 14:11:18 +08:00
parent 06b2c5b887
commit 78210c9c72
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -62,6 +62,7 @@ func (c *Client) createConn(ctx context.Context, dial DialFn) (*smux.Session, er
convid := randv2.Uint32()
kcpconn, err := kcp.NewConn4(convid, addr, c.block, config.DataShard, config.ParityShard, true, conn)
if err != nil {
_ = conn.Close()
return nil, err
}
kcpconn.SetStreamMode(true)
@@ -86,6 +87,7 @@ func (c *Client) createConn(ctx context.Context, dial DialFn) (*smux.Session, er
}
if err := smux.VerifyConfig(smuxConfig); err != nil {
_ = kcpconn.Close()
return nil, err
}
+1
View File
@@ -64,6 +64,7 @@ func (s *Server) Serve(pc net.PacketConn, handler func(net.Conn)) error {
mux, err := smux.Server(netConn, smuxConfig)
if err != nil {
_ = netConn.Close()
return
}
defer mux.Close()