commit 200d85fea08b2d0bee258560dd47bb59191051ed Author: Ana Custura ana@netstat.org.uk Date: Mon Mar 4 16:39:32 2019 +0100
Splits tor configuration into its own function --- onionperf/measurement.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/onionperf/measurement.py b/onionperf/measurement.py index 17cc399..a30b7e3 100644 --- a/onionperf/measurement.py +++ b/onionperf/measurement.py @@ -347,6 +347,12 @@ class Measurement(object):
return tgen_writable
+ def __create_tor_config(self, control_port, socks_port, tor_datadir): + tor_config_template = self.base_config + "RunAsDaemon 0\nORPort 0\nDirPort 0\nControlPort {0}\nSocksPort {1}\nSocksListenAddress 127.0.0.1\nClientOnly 1\n\ +WarnUnsafeSocks 0\nSafeLogging 0\nMaxCircuitDirtiness 60 seconds\nUseEntryGuards 0\nDataDirectory {2}\nLog INFO stdout\n" + tor_config = tor_config_template.format(control_port, socks_port, tor_datadir) + return tor_config + def __start_tor_client(self, control_port, socks_port): return self.__start_tor("client", control_port, socks_port)
@@ -355,14 +361,10 @@ class Measurement(object):
def __start_tor(self, name, control_port, socks_port, hs_port_mapping=None): logging.info("Starting Tor {0} process with ControlPort={1}, SocksPort={2}...".format(name, control_port, socks_port)) - tor_datadir = "{0}/tor-{1}".format(self.datadir_path, name) - if not os.path.exists(tor_datadir): os.makedirs(tor_datadir) - - tor_config_template = self.base_config + "RunAsDaemon 0\nORPort 0\nDirPort 0\nControlPort {0}\nSocksPort {1}\nSocksListenAddress 127.0.0.1\nClientOnly 1\n\ -WarnUnsafeSocks 0\nSafeLogging 0\nMaxCircuitDirtiness 60 seconds\nUseEntryGuards 0\nDataDirectory {2}\nLog INFO stdout\n" - tor_config = tor_config_template.format(control_port, socks_port, tor_datadir)
+ if not os.path.exists(tor_datadir): os.makedirs(tor_datadir) + tor_config = self.__create_tor_config(control_port,socks_port,tor_datadir) tor_logpath = "{0}/onionperf.tor.log".format(tor_datadir) tor_writable = util.FileWritable(tor_logpath) logging.info("Logging Tor {0} process output to {1}".format(name, tor_logpath))
tor-commits@lists.torproject.org