improved debug outpug of friendserver code

This commit is contained in:
csoler 2023-05-25 21:35:12 +02:00
parent 578cafe1e2
commit 238c6eda9f

View File

@ -27,6 +27,7 @@
#include "retroshare/rstor.h" #include "retroshare/rstor.h"
#include "retroshare/rsinit.h" #include "retroshare/rsinit.h"
#include "pqi/authgpg.h"
#include "friendserver.h" #include "friendserver.h"
@ -48,24 +49,31 @@ int main(int argc, char* argv[])
std::string base_directory = "FSData"; std::string base_directory = "FSData";
std::string tor_executable_path ; std::string tor_executable_path ;
bool verbose = false;
argstream as(argc,argv); argstream as(argc,argv);
as >> parameter( 'c',"base-dir", base_directory, "set base directory to store data files (keys, etc)", false ) as >> parameter( 'c',"base-dir", base_directory, "set base directory to store data files (keys, etc)", false )
>> parameter( 't',"tor-executable", tor_executable_path, "set absolute path for tor executable", false ) >> parameter( 't',"tor-executable", tor_executable_path, "set absolute path for tor executable", false )
>> option( 'v',"verbose", verbose, "display additional debug information")
>> help( 'h', "help", "Display this Help" ); >> help( 'h', "help", "Display this Help" );
as.defaultErrorHandling(true, true); as.defaultErrorHandling(true, true);
RsConfigOptions conf; RsConfigOptions conf;
conf.optBaseDir = base_directory;
conf.main_executable_path = argv[0]; conf.main_executable_path = argv[0];
if(!tor_executable_path.empty()) if(!tor_executable_path.empty())
RsTor::setTorExecutablePath(tor_executable_path); RsTor::setTorExecutablePath(tor_executable_path);
RsTor::setVerbose(verbose);
RsInit::InitRsConfig(); RsInit::InitRsConfig();
RsInit::InitRetroShare(conf); RsInit::InitRetroShare(conf);
AuthPGP::exit(); // This allows to release the keyring created by libretroshare, since it's not useful, as TorManager has its own.
// Create the base directory if needed // Create the base directory if needed
if(!RsDirUtil::checkCreateDirectory(base_directory)) if(!RsDirUtil::checkCreateDirectory(base_directory))
@ -107,22 +115,22 @@ int main(int argc, char* argv[])
RsTor::getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,target_port) ; RsTor::getHiddenServiceInfo(service_id,onion_address,service_port,service_target_address,target_port) ;
RsDbg() << "Tor properly started: " ; RsInfo() << "Tor properly started: " ;
RsDbg() << " Hidden service address: " << onion_address << ":" << service_port; RsInfo() << " Hidden service address: " << onion_address << ":" << service_port;
RsDbg() << " Target address : " << service_target_address << ":" << target_port; RsInfo() << " Target address : " << service_target_address << ":" << target_port;
// Now start the real thing. // Now start the real thing.
FriendServer fs(base_directory,service_target_address,target_port); FriendServer fs(base_directory,service_target_address,target_port);
fs.start(); fs.start();
RsDbg() << ""; RsInfo() << "";
RsDbg() << "================== Retroshare Friend Server has properly started =====================" ; RsInfo() << "================== Retroshare Friend Server has properly started =====================" ;
RsDbg() << "= ="; RsInfo() << "= =";
RsDbg() << "= Address:Port " << onion_address << ":" << service_port << ((service_port<10000)?" ":"") << " ="; RsInfo() << "= Address:Port " << onion_address << ":" << service_port << ((service_port<10000)?" ":"") << " =";
RsDbg() << "= ="; RsInfo() << "= =";
RsDbg() << "======================================================================================" ; RsInfo() << "======================================================================================" ;
RsDbg() << ""; RsInfo() << "";
while(fs.isRunning()) while(fs.isRunning())
std::this_thread::sleep_for(std::chrono::seconds(2)); std::this_thread::sleep_for(std::chrono::seconds(2));