From 935a64dbcac932adb57b413e98b6a3a375e88452 Mon Sep 17 00:00:00 2001 From: anonym Date: Thu, 16 Jul 2015 22:51:08 +0200 Subject: [PATCH] Allow specifying the Chutney listen address. It's controlled via the CHUTNEY_LISTEN_ADDRESS environment variable (default: localhost). Setting it to some interface's IP addtress allows us to make the simulated Tor network available on the network. --- lib/chutney/TorNet.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py index c79f64b..ac02a56 100644 --- a/lib/chutney/TorNet.py +++ b/lib/chutney/TorNet.py @@ -403,7 +403,7 @@ class LocalNodeBuilder(NodeBuilder): "--list-fingerprint", "--orport", "1", "--dirserver", - "xyzzy 127.0.0.1:1 ffffffffffffffffffffffffffffffffffffffff", + "xyzzy %s:1 ffffffffffffffffffffffffffffffffffffffff" % DEFAULTS['ip'], "--datadirectory", datadir] try: p = subprocess.Popen(cmdline, stdout=subprocess.PIPE) @@ -672,7 +672,7 @@ DEFAULTS = { 'tor': os.environ.get('CHUTNEY_TOR', 'tor'), 'tor-gencert': os.environ.get('CHUTNEY_TOR_GENCERT', None), 'auth_cert_lifetime': 12, - 'ip': '127.0.0.1', + 'ip': os.environ.get('CHUTNEY_LISTEN_ADDRESS', '127.0.0.1'), 'ipv6_addr': None, 'dirserver_flags': 'no-v2', 'chutney_dir': '.', @@ -914,7 +914,7 @@ class Network(object): and verify what is received.""" LISTEN_PORT = 4747 # FIXME: Do better! Note the default exit policy. # HSs must have a HiddenServiceDir with - # "HiddenServicePort 127.0.0.1:" + # "HiddenServicePort :" HS_PORT = 5858 # The amount of data to send between each source-sink pair, # each time the source connects. @@ -942,7 +942,7 @@ class Network(object): dot_reps = 0 tmpdata = {} # now make the connections - bind_to = ('127.0.0.1', LISTEN_PORT) + bind_to = (DEFAULTS['ip'], LISTEN_PORT) tt = chutney.Traffic.TrafficTester(bind_to, tmpdata, TIMEOUT, @@ -1014,7 +1014,8 @@ class Network(object): # if there are any exits, each client / bridge client transmits # via 4 nodes (including the client) to an arbitrary exit - # Each client binds directly to 127.0.0.1:LISTEN_PORT via an Exit relay + # Each client binds directly to :LISTEN_PORT + # via an Exit relay def _configure_exits(self, tt, bind_to, tmpdata, reps, client_list, exit_list, @@ -1028,7 +1029,7 @@ class Network(object): * connection_count) for op in client_list: print(" Exit to %s:%d via client %s:%s" - % ('127.0.0.1', LISTEN_PORT, + % (DEFAULTS['ip'], LISTEN_PORT, 'localhost', op._env['socksport'])) for i in range(connection_count): tt.add(chutney.Traffic.Source(tt, @@ -1040,7 +1041,7 @@ class Network(object): return exit_path_node_count # The HS redirects .onion connections made to hs_hostname:HS_PORT - # to the Traffic Tester's 127.0.0.1:LISTEN_PORT + # to the Traffic Tester's CHUTNEY_LISTEN_ADDRESS:LISTEN_PORT # an arbitrary client / bridge client transmits via 8 nodes # (including the client and hs) to each hidden service # Instead of binding directly to LISTEN_PORT via an Exit relay, @@ -1068,7 +1069,7 @@ class Network(object): for client in hs_client_list: print(" HS to %s:%d (%s:%d) via client %s:%s" % (hs._env['hs_hostname'], HS_PORT, - '127.0.0.1', LISTEN_PORT, + DEFAULTS['ip'], LISTEN_PORT, 'localhost', client._env['socksport'])) for i in range(connection_count): tt.add(chutney.Traffic.Source(tt, -- 2.8.0.rc3