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

[skip ci] allow skipping ci, assert neonet in roa.py

This commit is contained in:
JerryXiao 2020-05-12 11:12:00 +08:00
parent e3fd5dc9ae
commit d7f82ed57b
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA
2 changed files with 10 additions and 2 deletions

View file

@ -11,6 +11,7 @@ on:
jobs: jobs:
build: build:
name: Generate ROA name: Generate ROA
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View file

@ -2,10 +2,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from pathlib import Path from pathlib import Path
from ipaddress import IPv4Network, IPv6Network from ipaddress import IPv4Network, IPv6Network, ip_network
from itertools import combinations from itertools import combinations
import re import re
NEONET_ADDR_POOL = ('10.127.0.0/16', 'fd10:127::/32')
NEONET_ADDR_POOL = [ip_network(neo) for neo in NEONET_ADDR_POOL]
IS_NEONET = lambda net: bool([True for neo in NEONET_ADDR_POOL if net.version == neo.version and net.subnet_of(neo)])
class BashParser: class BashParser:
def __init__(self): def __init__(self):
self.__pa = None # are we parsing bash array? self.__pa = None # are we parsing bash array?
@ -151,10 +155,13 @@ def neonet_route2roa(dirname, is_ipv6=False):
asn = str2asn(fc.get('asn')) asn = str2asn(fc.get('asn'))
assert asn in ASNS # asn not in as-dir assert asn in ASNS # asn not in as-dir
route = f.name.replace(',', '/') route = f.name.replace(',', '/')
net = nettype(route, strict=True)
assert IS_NEONET(net)
supernet = get_supernet(fc.get('supernet')) supernet = get_supernet(fc.get('supernet'))
assert not supernet or IS_NEONET(supernet)
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, net, supernet, netname])))
else: else:
raise AssertionError # unknown type raise AssertionError # unknown type
except Exception: except Exception: