From 7e5e30d125182f29ac283f8d86f9350749c140e6 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Tue, 30 Aug 2022 00:35:22 +0300 Subject: [PATCH] Disable oniononly checkbox in Settings dialog if have no onion v3 nodes --- src/bitmessageqt/settings.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index 237d14e1..6e0d4792 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -6,6 +6,7 @@ import os import sys import tempfile +import six from PyQt4 import QtCore, QtGui import debug @@ -160,6 +161,26 @@ class SettingsDialog(QtGui.QDialog): else self.comboBoxProxyType.findText(self._proxy_type)) self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex()) + if self._proxy_type: + for node, info in six.iteritems( + knownnodes.knownNodes.get( + min(state.streamsInWhichIAmParticipating), []) + ): + if ( + node.host.endswith('.onion') and len(node.host) > 22 + and not info.get('self') + ): + break + else: + if self.checkBoxOnionOnly.isChecked(): + self.checkBoxOnionOnly.setText( + self.checkBoxOnionOnly.text() + ", " + _translate( + "MainWindow", "may cause connection problems!")) + self.checkBoxOnionOnly.setStyleSheet( + "QCheckBox { color : red; }") + else: + self.checkBoxOnionOnly.setEnabled(False) + self.lineEditSocksHostname.setText( config.get('bitmessagesettings', 'sockshostname')) self.lineEditSocksPort.setText(str(