From d06cc5af810dbc12edc48651c98e9b63cb642ed7 Mon Sep 17 00:00:00 2001 From: fekt Date: Mon, 7 Aug 2023 11:29:34 -0400 Subject: [PATCH] Allow setting IP for tor proxy --- src/connection.cpp | 4 +- src/createhushconfdialog.ui | 237 +++++++++++++++++++----------- src/mainwindow.cpp | 53 ++++++- src/mainwindow.h | 1 + src/settings.ui | 283 ++++++++++++++++-------------------- 5 files changed, 331 insertions(+), 247 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index b710de7..6539ae3 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -211,11 +211,13 @@ void ConnectionLoader::createHushConf() { // Show the dialog QString datadir = ""; bool useTor = false; + QString torProxy = "127.0.0.1"; QString torPort = "9050"; if (d.exec() == QDialog::Accepted) { datadir = ui.lblDirName->text(); useTor = ui.chkUseTor->isChecked(); + torProxy = ui.torProxy->text(); torPort = ui.torPort->text(); } @@ -266,7 +268,7 @@ void ConnectionLoader::createHushConf() { out << "datadir=" % datadir % "\n"; } if (useTor) { - out << "proxy=127.0.0.1:" << torPort << "\n"; + out << "proxy="<< torProxy << ":" << torPort << "\n"; } file.close(); diff --git a/src/createhushconfdialog.ui b/src/createhushconfdialog.ui index b150990..57cc99d 100644 --- a/src/createhushconfdialog.ui +++ b/src/createhushconfdialog.ui @@ -7,7 +7,7 @@ 0 0 508 - 352 + 369 @@ -95,93 +95,154 @@ - - - - - Use custom datadir - - - - - - - Please choose a directory to store your wallet.dat and blockchain - - - - - - - - - Choose directory - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - Connect over Tor - - - - - - - - Please note that you'll need to already have a Tor service configured - - - - - - - - Tor Port - - - - - - - - 9050 - - - - - + + + + 8 + 8 + 148 + 22 + + + + Use custom datadir + + + + + + 8 + 36 + 395 + 18 + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + + 8 + 102 + 16 + 18 + + + + + + + + + + 8 + 126 + 133 + 22 + + + + Connect over Tor + + + + + + 8 + 154 + 415 + 18 + + + + Please note that you'll need to already have a Tor service configured + + + + + + 178 + 178 + 49 + 18 + + + + Tor Port + + + + + + 230 + 178 + 59 + 32 + + + + 9050 + + + + + + 62 + 180 + 111 + 32 + + + + 127.0.0.1 + + + + + + 10 + 180 + 49 + 18 + + + + Proxy IP + + + + + + + + Choose directory + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2ce544e..0b9fff9 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -95,6 +95,9 @@ MainWindow::MainWindow(QWidget *parent) : // Validate Address QObject::connect(ui->actionValidate_Address, &QAction::triggered, this, &MainWindow::validateAddress); + // Get Block + //QObject::connect(ui->actionGet_Block, &QAction::triggered, this, &MainWindow::getBlock); + // Address Book QObject::connect(ui->action_Address_Book, &QAction::triggered, this, &MainWindow::addressBook); @@ -700,8 +703,9 @@ void MainWindow::setupSettingsModal() { if (!isUsingTor && settings.chkTor->isChecked()) { // If "use tor" was previously unchecked and now checked + QString torProxy= settings.torProxy->text(); QString torPort = settings.torPort->text(); - QString proxyConfig = "proxy=127.0.0.1:" % torPort; + QString proxyConfig = "proxy="%torProxy%":"%torPort; Settings::addToHushConf(hushConfLocation, proxyConfig); rpc->getConnection()->config->proxy = proxyConfig; @@ -896,8 +900,55 @@ void MainWindow::validateAddress() { d.exec(); }); +} + +// Get block info +/* +void MainWindow::getBlock() { + // Make sure everything is up and running + if (!getRPC() || !getRPC()->getConnection()) + return; + + // First thing is ask the user for a blocj height + bool ok; + auto blockheight = QInputDialog::getText(this, tr("Enter Block Height"), QLineEdit::Normal, "", &ok); + if (!ok) + return; + + getRPC()->validateAddress(address, [=] (QJsonValue props) { + QDialog d(this); + Ui_ValidateAddress va; + va.setupUi(&d); + Settings::saveRestore(&d); + Settings::saveRestoreTableHeader(va.tblProps, &d, "validateaddressprops"); + va.tblProps->horizontalHeader()->setStretchLastSection(true); + + va.lblAddress->setText(address); + + QList> propsList; + + for (QString property_name: props.toObject().keys()) { + + QString property_value; + + if (props.toObject()[property_name].isString()) + property_value = props.toObject()[property_name].toString(); + else + property_value = props.toObject()[property_name].toBool() ? "true" : "false" ; + + propsList.append( + QPair( property_name, + property_value ) + ); + } + ValidateAddressesModel model(va.tblProps, propsList); + va.tblProps->setModel(&model); + + d.exec(); + }); } +*/ void MainWindow::doImport(QList* keys) { if (rpc->getConnection() == nullptr) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 2eabd48..0c39a3a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -52,6 +52,7 @@ public: void payHushURI(QString uri = "", QString myAddr = ""); void validateAddress(); + void getBlock(); void updateLabels(); void updateTAddrCombo(bool checked); diff --git a/src/settings.ui b/src/settings.ui index 2a6d37d..65c30df 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -7,7 +7,7 @@ 0 0 623 - 653 + 622 @@ -145,228 +145,165 @@ Options - + Remember shielded transactions - - + + - Shield change from t-Addresses to your sapling address + Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab. + + + true - + Clear History - - + + - Connect to the internet to fetch prices + Allow custom fees - - - - Qt::Vertical - - - - 20 - 40 - + + + + Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. - - - - - - - 0 - 0 - + + true - - - default - - - - - blue - - - - - light - - - - - dark - - - - - midnight - - - - - dragonx - - - - - - - 0 - 0 - + + + + Shield change from t-Addresses to your sapling address - - - + + - Connect to the Tor network via SOCKS proxy, which runs on 127.0.0.1:9050 by default or 127.0.0.1:9150 for Tor Browser. Please note that you'll have to install and run the Tor service externally. + Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy. true - - - - - Tor Port - - - - - - - - 9050 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - + + - Theme - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Connect via Tor - - + + - Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. + Connect to the Tor network via SOCKS proxy, which runs on 127.0.0.1:9050 by default or 127.0.0.1:9150 for Tor Browser. Please note that you'll have to install and run the Tor service externally. true - - + + - Check git.hush.is for updates at startup + Proxy IP - - + + - Fetch prices + 127.0.0.1 - - + + - Connect to git.hush.is on startup to check for updates + Tor Port - - + + - Allow custom fees + 9050 - - + + - Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab. + Connect to git.hush.is on startup to check for updates - - true + + + + + + Connect to the internet to fetch prices - - + + - + 0 0 - - Local Currency - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Connect via Tor - + + + default + + + + + blue + + + + + light + + + + + dark + + + + + midnight + + + + + dragonx + + - - + + 0 @@ -374,14 +311,14 @@ - Language + Local Currency Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + @@ -606,13 +543,45 @@ - - + + + + + 0 + 0 + + - Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy. + Language - - true + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Theme + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter