removed the timeout issues Issue 1488:Web2py not run OpenSUSE 12.3 64Bits but it may now work as intended

This commit is contained in:
mdipierro
2013-05-11 22:11:21 -05:00
parent 18e45ab994
commit 9ac438d05a
3 changed files with 16 additions and 9 deletions

View File

@@ -1 +1 @@
Version 2.4.6-stable+timestamp.2013.05.11.22.01.55
Version 2.4.6-stable+timestamp.2013.05.11.22.10.09

View File

@@ -471,11 +471,13 @@ def wsgibase(environ, responder):
local_hosts.add(socket.gethostname())
local_hosts.add(fqdn)
local_hosts.update([
addrinfo[4][0] for addrinfo in getipaddrinfo(fqdn)])
addrinfo[4][0] for addrinfo
in getipaddrinfo(fqdn)])
if env.server_name:
local_hosts.add(env.server_name)
local_hosts.update([
addrinfo[4][0] for addrinfo in getipaddrinfo(env.server_name)])
addrinfo[4][0] for addrinfo
in getipaddrinfo(env.server_name)])
except (socket.gaierror, TypeError):
pass
global_settings.local_hosts = list(local_hosts)

View File

@@ -300,13 +300,15 @@ def is_loopback_ip_address(ip=None, addrinfo=None):
Determines whether the address appears to be a loopback address.
This assumes that the IP is valid.
"""
if addrinfo: # see socket.getaddrinfo() for layout of addrinfo tuple
if addrinfo: # see socket.getaddrinfo() for layout of addrinfo tuple
if addrinfo[0] == socket.AF_INET or addrinfo[0] == socket.AF_INET6:
ip = addrinfo[4]
if not isinstance(ip, basestring):
return False
if ip.count('.') == 3: # IPv4 or IPv6-embedded IPv4 or IPv4-compatible IPv6
return ip.lower().startswith(('127', '::127', '0:0:0:0:0:0:127', '::ffff:127', '0:0:0:0:0:ffff:127'))
# IPv4 or IPv6-embedded IPv4 or IPv4-compatible IPv6
if ip.count('.') == 3:
return ip.lower().startswith(('127', '::127', '0:0:0:0:0:0:127',
'::ffff:127', '0:0:0:0:0:ffff:127'))
return ip == '::1' or ip == '0:0:0:0:0:0:0:1' # IPv6 loopback
@@ -314,7 +316,10 @@ def getipaddrinfo(host):
"""
Filter out non-IP and bad IP addresses from getaddrinfo
"""
return [addrinfo for addrinfo in socket.getaddrinfo(host, None)
if (addrinfo[0] == socket.AF_INET or addrinfo[0] == socket.AF_INET6)
try:
return [addrinfo for addrinfo in socket.getaddrinfo(host, None)
if (addrinfo[0] == socket.AF_INET or
addrinfo[0] == socket.AF_INET6)
and isinstance(addrinfo[4][0], basestring)]
except socket.error:
return []