aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author251 <13120787+251Labs@users.noreply.github.com>2018-03-08 20:58:57 +0100
committerfanquake <fanquake@gmail.com>2018-04-26 23:43:54 +0800
commitf118a7a35b8c880740d5ebf6230498a5951bd889 (patch)
treec0bfb795d5095495a142cf5052a75090c5f9d30d /src
parentf60e84dba4723bc658ecc70f8b17db2619eb7e20 (diff)
downloadbitcoin-f118a7a35b8c880740d5ebf6230498a5951bd889.tar.xz
Fix illegal default `addProxy` and `addrSeparateProxyTor` settings.
GitHub-Pull: #12650 Rebased-From: 40c5886
Diffstat (limited to 'src')
-rw-r--r--src/qt/optionsmodel.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 4ade88d843..f5bf8f4d4d 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -29,6 +29,8 @@
const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
+static const QString GetDefaultProxyAddress();
+
OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
QAbstractListModel(parent)
{
@@ -126,7 +128,7 @@ void OptionsModel::Init(bool resetSettings)
if (!settings.contains("fUseProxy"))
settings.setValue("fUseProxy", false);
if (!settings.contains("addrProxy"))
- settings.setValue("addrProxy", QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST, DEFAULT_GUI_PROXY_PORT));
+ settings.setValue("addrProxy", GetDefaultProxyAddress());
// Only try to set -proxy, if user has enabled fUseProxy
if (settings.value("fUseProxy").toBool() && !gArgs.SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
addOverriddenOption("-proxy");
@@ -136,7 +138,7 @@ void OptionsModel::Init(bool resetSettings)
if (!settings.contains("fUseSeparateProxyTor"))
settings.setValue("fUseSeparateProxyTor", false);
if (!settings.contains("addrSeparateProxyTor"))
- settings.setValue("addrSeparateProxyTor", QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST, DEFAULT_GUI_PROXY_PORT));
+ settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress());
// Only try to set -onion, if user has enabled fUseSeparateProxyTor
if (settings.value("fUseSeparateProxyTor").toBool() && !gArgs.SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))
addOverriddenOption("-onion");
@@ -228,6 +230,11 @@ static void SetProxySetting(QSettings &settings, const QString &name, const Prox
settings.setValue(name, ip_port.ip + ":" + ip_port.port);
}
+static const QString GetDefaultProxyAddress()
+{
+ return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT);
+}
+
// read QSettings values and return them
QVariant OptionsModel::data(const QModelIndex & index, int role) const
{
@@ -490,4 +497,16 @@ void OptionsModel::checkAndMigrate()
settings.setValue(strSettingsVersionKey, CLIENT_VERSION);
}
+
+ // Overwrite the 'addrProxy' setting in case it has been set to an illegal
+ // default value (see issue #12623; PR #12650).
+ if (settings.contains("addrProxy") && settings.value("addrProxy").toString().endsWith("%2")) {
+ settings.setValue("addrProxy", GetDefaultProxyAddress());
+ }
+
+ // Overwrite the 'addrSeparateProxyTor' setting in case it has been set to an illegal
+ // default value (see issue #12623; PR #12650).
+ if (settings.contains("addrSeparateProxyTor") && settings.value("addrSeparateProxyTor").toString().endsWith("%2")) {
+ settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress());
+ }
}