Skip to content

Commit

Permalink
Use AlternateDirAuthority when Bridge Authority exists in network
Browse files Browse the repository at this point in the history
Setting both DirServer and AlternateBridgeAuthority are incompatible. We
should use AlternateDirAuthority when we also have a Bridge Authority.
  • Loading branch information
sysrqb committed Nov 13, 2013
1 parent 618ae49 commit cd68031
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/chutney/TorNet.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _genRouterKey(self):
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 ""."""
Expand Down Expand Up @@ -330,8 +330,10 @@ def _getAltAuthLines(self):
# 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 = ""
Expand Down Expand Up @@ -470,6 +472,7 @@ def stop(self, sig=signal.SIGINT):
DEFAULTS = {
'authority' : False,
'bridgeauthority' : False,
'hasbridgeauth' : False,
'relay' : False,
'bridge' : False,
'connlimit' : 60,
Expand Down Expand Up @@ -575,7 +578,8 @@ def configure(self):

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)
Expand Down Expand Up @@ -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}",
Expand Down

0 comments on commit cd68031

Please sign in to comment.