[tor-commits] [arm/release] Dropping "/s" when making torrc for rates

atagar at torproject.org atagar at torproject.org
Sun Jul 17 06:08:32 UTC 2011


commit ec0cdb0f1499910fc85337ac20c2ab6352578cb6
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Jul 9 18:25:12 2011 -0700

    Dropping "/s" when making torrc for rates
    
    The wizard shows bandwidth rates (for instance "5 MB/s") but the torrc just
    wants the volume part. Dropping the "/s" for RelayBandwidthRate and
    RelayBandwidthBurst.
---
 src/cli/wizard.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/cli/wizard.py b/src/cli/wizard.py
index cf544a5..8aa1a23 100644
--- a/src/cli/wizard.py
+++ b/src/cli/wizard.py
@@ -493,14 +493,21 @@ 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"):
+      value = value[:-2]
+    
     templateOptions[key.upper()] = value
   
   templateOptions[relayType.upper()] = True
   templateOptions["LOW_PORTS"] = config[Options.LOWPORTS]
   
   # uses double the relay rate for bursts
-  relayRateComp = config[Options.BANDWIDTH].getValue().split(" ")
-  templateOptions["BURST"] = "%i %s" % (int(relayRateComp[0]) * 2, " ".join(relayRateComp[1:]))
+  bwOpt = Options.BANDWIDTH.upper()
+  
+  if templateOptions[bwOpt] != TOR_DEFAULTS[Options.BANDWIDTH]:
+    relayRateComp = templateOptions[bwOpt].split(" ")
+    templateOptions["BURST"] = "%i %s" % (int(relayRateComp[0]) * 2, " ".join(relayRateComp[1:]))
   
   # exit notice will be in our data directory
   dataDir = cli.controller.getController().getDataDirectory()





More information about the tor-commits mailing list