Opened 6 weeks ago

Last modified 6 weeks ago

#28737 new defect

Redesign sbws torrc option configuration

Reported by: teor Owned by:
Priority: Medium Milestone: sbws: 1.1.x-final
Component: Core Tor/sbws Version:
Severity: Normal Keywords:
Cc: juga, teor Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description (last modified by teor)

sbws' torrc option handling is broken.

Here's a better scheme:

  1. sbws config.default.ini and config.ini contain the following sections:
    • tor.options.launch: a minimal set of options that must be configured when tor is launched. The minimal set contains the data directory config, control config, and log config. The network is disabled at launch. The initial options are:
          'DataDirectory': conf.getpath('tor', 'datadir'),
          'PidFile': conf.getpath('tor', 'pid'),
          # Because we need things from full server descriptors (namely for now: the
          # bandwidth line)
          'UseMicrodescriptors': '0',
      
          'ControlSocket': conf.getpath('tor', 'control_socket'),
          # Easier than password authentication
          'CookieAuthentication': '1',
      
          'Log': [
              'NOTICE file {}'.format(os.path.join(conf.getpath('tor', 'log'),
                                                   'notice.log')),
          ],
          # useful logging options for clients that don't care about anonymity
          'SafeLogging': '0',
          'LogTimeGranularity': '1',
          'ProtocolWarnings': '1',
      
          'DisableNetwork': '1',
      
    • tor.options.runtime.(group_name): Zero or more groups of tor options that can be set at runtime. The network is enabled at runtime. The "50-default" group of options is:
          # We will find out via the ControlPort and not setting something static
          # means a lower chance of conflict
          'SocksPort': 'auto',
      
          # To avoid path bias warnings
          'UseEntryGuards': '0',
      
          c.set_conf('__LeaveStreamsUnattached', '1')
      
          # Things needed to make circuits fail a little faster. We get the
          # circuit_timeout as a string instead of an int on purpose: stem only
          # accepts strings.
          'LearnCircuitBuildTimeout': '0',
          'CircuitBuildTimeout': conf['general']['circuit_timeout'],
      
          'DisableNetwork': '0',
      
    • Zero or more tor.runtime.ignore_failure.(group name): tor options that are set in groups at runtime, but ignored if they fail. #28692 and #28694 will add options to this list.

Options in config.ini override options with the same name in sbws.default.ini, with + and / having the same meaning as in a torrc file (+ appends, / removes). Launch options are applied first, then runtime options are applied in group name order. Tor will make later runtime options replace earlier runtime options, and launch options.

  1. sbws gets its control socket from the launch_options ControlSocket option(s)
  2. sbws gets its data directory, pid, log(s), and circuit build timeout using GETCONF
  1. For backwards compatibility:
    • if tor.extra_lines is present, it should be appended to tor.options.launch. sbws' option merging code never worked, so appending shouldn't cause any more issues than the existing code.
    • if any of these sbws options are present in an old config file, synthesise options.launch from the sbws options. If options.launch is also present in the same config file, it overrides the synthetic options. (sbws' option merging never worked for these options.)
              'DataDirectory': conf.getpath('tor', 'datadir'),
              'PidFile': conf.getpath('tor', 'pid'),
              'ControlSocket': conf.getpath('tor', 'control_socket'),
              'Log': [
                  'NOTICE file {}'.format(os.path.join(conf.getpath('tor', 'log'),
                                                       'notice.log')),
              ],
              # Things needed to make circuits fail a little faster. We get the
              # circuit_timeout as a string instead of an int on purpose: stem only
              # accepts strings.
              'CircuitBuildTimeout': conf['general']['circuit_timeout'],
      

The final option order is:

  • sbws creates options.launch, using the last option from:
    • synthetic legacy config options from config.default.ini
    • options.launch from config.default.ini
    • synthetic legacy config options from config.ini
    • options.launch from config.ini
  • sbws appends extra_lines to options.launch, using the last extra_lines from:
    • config.default.ini
    • config.ini
  • sbws creates options.runtime groups, using the last one of each group from:
    • config.default.ini
    • config.ini

sbws launches tor with options.launch, then applies each group of options.runtime in order.

This is a new feature, so it should go in sbws 1.1.

Child Tickets

Change History (3)

comment:1 Changed 6 weeks ago by teor

We could use defaults-torrc and torrc, but:

  • we would break backwards compatibility
  • tor can't ignore failures in torrc files

comment:2 Changed 6 weeks ago by teor

We should test the torrc options before and after this change, to make sure we haven't missed any.

comment:3 Changed 6 weeks ago by teor

Description: modified (diff)

Tweak the spec.

Note: See TracTickets for help on using tickets.