1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-12-26 00:29:23 +08:00

expose route-table to readme

This commit is contained in:
Septs 2020-05-23 19:13:09 +08:00
parent 7b933cc469
commit 2a65e8ba71

View file

@ -230,7 +230,7 @@ def make_summary():
node_table = node_to_asn(set(asn_table.keys())) node_table = node_to_asn(set(asn_table.keys()))
stream = StringIO() stream = StringIO()
with redirect_stdout(stream): with redirect_stdout(stream):
print("Entities:") print("Entity table:")
print("{:20}{:20}{}".format("Name", "Telegram", "Email")) print("{:20}{:20}{}".format("Name", "Telegram", "Email"))
for entity in sorted( for entity in sorted(
entities.values(), key=lambda entity: entity["name"].lower(), entities.values(), key=lambda entity: entity["name"].lower(),
@ -240,7 +240,7 @@ def make_summary():
telegram = contact.get("telegram", "") telegram = contact.get("telegram", "")
print("{:20}{:20}{}".format(entity["name"], telegram, email)) print("{:20}{:20}{}".format(entity["name"], telegram, email))
print() print()
print("AS List:") print("AS table:")
print("{:15}{:<17}{:20}{}".format("Source", "ASN", "Owner", "Name")) print("{:15}{:<17}{:20}{}".format("Source", "ASN", "Owner", "Name"))
for asn, entity in sorted(asn_table.items(), key=lambda item: item[0]): for asn, entity in sorted(asn_table.items(), key=lambda item: item[0]):
print( print(
@ -249,12 +249,12 @@ def make_summary():
) )
) )
print() print()
print("Node List:") print("Node table:")
print("{:<17}{}".format("ASN", "Name")) print("{:<17}{}".format("ASN", "Name"))
for name, asn in sorted(node_table.items(), key=lambda item: item[1]): for name, asn in sorted(node_table.items(), key=lambda item: item[1]):
print("AS{:<15}{}".format(asn, name)) print("AS{:<15}{}".format(asn, name))
print() print()
print("Peer List:") print("Peer table:")
peers = list(iter_toml_file("peer")) peers = list(iter_toml_file("peer"))
maxUpstreamLength = max(map(lambda item: len(item[0].stem), peers)) maxUpstreamLength = max(map(lambda item: len(item[0].stem), peers))
print("{:>{}} ~ {}".format("Upstream", maxUpstreamLength, "Downstream")) print("{:>{}} ~ {}".format("Upstream", maxUpstreamLength, "Downstream"))
@ -262,6 +262,13 @@ def make_summary():
upstream = item.stem upstream = item.stem
for downstream in sorted(entities["to-peer"], key=str.lower): for downstream in sorted(entities["to-peer"], key=str.lower):
print("{:>{}} ~ {}".format(upstream, maxUpstreamLength, downstream)) print("{:>{}} ~ {}".format(upstream, maxUpstreamLength, downstream))
print()
print("Route table:")
print("{:17}{:30}{:30}{}".format("ASN", "Name", "Prefix", "Supernet"))
for entity in route_to_roa(asn_table):
entity["prefix"] = str(entity["prefix"])
entity["supernet"] = str(entity["supernet"]) if entity["supernet"] else ""
print("AS{asn:<15}{name:30}{prefix:30}{supernet}".format_map(entity))
return stream.getvalue() return stream.getvalue()