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

[docs] Run requests through a SOCKS proxy #490

Open
ElijahLynn opened this issue May 25, 2022 · 7 comments
Open

[docs] Run requests through a SOCKS proxy #490

ElijahLynn opened this issue May 25, 2022 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@ElijahLynn
Copy link
Contributor

This is me rubber ducking for now. I need to figure out how to run the requests through a SOCKS proxy. I gather the http lib rust uses supports this. I searched https://book.goose.rs/?search=proxy and didn't see anything so once I figure it out, I'll post here and maybe we can get it documented.

@jeremyandrews
Copy link
Member

Ultimately the question is, how to use Reqwest through a SOCKS proxy:
https://docs.rs/reqwest/latest/reqwest/struct.Proxy.html

@ElijahLynn
Copy link
Contributor Author

ElijahLynn commented May 26, 2022

Ultimately the question is, how to use Reqwest through a SOCKS proxy:
https://docs.rs/reqwest/latest/reqwest/struct.Proxy.html

Thanks, this was helpful. From your lead, I then found https://docs.rs/reqwest/latest/reqwest/index.html#proxies which states that the usual HTTPS_PROXY and HTTP_PROXY environment variables can be used (export https_proxy=socks5://127.0.0.1:1086) and this almost seems to work but doesn't because DNS resolution isn't resolving through the SOCKS server, e.g. 'error trying to connect: dns error: failed to lookup address information: No address associated with hostname'.

curl works with DNS and HTTP_PROXY set though... I'll tinker some more tomorrow. I need to be 100% sure it is going through the proxy first.

edit: Oh, I had to add the socks feature to the below stanza to Cargo.toml, and run with cargo ... --features socks too.

[features]
default = ["reqwest/default-tls"]
socks = []
gaggle = ["nng"]
rustls-tls = ["reqwest/rustls-tls", "tokio-tungstenite/rustls-tls"]

@jeremyandrews
Copy link
Member

It looks like you have to specify the protocol differently to route DNS, see the update to the example in the codebase in this issue:
seanmonstar/reqwest#899

@ElijahLynn
Copy link
Contributor Author

ElijahLynn commented May 26, 2022

Hrm, so that is what the H is for (maybe)!

Turns out I actually tried both and the most recent run was the socks5h:// scheme.

image

I'll tinker some more in a bit once my day gets going. Maybe I'll post an upstream support issue in reqwest if I can't figure it out.

@ElijahLynn
Copy link
Contributor Author

ElijahLynn commented Jun 3, 2022

W00t, I got SOCKS working and I understand Features a bit more now, I had to enable it ON reqwest, like so:

[dependencies]
goose = "^0.16"
tokio = "^1.12"
goose-eggs = "0.4"
rand = "0.8.5"
reqwest = { version = "0.11.10", features = ["socks"]}

source: https://docs.rs/reqwest/latest/reqwest/index.html#optional-features and https://doc.rust-lang.org/stable/cargo/reference/features.html#the-features-section

@jeremyandrews
Copy link
Member

Perhaps you can summarize the steps required in the Goose documentation, adding to this page?
https://book.goose.rs/getting-started/tips.html

@jeremyandrews
Copy link
Member

Actually, it would make more sense to put it in this section, perhaps adding a new sub-page:
https://book.goose.rs/config/overview.html

@jeremyandrews jeremyandrews added the documentation Improvements or additions to documentation label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants