[tor-commits] [arm/master] Config options for client section of the wizard

atagar at torproject.org atagar at torproject.org
Fri Jul 1 17:17:27 UTC 2011


commit 3c2d5cbad683174b22f83619aa8c5046d5544627
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Jul 1 10:16:00 2011 -0700

    Config options for client section of the wizard
    
    Client config options include bridging and MaxCircuitDirtiness. It also
    provides a link for preconfigured tor setups:
    http://www.atagar.com/torUsageTips/
---
 src/cli/wizard.py |   41 +++++++++++++++++++++++++++++------------
 src/settings.cfg  |   21 +++++++++++++++++++--
 2 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/src/cli/wizard.py b/src/cli/wizard.py
index c6186e5..79f548e 100644
--- a/src/cli/wizard.py
+++ b/src/cli/wizard.py
@@ -15,7 +15,7 @@ from util import enum, uiTools
 RelayType = enum.Enum("RELAY", "EXIT", "BRIDGE", "CLIENT")
 
 # all options that can be configured
-Options = enum.Enum("DIVIDER", "NICKNAME", "CONTACT", "NOTIFY", "BANDWIDTH", "LIMIT", "CLIENT", "PORTFORWARD", "STARTUP", "NOTICE", "POLICY", "WEBSITES", "EMAIL", "IM", "MISC", "PLAINTEXT", "DISTRIBUTE")
+Options = enum.Enum("DIVIDER", "NICKNAME", "CONTACT", "NOTIFY", "BANDWIDTH", "LIMIT", "CLIENT", "PORTFORWARD", "STARTUP", "NOTICE", "POLICY", "WEBSITES", "EMAIL", "IM", "MISC", "PLAINTEXT", "DISTRIBUTE", "BRIDGED", "BRIDGE1", "BRIDGE2", "BRIDGE3", "REUSE")
 RelayOptions = {RelayType.RELAY:   (Options.NICKNAME,
                                     Options.CONTACT,
                                     Options.NOTIFY,
@@ -46,10 +46,16 @@ RelayOptions = {RelayType.RELAY:   (Options.NICKNAME,
                                     Options.CLIENT,
                                     Options.PORTFORWARD,
                                     Options.STARTUP
-                                   )}
+                                   ),
+                RelayType.CLIENT:  (Options.BRIDGED,
+                                    Options.BRIDGE1,
+                                    Options.BRIDGE2,
+                                    Options.BRIDGE3,
+                                    Options.REUSE)}
 
-# custom exit policy options
+# option sets
 CUSTOM_POLICIES = (Options.WEBSITES, Options.EMAIL, Options.IM, Options.MISC, Options.PLAINTEXT)
+BRIDGE_ENTRIES = (Options.BRIDGE1, Options.BRIDGE2, Options.BRIDGE3)
 
 # other options provided in the prompts
 CANCEL, NEXT, BACK = "Cancel", "Next", "Back"
@@ -61,8 +67,9 @@ DISABLED_COLOR = "cyan"
 
 CONFIG = {"wizard.message.role": "",
           "wizard.message.relay": "",
-          "wizard.message.bridge": "",
           "wizard.message.exit": "",
+          "wizard.message.bridge": "",
+          "wizard.message.client": "",
           "wizard.toggle": {},
           "wizard.suboptions": [],
           "wizard.default": {},
@@ -203,8 +210,15 @@ def showWizard():
   
   # enables custom policies when 'custom' is selected and disables otherwise
   policyOpt = config[Options.POLICY]
-  policyOpt.setValidator(functools.partial(_exitPolicyAction, config))
-  _exitPolicyAction(config, policyOpt, policyOpt.getValue())
+  customPolicies = [config[opt] for opt in CUSTOM_POLICIES]
+  policyOpt.setValidator(functools.partial(_toggleEnabledAction, customPolicies))
+  _toggleEnabledAction(customPolicies, policyOpt, policyOpt.getValue())
+  
+  # enables bridge entries when "Use Bridges" is set and disables otherwise
+  useBridgeOpt = config[Options.BRIDGED]
+  bridgeEntries = [config[opt] for opt in BRIDGE_ENTRIES]
+  useBridgeOpt.setValidator(functools.partial(_toggleEnabledAction, bridgeEntries))
+  _toggleEnabledAction(bridgeEntries, useBridgeOpt, useBridgeOpt.getValue())
   
   # remembers the last selection made on the type prompt page
   relaySelection = RelayType.RELAY
@@ -283,9 +297,6 @@ def promptConfigOptions(relayType, config):
   Prompts the user for the configuration of an internal relay.
   """
   
-  # TODO: skipping section if it isn't ready yet
-  if not relayType in RelayOptions: return NEXT
-  
   topContent = _splitStr(CONFIG.get("wizard.message.%s" % relayType.lower(), ""), 54)
   
   options = [config[opt] for opt in RelayOptions[relayType]]
@@ -395,11 +406,17 @@ def _splitStr(msg, width):
   
   return results
 
-def _exitPolicyAction(config, option, value):
+def _toggleEnabledAction(toggleOptions, option, value):
   """
   Enables or disables custom exit policy options based on our selection.
+  
+  Arguments:
+    toggleOptions - configuration options to be toggled to match our our
+                    selection (ie, true -> enabled, false -> disabled)
+    options       - our config option
+    value         - the value we're being set to
   """
   
-  for opt in CUSTOM_POLICIES:
-    config[opt].setEnabled(not value)
+  for opt in toggleOptions:
+    opt.setEnabled(value)
 
diff --git a/src/settings.cfg b/src/settings.cfg
index f05dd71..aacec0a 100644
--- a/src/settings.cfg
+++ b/src/settings.cfg
@@ -345,25 +345,30 @@ wizard.message.role Welcome to the Tor network! This will step you through the c
 wizard.message.relay Internal relays provide connections within the Tor network. Since you will only be connecting to Tor users and relays this is an easy, hassle free way of helping to make the network better.
 wizard.message.exit Exits connect between the Tor network and the outside Internet. This is the most vitally important role you can take, but it also needs some forethought. Please read 'http://www.atagar.com/torExitTips/' before proceeding further to avoid any nasty surprises!
 wizard.message.bridge Bridges are non-public relays used as stepping stones for censored users for accessing the Tor network.
+wizard.message.client This will make use of the Tor network without contributing to it. For easy, pre-configured setups that will help you to use Tor safely see 'http://www.atagar.com/torUsageTips/'.
 
 wizard.toggle Notify => Yes, No
 wizard.toggle Client => Enabled, Disabled
 wizard.toggle Portforward => Enabled, Disabled
 wizard.toggle Startup => Yes, No
 wizard.toggle Notice => Yes, No
-wizard.toggle Policy => Default, Custom
+wizard.toggle Policy => Custom, Default
 wizard.toggle Websites => Allow, Block
 wizard.toggle Email => Allow, Block
 wizard.toggle Im => Allow, Block
 wizard.toggle Misc => Allow, Block
 wizard.toggle Plaintext => Allow, Block
 wizard.toggle Distribute => Automated, Manual
+wizard.toggle Bridged => Yes, No
 
 wizard.suboptions Websites
 wizard.suboptions Email
 wizard.suboptions Im
 wizard.suboptions Misc
 wizard.suboptions Plaintext
+wizard.suboptions Bridge1
+wizard.suboptions Bridge2
+wizard.suboptions Bridge3
 
 wizard.default Nickname => Unnamed
 wizard.default Notify => true
@@ -372,13 +377,15 @@ wizard.default Startup => true
 wizard.default Client => false
 wizard.default Portforward => true
 wizard.default Notice => true
-wizard.default Policy => true
+wizard.default Policy => false
 wizard.default Websites => true
 wizard.default Email => true
 wizard.default Im => true
 wizard.default Misc => true
 wizard.default Plaintext => true
 wizard.default Distribute => true
+wizard.default Bridged => false
+wizard.default Reuse => 10 minutes
 
 wizard.label.general Cancel => Cancel
 wizard.label.general Back => Previous
@@ -403,6 +410,11 @@ wizard.label.opt Im => Instant Messaging
 wizard.label.opt Misc => Other Services
 wizard.label.opt Plaintext => Unencrypted Traffic
 wizard.label.opt Distribute => Distribution
+wizard.label.opt Bridged => Use Bridges
+wizard.label.opt Bridge1 => First Bridge
+wizard.label.opt Bridge2 => Second Bridge
+wizard.label.opt Bridge3 => Third Bridge
+wizard.label.opt Reuse => Circuit Duration
 
 wizard.description.general Cancel => Close without starting Tor.
 wizard.description.role Relay => Provides interconnections with other Tor relays. This is a safe and easy of making the network better.
@@ -425,6 +437,11 @@ wizard.description.opt Im => Common instant messaging protocols including Jabber
 wizard.description.opt Misc => Protocols from the default policy that aren't among the above.
 wizard.description.opt Plaintext => When blocked the policy will exclude ports that aren't commonly encrypted.
 wizard.description.opt Distribute => If automated then we'll attempt to get your bridge to censored users (email auto-responders, activist networks, etc). Otherwise it'll be up to you to distribute the bridge address to people who need it.
+wizard.description.opt Bridged => If you're being blocked from Tor then bridges provide a stepping stone you can use to connect. To get bridges visit 'https://bridges.torproject.org/' and enter the IP/port into the following entries (for instance "141.201.27.48:443").
+wizard.description.opt Bridge1 => Bridge used to connect to the Tor network.
+wizard.description.opt Bridge2 => Fallback bridge used for connecting if the first is unavailable.
+wizard.description.opt Bridge3 => Fallback bridge used for connecting if neither of the first two are available.
+wizard.description.opt Reuse => Duration that circuits will be reused before replacements are made for new connections. It's good to periodically change the route you use, but making circuits takes a fair bit of work so don't set this to be too low.
 
 # some config options are fetched via special values
 torrc.map HiddenServiceDir => HiddenServiceOptions



More information about the tor-commits mailing list