1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-11-22 06:50:41 +08:00

ROA Generator: removed nodes / peer support

This commit is contained in:
Neo_Chen 2023-05-04 14:04:08 +08:00
parent d8c0c41b87
commit 25b7a65cc2
No known key found for this signature in database
GPG key ID: CA0957540FD996CD

View file

@ -95,24 +95,6 @@ def load_asn(entities: dict):
assert entity["source"] in ["NeoNetwork", "DN42", "Internet"] assert entity["source"] in ["NeoNetwork", "DN42", "Internet"]
yield asn, entity yield asn, entity
def node_to_asn(orignal_asn_set: set):
node_table = dict()
for _, entities in iter_toml_file("node"):
mapping = {name: entity["asn"] for (name, entity) in entities.items()}
asn_set = set(mapping.values())
assert orignal_asn_set & asn_set == asn_set
node_table.update(mapping)
return node_table
def assert_peer(nodes: set):
for item, entities in iter_toml_file("peer"):
peers = set(entities["to-peer"])
assert item.stem in nodes
assert nodes & peers == peers
def route_to_roa(asn_table: dict): def route_to_roa(asn_table: dict):
def make_route(): def make_route():
for item, entity in iter_toml_file("route"): for item, entity in iter_toml_file("route"):
@ -319,7 +301,6 @@ def make_roa_records(roa4, roa6):
def make_summary(): def make_summary():
entities = dict(load_entities()) entities = dict(load_entities())
asn_table = dict(load_asn(entities)) asn_table = dict(load_asn(entities))
node_table = node_to_asn(set(asn_table.keys()))
stream = StringIO() stream = StringIO()
with redirect_stdout(stream): with redirect_stdout(stream):
print("# NeoNetwork Summary") print("# NeoNetwork Summary")
@ -352,32 +333,6 @@ def make_summary():
) )
print(as_table) print(as_table)
print() print()
print("## Node table")
print()
node_table = tabulate(
(
("AS{}".format(asn), name)
for name, asn in sorted(node_table.items(), key=lambda item: item[1])
),
headers=["ASN", "Name"],
tablefmt="github",
)
print(node_table)
print()
print("## Peer table")
print()
peer_table = tabulate(
(
(item.stem, downstream)
for item, entity in iter_toml_file("peer")
for downstream in entity["to-peer"]
),
headers=["Upstream", "Downstream"],
tablefmt="github",
colalign=("right",),
)
print(peer_table)
print()
print("## Route table") print("## Route table")
print() print()
route_table = tabulate( route_table = tabulate(
@ -472,8 +427,6 @@ def make_summary():
def main(args): def main(args):
entities = dict(load_entities()) entities = dict(load_entities())
asn_table = dict(load_asn(entities)) asn_table = dict(load_asn(entities))
node_table = node_to_asn(set(asn_table.keys()))
assert_peer(set(node_table.keys()))
roa4, roa6 = prehandle_roa(asn_table, args) roa4, roa6 = prehandle_roa(asn_table, args)
if args.export: if args.export:
return make_export(roa4, roa6) return make_export(roa4, roa6)