commit 68dfa73c33d4b6fb73e62e23ac8e60f468c23f60 Author: Damian Johnson atagar@torproject.org Date: Wed Dec 27 10:53:18 2017 -0800
Redefinition of local variable
Oops, on reflection we used the variable 'connections' for both the top categories and for local variables, overwriting the former. --- docs/_static/example/relay_connections.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/docs/_static/example/relay_connections.py b/docs/_static/example/relay_connections.py index 55bd8919..26f59f4c 100755 --- a/docs/_static/example/relay_connections.py +++ b/docs/_static/example/relay_connections.py @@ -52,7 +52,7 @@ def main():
# categorize our connections
- connections = collections.OrderedDict(( + categories = collections.OrderedDict(( (INBOUND_ORPORT, []), (INBOUND_DIRPORT, []), (INBOUND_CONTROLPORT, []), @@ -68,18 +68,18 @@ def main(): continue
if conn.local_port in controller.get_ports(Listener.OR, []): - connections[INBOUND_ORPORT].append(conn) + categories[INBOUND_ORPORT].append(conn) elif conn.local_port in controller.get_ports(Listener.DIR, []): - connections[INBOUND_DIRPORT].append(conn) + categories[INBOUND_DIRPORT].append(conn) elif conn.local_port in controller.get_ports(Listener.CONTROL, []): - connections[INBOUND_CONTROLPORT].append(conn) + categories[INBOUND_CONTROLPORT].append(conn) elif conn.remote_port in relays.get(conn.remote_address, []): - connections[OUTBOUND_ORPORT].append(conn) + categories[OUTBOUND_ORPORT].append(conn) elif policy.can_exit_to(conn.remote_address, conn.remote_port): - connections[OUTBOUND_EXIT].append(conn) + categories[OUTBOUND_EXIT].append(conn) exit_connections.setdefault(conn.remote_port, []).append(conn) else: - connections[OUTBOUND_UNKNOWN].append(conn) + categories[OUTBOUND_UNKNOWN].append(conn)
print(DIV) print(COLUMN % ('Type', 'IPv4', 'IPv6')) @@ -87,7 +87,7 @@ def main():
total_ipv4, total_ipv6 = 0, 0
- for label, connections in connections.items(): + for label, connections in categories.items(): if len(connections) == 0: continue