commit f9a9d9614cd09466e490a71c5e1f3f5b44a9375c Author: Nick Mathewson nickm@torproject.org Date: Tue May 14 14:01:27 2019 -0400
Allow nodes to be configured and launched by phase.
We're going to need this for obfs4, for which we cannot initialize the client until the bridge has been running long enough to generate its keys. --- lib/chutney/TorNet.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py index e2fc613..1e7b1e4 100644 --- a/lib/chutney/TorNet.py +++ b/lib/chutney/TorNet.py @@ -922,6 +922,15 @@ DEFAULTS = { 'dns_conf': (os.environ.get('CHUTNEY_DNS_CONF', '/etc/resolv.conf') if 'CHUTNEY_DNS_CONF' in os.environ else None), + + # The phase at which this instance needs to be + # configured/launched, if we're doing multiphase + # configuration/launch. + 'config_phase' : 1, + 'launch_phase' : 1, + + 'CUR_CONFIG_PHASE': getenv_int('CHUTNEY_CONFIG_PHASE', 1), + 'CUR_LAUNCH_PHASE': getenv_int('CHUTNEY_LAUNCH_PHASE', 1), }
@@ -1148,17 +1157,21 @@ class Network(object): n.getBuilder().checkConfig(self)
def configure(self): - self.create_new_nodes_dir() + phase = self._dfltEnv['CUR_CONFIG_PHASE'] + if phase == 1: + self.create_new_nodes_dir() network = self altauthlines = [] bridgelines = [] - builders = [n.getBuilder() for n in self._nodes] + all_builders = [ n.getBuilder() for n in self._nodes ] + builders = [ b for b in all_builders + if b._env['config_phase'] == phase ] self._checkConfig()
# XXX don't change node names or types or count if anything is # XXX running!
- for b in builders: + for b in all_builders: b.preConfig(network) altauthlines.append(b._getAltAuthLines( self._dfltEnv['hasbridgeauth'])) @@ -1188,7 +1201,9 @@ class Network(object): # format polling correctly - avoid printing a newline sys.stdout.write("Starting nodes") sys.stdout.flush() - rv = all([n.getController().start() for n in self._nodes]) + rv = all([n.getController().start() for n in self._nodes + if n._env['launch_phase'] == + self._dfltEnv['CUR_LAUNCH_PHASE']]) # now print a newline unconditionally - this stops poll()ing # output from being squashed together, at the cost of a blank # line in wait()ing output