From 0b5cddb2990d471eb08147e424fd0adb8b985b61 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Fri, 18 Nov 2022 23:03:20 +0300 Subject: [PATCH] tor status fix for unconfigured, add update on settings change; fix i2p out led status --- retroshare-gui/src/gui/MainWindow.cpp | 4 ++ retroshare-gui/src/gui/MainWindow.h | 1 + .../src/gui/settings/ServerPage.cpp | 41 ++++++++++++++----- .../src/gui/statusbar/torstatus.cpp | 7 +++- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 0af20e824..8695057a2 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1628,6 +1628,10 @@ NATStatus *MainWindow::natstatusInstance() return natstatus; } +void MainWindow::torstatusReset() +{ + torstatus->reset(); +} DHTStatus *MainWindow::dhtstatusInstance() { return dhtstatus; diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 23b70e66f..bac210f2c 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -187,6 +187,7 @@ public: RSComboBox *statusComboBoxInstance(); PeerStatus *peerstatusInstance(); NATStatus *natstatusInstance(); + void torstatusReset(); DHTStatus *dhtstatusInstance(); HashingStatus *hashingstatusInstance(); DiscStatus *discstatusInstance(); diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 5089bd90c..d5ede348d 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -21,6 +21,7 @@ #include "ServerPage.h" #include +#include "gui/MainWindow.h" #include "rshare.h" #include "rsharesettings.h" #include "util/i2pcommon.h" @@ -1357,6 +1358,7 @@ void ServerPage::saveAddressesHiddenNode() void ServerPage::updateOutProxyIndicator() { + MainWindow::getInstance()->torstatusReset(); QTcpSocket socket ; // Tor @@ -1373,22 +1375,39 @@ void ServerPage::updateOutProxyIndicator() ui.iconlabel_tor_outgoing->setToolTip(tr("Tor proxy is not enabled")) ; } - // I2P - SAM - // Note: there is only "the SAM port", there is no additional proxy port! - samStatus ss; - rsAutoProxyMonitor::taskSync(autoProxyType::I2PSAM3, autoProxyTask::status, &ss); - if(ss.state == samStatus::samState::online) + if (mHiddenType == RS_HIDDEN_TYPE_I2P && mSamSettings.enable) { - socket.disconnectFromHost(); - ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; - ui.iconlabel_i2p_outgoing->setToolTip(tr("Proxy seems to work.")) ; + // I2P - SAM + // Note: there is only "the SAM port", there is no additional proxy port! + samStatus ss; + rsAutoProxyMonitor::taskSync(autoProxyType::I2PSAM3, autoProxyTask::status, &ss); + if(ss.state == samStatus::samState::online) + { + socket.disconnectFromHost(); + ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; + ui.iconlabel_i2p_outgoing->setToolTip(tr("Proxy seems to work.")) ; + } + else + { + ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; + ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ; + } } else { - ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; - ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ; + socket.connectToHost(ui.hiddenpage_proxyAddress_i2p->text(),ui.hiddenpage_proxyPort_i2p->text().toInt()); + if(socket.waitForConnected(500)) + { + socket.disconnectFromHost(); + ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; + ui.iconlabel_i2p_outgoing->setToolTip(tr("Proxy seems to work.")) ; + } + else + { + ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; + ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ; + } } - socket.connectToHost(ui.hiddenpage_proxyAddress_i2p_2->text(), 7656); if(true == (mSamAccessible = socket.waitForConnected(1000))) { diff --git a/retroshare-gui/src/gui/statusbar/torstatus.cpp b/retroshare-gui/src/gui/statusbar/torstatus.cpp index fdde22337..d43de1df3 100644 --- a/retroshare-gui/src/gui/statusbar/torstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/torstatus.cpp @@ -168,7 +168,7 @@ void TorStatus::getTorStatus() torstatusLabel->setToolTip( text + tr("Tor proxy is not available")); } } - if(hiddentype == RS_HIDDEN_TYPE_I2P) + else if(hiddentype == RS_HIDDEN_TYPE_I2P) { statusTor->setText("" + tr("I2P") + ":"); rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status); @@ -185,6 +185,11 @@ void TorStatus::getTorStatus() torstatusLabel->setToolTip( text + tr("i2p proxy is not available")); } } + else + { + torstatusLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/icons/tile_inactive_48.png").scaledToHeight(S,Qt::SmoothTransformation)); + torstatusLabel->setToolTip(tr("No tor configuration")); + } _updated = true; } }