1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-05-18 13:31:46 +08:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
MagicNeko(Dev:Desktop) 2021-08-22 01:17:30 +08:00
commit 89839b45c8
No known key found for this signature in database
GPG key ID: 57604E26E6FDC8A3
50 changed files with 402 additions and 75 deletions

View file

@ -1,2 +1,2 @@
name = "Yhi Interconnect"
name = "Yhi Interconnection"
owner = "Junde Yhi"

View file

@ -1,3 +1,3 @@
name = "BAOSHUO-AS-NEO"
owner = "Ren Baoshuo"
description = "Baoshuo Network"
description = "Baoshuo Neo Network"

4
asn/AS4201270030.toml Normal file
View file

@ -0,0 +1,4 @@
name = "IWARP-NEO"
owner = "Yux"
desc = "IWARP Global Experimental NeoNetwork"

3
asn/AS4201270099.toml Normal file
View file

@ -0,0 +1,3 @@
name = "AS-NEO-TSINGYAO"
owner = "TsingYao"
description = "TsingYao Neo Network"

3
asn/AS4201271111.toml Normal file
View file

@ -0,0 +1,3 @@
name = "kskb"
owner = "kskb"
desc = "kskb's network"

2
asn/AS4201271488.toml Normal file
View file

@ -0,0 +1,2 @@
name = "Polar Bear"
owner = "SyllaBear"

3
asn/AS4201272526.toml Normal file
View file

@ -0,0 +1,3 @@
name = "ANILLC-AS-NEO"
owner = "Anillc"
description = "Anillc NEO Network"

2
asn/AS4201279999.toml Normal file
View file

@ -0,0 +1,2 @@
name = "Hydro-Neo-Network"
owner = "undefined-moe"

3
asn/AS4242420288.toml Normal file
View file

@ -0,0 +1,3 @@
name = "IWARP-DN42"
owner = "Yux"
desc = "IWARP DN42 Network"

3
asn/AS4242421331.toml Normal file
View file

@ -0,0 +1,3 @@
name = "Niantic Network"
owner = "Yukari"
description = "Niantic Network Backbone"

3
asn/AS4242421332.toml Normal file
View file

@ -0,0 +1,3 @@
name = "Niantic Network CN"
owner = "Yukari"
description = "Niantic Network China"

3
asn/AS4242423699.toml Normal file
View file

@ -0,0 +1,3 @@
name = "AS-NEO-TSINGYAO"
owner = "TsingYao"
description = "TsingYao Neo Network"

View file

@ -34,13 +34,20 @@ $TTL 3600
10.14 IN PTR neochen.gr-0-1-0-2.cr2.hkg1.licson.neo.
13.14 IN PTR gr-0-1-0-3.cr2.hkg1.licson.neo.
14.14 IN PTR jerry.gr-0-1-0-3.cr2.hkg1.licson.neo.
17.14 IN PTR gr-0-1-0-4.cr2.hkg1.licson.neo.
18.14 IN PTR yuetan.gr-0-1-0-4.cr2.hkg1.licson.neo.
21.14 IN PTR gr-0-1-0-5.cr2.hkg1.licson.neo.
22.14 IN PTR moecast.gr-0-1-0-5.cr2.hkg1.licson.neo.
1.15 IN PTR ae-0-1.cr2.hkg1.licson.neo.
58.15 IN PTR live.licson.neo.
1.8 IN PTR librehs.neo.
2.8 IN PTR blog.librehs.neo.
130.8 IN PTR edwardp.neo.
137.8 IN PTR lily.neo.
; Loopback Addresses
1.255 IN PTR NeoPDP-11.neo.
@ -80,9 +87,14 @@ $TTL 3600
21 IN NS ns.iedon.neo.
30 IN NS ns1.iwarp.neo.
127 IN NS ns1.yura.dn42.
127 IN NS ns2.yura.dn42.
66 IN NS ns1.fixmix.neo.
66 IN NS ns2.fixmix.neo.
66 IN NS ns3.fixmix.neo.
99 IN NS ns1.tsingyao.neo.
99 IN NS ns2.tsingyao.neo.

View file

@ -13,6 +13,8 @@ $TTL 3600
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.c.3.c.1.3.3.2.0 IN PTR liqingge.router.br-koishi.lo.she.as141706.koishi.moe.
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.f.2.f.2 IN PTR edwardp.neo.
7.3.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.7.a.b IN PTR lily.neo.
; Loopback Addresses
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.5.0.0.f.f.f.f IN PTR root-dns.neo.
@ -33,6 +35,8 @@ $TTL 3600
0.1.0.0 IN DS 11807 13 2 BBADC27B4EBFC90CBA79F4E69E4F167B9FFAF664B071F4CC46196902054B0910
0.1.0.0 IN DS 11807 13 4 CB48D8BABA0E44B9D363D3142463014EBDE6D28E15997EA8FB5FDBD42FDCF1CF3846E63925A5910DDD6A192571AEBD93
0.3.0.0 IN NS ns1.iwarp.neo.
7.0.0.0 IN NS ns1.staph.neo.
7.2.1.0 IN NS ns1.yura.dn42.
@ -44,4 +48,9 @@ $TTL 3600
6.6.a.a IN NS ns2.fixmix.neo.
6.6.a.a IN NS ns3.fixmix.neo.
8.8.4.1 IN NS ns1.bear.neo.
c.c.0.0 IN NS ns1.an.dn42.
9.9.0.0 IN NS ns1.tsingyao.neo.
9.9.0.0 IN NS ns2.tsingyao.neo.

View file

@ -35,6 +35,11 @@ acme IN AAAA fd10:127:53:223::1
edwardp IN A 10.127.8.130
edwardp IN AAAA fd10:127:2f2f::
tv IN A 10.127.15.58
lily IN A 10.127.8.137
lily IN AAAA fd10:127:ba7e::137
; DELEGATED ZONES
jerry IN NS ns1.jerry
jerry IN NS ns2.jerry
@ -119,4 +124,32 @@ ns1.fixmix IN AAAA fd10:127:aa66:11::
ns2.fixmix IN AAAA fd10:127:aa66:21::
ns3.fixmix IN AAAA fd10:127:aa66:31::
bear IN NS ns1.bear
koala IN NS ns1.bear
ns1.bear IN AAAA fd42:e621::53
iwarp IN NS ns1.iwarp
go IN NS ns1.iwarp
yux IN NS ns1.iwarp
ns1.iwarp IN A 10.127.30.53
ns1.iwarp IN AAAA fd10:127:30:53::1
an IN NS ns1.an.dn42.
dnswol IN NS ns1.dnswol
dnswol IN NS ns2.dnswol
dnswol IN DS 53285 14 1 88971c954d18aa1224a1b01e54c81dc6cd71a86e
dnswol IN DS 53285 14 2 d782d7d9afec4e20082913fe2f23fd9e2c0e0ad7206fa389cadc4050d11b7e80
dnswol IN DS 53285 14 4 1c0fcf050b4000de0648a8e25a8e809e35b7501c846ad785f07e2c4296610c305d217cb5113c34f937f62780e82b5e98
ns1.dnswol IN A 10.127.99.50
ns1.dnswol IN AAAA fd10:127:99::32:1
ns2.dnswol IN A 10.127.99.51
ns2.dnswol IN AAAA fd10:127:99::33:1
tsingyao IN NS ns1.dnswol
tsingyao IN NS ns2.dnswol
undefiend.moe IN A 10.127.88.1
*.undefined.moe IN A 10.127.88.1
undefiend.moe IN AAAA fd10:127:88::1
*.undefined.moe IN AAAA fd10:127:88::1

View file

@ -5,4 +5,4 @@ email = "noc@anillc.cn"
github = "Anillc"
[persona]
pgp = "DCD75832819A6CAB61C8F7D337F54FEE22679910"
pgp = "BB47FA42A55975F74AE19EF8918F98A096F9533C"

View file

@ -7,4 +7,4 @@ irc = "JerryXiao@hackint"
github = "isjerryxiao"
[persona]
pgp = "186242204A2EC70438E9CE3B9D9CE43650FF2BAA"
pgp = "5FC9AD5B960AD6F626E218DD22618F758B5BE2E5"

View file

@ -11,7 +11,7 @@ babel = [
]
[contact]
email = "lmy441900@live.com"
email = "neonetwork@yhi.moe"
telegram = "lmy441900"
mastodon = "@lmy441900@sn.angry.im"
github = "lmy441900"

8
entity/SyllaBear.toml Normal file
View file

@ -0,0 +1,8 @@
name = "SyllaBear"
[contact]
email = "bear@koala.gq"
github = "bearsylla"
[persona]
pgp = "F5EC83B433A35C8CDF5B66568FBCE429B9AB90F4"

10
entity/TsingYao.toml Normal file
View file

@ -0,0 +1,10 @@
name = "TsingYao"
babel = ["zh-N", "en"]
[contact]
email = "yujintong@126.com"
telegram = "yujintong"
github = "yujintong"
[persona]
pgp = "DD515D58188FBD2F9AF484F8AD04D02E24AC52C9"

View file

@ -2,5 +2,8 @@ name = "Yukari"
[contact]
telegram = "CharlesYang"
github = "SteveCharlesYang"
email = "charles@0x7f.cc"
github = "YukariChiba"
email = "i@0x7f.cc"
[persona]
pgp = "9DC663829861B7FDFB5DA8B39277CB21961D6DD5"

11
entity/Yux.toml Normal file
View file

@ -0,0 +1,11 @@
name = "Yux Zhu"
[contact]
email = "me@yux.im"
telegram = "im_yux"
github = "vfreex"
irc = "yux@hackint"
[persona]
pgp = "C1907229F1A6887550AD90A51ECBCCF8B5D891FD"

19
entity/kskb.toml Normal file
View file

@ -0,0 +1,19 @@
name = "kskb"
babel = [
"zh",
"en-3",
]
[contact]
email = "dn42@kskb.eu.org"
irc = "kskb"
telegram = "KusakabeSi"
mastodon = ""
github = "KusakabeSi"
# Details on identifying the entity online (optional). Usually, a PGP key
# fingerprint can be put here to help others communicate with the entity more
# securely.
[persona]
pgp = "716846E71E56F088BDF42E695A6761FECF4CAA65"

View file

@ -3,4 +3,4 @@ name = "licson"
[contact]
email = "admin@licson.net"
telegram = "licson"
github = "licson0729"
github = "licson"

View file

@ -0,0 +1,7 @@
name = "undefined-moe"
babel = ["zh", "en-3"]
[contact]
email = "i@undefined.moe"
telegram = "webpack_exports_undefined"
github = "undefined-moe"

2
node/IWarp.toml Normal file
View file

@ -0,0 +1,2 @@
[IWarp]
asn = 4201270030

3
node/TsingYao.toml Normal file
View file

@ -0,0 +1,3 @@
[TsingYao]
asn = 4201270099
description = "TsingYao Interconnection Region Edge Router"

View file

@ -1,3 +1,9 @@
[IX42-LAS]
asn = 207268
cidr = ["10.127.131.0/24", "fd10:127:1300::/48"]
[NIA-NET]
asn = 4242421331
[NIACN-NET]
asn = 4242421332

2
node/kskb.toml Normal file
View file

@ -0,0 +1,2 @@
[KSKB-HK1]
asn = 4201271111

View file

@ -1,2 +0,0 @@
[yhi-h]
asn = 4201270012

9
node/yhi.toml Normal file
View file

@ -0,0 +1,9 @@
[yhi-h]
asn = 4201270012
description = "Yhi Interconnection Region H Edge Router"
cidr = ["10.127.5.1/28"]
[yhi-s]
asn = 4201270012
description = "Yhi Interconnection Region S Edge Router"
cidr = ["10.127.5.17/28"]

View file

@ -1,9 +1,9 @@
["10.127.60.0/24"]
["10.127.17.0/24"]
type = "subnet"
name = "BAOSHUO-NEO-V4-1"
description = "Baoshuo Neo Network"
["fd10:127:9898::/48"]
["fd10:127:17::/48"]
type = "subnet"
name = "BAOSHUO-NEO-V6-1"
description = "Baoshuo Neo Network"

View file

@ -5,33 +5,23 @@ description = "Reserved"
["10.127.1.0/24"]
type = "subnet"
name = "CROOM"
description = "LAN at school"
name = "MAIN"
description = "LAN 1"
["10.127.2.0/24"]
type = "subnet"
name = "NeoSystem"
name = "Messed-up Network"
["10.127.16.0/24"]
type = "subnet"
name = "Neo_Chen ZeroTier-One Hub"
description = ""
["10.127.255.1/32"]
type = "loopback"
name = "NeoPDP-11"
description = "FreeBSD/frr"
["10.127.255.4/32"]
type = "loopback"
name = "fsnvax"
description = "Debian/frr"
["10.127.255.80/32"]
type = "loopback"
name = "NeoSystem"
description = "Arch Linux/frr"
["fd10:127:5f37:59df::/64"]
type = "subnet"
name = "NeoNetwork Origin"

View file

@ -1,4 +1,9 @@
["10.127.5.0/28"]
type = "subnet"
name = "yhi-h"
description = "Yhi Interconnect H"
description = "Yhi Interconnection Region H"
["10.127.5.16/28"]
type = "subnet"
name = "yhi-s"
description = "Yhi Interconnection Region S"

View file

@ -1,9 +1,9 @@
["10.127.60.0/24"]
["10.127.17.0/24"]
type = "subnet"
name = "BAOSHUO-NEO-V4-1"
description = "Baoshuo Neo Network"
["fd10:127:9898::/48"]
["fd10:127:17::/48"]
type = "subnet"
name = "BAOSHUO-NEO-V6-1"
description = "Baoshuo Neo Network"

10
route/AS4201270030.toml Normal file
View file

@ -0,0 +1,10 @@
["10.127.30.0/24"]
type = "subnet"
name = "IWARP-NEO-IP4-NETWORK"
description = "IWarp Global Experimental NeoNetwork - IPv4"
["fd10:127:30::/48"]
type = "subnet"
name = "IWARP-NEO-IP6-NETWORK"
description = "IWarp Global Experimental NeoNetwork - IPv6"

9
route/AS4201270099.toml Normal file
View file

@ -0,0 +1,9 @@
["10.127.99.0/24"]
type = "subnet"
name = "TSINTYAO-NEO-NET4"
description = "TsingYao Neo Network IPv4 Block"
["fd10:127:99::/48"]
type = "subnet"
name = "TSINGYAO-NEO-NET6"
description = "TsingYao Neo Network IPv6 Block"

9
route/AS4201271111.toml Normal file
View file

@ -0,0 +1,9 @@
["10.127.111.0/24"]
type = "subnet"
name = "kskb"
description = "kskb"
["fd10:127:e00f::/48"]
type = "subnet"
name = "kskb"
description = "kskb"

4
route/AS4201271488.toml Normal file
View file

@ -0,0 +1,4 @@
["fd10:127:1488::/48"]
type = "subnet"
name = "Bear"
description = "Bear Neo Network"

7
route/AS4201272526.toml Normal file
View file

@ -0,0 +1,7 @@
["10.127.3.0/24"]
type = "subnet"
name = "Anillc NEO Network v4"
["fd10:127:ee::/48"]
type = "subnet"
name = "Anillc NEO Network v6"

8
route/AS4201279999.toml Normal file
View file

@ -0,0 +1,8 @@
["10.127.88.0/24"]
type = "subnet"
name = "Hydro-Neo-Network-4"
["fd10:127:88::/48"]
type = "subnet"
name = "Hydro-Neo-Network-6"

View file

@ -1,9 +1,9 @@
["10.127.60.0/24"]
["10.127.17.0/24"]
type = "subnet"
name = "BAOSHUO-NEO-V4-1"
description = "Baoshuo Neo Network"
["fd10:127:9898::/48"]
["fd10:127:17::/48"]
type = "subnet"
name = "BAOSHUO-NEO-V6-1"
description = "Baoshuo Neo Network"

9
route/AS4242420288.toml Normal file
View file

@ -0,0 +1,9 @@
["10.127.30.0/24"]
type = "subnet"
name = "IWARP-NEO-IP4-NETWORK"
description = "IWarp Global Experimental NeoNetwork - IPv4"
["fd10:127:30::/48"]
type = "subnet"
name = "IWARP-NEO-IP6-NETWORK"
description = "IWarp Global Experimental NeoNetwork - IPv6"

9
route/AS4242421332.toml Normal file
View file

@ -0,0 +1,9 @@
["10.127.132.0/24"]
type = "subnet"
name = "NetUnion-IPv4"
description = "NetUnion access. (IPv4)"
["fd10:127:1332::/48"]
type = "subnet"
name = "NetUnion-IPv6"
description = "NetUnion access. (IPv6)"

9
route/AS4242423699.toml Normal file
View file

@ -0,0 +1,9 @@
["10.127.99.0/24"]
type = "subnet"
name = "TSINTYAO-NEO-NET4"
description = "TsingYao Neo Network IPv4 Block"
["fd10:127:99::/48"]
type = "subnet"
name = "TSINGYAO-NEO-NET6"
description = "TsingYao Neo Network IPv6 Block"

View file

@ -3,28 +3,42 @@ import sys
from pathlib import Path
import toml
from rfc2317 import gen_reverse_pointers
RESOLVE_FILE = Path("dns", "db.10.127")
from rfc2317 import gen_reverse_pointers, ZONE as RFC2317_ZONE
from roa import export_dnssec_dnskey
ZONE_FILE_MAP = {
'neo.': Path("dns", "neonetwork"),
'127.10.in-addr.arpa.': Path("dns", "db.10.127"),
'7.2.1.0.0.1.d.f.ip6.arpa.': Path("dns", "db.fd10.127")
}
RFC2317_FILE = Path("dns", "rfc2317.toml")
def iter_rfc2317_entry():
entries = toml.loads(RFC2317_FILE.read_text())
for (route, attributes) in entries.items():
ns = attributes.get('NS')
ds = attributes.get('DS', list())
ttl = attributes.get('TTL', -1)
yield(route, ns, ds, ttl)
ns = attributes.get("NS")
ds = attributes.get("DS", list())
ttl = attributes.get("TTL", -1)
yield (route, ns, ds, ttl)
def main():
orignal = RESOLVE_FILE.read_text()
records = [orignal, "; AUTOGENERATED"]
records.extend(("", "; rfc2317"))
for route, ns, ds, ttl in iter_rfc2317_entry():
records.extend(gen_reverse_pointers(route, ns, ds, ttl))
DNSKEYS = {entry['zone']: entry['records'] for entry in export_dnssec_dnskey()}
for zone, zone_file in ZONE_FILE_MAP.items():
orignal = zone_file.read_text()
records = [orignal, "; AUTOGENERATED"]
if zone.strip('.') == RFC2317_ZONE.strip('.'):
records.extend(("", "; rfc2317"))
for route, ns, ds, ttl in iter_rfc2317_entry():
records.extend(gen_reverse_pointers(route, ns, ds, ttl))
records.append("")
records.extend(("", "; dnskey"))
for key_ds in DNSKEYS[zone]:
records.append(f"@ IN DNSKEY {key_ds['dnskey']}")
records.append("")
RESOLVE_FILE.write_text("\n".join(records))
zone_file.write_text("\n".join(records))
if __name__ == "__main__":

View file

@ -6,11 +6,11 @@ import argparse
from pathlib import Path
if __name__ == "__main__":
parser = argparse.ArgumentParser('named-formatzone')
parser = argparse.ArgumentParser("named-formatzone")
parser.add_argument("file")
args = parser.parse_args()
zonefile = Path(args.file)
zonelines = zonefile.read_text().split('\n')
zonelines = zonefile.read_text().split("\n")
formatted = list()
max_length = [0, 0, 0, 0, 0]
in_soa = False
@ -18,7 +18,7 @@ if __name__ == "__main__":
def iter_lines(scan_only=True):
soafound = None
for rline in zonelines:
line, *comments = rline.split(';')
line, *comments = rline.split(";")
comments = ";".join(comments)
line = line.strip()
if "SOA" in line and soafound is None:
@ -41,7 +41,7 @@ if __name__ == "__main__":
else:
fmtlline = list()
for i, entry in enumerate(cols):
entry += " "*(max_length[i]-len(entry)+3)
entry += " " * (max_length[i] - len(entry) + 3)
if entry:
fmtlline.append(entry)
fmtline = " ".join(fmtlline)
@ -50,6 +50,7 @@ if __name__ == "__main__":
else:
if not scan_only:
formatted.append(rline)
iter_lines()
iter_lines(False)

View file

@ -2,12 +2,15 @@
import ipaddress
ZONE = '.127.10.in-addr.arpa'
ZONE = ".127.10.in-addr.arpa"
def truncate(rev: str) -> str:
assert rev.endswith(ZONE)
rev = rev[:-len(ZONE)]
rev = rev[: -len(ZONE)]
return rev
def gen_reverse_pointers(network: str, ns: list, ds: list = [], ttl: int = -1) -> list:
ttl = f"{ttl} " if 900 <= ttl <= 86400 else ""
buf = list()
@ -25,5 +28,17 @@ def gen_reverse_pointers(network: str, ns: list, ds: list = [], ttl: int = -1) -
buf.append(f"{cnamefr} {ttl}IN CNAME {cnameto}")
return buf
if __name__ == "__main__":
print("\n".join(gen_reverse_pointers('10.127.8.64/26', ['ns1.jerry.neo.'], ['18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804'], ttl=1500)))
print(
"\n".join(
gen_reverse_pointers(
"10.127.8.64/26",
["ns1.jerry.neo."],
[
"18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804"
],
ttl=1500,
)
)
)

View file

@ -3,8 +3,12 @@ import argparse
import json
import re
import time
# dnssec
from base64 import b64decode
from collections import defaultdict
from contextlib import redirect_stdout
from functools import wraps
from io import StringIO
from ipaddress import IPv4Network, IPv6Network, ip_network
from itertools import combinations
@ -12,12 +16,9 @@ from pathlib import Path
import netaddr
import toml
from tabulate import tabulate
# dnssec
from base64 import b64decode
from dns.dnssec import make_ds
from dns.rdtypes.ANY.DNSKEY import DNSKEY
from tabulate import tabulate
NEO_NETWORK_POOL = [ip_network("10.127.0.0/16"), ip_network("fd10:127::/32")]
@ -62,11 +63,24 @@ def iter_toml_file(path: str):
yield item, toml.loads(item.read_text())
def _sort_as_iterator(func):
@wraps(func)
def wrapped(*args, **kwargs):
for item in sorted(
list(func(*args, **kwargs)), key=lambda x: x[0], reverse=False
):
yield item
return wrapped
@_sort_as_iterator
def load_entities():
for item, entity in iter_toml_file("entity"):
yield item.stem, entity
@_sort_as_iterator
def load_asn(entities: dict):
for item, entity in iter_toml_file("asn"):
asn = int(item.stem.lstrip("AS"))
@ -133,7 +147,9 @@ def route_to_roa(asn_table: dict):
try:
assert net1["prefix"] != net2["prefix"]
except AssertionError:
assert net1['asn'] != net2['asn'] and entity_from_net(net1) == entity_from_net(net2)
assert net1["asn"] != net2["asn"] and entity_from_net(
net1
) == entity_from_net(net2)
continue
assert net1["prefix"].supernet_of(net2["prefix"])
s1net, s2net = (net1["supernet"], net2["supernet"])
@ -170,10 +186,19 @@ def prehandle_roa(asn_table: dict, args):
r["prefix"] = r["prefix"].with_prefixlen
return roa4, roa6
def export_dnssec_dnskey():
def ds_from_dnskey(zone, flags, protocol, algorithm, *key):
dnspy_dnskey = DNSKEY("IN", "DNSKEY", int(flags), int(protocol), int(algorithm), b64decode(" ".join(key)))
dnspy_dnskey = DNSKEY(
"IN",
"DNSKEY",
int(flags),
int(protocol),
int(algorithm),
b64decode(" ".join(key)),
)
return make_ds(zone, dnspy_dnskey, "SHA256").to_text()
dnskey_path = Path("dns") / "dnssec"
dnskeys = list()
for f in dnskey_path.iterdir():
@ -188,14 +213,17 @@ def export_dnssec_dnskey():
zonekey["zone"] = zone
else:
assert zonekey["zone"] == zone
zonekey["records"].append({
"dnskey": " ".join(dnskey),
"ds": ds_from_dnskey(zone, *dnskey),
})
zonekey["records"].append(
{
"dnskey": " ".join(dnskey),
"ds": ds_from_dnskey(zone, *dnskey),
}
)
if zonekey["zone"]:
dnskeys.append(zonekey)
return dnskeys
def make_export(roa4, roa6):
def modify_entity(entity):
entity["nic_hdl"] = name_to_nic_hdl(entity["name"])
@ -234,7 +262,7 @@ def make_export(roa4, roa6):
}
for owner, entity in entities.items()
},
"dnssec": export_dnssec_dnskey()
"dnssec": export_dnssec_dnskey(),
}
return json.dumps(output, indent=2)
@ -263,7 +291,10 @@ def make_rfc8416(roa4, roa6):
"bgpsecAssertions": [],
"prefixAssertions": [
pick(
roa, ["asn", "prefix"], maxLength="maxPrefixLength", name="comment",
roa,
["asn", "prefix"],
maxLength="maxPrefixLength",
name="comment",
)
for roa in (*roa4, *roa6)
],
@ -371,19 +402,51 @@ def make_summary():
print(prefix)
print("```")
IP_VRSIONS = {4, 6}
total_ip_count = {ver: sum([prefix.num_addresses for prefix in NEO_NETWORK_POOL if prefix.version == ver]) for ver in IP_VRSIONS}
used_ip_count = {ver: sum([ip_network(str(prefix)).num_addresses for prefix in prefixes if prefix.version == ver]) for ver in IP_VRSIONS}
total_ip_count = {
ver: sum(
[
prefix.num_addresses
for prefix in NEO_NETWORK_POOL
if prefix.version == ver
]
)
for ver in IP_VRSIONS
}
used_ip_count = {
ver: sum(
[
ip_network(str(prefix)).num_addresses
for prefix in prefixes
if prefix.version == ver
]
)
for ver in IP_VRSIONS
}
print()
print("## Address Space Usage")
print()
address_space_usage_table = tabulate(
(
(f"IPv{ver}", f"{(t:=total_ip_count.get(ver)):.5g}", f"{(u:=used_ip_count.get(ver)):.5g}", f"{t-u:.5g}", f"{u/t*100:.2f}%", f"{(t-u)/t*100:.2f}%")
(
f"IPv{ver}",
f"{(t:=total_ip_count.get(ver)):.5g}",
f"{(u:=used_ip_count.get(ver)):.5g}",
f"{t-u:.5g}",
f"{u/t*100:.2f}%",
f"{(t-u)/t*100:.2f}%",
)
for ver in IP_VRSIONS
),
headers=["IP Version", "Total", "Used", "Free", "Percent Used", "Percent Free"],
headers=[
"IP Version",
"Total",
"Used",
"Free",
"Percent Used",
"Percent Free",
],
tablefmt="github",
disable_numparse=True
disable_numparse=True,
)
print(address_space_usage_table)
return stream.getvalue()

View file

@ -1,23 +1,24 @@
#!/usr/bin/env python3
from pathlib import Path
import subprocess
from time import time
from re import match
from os import chdir
from pathlib import Path
from re import match
from time import time
zone_files = [
'neonetwork',
'db.10.127',
'db.fd10.127',
"neonetwork",
"db.10.127",
"db.fd10.127",
]
serial_base = 1586876035
new_serial = int(time()) - serial_base
def update_serial_to(zone: Path, serial: int = 0) -> int:
lines = zone.read_text().split("\n")
processed = list()
assert 0 <= serial <= 2**32
assert 0 <= serial <= 2 ** 32
found = False
old_serial = None
for line in lines:
@ -34,6 +35,7 @@ def update_serial_to(zone: Path, serial: int = 0) -> int:
zone.write_text("\n".join(processed))
return old_serial
for zone in zone_files:
gen_zone = Path("generated") / "dns" / zone
repo_zone = Path("dns") / zone
@ -42,7 +44,9 @@ for zone in zone_files:
old_serial = update_serial_to(gen_zone)
update_serial_to(repo_zone, old_serial)
gen_zone.write_text(repo_zone.read_text())
p = subprocess.run(['git', 'diff', '--exit-code', gen_zone.name], cwd=gen_zone.parent)
p = subprocess.run(
["git", "diff", "--exit-code", gen_zone.name], cwd=gen_zone.parent
)
if p.returncode == 0:
print(f"skip {repo_zone.name}")
else: