bridgedb.Main

This module sets up BridgeDB and starts the servers running.

load(state, hashring, clear=False)[source]

Read and parse all descriptors, and load into a bridge hashring.

Read all the appropriate bridge files from the saved State, parse and validate them, and then store them into our state.hashring instance. The state will be saved again at the end of this function.

Parameters:
  • hashring (BridgeSplitter) – A class which provides a mechanism for HMACing Bridges in order to assign them to hashrings.
  • clear (boolean) – If True, clear all previous bridges from the hashring before parsing for new ones.
_reloadFn(*args)[source]

Placeholder callback function for _handleSIGHUP().

_handleSIGHUP(*args)[source]

Called when we receive a SIGHUP; invokes _reloadFn.

_handleSIGUSR1(*args)[source]

Handler for SIGUSR1. Calls doDumpBridges().

replaceBridgeRings(current, replacement)[source]

Replace the current thing with the new one

createBridgeRings(cfg, proxyList, key)[source]

Create the bridge distributors defined by the config file

Parameters:
  • cfg (Conf) – The current configuration, including any in-memory settings (i.e. settings whose values were not obtained from the config file, but were set via a function somewhere)
  • proxyList (ProxySet) – The container for the IP addresses of any currently known open proxies.
  • key (bytes) – Hashring master key
Return type:

tuple

Returns:

A BridgeSplitter hashring, an HTTPSDistributor or None, and an EmailDistributor or None.

run(options, reactor=<twisted.internet.epollreactor.EPollReactor object>)[source]

This is BridgeDB’s main entry point and main runtime loop.

Given the parsed commandline options, this function handles locating the configuration file, loading and parsing it, and then either (re)parsing plus (re)starting the servers, or dumping bridge assignments to files.

Parameters:
Variables:

state – A persistent state object which holds config changes.

runSubcommand(options, config)[source]

Run a subcommand from the ‘Commands’ section of the bridgedb help menu.

Parameters:
  • options (bridgedb.opt.MainOptions) – A pre-parsed options class containing any arguments and options given in the commandline we were called with.
  • config (bridgedb.Main.Conf) – The current configuration.
Raises:

SystemExit when all subCommands and subOptions have finished running.