1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-12-26 13:39:24 +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" owner = "Junde Yhi"

View file

@ -1,3 +1,3 @@
name = "BAOSHUO-AS-NEO" name = "BAOSHUO-AS-NEO"
owner = "Ren Baoshuo" 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. 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. 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. 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. 1.15 IN PTR ae-0-1.cr2.hkg1.licson.neo.
58.15 IN PTR live.licson.neo.
1.8 IN PTR librehs.neo. 1.8 IN PTR librehs.neo.
2.8 IN PTR blog.librehs.neo. 2.8 IN PTR blog.librehs.neo.
130.8 IN PTR edwardp.neo. 130.8 IN PTR edwardp.neo.
137.8 IN PTR lily.neo.
; Loopback Addresses ; Loopback Addresses
1.255 IN PTR NeoPDP-11.neo. 1.255 IN PTR NeoPDP-11.neo.
@ -80,9 +87,14 @@ $TTL 3600
21 IN NS ns.iedon.neo. 21 IN NS ns.iedon.neo.
30 IN NS ns1.iwarp.neo.
127 IN NS ns1.yura.dn42. 127 IN NS ns1.yura.dn42.
127 IN NS ns2.yura.dn42. 127 IN NS ns2.yura.dn42.
66 IN NS ns1.fixmix.neo. 66 IN NS ns1.fixmix.neo.
66 IN NS ns2.fixmix.neo. 66 IN NS ns2.fixmix.neo.
66 IN NS ns3.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. 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. 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 ; 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. 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 2 BBADC27B4EBFC90CBA79F4E69E4F167B9FFAF664B071F4CC46196902054B0910
0.1.0.0 IN DS 11807 13 4 CB48D8BABA0E44B9D363D3142463014EBDE6D28E15997EA8FB5FDBD42FDCF1CF3846E63925A5910DDD6A192571AEBD93 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.0.0.0 IN NS ns1.staph.neo.
7.2.1.0 IN NS ns1.yura.dn42. 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 ns2.fixmix.neo.
6.6.a.a IN NS ns3.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. 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 A 10.127.8.130
edwardp IN AAAA fd10:127:2f2f:: 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 ; DELEGATED ZONES
jerry IN NS ns1.jerry jerry IN NS ns1.jerry
jerry IN NS ns2.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:: ns2.fixmix IN AAAA fd10:127:aa66:21::
ns3.fixmix IN AAAA fd10:127:aa66:31:: 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. 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" github = "Anillc"
[persona] [persona]
pgp = "DCD75832819A6CAB61C8F7D337F54FEE22679910" pgp = "BB47FA42A55975F74AE19EF8918F98A096F9533C"

View file

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

View file

@ -11,7 +11,7 @@ babel = [
] ]
[contact] [contact]
email = "lmy441900@live.com" email = "neonetwork@yhi.moe"
telegram = "lmy441900" telegram = "lmy441900"
mastodon = "@lmy441900@sn.angry.im" mastodon = "@lmy441900@sn.angry.im"
github = "lmy441900" 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] [contact]
telegram = "CharlesYang" telegram = "CharlesYang"
github = "SteveCharlesYang" github = "YukariChiba"
email = "charles@0x7f.cc" 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] [contact]
email = "admin@licson.net" email = "admin@licson.net"
telegram = "licson" 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] [IX42-LAS]
asn = 207268 asn = 207268
cidr = ["10.127.131.0/24", "fd10:127:1300::/48"] 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" type = "subnet"
name = "BAOSHUO-NEO-V4-1" name = "BAOSHUO-NEO-V4-1"
description = "Baoshuo Neo Network" description = "Baoshuo Neo Network"
["fd10:127:9898::/48"] ["fd10:127:17::/48"]
type = "subnet" type = "subnet"
name = "BAOSHUO-NEO-V6-1" name = "BAOSHUO-NEO-V6-1"
description = "Baoshuo Neo Network" description = "Baoshuo Neo Network"

View file

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

View file

@ -1,4 +1,9 @@
["10.127.5.0/28"] ["10.127.5.0/28"]
type = "subnet" type = "subnet"
name = "yhi-h" 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" type = "subnet"
name = "BAOSHUO-NEO-V4-1" name = "BAOSHUO-NEO-V4-1"
description = "Baoshuo Neo Network" description = "Baoshuo Neo Network"
["fd10:127:9898::/48"] ["fd10:127:17::/48"]
type = "subnet" type = "subnet"
name = "BAOSHUO-NEO-V6-1" name = "BAOSHUO-NEO-V6-1"
description = "Baoshuo Neo Network" 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" type = "subnet"
name = "BAOSHUO-NEO-V4-1" name = "BAOSHUO-NEO-V4-1"
description = "Baoshuo Neo Network" description = "Baoshuo Neo Network"
["fd10:127:9898::/48"] ["fd10:127:17::/48"]
type = "subnet" type = "subnet"
name = "BAOSHUO-NEO-V6-1" name = "BAOSHUO-NEO-V6-1"
description = "Baoshuo Neo Network" 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 from pathlib import Path
import toml 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") RFC2317_FILE = Path("dns", "rfc2317.toml")
def iter_rfc2317_entry(): def iter_rfc2317_entry():
entries = toml.loads(RFC2317_FILE.read_text()) entries = toml.loads(RFC2317_FILE.read_text())
for (route, attributes) in entries.items(): for (route, attributes) in entries.items():
ns = attributes.get('NS') ns = attributes.get("NS")
ds = attributes.get('DS', list()) ds = attributes.get("DS", list())
ttl = attributes.get('TTL', -1) ttl = attributes.get("TTL", -1)
yield(route, ns, ds, ttl) yield (route, ns, ds, ttl)
def main(): def main():
orignal = RESOLVE_FILE.read_text() 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"] records = [orignal, "; AUTOGENERATED"]
if zone.strip('.') == RFC2317_ZONE.strip('.'):
records.extend(("", "; rfc2317")) records.extend(("", "; rfc2317"))
for route, ns, ds, ttl in iter_rfc2317_entry(): for route, ns, ds, ttl in iter_rfc2317_entry():
records.extend(gen_reverse_pointers(route, ns, ds, ttl)) records.extend(gen_reverse_pointers(route, ns, ds, ttl))
records.append("") records.append("")
records.extend(("", "; dnskey"))
RESOLVE_FILE.write_text("\n".join(records)) for key_ds in DNSKEYS[zone]:
records.append(f"@ IN DNSKEY {key_ds['dnskey']}")
records.append("")
zone_file.write_text("\n".join(records))
if __name__ == "__main__": if __name__ == "__main__":

View file

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

View file

@ -2,12 +2,15 @@
import ipaddress import ipaddress
ZONE = '.127.10.in-addr.arpa' ZONE = ".127.10.in-addr.arpa"
def truncate(rev: str) -> str: def truncate(rev: str) -> str:
assert rev.endswith(ZONE) assert rev.endswith(ZONE)
rev = rev[:-len(ZONE)] rev = rev[: -len(ZONE)]
return rev return rev
def gen_reverse_pointers(network: str, ns: list, ds: list = [], ttl: int = -1) -> list: def gen_reverse_pointers(network: str, ns: list, ds: list = [], ttl: int = -1) -> list:
ttl = f"{ttl} " if 900 <= ttl <= 86400 else "" ttl = f"{ttl} " if 900 <= ttl <= 86400 else ""
buf = list() 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}") buf.append(f"{cnamefr} {ttl}IN CNAME {cnameto}")
return buf return buf
if __name__ == "__main__": 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 json
import re import re
import time import time
# dnssec
from base64 import b64decode
from collections import defaultdict from collections import defaultdict
from contextlib import redirect_stdout from contextlib import redirect_stdout
from functools import wraps
from io import StringIO from io import StringIO
from ipaddress import IPv4Network, IPv6Network, ip_network from ipaddress import IPv4Network, IPv6Network, ip_network
from itertools import combinations from itertools import combinations
@ -12,12 +16,9 @@ from pathlib import Path
import netaddr import netaddr
import toml import toml
from tabulate import tabulate
# dnssec
from base64 import b64decode
from dns.dnssec import make_ds from dns.dnssec import make_ds
from dns.rdtypes.ANY.DNSKEY import DNSKEY 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")] 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()) 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(): def load_entities():
for item, entity in iter_toml_file("entity"): for item, entity in iter_toml_file("entity"):
yield item.stem, entity yield item.stem, entity
@_sort_as_iterator
def load_asn(entities: dict): def load_asn(entities: dict):
for item, entity in iter_toml_file("asn"): for item, entity in iter_toml_file("asn"):
asn = int(item.stem.lstrip("AS")) asn = int(item.stem.lstrip("AS"))
@ -133,7 +147,9 @@ def route_to_roa(asn_table: dict):
try: try:
assert net1["prefix"] != net2["prefix"] assert net1["prefix"] != net2["prefix"]
except AssertionError: 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 continue
assert net1["prefix"].supernet_of(net2["prefix"]) assert net1["prefix"].supernet_of(net2["prefix"])
s1net, s2net = (net1["supernet"], net2["supernet"]) s1net, s2net = (net1["supernet"], net2["supernet"])
@ -170,10 +186,19 @@ def prehandle_roa(asn_table: dict, args):
r["prefix"] = r["prefix"].with_prefixlen r["prefix"] = r["prefix"].with_prefixlen
return roa4, roa6 return roa4, roa6
def export_dnssec_dnskey(): def export_dnssec_dnskey():
def ds_from_dnskey(zone, flags, protocol, algorithm, *key): 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() return make_ds(zone, dnspy_dnskey, "SHA256").to_text()
dnskey_path = Path("dns") / "dnssec" dnskey_path = Path("dns") / "dnssec"
dnskeys = list() dnskeys = list()
for f in dnskey_path.iterdir(): for f in dnskey_path.iterdir():
@ -188,14 +213,17 @@ def export_dnssec_dnskey():
zonekey["zone"] = zone zonekey["zone"] = zone
else: else:
assert zonekey["zone"] == zone assert zonekey["zone"] == zone
zonekey["records"].append({ zonekey["records"].append(
{
"dnskey": " ".join(dnskey), "dnskey": " ".join(dnskey),
"ds": ds_from_dnskey(zone, *dnskey), "ds": ds_from_dnskey(zone, *dnskey),
}) }
)
if zonekey["zone"]: if zonekey["zone"]:
dnskeys.append(zonekey) dnskeys.append(zonekey)
return dnskeys return dnskeys
def make_export(roa4, roa6): def make_export(roa4, roa6):
def modify_entity(entity): def modify_entity(entity):
entity["nic_hdl"] = name_to_nic_hdl(entity["name"]) entity["nic_hdl"] = name_to_nic_hdl(entity["name"])
@ -234,7 +262,7 @@ def make_export(roa4, roa6):
} }
for owner, entity in entities.items() for owner, entity in entities.items()
}, },
"dnssec": export_dnssec_dnskey() "dnssec": export_dnssec_dnskey(),
} }
return json.dumps(output, indent=2) return json.dumps(output, indent=2)
@ -263,7 +291,10 @@ def make_rfc8416(roa4, roa6):
"bgpsecAssertions": [], "bgpsecAssertions": [],
"prefixAssertions": [ "prefixAssertions": [
pick( pick(
roa, ["asn", "prefix"], maxLength="maxPrefixLength", name="comment", roa,
["asn", "prefix"],
maxLength="maxPrefixLength",
name="comment",
) )
for roa in (*roa4, *roa6) for roa in (*roa4, *roa6)
], ],
@ -371,19 +402,51 @@ def make_summary():
print(prefix) print(prefix)
print("```") print("```")
IP_VRSIONS = {4, 6} 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} total_ip_count = {
used_ip_count = {ver: sum([ip_network(str(prefix)).num_addresses for prefix in prefixes if prefix.version == ver]) for ver in IP_VRSIONS} 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()
print("## Address Space Usage") print("## Address Space Usage")
print() print()
address_space_usage_table = tabulate( 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 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", tablefmt="github",
disable_numparse=True disable_numparse=True,
) )
print(address_space_usage_table) print(address_space_usage_table)
return stream.getvalue() return stream.getvalue()

View file

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