commit 65aeb0bd3c40da82dd6f9a85eb8dc4889008f09f
parent bc591377e8f398a187449b6834c7f01e0d97edde
Author: ThomasV <thomasv@electrum.org>
Date: Wed, 1 Mar 2017 10:11:16 +0100
fix 5e7169bf355f2ac3ec8791c4768f0cd971e1640d
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git 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]))]