diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-08-07 13:42:02 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-08-07 13:43:13 +0200 |
commit | 0c465f5e6035c6df2868cbd5b940f9b24c07293f (patch) | |
tree | 174128ba61d448af0e158132aab5fbbdfdc8f0f2 /src/qt/optionsmodel.cpp | |
parent | 100c9d3994efa0527915bf15d6cc3078d6b80856 (diff) | |
parent | ed166dfa8284778bc6e42acc2efcafa893f33cec (diff) |
Merge pull request #4587
ed166df [Qt] allow users to set -onion via GUI (Philip Kaufmann)
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r-- | src/qt/optionsmodel.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 6191edc44c..65e490570e 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -117,6 +117,16 @@ void OptionsModel::Init() else if(!settings.value("fUseProxy").toBool() && !GetArg("-proxy", "").empty()) addOverriddenOption("-proxy"); + if (!settings.contains("fUseSeparateProxyTor")) + settings.setValue("fUseSeparateProxyTor", false); + if (!settings.contains("addrSeparateProxyTor")) + settings.setValue("addrSeparateProxyTor", "127.0.0.1:9050"); + // Only try to set -onion, if user has enabled fUseSeparateProxyTor + if (settings.value("fUseSeparateProxyTor").toBool() && !SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString())) + addOverriddenOption("-onion"); + else if(!settings.value("fUseSeparateProxyTor").toBool() && !GetArg("-onion", "").empty()) + addOverriddenOption("-onion"); + // Display if (!settings.contains("language")) settings.setValue("language", ""); @@ -178,6 +188,20 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return strlIpPort.at(1); } + // separate Tor proxy + case ProxyUseTor: + return settings.value("fUseSeparateProxyTor", false); + case ProxyIPTor: { + // contains IP at index 0 and port at index 1 + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + return strlIpPort.at(0); + } + case ProxyPortTor: { + // contains IP at index 0 and port at index 1 + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + return strlIpPort.at(1); + } + #ifdef ENABLE_WALLET case SpendZeroConfChange: return settings.value("bSpendZeroConfChange"); @@ -259,6 +283,39 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in } } break; + + // separate Tor proxy + case ProxyUseTor: + if (settings.value("fUseSeparateProxyTor") != value) { + settings.setValue("fUseSeparateProxyTor", value.toBool()); + setRestartRequired(true); + } + break; + case ProxyIPTor: { + // contains current IP at index 0 and current port at index 1 + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + // if that key doesn't exist or has a changed IP + if (!settings.contains("addrSeparateProxyTor") || strlIpPort.at(0) != value.toString()) { + // construct new value from new IP and current port + QString strNewValue = value.toString() + ":" + strlIpPort.at(1); + settings.setValue("addrSeparateProxyTor", strNewValue); + setRestartRequired(true); + } + } + break; + case ProxyPortTor: { + // contains current IP at index 0 and current port at index 1 + QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); + // if that key doesn't exist or has a changed port + if (!settings.contains("addrSeparateProxyTor") || strlIpPort.at(1) != value.toString()) { + // construct new value from current IP and new port + QString strNewValue = strlIpPort.at(0) + ":" + value.toString(); + settings.setValue("addrSeparateProxyTor", strNewValue); + setRestartRequired(true); + } + } + break; + #ifdef ENABLE_WALLET case SpendZeroConfChange: if (settings.value("bSpendZeroConfChange") != value) { |