From e3fd5dc9aef8fb975f7056b76e3268bbab19785a Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 12 May 2020 10:49:37 +0800 Subject: [PATCH] roa.py: check peer-dir --- scripts/roa.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/roa.py b/scripts/roa.py index f8103fb..3856ce2 100755 --- a/scripts/roa.py +++ b/scripts/roa.py @@ -113,6 +113,7 @@ def node2asn(): continue fc = shell2dict(f.read_text()) asn = str2asn(fc.get('asn')) + assert asn in ASNS node_table[f.name] = asn except Exception: print("[!] Error while processing file", f) @@ -120,6 +121,22 @@ def node2asn(): return node_table NODE_TABLE = node2asn() +def neonet_peercheck(): + for f in (cwd / "peer").iterdir(): + try: + if not f.is_file(): + continue + fc = shell2dict(f.read_text()) + desc = fc.get('desc') + assert desc is not None + upstream, downstream = f.name.split('~') + assert upstream in NODE_TABLE + assert downstream in NODE_TABLE + except Exception: + print("[!] Error while processing file", f) + raise +neonet_peercheck() + def neonet_route2roa(dirname, is_ipv6=False): roa_entries = list() for f in (cwd / dirname).iterdir(): @@ -138,17 +155,6 @@ def neonet_route2roa(dirname, is_ipv6=False): netname = fc.get('name') assert netname roa_entries.append(dict(zip(roa_entries_key, [asn, nettype(route, strict=True), supernet, netname]))) - elif fc.get('type').lower().startswith('tun'): - assert NODE_TABLE[fc.get('downstream')] # not in node-dir - asn = NODE_TABLE[fc.get('upstream')] - assert asn in ASNS - route = f.name.replace(',', '/') - supernet = get_supernet(fc.get('supernet')) - netname = "%s-%s" % (fc.get('type'), route) - roa_entries.append(dict(zip(roa_entries_key, [asn, nettype(route, strict=True), supernet, netname]))) - elif fc.get('type').lower() == 'ptp': - assert NODE_TABLE[fc.get('upstream')] # not in node-dir - assert NODE_TABLE[fc.get('downstream')] # not in node-dir else: raise AssertionError # unknown type except Exception: