commit 9d473588c4aedcbc6832a4c3927210b876c5d4c9 Author: Damian Johnson atagar@torproject.org Date: Sun Jul 10 17:29:31 2011 -0700
Copying exit notice to data dir when needed
If running an exit with an exit notice then copies the notice (an html file and image) to the data directory. --- src/cli/wizard.py | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/cli/wizard.py b/src/cli/wizard.py index 6539a82..9b8c1d7 100644 --- a/src/cli/wizard.py +++ b/src/cli/wizard.py @@ -295,12 +295,26 @@ def showWizard(): torrcFile.write(generatedTorrc) torrcFile.close()
+ # copies exit notice into data directory if it's being used + if Options.NOTICE in RelayOptions[relayType] and config[Options.NOTICE].getValue() and config[Options.LOWPORTS].getValue(): + dataDir = cli.controller.getController().getDataDirectory() + + pathPrefix = os.path.dirname(sys.argv[0]) + if pathPrefix and not pathPrefix.endswith("/"): + pathPrefix = pathPrefix + "/" + + src = "%sresources/exitNotice" % pathPrefix + dst = "%sexitNotice" % dataDir + + if not os.path.exists(dst): + shutil.copytree(src, dst) + # If we're connected to a managed instance then just need to # issue a sighup to pick up the new settings. Otherwise starts # a new tor instance.
conn = torTools.getConn() - if manager.isManaged(conn): conn.reset() + if manager.isManaged(conn): conn.reload() else: manager.startManagedInstance()
break @@ -490,9 +504,12 @@ def getTorrc(relayType, config): if isinstance(value, ConfigOption): value = value.getValue()
- # truncates "/s" from the rate for RelayBandwidthRate entry if key == Options.BANDWIDTH and value.endswith("/s"): + # truncates "/s" from the rate for RelayBandwidthRate entry value = value[:-2] + elif key == Options.NOTICE: + # notice option is only applied if using low ports + value &= config[Options.LOWPORTS].getValue()
templateOptions[key.upper()] = value
@@ -508,7 +525,7 @@ def getTorrc(relayType, config):
# exit notice will be in our data directory dataDir = cli.controller.getController().getDataDirectory() - templateOptions["NOTICE_PATH"] = dataDir + "exit-notice.html" + templateOptions["NOTICE_PATH"] = dataDir + "exitNotice/exit-notice.html" templateOptions["LOG_ENTRY"] = "notice file %stor_log" % dataDir
policyCategories = []
tor-commits@lists.torproject.org