[BUG] IPv6 connectivity is broken with v0.6.0
DogukanErgun opened this issue · 6 comments
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.
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.
Thanks for experimenting, I transferred the issue here for better tracking.
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?
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
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?
curl_cffi==0.6.2 on PyPI and yifeikong/curl-impersonate v0.6.1 have been released to address this issue.