From cd68031aec2bccad647cda5d1bb82454dfb0e158 Mon Sep 17 00:00:00 2001 From: Matthew Finkel Date: Wed, 13 Nov 2013 23:24:19 +0000 Subject: Use AlternateDirAuthority when Bridge Authority exists in network Setting both DirServer and AlternateBridgeAuthority are incompatible. We should use AlternateDirAuthority when we also have a Bridge Authority. --- lib/chutney/TorNet.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py index c377a03..77e768a 100644 --- a/lib/chutney/TorNet.py +++ b/lib/chutney/TorNet.py @@ -302,7 +302,7 @@ class LocalNodeBuilder(NodeBuilder): assert re.match(r'^[A-F0-9]{40}$', fingerprint) self._env['fingerprint'] = fingerprint - def _getAltAuthLines(self): + def _getAltAuthLines(self, hasbridgeauth=False): """Return a combination of AlternateDirAuthority, AlternateHSAuthority and AlternateBridgeAuthority lines for this Node, appropriately. Non-authorities return "".""" @@ -330,8 +330,10 @@ class LocalNodeBuilder(NodeBuilder): # the 'hs' and 'v3ident' flags set. # XXXX This next line is needed for 'bridges' but breaks # 'basic' - #options = ("AlternateDirAuthority",) - options = ("DirServer",) + if hasbridgeauth: + options = ("AlternateDirAuthority",) + else: + options = ("DirAuthority",) self._env['dirserver_flags'] += " hs v3ident=%s" % v3id authlines = "" @@ -470,6 +472,7 @@ class LocalNodeController(NodeController): DEFAULTS = { 'authority' : False, 'bridgeauthority' : False, + 'hasbridgeauth' : False, 'relay' : False, 'bridge' : False, 'connlimit' : 60, @@ -575,7 +578,8 @@ class Network(object): for b in builders: b.preConfig(network) - altauthlines.append(b._getAltAuthLines()) + altauthlines.append(b._getAltAuthLines( + self._dfltEnv['hasbridgeauth'])) bridgelines.append(b._getBridgeLines()) self._dfltEnv['authorities'] = "".join(altauthlines) @@ -656,6 +660,8 @@ def ConfigureNodes(nodelist): for n in nodelist: network._addNode(n) + if n._env['bridgeauthority']: + network._dfltEnv['hasbridgeauth'] = True def usage(network): return "\n".join(["Usage: chutney {command} {networkfile}", -- cgit v1.2.3