File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1552,6 +1552,17 @@ def test_winreg_proxy_bypass(self):
15521552 "expect <local> to bypass intranet address '%s'"
15531553 % host )
15541554
1555+ # check IP CIDR bypass
1556+ proxy_override = "192.168.0.0/16; 2001:db8::/32"
1557+ for host in ("192.168.1.1" , "192.168.1.1:443" ,
1558+ "2001:db8::1" , "[2001:db8::1]:443" ):
1559+ self .assertTrue (proxy_bypass (host , proxy_override ),
1560+ "expected bypass of %s to be true" % host )
1561+
1562+ for host in ("192.169.1.1" , "2001:db9::1" ):
1563+ self .assertFalse (proxy_bypass (host , proxy_override ),
1564+ "expected bypass of %s to be False" % host )
1565+
15551566 @unittest .skipUnless (sys .platform == 'darwin' , "only relevant for OSX" )
15561567 def test_osx_proxy_bypass (self ):
15571568 bypass = {
Original file line number Diff line number Diff line change @@ -2054,10 +2054,11 @@ def _proxy_bypass_winreg_override(host, override):
20542054 Internet settings proxy override registry value.
20552055
20562056 An example of a proxy override value is:
2057- "www.example.com;*.example.net; 192.168.0.1"
2057+ "www.example.com;*.example.net; 192.168.0.1; 192.168.0.0/16 "
20582058 """
20592059 from fnmatch import fnmatch
20602060
2061+ host_ip = _ip_address_from_host (host )
20612062 host , _ = _splitport (host )
20622063 proxy_override = override .split (';' )
20632064 for test in proxy_override :
@@ -2066,6 +2067,8 @@ def _proxy_bypass_winreg_override(host, override):
20662067 if test == '<local>' :
20672068 if '.' not in host :
20682069 return True
2070+ elif '/' in test and _is_ip_address_in_network (host_ip , test ):
2071+ return True
20692072 elif fnmatch (host , test ):
20702073 return True
20712074 return False
You can’t perform that action at this time.
0 commit comments