Add ipv6 support to should_bypass_proxies - #5953
Conversation
a83438f to
6a623af
Compare
6a623af to
c414e8f
Compare
| netmask = struct.unpack('=L', socket.inet_aton(dotted_netmask(int(bits))))[0] | ||
| network = struct.unpack('=L', socket.inet_aton(netaddr))[0] & netmask | ||
| if is_ipv4_address(ip) and is_ipv4_address(netaddr): | ||
| ipaddr = struct.unpack('>L', socket.inet_aton(ip))[0] |
There was a problem hiding this comment.
I've tested this switch to 'big-endian' from 'native' on both big and little endian systems. Unit tests passed on both.
c414e8f to
83dad59
Compare
|
Hi @nateprewitt @sethmlarson , is this something you'd consider merging ? |
|
I'm facing this same issue. @nateprewitt @sethmlarson Any update on your thoughts? |
83dad59 to
502e275
Compare
f2e8dc6 to
4f89a66
Compare
|
Running into the same problem with this, it sure would be nice to have the ability to specify IPv6 CIDRs in no_proxy. What's holding this up? |
**Fixed** - Static type checker not accepting **list\[str\]** in values for argument **data**. **Misc** - Changed the documentation theme by **furo**. **Added** - IPv6 support in the `NO_PROXY` environment variable or in the **proxies** (key no_proxy) argument. Patch taken from idle upstream PR psf#5953 - Preemptively register a website to be HTTP/3 capable prior to the first TLS over TCP handshake. You can do so by doing like: ```python from niquests import Session s = Session() s.quic_cache_layer.add_domain("cloudflare.com") ``` - Passed **data** will be converted to form-data if headers have a Content-Type header and is set to `multipart/form-data`. Otherwise, by default, it is still urlencoded. If you specified a boundary, it will be used, otherwise, a random one will be generated.
**Fixed** - Static type checker not accepting **list\[str\]** in values for argument **data**. **Misc** - Changed the documentation theme by **furo**. **Added** - IPv6 support in the `NO_PROXY` environment variable or in the **proxies** (key no_proxy) argument. Patch taken from idle upstream PR psf#5953 - Preemptively register a website to be HTTP/3 capable prior to the first TLS over TCP handshake. You can do so by doing like: ```python from niquests import Session s = Session() s.quic_cache_layer.add_domain("cloudflare.com") ``` - Passed **data** will be converted to form-data if headers have a Content-Type header and is set to `multipart/form-data`. Otherwise, by default, it is still urlencoded. If you specified a boundary, it will be used, otherwise, a random one will be generated.
**Fixed** - Static type checker not accepting **list\[str\]** in values for argument **data**. **Misc** - Changed the documentation theme by **furo**. **Added** - IPv6 support in the `NO_PROXY` environment variable or in the **proxies** (key no_proxy) argument. Patch taken from idle upstream PR psf#5953 - Preemptively register a website to be HTTP/3 capable prior to the first TLS over TCP handshake. You can do so by doing like: ```python from niquests import Session s = Session() s.quic_cache_layer.add_domain("cloudflare.com") ``` - Passed **data** will be converted to form-data if headers have a Content-Type header and is set to `multipart/form-data`. Otherwise, by default, it is still urlencoded. If you specified a boundary, it will be used, otherwise, a random one will be generated.
**Fixed** - Static type checker not accepting **list\[str\]** in values for argument **data**. **Misc** - Changed the documentation theme by **furo**. **Added** - IPv6 support in the `NO_PROXY` environment variable or in the **proxies** (key no_proxy) argument. Patch taken from idle upstream PR psf#5953 - Preemptively register a website to be HTTP/3 capable prior to the first TLS over TCP handshake. You can do so by doing like: ```python from niquests import Session s = Session() s.quic_cache_layer.add_domain("cloudflare.com") ``` - Passed **data** will be converted to form-data if headers have a Content-Type header and is set to `multipart/form-data`. Otherwise, by default, it is still urlencoded. If you specified a boundary, it will be used, otherwise, a random one will be generated.
|
@nateprewitt @sigmavirus24 @sethmlarson would you have a chance to look at this please, its been hanging around for over 2 years and still causing me problems. |
|
It'd be nice to have this implemented. Is there any way I can help? |
|
Hi @frenzymadness , if you can review or confirm that this works for your use case then that would be appreciated but |
frenzymadness
left a comment
There was a problem hiding this comment.
I checked the code and it looks good to me. I'm looking for more ways to test it.
| ) | ||
| network = (network_msb << 64) ^ network_lsb | ||
| else: | ||
| return False |
There was a problem hiding this comment.
Is returning False the correct thing to do when this function is called with IPv4 IP and IPv6 network or vice versa? What about raising an exception here?
There was a problem hiding this comment.
I think this is fine as is (i.e. returning false), the function is used to test if a IP address is a member of any of the CIDR's listed in no_proxy, having a no_proxy with mixed IPv4 and IPv6 CIDR's would be valid, I don't think I'd expect an exception to the raised in this instance.
|
We are going to test this change internally to get some confidence. |
|
Derek tested the package in OpenShift 4.15 and the functionality proposed here works as expected. Is there any chance to merge this? |
|
During additional testing, my colleague raised an interesting question: Are I see a use-case for |
|
What can I do to get this merged? We've reviewed the change and tested it in a real environment with real use cases. Is there anything else we can do? |
6e0403b to
bc8624b
Compare
Add support to should_bypass_proxies to support IPv6 ipaddresses and CIDRs in no_proxy. Includes adding IPv6 support to various other helper functions.
bc8624b to
4703994
Compare
|
Rebased onto current main. Also worth noting - this patch has been carried in Fedora's python3-requests package since at least 2024. |
Add support to should_bypass_proxies to support
IPv6 ipaddresses and CIDRs in no_proxy. Includes
adding IPv6 support to various other helper functions.