Skip to content

Commit

Permalink
Fix http socks close
Browse files Browse the repository at this point in the history
  • Loading branch information
xchacha20-poly1305 authored and nekohasekai committed Jun 17, 2024
1 parent b8736cc commit d9f2559
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions protocol/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
Expand Down
2 changes: 2 additions & 0 deletions protocol/socks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

0 comments on commit d9f2559

Please sign in to comment.