#!/usr/bin/env python # Usage: # wget -O bridges.json https://onionoo.torproject.org/details?type=relay # ./nodeinfo < bridges.json import datetime import json import sys DATEFMT = "%Y-%m-%d %H:%M:%S" def output_relay(r): try: fingerprint = r["fingerprint"] except KeyError: fingerprint = r["hashed_fingerprint"] print "%s %-17s %s %s %s %-26s %s" % ( fingerprint, r["nickname"], r["first_seen"].format(DATEFMT), r["last_seen"].format(DATEFMT), r["last_restarted"].format(DATEFMT), r["platform"], ",".join(r.get("transports", ())), ) j = json.load(sys.stdin) for r in j["relays"] + j["bridges"]: output_relay(r)