#28737 closed defect (wontfix)

Redesign sbws torrc option configuration

Reported by: teor Owned by:
Priority: Medium Milestone: sbws: unspecified
Component: Core Tor/sbws Version:
Severity: Normal Keywords: changes-version-major, sbws-11x-final-removed-20190312, tech-debt, refactor, config
Cc: juga, teor Actual Points:
Parent ID: #28684 Points: 1
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'),
          # 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'),
              # 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 (9)

comment:1 Changed 23 months 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 23 months 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 23 months ago by teor

Description: modified (diff)

Tweak the spec.

comment:4 Changed 20 months ago by juga

Keywords: no-changes-version added

Add keyword to help planify releases/milestones.
Tickets that doesn't imply a change of version are tickets which do not affect the code (docs, tests) and some time of refactors.

comment:5 Changed 20 months ago by juga

Keywords: sbws-11x-final-removed-20190312 added
Milestone: sbws: 1.1.x-finalsbws: unspecified

Remove tickets from 11x-final that can be implemented next month

comment:6 Changed 20 months ago by juga

Keywords: changes-version-major added; no-changes-version removed
Parent ID: #28684
Points: 1

comment:7 Changed 20 months ago by juga

Keywords: tech-debt refactor added

Add keywords

comment:8 Changed 19 months ago by juga

Keywords: config added

comment:9 Changed 18 months ago by teor

Resolution: wontfix
Status: newclosed

This is too complicated: what we have works right now.

Note: See TracTickets for help on using tickets.