Fix close conn

This commit is contained in:
世界
2023-03-03 16:46:49 +08:00
parent b54c1b1aa7
commit 06bc57d85a
6 changed files with 8 additions and 3 deletions

View File

@@ -109,11 +109,13 @@ func (h *ShadowsocksR) DialContext(ctx context.Context, network string, destinat
conn = h.cipher.StreamConn(h.obfs.StreamConn(conn))
writeIv, err := conn.(*shadowstream.Conn).ObtainWriteIV()
if err != nil {
conn.Close()
return nil, err
}
conn = h.protocol.StreamConn(conn, writeIv)
err = M.SocksaddrSerializer.WriteAddrPort(conn, destination)
if err != nil {
conn.Close()
return nil, E.Cause(err, "write request")
}
return conn, nil

View File

@@ -124,6 +124,7 @@ func (h *trojanDialer) DialContext(ctx context.Context, network string, destinat
}
}
if err != nil {
common.Close(conn)
return nil, err
}
switch N.NetworkName(network) {

View File

@@ -123,6 +123,7 @@ func (h *VLESS) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.
}
}
if err != nil {
common.Close(conn)
return nil, err
}
if h.xudp {

View File

@@ -154,6 +154,7 @@ func (h *vmessDialer) DialContext(ctx context.Context, network string, destinati
}
}
if err != nil {
common.Close(conn)
return nil, err
}
switch N.NetworkName(network) {