client/rhel/rhnlib/rhn/connections.py | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
New commits:
commit 1f67aa02da52c26d4954df3740227fcfe5d5949c
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Tue Aug 16 10:34:20 2011 +0200
730744 - support IPv6 connections
diff --git a/client/rhel/rhnlib/rhn/connections.py
b/client/rhel/rhnlib/rhn/connections.py
index a33ce15..2403bf8 100644
--- a/client/rhel/rhnlib/rhn/connections.py
+++ b/client/rhel/rhnlib/rhn/connections.py
@@ -157,9 +157,31 @@ class HTTPSConnection(HTTPConnection):
def connect(self):
"Connect to a host on a given (SSL) port"
import socket
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.settimeout(SSL.DEFAULT_TIMEOUT)
- sock.connect((self.host, self.port))
+
+ results = socket.getaddrinfo(self.host, self.port,
+ socket.AF_UNSPEC, socket.SOCK_STREAM)
+
+ for r in results:
+ af, socktype, proto, canonname, sa = r
+ try:
+ sock = socket.socket(af, socktype, proto)
+ except socket.error, msg:
+ sock = None
+ continue
+
+ sock.settimeout(SSL.DEFAULT_TIMEOUT)
+
+ try:
+ sock.connect((self.host, self.port))
+ except socket.error, e:
+ sock.close()
+ sock = None
+ continue
+ break
+
+ if sock is None:
+ raise socket.error("Unable to connect to the host and port
specified")
+
self.sock = SSL.SSLSocket(sock, self.trusted_certs)
self.sock.init_ssl()
Show replies by date