issue Issue 1474 attachment: addrinfo.patch, thanks Jonathan
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.4.6-stable+timestamp.2013.05.03.21.36.38
|
Version 2.4.6-stable+timestamp.2013.05.03.21.41.37
|
||||||
|
|||||||
+3
-5
@@ -95,7 +95,7 @@ from settings import global_settings
|
|||||||
from validators import CRYPT
|
from validators import CRYPT
|
||||||
from cache import CacheInRam
|
from cache import CacheInRam
|
||||||
from html import URL, xmlescape
|
from html import URL, xmlescape
|
||||||
from utils import is_valid_ip_address
|
from utils import is_valid_ip_address, getipaddrinfo
|
||||||
from rewrite import load, url_in, THREAD_LOCAL as rwthread, \
|
from rewrite import load, url_in, THREAD_LOCAL as rwthread, \
|
||||||
try_rewrite_on_error, fixup_missing_path_info
|
try_rewrite_on_error, fixup_missing_path_info
|
||||||
import newcron
|
import newcron
|
||||||
@@ -471,13 +471,11 @@ def wsgibase(environ, responder):
|
|||||||
local_hosts.add(socket.gethostname())
|
local_hosts.add(socket.gethostname())
|
||||||
local_hosts.add(fqdn)
|
local_hosts.add(fqdn)
|
||||||
local_hosts.update([
|
local_hosts.update([
|
||||||
ip[4][0] for ip in socket.getaddrinfo(
|
ip[4][0] for ip in getipaddrinfo(fqdn)])
|
||||||
fqdn, 0)])
|
|
||||||
if env.server_name:
|
if env.server_name:
|
||||||
local_hosts.add(env.server_name)
|
local_hosts.add(env.server_name)
|
||||||
local_hosts.update([
|
local_hosts.update([
|
||||||
ip[4][0] for ip in socket.getaddrinfo(
|
ip[4][0] for ip in getipaddrinfo(env.server_name)])
|
||||||
env.server_name, 0)])
|
|
||||||
except (socket.gaierror, TypeError):
|
except (socket.gaierror, TypeError):
|
||||||
pass
|
pass
|
||||||
global_settings.local_hosts = list(local_hosts)
|
global_settings.local_hosts = list(local_hosts)
|
||||||
|
|||||||
+17
-3
@@ -295,14 +295,28 @@ def is_valid_ip_address(address):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def is_loopback_ip_address(ip):
|
def is_loopback_ip_address(ip=None, addrinfo=None):
|
||||||
"""Determines whether the IP address appears to be a loopback address.
|
"""
|
||||||
|
Determines whether the address appears to be a loopback address.
|
||||||
|
|
||||||
This assumes that the IP is valid. The IPv6 check is limited to '::1'.
|
This assumes that the IP is valid. The IPv6 check is limited to '::1'.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if addrinfo: # see socket.getaddrinfo() for layout of addrinfo tuple
|
||||||
|
if addrinfo[0] == socket.AF_NET or addrinfo[0] == socket.AF_INET6:
|
||||||
|
ip = addrinfo[4]
|
||||||
if not ip:
|
if not ip:
|
||||||
return False
|
return False
|
||||||
if ip.count('.') == 3: # IPv4
|
if isinstance(ip, basestring) and ip.count('.') == 3: # IPv4
|
||||||
return ip.startswith('127') or ip.startswith('::ffff:127')
|
return ip.startswith('127') or ip.startswith('::ffff:127')
|
||||||
return ip == '::1' # IPv6
|
return ip == '::1' # IPv6
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
and isinstance(addrinfo[4][0], basestring)]
|
||||||
|
|
||||||
|
|||||||
+4
-6
@@ -15,7 +15,6 @@ import cStringIO
|
|||||||
import time
|
import time
|
||||||
import thread
|
import thread
|
||||||
import threading
|
import threading
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import signal
|
import signal
|
||||||
@@ -25,10 +24,10 @@ import newcron
|
|||||||
import getpass
|
import getpass
|
||||||
import main
|
import main
|
||||||
|
|
||||||
from fileutils import w2p_pack, read_file, write_file, create_welcome_w2p
|
from fileutils import read_file, write_file, create_welcome_w2p
|
||||||
from settings import global_settings
|
from settings import global_settings
|
||||||
from shell import run, test
|
from shell import run, test
|
||||||
from utils import is_valid_ip_address, is_loopback_ip_address
|
from utils import is_valid_ip_address, is_loopback_ip_address, getipaddrinfo
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import Tkinter
|
import Tkinter
|
||||||
@@ -338,7 +337,6 @@ class web2pyDialog(object):
|
|||||||
self.tb = None
|
self.tb = None
|
||||||
|
|
||||||
def update_schedulers(self, start=False):
|
def update_schedulers(self, start=False):
|
||||||
x = 0
|
|
||||||
apps = []
|
apps = []
|
||||||
available_apps = [arq for arq in os.listdir('applications/')]
|
available_apps = [arq for arq in os.listdir('applications/')]
|
||||||
available_apps = [arq for arq in available_apps
|
available_apps = [arq for arq in available_apps
|
||||||
@@ -942,8 +940,8 @@ def console():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
options.ips = list(set([
|
options.ips = list(set([
|
||||||
ip[4][0] for ip in socket.getaddrinfo(socket.getfqdn(), 0)
|
addrinfo[4][0] for addrinfo in getipaddrinfo(socket.getfqdn())
|
||||||
if not is_loopback_ip_address(ip[4][0])]))
|
if not is_loopback_ip_address(addrinfo=addrinfo)]))
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
options.ips = []
|
options.ips = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user