Merge pull request #2655 from RetroPooh/tor-status-fix

tor status fix for unconfigured, add update on settings change; fix i2p out led status
This commit is contained in:
csoler 2023-03-04 17:18:02 +01:00 committed by GitHub
commit b3dba19b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 12 deletions

View File

@ -1628,6 +1628,10 @@ NATStatus *MainWindow::natstatusInstance()
return natstatus; return natstatus;
} }
void MainWindow::torstatusReset()
{
torstatus->reset();
}
DHTStatus *MainWindow::dhtstatusInstance() DHTStatus *MainWindow::dhtstatusInstance()
{ {
return dhtstatus; return dhtstatus;

View File

@ -187,6 +187,7 @@ public:
RSComboBox *statusComboBoxInstance(); RSComboBox *statusComboBoxInstance();
PeerStatus *peerstatusInstance(); PeerStatus *peerstatusInstance();
NATStatus *natstatusInstance(); NATStatus *natstatusInstance();
void torstatusReset();
DHTStatus *dhtstatusInstance(); DHTStatus *dhtstatusInstance();
HashingStatus *hashingstatusInstance(); HashingStatus *hashingstatusInstance();
DiscStatus *discstatusInstance(); DiscStatus *discstatusInstance();

View File

@ -21,6 +21,7 @@
#include "ServerPage.h" #include "ServerPage.h"
#include <gui/notifyqt.h> #include <gui/notifyqt.h>
#include "gui/MainWindow.h"
#include "rshare.h" #include "rshare.h"
#include "rsharesettings.h" #include "rsharesettings.h"
#include "util/i2pcommon.h" #include "util/i2pcommon.h"
@ -1366,6 +1367,7 @@ void ServerPage::saveAddressesHiddenNode()
void ServerPage::updateOutProxyIndicator() void ServerPage::updateOutProxyIndicator()
{ {
MainWindow::getInstance()->torstatusReset();
QTcpSocket socket ; QTcpSocket socket ;
// Tor // Tor
@ -1382,22 +1384,39 @@ void ServerPage::updateOutProxyIndicator()
ui.iconlabel_tor_outgoing->setToolTip(tr("Tor proxy is not enabled")) ; ui.iconlabel_tor_outgoing->setToolTip(tr("Tor proxy is not enabled")) ;
} }
// I2P - SAM if (mHiddenType == RS_HIDDEN_TYPE_I2P && mSamSettings.enable)
// 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(); // I2P - SAM
ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_OK)) ; // Note: there is only "the SAM port", there is no additional proxy port!
ui.iconlabel_i2p_outgoing->setToolTip(tr("Proxy seems to work.")) ; 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 else
{ {
ui.iconlabel_i2p_outgoing->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ICON_STATUS_UNKNOWN)) ; socket.connectToHost(ui.hiddenpage_proxyAddress_i2p->text(),ui.hiddenpage_proxyPort_i2p->text().toInt());
ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ; 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); socket.connectToHost(ui.hiddenpage_proxyAddress_i2p_2->text(), 7656);
if(true == (mSamAccessible = socket.waitForConnected(1000))) if(true == (mSamAccessible = socket.waitForConnected(1000)))
{ {

View File

@ -168,7 +168,7 @@ void TorStatus::getTorStatus()
torstatusLabel->setToolTip( text + tr("Tor proxy is not available")); torstatusLabel->setToolTip( text + tr("Tor proxy is not available"));
} }
} }
if(hiddentype == RS_HIDDEN_TYPE_I2P) else if(hiddentype == RS_HIDDEN_TYPE_I2P)
{ {
statusTor->setText("<strong>" + tr("I2P") + ":</strong>"); statusTor->setText("<strong>" + tr("I2P") + ":</strong>");
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status); 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")); 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; _updated = true;
} }
} }