Ticket #13162: 0001-Fix-chutney-to-work-with-latest-tor-versions-add-var.patch

File 0001-Fix-chutney-to-work-with-latest-tor-versions-add-var.patch, 11.5 KB (added by teor, 6 years ago)

Patch generated with git format-patch

  • lib/chutney/TorNet.py

    From 9b09bf6c8f77c5f791980f72a1c9dd78080575a4 Mon Sep 17 00:00:00 2001
    From: twilsonb <twilsonb mac com>
    Date: Sun, 14 Sep 2014 09:48:34 +1000
    Subject: [PATCH 1/3] Fix chutney to work with latest tor versions, add
     variants
    
    ---
     lib/chutney/TorNet.py               | 28 ++++++++++++++++++++++++++--
     networks/basic                      |  6 ++++--
     networks/basic+middle               | 10 ++++++++++
     networks/bridges                    |  2 +-
     networks/bridges+ipv6               |  2 +-
     networks/huge                       |  8 ++++++++
     networks/large                      | 10 ++++++++++
     networks/mixed                      |  4 ++--
     tools/bootstrap-network.sh          |  4 ++++
     tools/kill-zombies.sh               |  4 ++++
     torrc_templates/authority-huge.tmpl | 19 +++++++++++++++++++
     torrc_templates/authority.tmpl      | 10 ++++++++++
     torrc_templates/client-huge.tmpl    |  6 ++++++
     torrc_templates/common.i            |  3 ++-
     torrc_templates/exit-huge.tmpl      |  4 ++++
     torrc_templates/exit.tmpl           |  4 ++++
     torrc_templates/relay-huge.tmpl     |  9 +++++++++
     17 files changed, 124 insertions(+), 9 deletions(-)
     create mode 100644 networks/basic+middle
     create mode 100644 networks/huge
     create mode 100644 networks/large
     create mode 100755 tools/kill-zombies.sh
     create mode 100644 torrc_templates/authority-huge.tmpl
     create mode 100644 torrc_templates/client-huge.tmpl
     create mode 100644 torrc_templates/exit-huge.tmpl
     create mode 100644 torrc_templates/exit.tmpl
     create mode 100644 torrc_templates/relay-huge.tmpl
    
    diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
    index 6a1fc8b..8b41785 100644
    a b class LocalNodeController(NodeController): 
    495495                sys.exit(0)
    496496            else:
    497497                raise
     498
    498499        # XXXX this requires that RunAsDaemon is set.
    499500        p.wait()
    500         if p.returncode != 0:
     501       
     502        # XXXX this does not require RunAsDaemon to be set, but is slower.
     503       
     504        # poll() only catches failures before the call itself
     505        # so let's sleep a little first
     506        # this does, of course, slow down process launch
     507        # which can require an adjustment to the voting interval
     508
     509        # avoid writing a newline or space
     510        #sys.stdout.write('.')
     511        #sys.stdout.flush()
     512       
     513        #time.sleep(0.1)
     514        #p.poll()
     515       
     516        # XXXX end not RunAsDaemon
     517       
     518        if p.returncode != None and p.returncode != 0:
    501519            print "Couldn't launch %s (%s): %s" % (self._env['nick'],
    502520                                                   " ".join(cmdline),
    503521                                                   p.returncode)
    class Network(object): 
    668686        self.start()
    669687
    670688    def start(self):
     689        # avoid printing a newline
     690        #sys.stdout.write("Starting nodes")
     691        #sys.stdout.flush()
    671692        print "Starting nodes"
    672         return all([n.getController().start() for n in self._nodes])
     693        rv = all([n.getController().start() for n in self._nodes])
     694        #print ""
     695        return rv
     696   
    673697
    674698    def hup(self):
    675699        print "Sending SIGHUP to nodes"
  • networks/basic

    diff --git a/networks/basic b/networks/basic
    index b15a0b7..4dc3aeb 100644
    a b  
    11Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
    2 Relay = Node(tag="r", relay=1, torrc="relay.tmpl")
     2Relay = Node(tag="r", relay=1, torrc="exit.tmpl")
    33Client = Node(tag="c", torrc="client.tmpl")
    44
    5 NODES = Authority.getN(3) + Relay.getN(5) + Client.getN(2)
     5# Guard percentage has been reduced from 50% to 25% of relays
     6# This may require more relay nodes
     7NODES = Authority.getN(3) + Relay.getN(9) + Client.getN(2)
    68
    79ConfigureNodes(NODES)
  • new file networks/basic+middle

    diff --git a/networks/basic+middle b/networks/basic+middle
    new file mode 100644
    index 0000000..53f3b4f
    - +  
     1Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
     2Relay = Node(tag="r", relay=1, torrc="relay.tmpl")
     3Exit = Node(tag="e", relay=1, torrc="exit.tmpl")
     4Client = Node(tag="c", torrc="client.tmpl")
     5
     6# Guard percentage has been reduced from 50% to 25% of relays
     7# This may require more relay nodes
     8NODES = Authority.getN(3) + Relay.getN(5) + Exit.getN(5) + Client.getN(2)
     9
     10ConfigureNodes(NODES)
  • networks/bridges

    diff --git a/networks/bridges b/networks/bridges
    index ce9116b..0ae4ea1 100644
    a b  
    11Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
    2 Relay = Node(tag="r", relay=1, torrc="relay.tmpl")
     2Relay = Node(tag="r", relay=1, torrc="exit.tmpl")
    33Client = Node(tag="c", torrc="client.tmpl")
    44
    55BridgeAuthority = Node(tag="ba", authority=1, bridgeauthority=1,
  • networks/bridges+ipv6

    diff --git a/networks/bridges+ipv6 b/networks/bridges+ipv6
    index 00e6029..e327fb5 100644
    a b  
    11Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
    2 Relay = Node(tag="r", relay=1, torrc="relay.tmpl")
     2Relay = Node(tag="r", relay=1, torrc="exit.tmpl")
    33Client = Node(tag="c", torrc="client.tmpl")
    44
    55BridgeAuthority = Node(tag="ba", authority=1, bridgeauthority=1,
  • new file networks/huge

    diff --git a/networks/huge b/networks/huge
    new file mode 100644
    index 0000000..48385ea
    - +  
     1Authority = Node(tag="a", authority=1, relay=1, torrc="authority-huge.tmpl")
     2Relay = Node(tag="r", relay=1, torrc="relay-huge.tmpl")
     3Exit = Node(tag="e", relay=1, torrc="exit-huge.tmpl")
     4Client = Node(tag="c", torrc="client-huge.tmpl")
     5
     6NODES = Authority.getN(3) + Relay.getN(20) + Exit.getN(10) + Client.getN(40)
     7
     8ConfigureNodes(NODES)
  • new file networks/large

    diff --git a/networks/large b/networks/large
    new file mode 100644
    index 0000000..74e08f8
    - +  
     1Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
     2Relay = Node(tag="r", relay=1, torrc="relay.tmpl")
     3Exit = Node(tag="e", relay=1, torrc="exit.tmpl")
     4Client = Node(tag="c", torrc="client.tmpl")
     5
     6# Guard percentage has been reduced from 50% to 25% of relays
     7# This may require more relay nodes
     8NODES = Authority.getN(4) + Relay.getN(8) + Exit.getN(8) + Client.getN(5)
     9
     10ConfigureNodes(NODES)
  • networks/mixed

    diff --git a/networks/mixed b/networks/mixed
    index 9dd40c2..98873c1 100644
    a b OLD_TOR="tor-stable" 
    33Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
    44OldAuthority = Node(tag="aOLD", authority=1, relay=1, torrc="authority.tmpl",
    55             tor=OLD_TOR)
    6 Relay = Node(tag="r", relay=1, torrc="relay.tmpl")
    7 OldRelay = Node(tag="rOLD", relay=1, torrc="relay.tmpl", tor=OLD_TOR)
     6Relay = Node(tag="r", relay=1, torrc="exit.tmpl")
     7OldRelay = Node(tag="rOLD", relay=1, torrc="exit.tmpl", tor=OLD_TOR)
    88Client = Node(tag="c", torrc="client.tmpl")
    99OldClient = Node(tag="cOLD", torrc="client.tmpl", tor=OLD_TOR)
    1010
  • tools/bootstrap-network.sh

    diff --git a/tools/bootstrap-network.sh b/tools/bootstrap-network.sh
    index 17c9792..bcb8c04 100755
    a b flavour=basic; [ -n "$1" ] && { flavour=$1; shift; } 
    2424
    2525$CHUTNEY stop networks/$flavour
    2626[ -d net/nodes ] && {
     27    # XXXX stop may not work if you've changed the network flavour
     28    # XXXX between start and stop. So we kill all previous tor nodes.
     29    echo "$myname: NOTE: killing any leftover tor processes in net/nodes"
     30    cat net/nodes/*/pid | xargs kill -KILL
    2731    DEST=net/nodes.$(date +%s)
    2832    echo "$myname: NOTE: renaming net/nodes to $DEST"
    2933    mv net/nodes $DEST
  • new file tools/kill-zombies.sh

    diff --git a/tools/kill-zombies.sh b/tools/kill-zombies.sh
    new file mode 100755
    index 0000000..eddf17e
    - +  
     1#!/bin/sh
     2# we assume "chutney" appears somewhere in the tor command line for test procs
     3# (and doesn't appear in any tor processes you don't want killed)
     4ps uxw | grep tor | grep chutney | cut -d" " -f2 | xargs kill -KILL
  • new file torrc_templates/authority-huge.tmpl

    diff --git a/torrc_templates/authority-huge.tmpl b/torrc_templates/authority-huge.tmpl
    new file mode 100644
    index 0000000..332bed5
    - +  
     1${include:relay-huge.tmpl}
     2AuthoritativeDirectory 1
     3V3AuthoritativeDirectory 1
     4ContactInfo auth${nodenum}@test.test
     5ExitPolicy reject *:*
     6TestingV3AuthInitialVotingInterval 300
     7TestingV3AuthInitialVoteDelay 2
     8TestingV3AuthInitialDistDelay 2
     9TestingV3AuthVotingStartOffset 0
     10V3AuthVotingInterval 300
     11V3AuthVoteDelay 2
     12V3AuthDistDelay 2
     13# Work around situations where the Exit and Guard flags aren't being set
     14# These flags are set eventually, but it takes ~30 minutes
     15# We could be more precise here, but it's easiest just to vote everything
     16# Clients are sensible enough to filter out Exits without any exit ports,
     17# and Guards without ORPorts
     18TestingDirAuthVoteExit *
     19TestingDirAuthVoteGuard *
  • torrc_templates/authority.tmpl

    diff --git a/torrc_templates/authority.tmpl b/torrc_templates/authority.tmpl
    index 7bf99af..941eb01 100644
    a b TestingV3AuthInitialVotingInterval 300 
    77TestingV3AuthInitialVoteDelay 2
    88TestingV3AuthInitialDistDelay 2
    99TestingV3AuthVotingStartOffset 0
     10V3AuthVotingInterval 300
     11V3AuthVoteDelay 2
     12V3AuthDistDelay 2
     13# Work around situations where the Exit and Guard flags aren't being set
     14# These flags are set eventually, but it takes ~30 minutes
     15# We could be more precise here, but it's easiest just to vote everything
     16# Clients are sensible enough to filter out Exits without any exit ports,
     17# and Guards without ORPorts
     18TestingDirAuthVoteExit *
     19TestingDirAuthVoteGuard *
  • new file torrc_templates/client-huge.tmpl

    diff --git a/torrc_templates/client-huge.tmpl b/torrc_templates/client-huge.tmpl
    new file mode 100644
    index 0000000..1eb1d99
    - +  
     1${include:common.i}
     2SocksPort $socksport
     3#NOTE: Setting TestingClientConsensusDownloadSchedule doesn't
     4#      help -- dl_stats.schedule is not DL_SCHED_CONSENSUS
     5#      at boostrap time.
     6TestingClientDownloadSchedule 10, 2, 2, 4, 4, 8, 13, 18, 25, 40, 60
  • torrc_templates/common.i

    diff --git a/torrc_templates/common.i b/torrc_templates/common.i
    index 2b5e4fa..08736f9 100644
    a b  
    11TestingTorNetwork 1
    22DataDirectory $dir
    33RunAsDaemon 1
     4DisableDebuggerAttachment 0
    45ConnLimit $connlimit
    56Nickname $nick
    67ShutdownWaitLength 0
    78PidFile ${dir}/pid
    89Log notice file ${dir}/notice.log
    910Log info file ${dir}/info.log
     11#Log debug file ${dir}/debug.log
    1012ProtocolWarnings 1
    1113SafeLogging 0
    1214${authorities}
    13 
  • new file torrc_templates/exit-huge.tmpl

    diff --git a/torrc_templates/exit-huge.tmpl b/torrc_templates/exit-huge.tmpl
    new file mode 100644
    index 0000000..4cd5f0b
    - +  
     1${include:relay-huge.tmpl}
     2ExitPolicy accept 127.0.0.0/8:*
     3#ExitPolicy accept [::1]:*
     4#IPv6Exit 1
  • new file torrc_templates/exit.tmpl

    diff --git a/torrc_templates/exit.tmpl b/torrc_templates/exit.tmpl
    new file mode 100644
    index 0000000..8d6a14c
    - +  
     1${include:relay.tmpl}
     2ExitPolicy accept 127.0.0.0/8:*
     3#ExitPolicy accept [::1]:*
     4#IPv6Exit 1
  • new file torrc_templates/relay-huge.tmpl

    diff --git a/torrc_templates/relay-huge.tmpl b/torrc_templates/relay-huge.tmpl
    new file mode 100644
    index 0000000..2f4b7f1
    - +  
     1${include:common.i}
     2SocksPort 0
     3OrPort $orport
     4Address $ip
     5DirPort $dirport
     6#NOTE: Setting TestingServerConsensusDownloadSchedule doesn't
     7#      help -- dl_stats.schedule is not DL_SCHED_CONSENSUS
     8#      at boostrap time.
     9TestingServerDownloadSchedule 10, 2, 2, 4, 4, 8, 13, 18, 25, 40, 60