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

-4 option doesn't work when using --proxy option #11949

Closed
ammarfaizi2 opened this issue Sep 26, 2023 · 4 comments
Closed

-4 option doesn't work when using --proxy option #11949

ammarfaizi2 opened this issue Sep 26, 2023 · 4 comments

Comments

@ammarfaizi2
Copy link

I did this

$ curl --proxy socks5://127.0.0.1:8081 https://ip.me -v4
*   Trying 127.0.0.1:8081...
* SOCKS5 connect to IPv6 2a02:6ea0:c035::11:443 (locally resolved)
* Can't complete SOCKS5 connection to ip.me. (4)
* Closing connection 0
curl: (97) Can't complete SOCKS5 connection to ip.me. (4)

I expected the following

I want it not to resolve IPv6.

curl/libcurl version

curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.16
Release-Date: 2022-01-05
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets zstd

operating system

Ubuntu 22.04
Linux integral2 6.6.0-rc2-af-home-2023-09-22-g7c039646b886 #1 SMP PREEMPT_DYNAMIC Thu Sep 21 22:16:01 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

@bagder
Copy link
Member

bagder commented Sep 26, 2023

The -4 option controls the primary connection done to the proxy/host, it does not limit the name resolve of the remove host.

Example:

$ curl --proxy socks5://proxy.example:8081 https://ip.me -4

Will make sure to connect to proxy.example using IPv4. While using -6 insists on IPv6 to the proxy.

You could very well do Ipv4 to the proxy and send and IPv6 address to it (like you ask for) or send an IPv4 address to the proxy when speaking IPv6 with it.

curl actually has no option for forcing the IP version of the address for the remote name to get passed to the socks proxy.

@jay
Copy link
Member

jay commented Sep 26, 2023

The -4 option controls the primary connection done to the proxy/host, it does not limit the name resolve of the remove host.

I didn't know that. That's tricky and not something I'd expect. Also, see the doc:

"This option tells curl to use IPv4 addresses only when resolving host names, and not for example try IPv6."

@bagder
Copy link
Member

bagder commented Sep 27, 2023

A key property of curl is to have different options for different actions and not chain them, so that you can mix and match at your own choice.

@bagder
Copy link
Member

bagder commented Oct 20, 2023

Thinking further, I think it is reasonable to apply the IP selection also on this resolve to do what is more likely asked for. A future improvement could be to introduce a more fine-grained selection.

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

Successfully merging a pull request may close this issue.

3 participants