fix: close connection after error handling in kcptun

This commit is contained in:
wwqgtxx committed 2026-09-14 14:11:18 +08:00
1 parent 06b2c5b887
commit 78210c9c72
2 files changed
+3

No files matched your search

+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()