From 9d09f9f3cee36f87f88c68d96d69f61669398a1e Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Wed, 5 Jul 2017 09:07:00 +0200 Subject: [PATCH] Reduce severity of socks connectivity errors - Fixes #1024 - Fixes #1019 --- src/network/socks4a.py | 6 ++++++ src/network/socks5.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/network/socks4a.py b/src/network/socks4a.py index 61f3ec7d..350e163e 100644 --- a/src/network/socks4a.py +++ b/src/network/socks4a.py @@ -84,6 +84,12 @@ class Socks4aConnection(Socks4a): self.writeQueue.put(self.destination[0] + chr(0x00).encode()) self.set_state("pre_connect", 0) + def state_pre_connect(self): + try: + Socks4a.state_pre_connect(self) + except Socks4aError as e: + self.handle_close(e.message) + class Socks4aResolver(Socks4a): def __init__(self, host): diff --git a/src/network/socks5.py b/src/network/socks5.py index 89c3c9b2..f2bc83e4 100644 --- a/src/network/socks5.py +++ b/src/network/socks5.py @@ -156,6 +156,12 @@ class Socks5Connection(Socks5): self.writeQueue.put(struct.pack(">H", self.destination[1])) self.set_state("pre_connect", 0) + def state_pre_connect(self): + try: + Socks5.state_pre_connect(self) + except Socks5Error as e: + self.handle_close(e.message) + class Socks5Resolver(Socks5): def __init__(self, host):