Fix for host with IPv6 enable but without default IPv6 route

This commit is contained in:
Cédric Krier committed 2008-11-24 17:11:57 +01:00
1 parent 451a3aaa73
commit fc7b5a761e
2 files changed
+12 -6

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Fix for host with IPv6 enable but without default IPv6 route
* Add win32 single executable
* Allow egg installation
+11 -6
View File
@@ -10,6 +10,7 @@ except ImportError:
DNS_CACHE = {}
MAX_SIZE = 999999999
MAX_LENGHT = len(str(MAX_SIZE))
TIMEOUT = 120
_ALLOWED_MODULES = {'datetime': ['datetime', 'date'], 'decimal': ['Decimal']}
@@ -44,12 +45,14 @@ class PySocket:
socket.getaddrinfo(host, int(port), socket.AF_INET6)
self.sock = socket.socket(socket.AF_INET6,
socket.SOCK_STREAM)
self.sock.settimeout(TIMEOUT)
self.sock.connect((host, int(port)))
except:
pass
self.sock = None
if self.sock is None:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(120)
self.sock.connect((host, int(port)))
self.sock.settimeout(TIMEOUT)
self.sock.connect((host, int(port)))
DNS_CACHE[hostname], port = self.sock.getpeername()[:2]
try:
sock = None
@@ -57,12 +60,14 @@ class PySocket:
try:
socket.getaddrinfo(host, int(port), socket.AF_INET6)
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.settimeout(TIMEOUT)
sock.connect((host, int(port)))
except:
pass
sock = None
if sock is None:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(120)
sock.connect((host, int(port)))
sock.settimeout(TIMEOUT)
sock.connect((host, int(port)))
if hasattr(socket, 'ssl'):
ssl_sock = socket.ssl(sock)
self.ssl = True