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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user