Fix for host with IPv6 enable but without default IPv6 route

This commit is contained in:
Cédric Krier
2008-11-24 17:12:51 +01:00
parent a6e3174166
commit 50619552cf
2 changed files with 12 additions and 6 deletions
+1
View File
@@ -1,3 +1,4 @@
* Fix for host with IPv6 enable but without default IPv6 route
* Allow egg installation
Version 1.0.0 - 2008-11-17
+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