aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qt/optionsdialog.cpp3
-rw-r--r--src/qt/optionsmodel.cpp24
-rw-r--r--src/qt/optionsmodel.h6
-rw-r--r--src/qt/paymentserver.cpp25
4 files changed, 39 insertions, 19 deletions
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index d024e3b7aa..f61bb3ed2c 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -53,7 +53,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, SLOT(setEnabled(bool)));
- connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy()));
ui->proxyIp->installEventFilter(this);
@@ -204,7 +203,7 @@ void OptionsDialog::on_resetButton_clicked()
if(btnRetVal == QMessageBox::Cancel)
return;
- /* reset all options and close Bitcoin-Qt */
+ /* reset all options and close GUI */
model->Reset();
QApplication::quit();
}
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 1133c457b3..a18fd1d514 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -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;
}
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index d05cb46746..7a71b772b2 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -7,6 +7,10 @@
#include <QAbstractListModel>
+QT_BEGIN_NAMESPACE
+class QNetworkProxy;
+QT_END_NAMESPACE
+
/** Interface from Qt to configuration data structure for Bitcoin client.
To Qt, the options are presented as a list with the different options
laid out vertically.
@@ -54,7 +58,7 @@ public:
bool getMinimizeOnClose() { return fMinimizeOnClose; }
int getDisplayUnit() { return nDisplayUnit; }
bool getDisplayAddresses() { return bDisplayAddresses; }
- bool getProxySettings(QString& proxyIP, quint16 &proxyPort) const;
+ bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 7642cd117a..ca6ae17990 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -335,17 +335,22 @@ void PaymentServer::initNetManager()
// netManager is used to fetch paymentrequests given in bitcoin: URIs
netManager = new QNetworkAccessManager(this);
- // Use proxy settings from optionsModel
- QString proxyIP;
- quint16 proxyPort;
- if (optionsModel->getProxySettings(proxyIP, proxyPort))
- {
- QNetworkProxy proxy;
- proxy.setType(QNetworkProxy::Socks5Proxy);
- proxy.setHostName(proxyIP);
- proxy.setPort(proxyPort);
- netManager->setProxy(proxy);
+ QNetworkProxy proxy;
+
+ // Query active proxy (fails if no SOCKS5 proxy)
+ if (optionsModel->getProxySettings(proxy)) {
+ if (proxy.type() == QNetworkProxy::Socks5Proxy) {
+ netManager->setProxy(proxy);
+
+ qDebug() << "PaymentServer::initNetManager : Using SOCKS5 proxy" << proxy.hostName() << ":" << proxy.port();
+ }
+ else
+ qDebug() << "PaymentServer::initNetManager : No active proxy server found.";
}
+ else
+ emit message(tr("Net manager warning"),
+ tr("Your active proxy doesn't support SOCKS5, which is required for payment requests via proxy."),
+ CClientUIInterface::MSG_WARNING);
connect(netManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(netRequestFinished(QNetworkReply*)));