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

[BUG] IPv6 connectivity is broken with v0.6.0 #45

Closed
DogukanErgun opened this issue Feb 27, 2024 · 6 comments · Fixed by #47
Closed

[BUG] IPv6 connectivity is broken with v0.6.0 #45

DogukanErgun opened this issue Feb 27, 2024 · 6 comments · Fixed by #47
Assignees
Labels
bug Something isn't working

Comments

@DogukanErgun
Copy link

Describe the bug
It is not possible to bind to an IPv6 address while creating
requests.Session(impersonate="chrome99", interface="ipv6_here")
Binding to ipv4 works.
The feature works until v0.6.0, it is broken for both 0.6.0 and 0.6.1
It works on 0.6.0b9

To Reproduce

session = requests.Session(impersonate="chrome99", interface="ipv6_here")`
ip = session.get('https://ifconfig.me/ip').text

Error Output

File "/home/user/Workspace/project/network/NetworkController.py", line 49, in init
self.ip = self.session.get('https://ifconfig.me/ip').text
, File "/home/user/.local/lib/python3.10/site-packages/curl_cffi/requests/session.py", line 834, in request
raise RequestsError(str(e), e.code, rsp) from e
, curl_cffi.requests.errors.RequestsError: Failed to perform, ErrCode: 45, Reason: 'Couldn't bind to 'IP HERE'. This may be a libcurl error, See https://curl.se/libcurl/c/libcurl-errors.html first for more details.

Expected behavior
Requests use the specified ip address for HTTP calls.

Versions

  • OS: Ubuntu 22.04, x86_64
  • curl_cffi version 0.6.0

Additional context

  • I have only tried using Session.
@DogukanErgun DogukanErgun added the bug Something isn't working label Feb 27, 2024
@DogukanErgun
Copy link
Author

After writing this, I have tried the curl_impersonate binaries from the other repository.

Simply executing:
/curl_chrome99 --interface "IPv6 HERE" https://ifconfig.me/ip'
returns
curl: (45) Couldn't bind to 'IPv6 HERE'
while it works for the binaries on 0.6.0b9.

If keeping this here does not make sense, I can create a new issue at the other repository.

@perklet perklet transferred this issue from lexiforest/curl_cffi Feb 27, 2024
@perklet
Copy link
Collaborator

perklet commented Feb 27, 2024

Thanks for experimenting, I transferred the issue here for better tracking.

@perklet
Copy link
Collaborator

perklet commented Feb 27, 2024

Can you add the --verbose flag and post the results here?

/curl_chrome99 --verbose --interface "IPv6 HERE"  https://ifconfig.me/ip

Add does it work for normal curl on your machine?

@DogukanErgun
Copy link
Author

Sure, v0.6.0 with --verbose output:

./curl_chrome99 --interface "MY IPv6'"  https://ifconfig.me/ip --verbose
*   Trying 34.117.118.44:443...
* Could not resolve host:  'MY IPv6'
* Couldn't bind to  'MY IPv6'
* Failed to connect to ifconfig.me port 443 after 17 ms: Failed binding local connection end
* Closing connection 0
curl: (45) Couldn't bind to 'MY IPv6'

Normal curl works without any issue. The output with normal curl:

curl --interface "MY IPv6'"  https://ifconfig.me/ip --verbose
*   Trying 34.117.118.44:443...
* Name 'MY IPv6'' family 2 resolved to 'MY IPv6'' family 10
*   Trying 2600:1901:0:bbc3:::443...
* Hostname MY IPv6' was found in DNS cache
* Name 'MY IPv6'' family 10 resolved to 'MY IPv6'' family 10
* Local port: 0
* Connected to ifconfig.me (2600:1901:0:bbc3::) port 443 (#0)

I have truncated the rest of the log.

I though it might be related to name resolution, so I have provided the target ipv6 address but it still fails with:

./curl_chrome99 --interface "MY IPv6'"  https://ifconfig.me/ip --verbose --resolve "ifconfig.me:443:2600:1901:0:bbc3::"
* Ignoring resolve address '2600:1901:0:bbc3::', missing IPv6 support.
* Couldn't parse CURLOPT_RESOLVE entry 'ifconfig.me:443:2600:1901:0:bbc3::'
curl: (49) Couldn't parse CURLOPT_RESOLVE entry 'ifconfig.me:443:2600:1901:0:bbc3::'

This works with normal curl too

curl --interface "MY IPv6"  https://ifconfig.me/ip --verbose --resolve "ifconfig.me:443:2600:1901:0:bbc3::"
* Added ifconfig.me:443:2600:1901:0:bbc3:: to DNS cache
* Hostname ifconfig.me was found in DNS cache
*   Trying 2600:1901:0:bbc3:::443...
* Name 'MY IPv6' family 10 resolved to 'MY IPv6' family 10
* Local port: 0
* Connected to ifconfig.me (2600:1901:0:bbc3::) port 443 (#0)

My curl 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

@DogukanErgun
Copy link
Author

DogukanErgun commented Feb 27, 2024

Oh, it says missing ipv6 support, maybe some build flag went wrong?
Edit: Yeah, ipv6 only websites are inaccessible, without even using --interface flag
Edit2: Just built the executable from sources using the install guide on tag v0.6.0. on the machine I am doing the experiments, everything is OK. Could there be something wrong with the workflow scripts?

@DogukanErgun DogukanErgun changed the title [BUG] Binding to an ipv6 address is broken with v0.6.0 [BUG] IPv6 connectivity is broken with v0.6.0 Feb 27, 2024
@perklet perklet mentioned this issue Feb 28, 2024
@perklet
Copy link
Collaborator

perklet commented Mar 2, 2024

curl_cffi==0.6.2 on PyPI and yifeikong/curl-impersonate v0.6.1 have been released to address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants