From 65aeb0bd3c40da82dd6f9a85eb8dc4889008f09f Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 1 Mar 2017 10:11:16 +0100 Subject: [PATCH] fix 5e7169bf355f2ac3ec8791c4768f0cd971e1640d --- lib/network.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/network.py b/lib/network.py index 43f96ba18..1ed4672b8 100644 --- a/lib/network.py +++ b/lib/network.py @@ -434,6 +434,10 @@ class Network(util.DaemonThread): def set_proxy(self, proxy): self.proxy = proxy + # Store these somewhere so we can un-monkey-patch + if not hasattr(socket, "_socketobject"): + socket._socketobject = socket.socket + socket._getaddrinfo = socket.getaddrinfo if proxy: self.print_error('setting proxy', proxy) proxy_mode = proxy_modes.index(proxy["mode"]) + 1 @@ -443,10 +447,6 @@ class Network(util.DaemonThread): # socks.py seems to want either None or a non-empty string username=(proxy.get("user", "") or None), password=(proxy.get("password", "") or None)) - # Store these somewhere so we can un-monkey-patch - if not hasattr(socket, "_socketobject"): - socket._socketobject = socket.socket - socket._getaddrinfo = socket.getaddrinfo socket.socket = socks.socksocket # prevent dns leaks, see http://stackoverflow.com/questions/13184205/dns-over-proxy socket.getaddrinfo = lambda *args: [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]