added parameter to supply user defined tor executable path

This commit is contained in:
csoler 2022-11-02 21:00:24 +01:00
parent 1474dfdd66
commit 486aa83680

View File

@ -47,10 +47,12 @@ int main(int argc, char* argv[])
//RsControl::earlyInitNotificationSystem();
std::string base_directory = "FSData";
std::string tor_executable_path ;
argstream as(argc,argv);
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 )
>> help( 'h', "help", "Display this Help" );
as.defaultErrorHandling(true, true);
@ -58,6 +60,9 @@ int main(int argc, char* argv[])
RsConfigOptions conf;
conf.main_executable_path = argv[0];
if(!tor_executable_path.empty())
RsTor::setTorExecutablePath(tor_executable_path);
RsInit::InitRsConfig();
RsInit::InitRetroShare(conf);
@ -68,6 +73,17 @@ int main(int argc, char* argv[])
RsErr() << "Cannot create base directory \"" << base_directory << "\". Check permissions, paths, etc." ;
return 1;
}
// Check the existance of the Tor executable path
if (!RsDirUtil::fileExists(RsTor::torExecutablePath()))
{
RsErr() << "Tor executable not found. Try supplying the full path for tor executable with the -t option.";
return 1;
}
else
RsDbg() << "Using Tor executable: \"" << RsTor::torExecutablePath() << "\"";
// Create/start TorManager
RsTor::setTorDataDirectory(RsDirUtil::makePath(base_directory,"tor"));