Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add socks5 support via the reqwest rust package #7484

Closed
rh314 opened this issue Sep 18, 2024 · 2 comments · Fixed by #7503
Closed

Please add socks5 support via the reqwest rust package #7484

rh314 opened this issue Sep 18, 2024 · 2 comments · Fixed by #7503

Comments

@rh314
Copy link

rh314 commented Sep 18, 2024

I've been trying to get uv to connect via a socks5 proxy. To my surprise, I could not get it working. After some digging, I see that the reqwest does support socks5, but you would need to add it explicitly to Cargo.toml as per this example.

Here is what I have tried so far (minimal code snippet that reproduces the bug):

# Set up proxy variables as per documentation
MY_SOCKS_PROXY=socks5://127.0.0.1:8080   # a proxy provided by an SSH connection
export HTTP_PROXY=$MY_SOCKS_PROXY
export HTTPS_PROXY=$MY_SOCKS_PROXY
export ALL_PROXY=$MY_SOCKS_PROXY
# then,
uv ...   # any uv command

The error messages varied depending on what I tried, but it was usually something along the lines of Caused by: error sending request for url (https://REDACTED/simple/REDACTED/)

Version:

$ uv --version
uv 0.4.0

Summary:

  • Can we please add "socks" in the line that specifies reqwests in the Cargo.toml file? Or some other method to allow the use of socks-based proxies 🙏
@rh314
Copy link
Author

rh314 commented Sep 18, 2024

For completeness' sake, I'm also going to share my current workaround.

I'm currently layering another proxy (an HTTP proxy) on top of the SOCKS5 proxy to work around this. To this end, I'm using privoxy.

Here is a snippet of my privoxy_config file:

# Listen on port 8081
listen-address  127.0.0.1:8081

# Allow CONNECT method for HTTPS traffic
enable-remote-toggle  1
enable-remote-http-toggle  1
enable-edit-actions  1

# Forward all traffic through the SOCKS5 proxy
forward-socks5 / 127.0.0.1:8080 .

# start command:
#   privoxy --no-daemon /REDACTED/privoxy_config

Then I just set the *PROXY* env variables to use port 8081.

charliermarsh added a commit that referenced this issue Sep 18, 2024
## Summary

This adds about 50 KB to the binary:

```
❯ du ./target/release/socks
44736	./target/release/socks

❯ du ./target/release/uv
44632	./target/release/uv
```

So need some input on whether it's worth supporting.

Closes #7484.
@rh314
Copy link
Author

rh314 commented Sep 18, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant