mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-11-26 06:40:41 +08:00
roa.py: check peer-dir
This commit is contained in:
parent
927d9c2997
commit
e3fd5dc9ae
1 changed files with 17 additions and 11 deletions
|
@ -113,6 +113,7 @@ def node2asn():
|
||||||
continue
|
continue
|
||||||
fc = shell2dict(f.read_text())
|
fc = shell2dict(f.read_text())
|
||||||
asn = str2asn(fc.get('asn'))
|
asn = str2asn(fc.get('asn'))
|
||||||
|
assert asn in ASNS
|
||||||
node_table[f.name] = asn
|
node_table[f.name] = asn
|
||||||
except Exception:
|
except Exception:
|
||||||
print("[!] Error while processing file", f)
|
print("[!] Error while processing file", f)
|
||||||
|
@ -120,6 +121,22 @@ def node2asn():
|
||||||
return node_table
|
return node_table
|
||||||
NODE_TABLE = node2asn()
|
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):
|
def neonet_route2roa(dirname, is_ipv6=False):
|
||||||
roa_entries = list()
|
roa_entries = list()
|
||||||
for f in (cwd / dirname).iterdir():
|
for f in (cwd / dirname).iterdir():
|
||||||
|
@ -138,17 +155,6 @@ def neonet_route2roa(dirname, is_ipv6=False):
|
||||||
netname = fc.get('name')
|
netname = fc.get('name')
|
||||||
assert netname
|
assert netname
|
||||||
roa_entries.append(dict(zip(roa_entries_key, [asn, nettype(route, strict=True), supernet, 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:
|
else:
|
||||||
raise AssertionError # unknown type
|
raise AssertionError # unknown type
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in a new issue