Merge "Skip IPv6 addresses in cname_lookup middleware."
This commit is contained in:
commit
678a3ae832
@ -62,10 +62,14 @@ def lookup_cname(domain): # pragma: no cover
|
|||||||
|
|
||||||
def is_ip(domain):
|
def is_ip(domain):
|
||||||
try:
|
try:
|
||||||
socket.inet_aton(domain)
|
socket.inet_pton(socket.AF_INET, domain)
|
||||||
return True
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
return False
|
try:
|
||||||
|
socket.inet_pton(socket.AF_INET6, domain)
|
||||||
|
return True
|
||||||
|
except socket.error:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class CNAMELookupMiddleware(object):
|
class CNAMELookupMiddleware(object):
|
||||||
|
@ -47,7 +47,6 @@ class TestCNAMELookup(unittest.TestCase):
|
|||||||
{'lookup_depth': 2})
|
{'lookup_depth': 2})
|
||||||
|
|
||||||
def test_pass_ip_addresses(self):
|
def test_pass_ip_addresses(self):
|
||||||
|
|
||||||
cname_lookup.lookup_cname = original_lookup
|
cname_lookup.lookup_cname = original_lookup
|
||||||
|
|
||||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
|
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
|
||||||
@ -55,6 +54,11 @@ class TestCNAMELookup(unittest.TestCase):
|
|||||||
resp = self.app(req.environ, start_response)
|
resp = self.app(req.environ, start_response)
|
||||||
self.assertEquals(resp, 'FAKE APP')
|
self.assertEquals(resp, 'FAKE APP')
|
||||||
|
|
||||||
|
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
|
||||||
|
headers={'Host': 'fc00:7ea1:f155::6321:8841'})
|
||||||
|
resp = self.app(req.environ, start_response)
|
||||||
|
self.assertEquals(resp, 'FAKE APP')
|
||||||
|
|
||||||
def test_passthrough(self):
|
def test_passthrough(self):
|
||||||
|
|
||||||
def my_lookup(d):
|
def my_lookup(d):
|
||||||
|
Loading…
Reference in New Issue
Block a user