Make proxies work
This commit is contained in:
parent
d4d93b3928
commit
8e54d5c4d4
|
@ -52,7 +52,7 @@ try:
|
|||
except Exception as e:
|
||||
print(e)
|
||||
print("Error: Could not find icons file.")
|
||||
print("Please run 'pyrcc4 icons.qrc -o gui/qt/icons_rc.py', and reinstall Electrum")
|
||||
print("Please run 'pyrcc4 icons.qrc -o gui/qt/icons_rc.py -py3', and reinstall Electrum")
|
||||
sys.exit(1)
|
||||
|
||||
from .util import * # * needed for plugins
|
||||
|
|
|
@ -497,12 +497,12 @@ class TorDetector(QThread):
|
|||
@staticmethod
|
||||
def is_tor_port(port):
|
||||
try:
|
||||
s = socket._socketobject(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s = (socket._socketobject if hasattr(socket, "_socketobject") else socket.socket)(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(0.1)
|
||||
s.connect(("127.0.0.1", port))
|
||||
# Tor responds uniquely to HTTP-like requests
|
||||
s.send("GET\n")
|
||||
if "Tor is not an HTTP Proxy" in s.recv(1024):
|
||||
s.send(b"GET\n")
|
||||
if b"Tor is not an HTTP Proxy" in s.recv(1024):
|
||||
return True
|
||||
except socket.error:
|
||||
pass
|
||||
|
|
|
@ -40,7 +40,7 @@ import threading
|
|||
import socket
|
||||
import json
|
||||
|
||||
from . import socks
|
||||
import socks
|
||||
from . import util
|
||||
from . import bitcoin
|
||||
from .bitcoin import *
|
||||
|
@ -443,13 +443,16 @@ 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]))]
|
||||
else:
|
||||
if six.PY2:
|
||||
socket.socket = socket._socketobject
|
||||
socket.getaddrinfo = socket._socket.getaddrinfo
|
||||
socket.getaddrinfo = socket._getaddrinfo
|
||||
|
||||
def start_network(self, protocol, proxy):
|
||||
assert not self.interface and not self.interfaces
|
||||
|
|
|
@ -42,7 +42,7 @@ from six.moves import urllib_parse
|
|||
|
||||
|
||||
try:
|
||||
from . import paymentrequest_pb2_py3 as pb2
|
||||
from . import paymentrequest_pb2 as pb2
|
||||
except ImportError:
|
||||
sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto'")
|
||||
|
||||
|
|
Loading…
Reference in New Issue