diff --git a/protocol/http/client.go b/protocol/http/client.go index 727d4d95c..962235230 100644 --- a/protocol/http/client.go +++ b/protocol/http/client.go @@ -80,6 +80,7 @@ func (c *Client) DialContext(ctx context.Context, network string, destination M. } if c.host != "" && c.host != destination.Fqdn { if c.path != "" { + _ = conn.Close() return nil, E.New("Host header and path are not allowed at the same time") } request.Host = c.host @@ -90,6 +91,7 @@ func (c *Client) DialContext(ctx context.Context, network string, destination M. if c.path != "" { err = URLSetPath(request.URL, c.path) if err != nil { + _ = conn.Close() return nil, err } } diff --git a/protocol/socks/client.go b/protocol/socks/client.go index 6004f833a..9e4a1f552 100644 --- a/protocol/socks/client.go +++ b/protocol/socks/client.go @@ -149,6 +149,7 @@ func (c *Client) DialContext(ctx context.Context, network string, address M.Sock } return NewAssociatePacketConn(udpConn, address, tcpConn), nil } + _ = tcpConn.Close() return nil, os.ErrInvalid } @@ -181,5 +182,6 @@ func (c *Client) BindContext(ctx context.Context, address M.Socksaddr) (net.Conn } return tcpConn, nil } + _ = tcpConn.Close() return nil, os.ErrInvalid }