From 69f6adb6b490c7386925b3bf70ccaf2c730d183e Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 10 Jan 2022 17:48:33 +0100 Subject: [PATCH] added ifdef and option to enable/disable embeded friend server --- libretroshare/src/libretroshare.pro | 24 ++++--- libretroshare/src/rsserver/rsinit.cc | 5 ++ .../src/gui/FriendServerControl.cpp | 63 ++++++++++++------- retroshare-gui/src/gui/FriendServerControl.h | 1 + retroshare-gui/src/gui/FriendServerControl.ui | 43 +++++++++++-- retroshare-gui/src/gui/FriendsDialog.cpp | 2 + retroshare-gui/src/retroshare-gui.pro | 10 ++- 7 files changed, 110 insertions(+), 38 deletions(-) diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 49c16227f..585c9af67 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -147,7 +147,6 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \ retroshare/rsrtt.h \ retroshare/rsconfig.h \ retroshare/rsversion.h \ - retroshare/rsfriendserver.h \ retroshare/rsservicecontrol.h \ retroshare/rsgxsdistsync.h @@ -409,10 +408,6 @@ HEADERS += pqi/authssl.h \ pqi/pqinetstatebox.h \ pqi/p3servicecontrol.h -SOURCES += friend_server/fsclient.h \ - friend_server/fsitem.h \ - friend_server/fsmanager.h - HEADERS += rsserver/p3face.h \ rsserver/p3history.h \ rsserver/p3msgs.h \ @@ -582,9 +577,6 @@ SOURCES += pqi/authgpg.cc \ pqi/pqinetstatebox.cc \ pqi/p3servicecontrol.cc -SOURCES += friend_server/fsclient.cc \ - friend_server/fsmanager.cc - SOURCES += rsserver/p3face-config.cc \ rsserver/p3face-server.cc \ rsserver/p3face-info.cc \ @@ -842,6 +834,22 @@ wikipoos { rsitems/rswikiitems.cc \ } +# Friend server + +rs_efs { + DEFINES *= RS_EMBEDED_FRIEND_SERVER + + HEADERS += friend_server/fsclient.h \ + friend_server/fsitem.h \ + friend_server/fsmanager.h \ + retroshare/rsfriendserver.h + + SOURCES += friend_server/fsclient.cc \ + friend_server/fsmanager.cc +} + +# The Wire + gxsthewire { DEFINES *= RS_USE_WIRE diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 2417cd69e..5729b552c 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -51,7 +51,10 @@ #include "retroshare/rsversion.h" #include "rsserver/rsloginhandler.h" #include "rsserver/rsaccounts.h" + +#ifdef RS_EMBEDED_FRIEND_SERVER #include "friend_server/fsmanager.h" +#endif #include #include @@ -1176,8 +1179,10 @@ int RsServer::StartupRetroShare() serviceCtrl->setServiceServer(pqih) ; +#ifdef RS_EMBEDED_FRIEND_SERVER // setup friend server rsFriendServer = new FriendServerManager(); +#endif /****** New Ft Server **** !!! */ ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl); diff --git a/retroshare-gui/src/gui/FriendServerControl.cpp b/retroshare-gui/src/gui/FriendServerControl.cpp index 50c98217d..5598ff477 100644 --- a/retroshare-gui/src/gui/FriendServerControl.cpp +++ b/retroshare-gui/src/gui/FriendServerControl.cpp @@ -23,6 +23,7 @@ #include #include "retroshare/rsfriendserver.h" +#include "retroshare/rstor.h" #include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" @@ -36,6 +37,7 @@ /** Constructor */ FriendServerControl::FriendServerControl(QWidget *parent) + : QWidget(parent) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -66,6 +68,18 @@ FriendServerControl::FriendServerControl(QWidget *parent) serverStatusCheckResult_LB->setMovie(mCheckingServerMovie); updateFriendServerStatusIcon(false); + updateTorProxyInfo(); +} + +void FriendServerControl::updateTorProxyInfo() +{ + std::string friend_proxy_address; + uint16_t friend_proxy_port; + + RsTor::getProxyServerInfo(friend_proxy_address,friend_proxy_port); + + torProxyPort_SB->setValue(friend_proxy_port); + torProxyAddress_LE->setText(QString::fromStdString(friend_proxy_address)); } FriendServerControl::~FriendServerControl() @@ -83,34 +97,39 @@ void FriendServerControl::onOnOffClick(bool b) } void FriendServerControl::onOnionPortEdit(int) { - // 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(); - } +#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()); } 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(); - } +// 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()); } void FriendServerControl::checkServerAddress() diff --git a/retroshare-gui/src/gui/FriendServerControl.h b/retroshare-gui/src/gui/FriendServerControl.h index d453d37bc..f02c8dadc 100644 --- a/retroshare-gui/src/gui/FriendServerControl.h +++ b/retroshare-gui/src/gui/FriendServerControl.h @@ -37,6 +37,7 @@ protected slots: void onOnionAddressEdit(const QString&); void onOnionPortEdit(int); void onNbFriendsToRequestsChanged(int n); + void updateTorProxyInfo(); private: void checkServerAddress(); diff --git a/retroshare-gui/src/gui/FriendServerControl.ui b/retroshare-gui/src/gui/FriendServerControl.ui index d00ae32e0..73a5625d6 100644 --- a/retroshare-gui/src/gui/FriendServerControl.ui +++ b/retroshare-gui/src/gui/FriendServerControl.ui @@ -73,7 +73,20 @@ - 127.0.0.1 + .onion + + + + + + + 1025 + + + 65536 + + + 2017 @@ -98,23 +111,43 @@ - Server port: + Tor proxy address: - + + + 127.0.0.1 + + + + + 1025 - 65536 + 65535 - 2017 + 9050 + + + + Qt::Horizontal + + + + 40 + 20 + + + + diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 5e896af02..5e0ba533d 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -89,7 +89,9 @@ FriendsDialog::FriendsDialog(QWidget *parent) : MainPage(parent) ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME); ui.tabWidget->setTabPosition(QTabWidget::North); +#ifdef RS_EMBEDED_FRIEND_SERVER ui.tabWidget->addTab(friendServerControl = new FriendServerControl(),QIcon(IMAGE_PEERS), tr("Friend Server")); +#endif ui.tabWidget->addTab(networkView = new NetworkView(),QIcon(IMAGE_NETWORK2), tr("Network graph")); ui.tabWidget->addTab(networkDialog = new NetworkDialog(),QIcon(IMAGE_PEERS), tr("Keyring")); diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 4c6ec6dc8..26ac5b43a 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -383,7 +383,6 @@ HEADERS += rshare.h \ gui/AboutDialog.h \ gui/AboutWidget.h \ gui/NetworkView.h \ - gui/FriendServerControl.h \ gui/FriendsDialog.h \ gui/ServicePermissionDialog.h \ gui/RemoteDirModel.h \ @@ -648,7 +647,6 @@ FORMS += gui/StartDialog.ui \ gui/FileTransfer/BannedFilesDialog.ui \ gui/MainWindow.ui \ gui/NetworkView.ui \ - gui/FriendServerControl.ui \ gui/FriendsDialog.ui \ gui/ShareManager.ui \ # gui/ShareDialog.ui \ @@ -769,7 +767,6 @@ SOURCES += main.cpp \ gui/mainpagestack.cpp \ gui/MainWindow.cpp \ gui/NetworkView.cpp \ - gui/FriendServerControl.cpp \ gui/FriendsDialog.cpp \ gui/ServicePermissionDialog.cpp \ gui/RemoteDirModel.cpp \ @@ -1092,6 +1089,13 @@ DEFINES *= CHANNELS_FRAME_CATCHER } +# Embedded Friend Server + +rs_efs { + SOURCES += gui/FriendServerControl.cpp + HEADERS += gui/FriendServerControl.h + FORMS += gui/FriendServerControl.ui +} # BELOW IS GXS Unfinished Services.