From 5ab19eb56409b07f791c2640d0432759aaee9cea Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Jan 2022 21:53:07 +0100 Subject: [PATCH] added testing system for distant Tor server --- libretroshare | 2 +- .../src/gui/FriendServerControl.cpp | 60 +++++++++---------- retroshare-gui/src/retroshare-gui.pro | 1 + 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/libretroshare b/libretroshare index f708e893a..a7a430008 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit f708e893a0cc7d195a53566342bd213973c70176 +Subproject commit a7a430008b76e53727598c4d13106e7ce95221d7 diff --git a/retroshare-gui/src/gui/FriendServerControl.cpp b/retroshare-gui/src/gui/FriendServerControl.cpp index 5598ff477..60f838e62 100644 --- a/retroshare-gui/src/gui/FriendServerControl.cpp +++ b/retroshare-gui/src/gui/FriendServerControl.cpp @@ -61,6 +61,7 @@ FriendServerControl::FriendServerControl(QWidget *parent) QObject::connect(friendServerOnOff_CB,SIGNAL(toggled(bool)),this,SLOT(onOnOffClick(bool))); QObject::connect(torServerFriendsToRequest_SB,SIGNAL(valueChanged(int)),this,SLOT(onFriendsToRequestChanged(int))); QObject::connect(torServerAddress_LE,SIGNAL(textChanged(const QString&)),this,SLOT(onOnionAddressEdit(const QString&))); + QObject::connect(torServerPort_SB,SIGNAL(valueChanged(int)),this,SLOT(onOnionAddressEdit(int))); QObject::connect(mConnectionCheckTimer,SIGNAL(timeout()),this,SLOT(checkServerAddress())); @@ -97,50 +98,47 @@ void FriendServerControl::onOnOffClick(bool b) } void FriendServerControl::onOnionPortEdit(int) { -#warning TODO -// // Setup timer to auto-check the friend server address -// -// mConnectionCheckTimer->setSingleShot(true); -// mConnectionCheckTimer->setInterval(5000); // check in 5 secs unless something is changed in the mean time. -// -// mConnectionCheckTimer->start(); -// -// if(mCheckingServerMovie->fileName() != QString(":/images/loader/circleball-16.gif" )) -// { -// mCheckingServerMovie->setFileName(":/images/loader/circleball-16.gif"); -// mCheckingServerMovie->start(); -// } - rsFriendServer->setServerAddress(torServerAddress_LE->text().toStdString(),torServerPort_SB->value()); - rsFriendServer->setProxyAddress(torProxyAddress_LE->text().toStdString(),torProxyPort_SB->value()); + // Setup timer to auto-check the friend server address + + mConnectionCheckTimer->stop(); + mConnectionCheckTimer->setSingleShot(true); + mConnectionCheckTimer->setInterval(5000); // check in 5 secs unless something is changed in the mean time. + + mConnectionCheckTimer->start(); + + if(mCheckingServerMovie->fileName() != QString(":/images/loader/circleball-16.gif" )) + { + mCheckingServerMovie->setFileName(":/images/loader/circleball-16.gif"); + mCheckingServerMovie->start(); + } } void FriendServerControl::onOnionAddressEdit(const QString&) { // Setup timer to auto-check the friend server address -// mConnectionCheckTimer->setSingleShot(true); -// mConnectionCheckTimer->setInterval(5000); // check in 5 secs unless something is changed in the mean time. -// -// mConnectionCheckTimer->start(); -// -// if(mCheckingServerMovie->fileName() != QString(":/images/loader/circleball-16.gif" )) -// { -// mCheckingServerMovie->setFileName(":/images/loader/circleball-16.gif"); -// mCheckingServerMovie->start(); -// } - rsFriendServer->setServerAddress(torServerAddress_LE->text().toStdString(),torServerPort_SB->value()); - rsFriendServer->setProxyAddress(torProxyAddress_LE->text().toStdString(),torProxyPort_SB->value()); + mConnectionCheckTimer->stop(); + mConnectionCheckTimer->setSingleShot(true); + mConnectionCheckTimer->setInterval(5000); // check in 5 secs unless something is changed in the mean time. + + mConnectionCheckTimer->start(); + + if(mCheckingServerMovie->fileName() != QString(":/images/loader/circleball-16.gif" )) + { + mCheckingServerMovie->setFileName(":/images/loader/circleball-16.gif"); + mCheckingServerMovie->start(); + } } void FriendServerControl::checkServerAddress() { - rsFriendServer->checkServerAddress_async(torServerAddress_LE->text().toStdString(),torServerPort_SB->value(), - [this](const std::string& address,bool test_result) + rsFriendServer->checkServerAddress_async(torServerAddress_LE->text().toStdString(),torServerPort_SB->value(),5000, + [this](const std::string& address,uint16_t port,bool test_result) { if(test_result) - rsFriendServer->setServerAddress(address,1729); + rsFriendServer->setServerAddress(address,port); - RsQThreadUtils::postToObject( [=]() { updateFriendServerStatusIcon(test_result); },this); + RsQThreadUtils::postToObject( [=]() { updateFriendServerStatusIcon(test_result); },this); } ); } diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 53c4835dd..3340e0f0c 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1088,6 +1088,7 @@ DEFINES *= CHANNELS_FRAME_CATCHER # Embedded Friend Server rs_efs { + DEFINES *= RS_EMBEDED_FRIEND_SERVER SOURCES += gui/FriendServerControl.cpp HEADERS += gui/FriendServerControl.h FORMS += gui/FriendServerControl.ui