From 03a576589e701deb08957cfafd39c5e807c91ba8 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 7 Nov 2022 21:10:55 +0100 Subject: [PATCH] allow user to supply his own Tor executable --- retroshare-gui/src/main.cpp | 6 ++++- retroshare-service/src/retroshare-service.cc | 23 +++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 82d78d2b2..2d3fabf89 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -239,7 +239,8 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); >> parameter('d',"debug-level" ,conf.debugLevel ,"level" ,"Set debug level." ,false) >> parameter('i',"ip-address" ,conf.forcedInetAddress,"nnn.nnn.nnn.nnn", "Force IP address to use (if cannot be detected)." ,false) >> parameter('p',"port" ,conf.forcedPort ,"port" ,"Set listenning port to use." ,false) - >> parameter('o',"opmode" ,conf.opModeStr ,"opmode" ,"Set Operating mode (Full, NoTurtle, Gaming, Minimal)." ,false); + >> parameter('o',"opmode" ,conf.opModeStr ,"opmode" ,"Set Operating mode (Full, NoTurtle, Gaming, Minimal)." ,false) + >> parameter('t',"opmode" ,conf.userSuppliedTorExecutable,"tor" ,"supply full tor eecutable path." ,false); #ifdef RS_JSONAPI as >> parameter('J', "jsonApiPort", conf.jsonApiPort, "jsonApiPort", "Enable JSON API on the specified port", false ) >> parameter('P', "jsonApiBindAddress", conf.jsonApiBindAddress, "jsonApiBindAddress", "JSON API Bind Address.", false); @@ -393,6 +394,9 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); if(is_auto_tor) { + if(!conf.userSuppliedTorExecutable.empty()) + RsTor::setTorExecutablePath(conf.userSuppliedTorExecutable); + // Now that we know the Tor service running, and we know the SSL id, we can make sure it provides a viable hidden service std::string tor_hidden_service_dir = RsAccounts::AccountDirectory() + "/hidden_service/" ; diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index 2390739fd..040a2012d 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -126,19 +126,13 @@ int main(int argc, char* argv[]) "output to stderr instead of log file." ) >> option( 'u',"udp", conf.udpListenerOnly, "Only listen to UDP." ) - >> parameter( 'c',"base-dir", conf.optBaseDir, "directory", - "Set base directory.", false ) - >> parameter( 'l', "log-file", conf.logfname, "logfile", - "Set Log filename.", false ) - >> parameter( 'd', "debug-level", conf.debugLevel, "level", - "Set debug level.", false ) - >> parameter( 'i', "ip-address", conf.forcedInetAddress, "IP", - "Force IP address to use (if cannot be detected).", false ) - >> parameter( 'o', "opmode", conf.opModeStr, "opmode", - "Set Operating mode (Full, NoTurtle, Gaming, Minimal).", - false ) - >> parameter( 'p', "port", conf.forcedPort, "port", - "Set listenning port to use.", false ); + >> parameter( 'c',"base-dir", conf.optBaseDir, "directory", "Set base directory.", false ) + >> parameter( 'l', "log-file", conf.logfname, "logfile", "Set Log filename.", false ) + >> parameter( 'd', "debug-level", conf.debugLevel, "level", "Set debug level.", false ) + >> parameter( 'i', "ip-address", conf.forcedInetAddress, "IP", "Force IP address to use (if cannot be detected).", false ) + >> parameter( 'o', "opmode", conf.opModeStr, "opmode", "Set Operating mode (Full, NoTurtle, Gaming, Minimal).", false ) + >> parameter( 'p', "port", conf.forcedPort, "port", "Set listenning port to use.", false ) + >> parameter( 't', "tor", conf.userSuppliedTorExecutable, "tor", "Set Tor executable full path.", false ); #ifdef RS_SERVICE_TERMINAL_LOGIN as >> parameter( 'U', "user-id", prefUserString, "ID", @@ -176,6 +170,9 @@ int main(int argc, char* argv[]) as >> help( 'h', "help", "Display this Help" ); as.defaultErrorHandling(true, true); + if(!conf.userSuppliedTorExecutable.empty()) + RsTor::setTorExecutablePath(conf.userSuppliedTorExecutable); + #if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) std::string webui_pass1; if(askWebUiPassword)