diff --git a/lib/interface.py b/lib/interface.py index 9edfff045..227723a48 100644 --- a/lib/interface.py +++ b/lib/interface.py @@ -40,7 +40,7 @@ proxy_modes = ['socks4', 'socks5', 'http'] def pick_random_server(): - return random_choice( DEFAULT_SERVERS ) + return random.choice( DEFAULT_SERVERS ) def pick_random_interface(): servers = DEFAULT_SERVERS diff --git a/scripts/servers b/scripts/servers index 82971350e..69c0ade59 100755 --- a/scripts/servers +++ b/scripts/servers @@ -13,6 +13,7 @@ for i in interfaces: i.send([('blockchain.numblocks.subscribe',[])]) else: servers.remove(i.server) + i.status = "unreachable" for i in interfaces: while True: @@ -23,11 +24,12 @@ for i in interfaces: if r.get('method') == 'blockchain.numblocks.subscribe': results.append((i.host, r.get('result'))) + i.status = "ok" servers.remove(i.server) break for s in servers: - print "%30s "%s, "timed out" + i.status = "timed out" from collections import defaultdict d = defaultdict(int) @@ -36,6 +38,9 @@ for e in results: v = d.values() numblocks = d.keys()[v.index(max(v))] +for i in interfaces: + print i.host, i.status + for s,n in results: print "%30s %d "%(s, n), "ok" if abs(n-numblocks)<2 else "lagging"