mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
[Qt] let OptionsModel::getProxySettings() directly query proxy
- as a proxy set via GUI can be overridden via -proxy, directly query the core to get active proxy - give a warning, if active proxy is not SOCKS5 (needs to be SOCKS5 for the Qt networking code to work) - also remove an obsolete connect() call from optionsdialog.cpp and a reference to Bitcoin-Qt (now just GUI)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "walletdb.h"
|
||||
#endif
|
||||
|
||||
#include <QNetworkProxy>
|
||||
#include <QSettings>
|
||||
#include <QStringList>
|
||||
|
||||
@@ -375,14 +376,25 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
return successful;
|
||||
}
|
||||
|
||||
bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const
|
||||
bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
|
||||
{
|
||||
std::string proxy = GetArg("-proxy", "");
|
||||
if (proxy.empty()) return false;
|
||||
// Directly query current base proxy, because
|
||||
// GUI settings can be overridden with -proxy.
|
||||
proxyType curProxy;
|
||||
if (GetProxy(NET_IPV4, curProxy)) {
|
||||
if (curProxy.second == 5) {
|
||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
proxy.setHostName(QString::fromStdString(curProxy.first.ToStringIP()));
|
||||
proxy.setPort(curProxy.first.GetPort());
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
proxy.setType(QNetworkProxy::NoProxy);
|
||||
|
||||
CService addrProxy(proxy);
|
||||
proxyIP = QString(addrProxy.ToStringIP().c_str());
|
||||
proxyPort = addrProxy.GetPort();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user