From 5764374e5de55b572142f61c44117c44585ecc9a Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Thu, 14 Sep 2006 08:40:09 +0000 Subject: [PATCH] set proxy as invalid if hostname cannot be resolved --- src/common/proxy65_manager.py | 3 +++ src/common/socks5.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/proxy65_manager.py b/src/common/proxy65_manager.py index 5f2a9f528..5145632db 100644 --- a/src/common/proxy65_manager.py +++ b/src/common/proxy65_manager.py @@ -186,6 +186,9 @@ class HostTester(Socks5, IdleObject): def connect(self): ''' create the socket and plug it to the idlequeue ''' + if self.host is None: + self.on_failure() + return None self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._sock.setblocking(False) self.fd = self._sock.fileno() diff --git a/src/common/socks5.py b/src/common/socks5.py index 9039dab54..6e472e1b8 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -350,7 +350,10 @@ class SocksQueue: class Socks5: def __init__(self, idlequeue, host, port, initiator, target, sid): if host is not None: - self.host = socket.gethostbyname(host) + try: + self.host = socket.gethostbyname(host) + except socket.gaierror: + self.host = None self.idlequeue = idlequeue self.fd = -1 self.port = port