From ef3e002db33454560b9d6b4f9d5017d2902ba162 Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 22 Aug 2005 18:52:37 +0000 Subject: [PATCH] src/utils/net: Fix our method of determining whether an IPV6 or IP socket is needed. --- src/utils/net.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/net.py b/src/utils/net.py index 96f2f7ec5..bddddc829 100644 --- a/src/utils/net.py +++ b/src/utils/net.py @@ -36,13 +36,14 @@ import socket emailRe = re.compile(r"^(\w&.+-]+!)*[\w&.+-]+@" r"(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)[a-z]{2,6}|" - r"([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I) + r"([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I) def getSocket(host): """Returns a socket of the correct AF_INET type (v4 or v6) in order to communicate with host. """ - host = socket.gethostbyname(host) + addrinfo = socket.getaddrinfo(host, None) + host = addrinfo[0][4][0] if isIP(host): return socket.socket(socket.AF_INET, socket.SOCK_STREAM) elif isIPV6(host):