Make proxies work
This commit is contained in:
@@ -52,7 +52,7 @@ try:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("Error: Could not find icons file.")
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
from .util import * # * needed for plugins
|
from .util import * # * needed for plugins
|
||||||
|
|||||||
@@ -497,12 +497,12 @@ class TorDetector(QThread):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def is_tor_port(port):
|
def is_tor_port(port):
|
||||||
try:
|
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.settimeout(0.1)
|
||||||
s.connect(("127.0.0.1", port))
|
s.connect(("127.0.0.1", port))
|
||||||
# Tor responds uniquely to HTTP-like requests
|
# Tor responds uniquely to HTTP-like requests
|
||||||
s.send("GET\n")
|
s.send(b"GET\n")
|
||||||
if "Tor is not an HTTP Proxy" in s.recv(1024):
|
if b"Tor is not an HTTP Proxy" in s.recv(1024):
|
||||||
return True
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import threading
|
|||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from . import socks
|
import socks
|
||||||
from . import util
|
from . import util
|
||||||
from . import bitcoin
|
from . import bitcoin
|
||||||
from .bitcoin import *
|
from .bitcoin import *
|
||||||
@@ -443,13 +443,16 @@ class Network(util.DaemonThread):
|
|||||||
# socks.py seems to want either None or a non-empty string
|
# socks.py seems to want either None or a non-empty string
|
||||||
username=(proxy.get("user", "") or None),
|
username=(proxy.get("user", "") or None),
|
||||||
password=(proxy.get("password", "") 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
|
socket.socket = socks.socksocket
|
||||||
# prevent dns leaks, see http://stackoverflow.com/questions/13184205/dns-over-proxy
|
# 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]))]
|
socket.getaddrinfo = lambda *args: [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
|
||||||
else:
|
else:
|
||||||
if six.PY2:
|
socket.socket = socket._socketobject
|
||||||
socket.socket = socket._socketobject
|
socket.getaddrinfo = socket._getaddrinfo
|
||||||
socket.getaddrinfo = socket._socket.getaddrinfo
|
|
||||||
|
|
||||||
def start_network(self, protocol, proxy):
|
def start_network(self, protocol, proxy):
|
||||||
assert not self.interface and not self.interfaces
|
assert not self.interface and not self.interfaces
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ from six.moves import urllib_parse
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import paymentrequest_pb2_py3 as pb2
|
from . import paymentrequest_pb2 as pb2
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto'")
|
sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto'")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user