Proxy SOCKS support
Problem to solve
ssh -D8080 user@host
curl --socks5 localhost:8080 https://httpbin.org/anything
Proposal
~In the [Options] section, the proxy field should be a URL, such as:~
-
http://localhost:8012 -
socks5://localhost:8012 - ...
~The scheme of the URL could then be used to determine the type of proxy (no scheme would default to HTTP for backward compatibility) we want to connect to.~
~Then, we should be able to connect to SOCKS proxy as demonstrated with cURL above.~
EDIT: Let's add instead a
sock5request option with the host and port of the SOCKS proxy to use.
Additional context and resources
We are using Hurl to implement the test suite of a Reverse Proxy service we provide in our infrastructure. Its configuration is pulled from Netbox. One feature is the Access Control Lists, which translates to the following NGINX configuration:
server {
# ...
location / {
# ...
deny 192.168.2.0/24;
allow all;
# ...
}
# ...
}
The test we want to execute is the following:
# Rejection when coming from 192.168.2.0/24
GET https://example.com
HTTP 403
# No rejection when coming from 127.0.0.1/8
GET https://example.com
[Options]
socks5: localhost:8012
HTTP 200
Tasks to complete
- [x] ~Support URLs in
proxyrequest option~ - [ ] Add
socks5request option - [ ] Support Proxy SOCKS protocol
Hi @linkdd
I think I prefer to have a dedicated socks5 option to match exactly the curl option name
GET https://example.com
[Options]
socks5: localhost:8012
HTTP 200
Sounds good to me. But what would be the behavior when we define both proxy and socks5 fields then? Should it be an error?
Yes we can check what is the behavior of curl in this case and try to match it.
Ok, I updated the issue description accordingly.
It seems the curl crate you use already provides everything needed, the Easy2::proxy() function (docs) seems to accept URLs of the form socks5://host:port, which correspond to the CURLOPT_PROXY option.
@linkdd Reviewing the code, I see that we have no restriction on urls passed to proxy option.
Could you try this syntax ?
# Rejection when coming from 192.168.2.0/24
GET https://example.com
HTTP 403
# No rejection when coming from 127.0.0.1/8
GET https://example.com
[Options]
proxy: socks5://localhost:8012
HTTP 200