commit d6b77781a9c0d78f2c95c7a2426b9a8193129958
parent 58d889e4806ab649b52f407bf20500c7bd583ad9
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 16 Jan 2018 13:49:02 +0100
Merge pull request #3733 from SomberNight/remove_nossl
remove --nossl option
Diffstat:
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/gui/qt/network_dialog.py b/gui/qt/network_dialog.py
@@ -33,6 +33,7 @@ import PyQt5.QtCore as QtCore
from electrum.i18n import _
from electrum.bitcoin import NetworkConstants
from electrum.util import print_error
+from electrum.network import serialize_server, deserialize_server
from .util import *
@@ -145,7 +146,7 @@ class ServerListWidget(QTreeWidget):
menu.exec_(self.viewport().mapToGlobal(position))
def set_server(self, s):
- host, port, protocol = s.split(':')
+ host, port, protocol = deserialize_server(s)
self.parent.server_host.setText(host)
self.parent.server_port.setText(port)
self.parent.set_server()
@@ -170,7 +171,7 @@ class ServerListWidget(QTreeWidget):
port = d.get(protocol)
if port:
x = QTreeWidgetItem([_host, port])
- server = _host+':'+port+':'+protocol
+ server = serialize_server(_host, port, protocol)
x.setData(1, Qt.UserRole, server)
self.addTopLevelItem(x)
@@ -408,7 +409,7 @@ class NetworkChoiceLayout(object):
def follow_server(self, server):
self.network.switch_to_interface(server)
host, port, protocol, proxy, auto_connect = self.network.get_parameters()
- host, port, protocol = server.split(':')
+ host, port, protocol = deserialize_server(server)
self.network.set_parameters(host, port, protocol, proxy, auto_connect)
self.update()
@@ -441,7 +442,6 @@ class NetworkChoiceLayout(object):
host, port, protocol, proxy, auto_connect = self.network.get_parameters()
host = str(self.server_host.text())
port = str(self.server_port.text())
- protocol = 't' if self.config.get('nossl') else 's'
auto_connect = self.autoconnect_cb.isChecked()
self.network.set_parameters(host, port, protocol, proxy, auto_connect)
diff --git a/lib/commands.py b/lib/commands.py
@@ -823,7 +823,6 @@ def add_global_options(parser):
group.add_argument("-P", "--portable", action="store_true", dest="portable", default=False, help="Use local 'electrum_data' directory")
group.add_argument("-w", "--wallet", dest="wallet_path", help="wallet path")
group.add_argument("--testnet", action="store_true", dest="testnet", default=False, help="Use Testnet")
- group.add_argument("--nossl", action="store_true", dest="nossl", default=False, help="Disable SSL")
def get_parser():
# create main parser
diff --git a/lib/network.py b/lib/network.py
@@ -137,7 +137,7 @@ def deserialize_proxy(s):
def deserialize_server(server_str):
- host, port, protocol = str(server_str).split(':')
+ host, port, protocol = str(server_str).rsplit(':', 2)
assert protocol in 'st'
int(port) # Throw if cannot be converted to int
return host, port, protocol
@@ -171,15 +171,15 @@ class Network(util.DaemonThread):
self.blockchain_index = config.get('blockchain_index', 0)
if self.blockchain_index not in self.blockchains.keys():
self.blockchain_index = 0
- self.protocol = 't' if self.config.get('nossl') else 's'
# Server for addresses and transactions
- self.default_server = self.config.get('server')
+ self.default_server = self.config.get('server', None)
# Sanitize default server
- try:
- host, port, protocol = deserialize_server(self.default_server)
- assert protocol == self.protocol
- except:
- self.default_server = None
+ if self.default_server:
+ try:
+ deserialize_server(self.default_server)
+ except:
+ self.print_error('Warning: failed to parse server-string; falling back to random.')
+ self.default_server = None
if not self.default_server:
self.default_server = pick_random_server()
self.lock = threading.Lock()
@@ -220,7 +220,8 @@ class Network(util.DaemonThread):
self.connecting = set()
self.requested_chunks = set()
self.socket_queue = queue.Queue()
- self.start_network(self.protocol, deserialize_proxy(self.config.get('proxy')))
+ self.start_network(deserialize_server(self.default_server)[2],
+ deserialize_proxy(self.config.get('proxy')))
def register_callback(self, callback, events):
with self.lock: