mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #12650: gui: Fix issue: "default port not shown correctly in settings dialog"
40c5886
Fix illegal default `addProxy` and `addrSeparateProxyTor` settings. (251) Pull request description: Inf05d349
the value of the `addrProxy` and `addrSeparateProxyTor` settings is set to an illegal default value, because the value of `DEFAULT_GUI_PROXY_PORT ` is passed to the `fieldWidth` parameter of the `QString QString::arg(const QString &a, int fieldWidth = 0, QChar fillChar = QLatin1Char( ' ' )) const` method:29fad97c32/src/qt/optionsmodel.cpp (L129)
29fad97c32/src/qt/optionsmodel.cpp (L139)
This will create a default proxy setting that consists of 9053 characters and ends with the string `127.0.0.1:%2`. This PR attempts to resolve #12623 by setting the correct value for the `addrProxy` and `addrSeparateProxyTor` settings (i) if the proxy setting does not exist; or (ii) if the proxy setting has an illegal value caused by to the aforementioned bug. The second condition is *only* relevant if we don't want Bitcoin Core 0.16.0 users to explicitly reset their settings to see the correct default proxy port value. Tree-SHA512: 3dc3de2eb7da831f6e318797df67341ced2076b48f9b561c73677bf6beb67b259d8e413095f290356fb92e32e4e8162d48accbc575c4e612060fd5d6dde7ac8d
This commit is contained in:
parent
89bc82625b
commit
547aef1b0b
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
|
const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
|
||||||
|
|
||||||
|
static const QString GetDefaultProxyAddress();
|
||||||
|
|
||||||
OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
|
OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
|
||||||
QAbstractListModel(parent)
|
QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
@ -170,7 +172,7 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
if (!settings.contains("fUseProxy"))
|
if (!settings.contains("fUseProxy"))
|
||||||
settings.setValue("fUseProxy", false);
|
settings.setValue("fUseProxy", false);
|
||||||
if (!settings.contains("addrProxy"))
|
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
|
// Only try to set -proxy, if user has enabled fUseProxy
|
||||||
if (settings.value("fUseProxy").toBool() && !gArgs.SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
|
if (settings.value("fUseProxy").toBool() && !gArgs.SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
|
||||||
addOverriddenOption("-proxy");
|
addOverriddenOption("-proxy");
|
||||||
@ -180,7 +182,7 @@ void OptionsModel::Init(bool resetSettings)
|
|||||||
if (!settings.contains("fUseSeparateProxyTor"))
|
if (!settings.contains("fUseSeparateProxyTor"))
|
||||||
settings.setValue("fUseSeparateProxyTor", false);
|
settings.setValue("fUseSeparateProxyTor", false);
|
||||||
if (!settings.contains("addrSeparateProxyTor"))
|
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
|
// Only try to set -onion, if user has enabled fUseSeparateProxyTor
|
||||||
if (settings.value("fUseSeparateProxyTor").toBool() && !gArgs.SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))
|
if (settings.value("fUseSeparateProxyTor").toBool() && !gArgs.SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))
|
||||||
addOverriddenOption("-onion");
|
addOverriddenOption("-onion");
|
||||||
@ -263,6 +265,11 @@ static void SetProxySetting(QSettings &settings, const QString &name, const Prox
|
|||||||
settings.setValue(name, ip_port.ip + ":" + ip_port.port);
|
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
|
// read QSettings values and return them
|
||||||
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||||
{
|
{
|
||||||
@ -603,4 +610,16 @@ void OptionsModel::checkAndMigrate()
|
|||||||
|
|
||||||
settings.setValue(strSettingsVersionKey, CLIENT_VERSION);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user