Browse Source

fix proxy issues: override config with command line option, and use interface.proxy in gui

283
thomasv 12 years ago
parent
commit
fd13d19cb8
  1. 6
      electrum
  2. 21
      lib/gui_qt.py
  3. 9
      lib/simple_config.py

6
electrum

@ -118,9 +118,7 @@ if __name__ == '__main__':
parser.add_option("-p", "--proxy", dest="proxy", default=None, help="set proxy [type:]host[:port], where type is socks4,socks5 or http")
options, args = parser.parse_args()
if options.proxy:
options.proxy = parse_proxy_options(options.proxy)
proxy = parse_proxy_options(options.proxy) if options.proxy else simple_config.config["proxy"]
wallet = Wallet()
wallet.set_path(options.wallet_path)
wallet.read()
@ -180,7 +178,7 @@ if __name__ == '__main__':
sys.exit("Error: Unknown GUI: " + options.gui)
gui = gui.ElectrumGui(wallet)
interface = WalletSynchronizer(wallet, True, gui.server_list_changed, options.proxy)
interface = WalletSynchronizer(wallet, True, gui.server_list_changed, proxy)
interface.start()
try:

21
lib/gui_qt.py

@ -1406,11 +1406,11 @@ class ElectrumWindow(QMainWindow):
proxy_port.setFixedWidth(50)
proxy_mode.addItems(['NONE', 'SOCKS4', 'SOCKS5', 'HTTP'])
cfg = SimpleConfig()
proxy_config = cfg.config['proxy']
proxy_mode.setCurrentIndex(proxy_mode.findText(str(proxy_config["mode"]).upper()))
proxy_host.setText(proxy_config["host"])
proxy_port.setText(proxy_config["port"])
proxy_config = interface.proxy if interface.proxy else { "mode":"none", "host":"localhost", "port":"8080"}
proxy_mode.setCurrentIndex(proxy_mode.findText(str(proxy_config.get("mode").upper())))
proxy_host.setText(proxy_config.get("host"))
proxy_port.setText(proxy_config.get("port"))
hbox.addWidget(QLabel(_('Proxy') + ':'))
hbox.addWidget(proxy_mode)
hbox.addWidget(proxy_host)
@ -1451,11 +1451,14 @@ class ElectrumWindow(QMainWindow):
server = unicode( host_line.text() )
try:
cfg.set_key("proxy", { u'mode':unicode(proxy_mode.currentText()).lower(), u'host':unicode(proxy_host.text()), u'port':unicode(proxy_port.text()) }, True)
if cfg.config["proxy"]["mode"] != "none":
wallet.set_server(server, cfg.config["proxy"])
if proxy_mode.currentText() != 'NONE':
proxy = { u'mode':unicode(proxy_mode.currentText()).lower(), u'host':unicode(proxy_host.text()), u'port':unicode(proxy_port.text()) }
else:
wallet.set_server(server)
proxy = None
cfg = SimpleConfig()
cfg.set_key("proxy", proxy, True)
wallet.set_server(server, proxy)
except Exception as err:
QMessageBox.information(None, _('Error'), str(err), _('OK'))

9
lib/simple_config.py

@ -5,8 +5,13 @@ from util import user_dir
class SimpleConfig:
default_options = {"gui": "lite", "proxy": { "mode": "none", "host":"localhost", "port":"8080" },
"winpos-qt": [100, 100, 840, 400], "winpos-lite": [4, 25, 351, 149], "history": False }
default_options = {
"gui": "lite",
"proxy": None,
"winpos-qt": [100, 100, 840, 400],
"winpos-lite": [4, 25, 351, 149],
"history": False
}
def __init__(self):
# Find electrum data folder

Loading…
Cancel
Save