3 Commits

40 changed files with 2895 additions and 1529 deletions
Unified View
  1. +21
    -0
      .gitignore
  2. +18
    -0
      check-my-stuff
  3. +1
    -1
      data/as-block/AS1-AS4294967294
  4. +1
    -1
      data/as-block/AS4266030000-AS4266033999
  5. +13
    -13
      data/inet6num/::_0
  6. +10
    -10
      data/inet6num/fd00::_8
  7. +1
    -1
      data/inetnum/0.0.0.0_0
  8. +1
    -1
      data/inetnum/172.24.0.0_14
  9. +1
    -1
      data/inetnum/172.24.0.0_16
  10. +1
    -1
      data/inetnum/172.24.0.0_18
  11. +1
    -1
      data/inetnum/172.24.0.0_24
  12. +1
    -1
      data/inetnum/172.24.64.0_18
  13. +1
    -1
      data/inetnum/172.25.0.0_16
  14. +1
    -1
      data/inetnum/172.25.0.0_24
  15. +1
    -1
      data/inetnum/172.26.0.0_16
  16. +1
    -1
      data/inetnum/172.26.0.0_24
  17. +1
    -1
      data/inetnum/172.27.0.0_16
  18. +1
    -1
      data/inetnum/172.27.0.0_24
  19. +1
    -1
      data/mntner/NX3-MNT
  20. +4
    -4
      data/registry/NX3
  21. +1
    -1
      data/schema/AS-BLOCK-SCHEMA
  22. +1
    -1
      data/schema/AS-SET-SCHEMA
  23. +1
    -1
      data/schema/AUT-NUM-SCHEMA
  24. +1
    -1
      data/schema/DNS-SCHEMA
  25. +1
    -1
      data/schema/INET6NUM-SCHEMA
  26. +1
    -1
      data/schema/INETNUM-SCHEMA
  27. +1
    -1
      data/schema/KEY-CERT-SCHEMA
  28. +1
    -1
      data/schema/MNTNER-SCHEMA
  29. +1
    -1
      data/schema/ORGANISATION-SCHEMA
  30. +1
    -1
      data/schema/PERSON-SCHEMA
  31. +1
    -1
      data/schema/REGISTRY-SCHEMA
  32. +1
    -1
      data/schema/ROLE-SCHEMA
  33. +1
    -1
      data/schema/ROUTE-SCHEMA
  34. +1
    -1
      data/schema/ROUTE-SET-SCHEMA
  35. +1
    -1
      data/schema/ROUTE6-SCHEMA
  36. +1
    -10
      data/schema/SCHEMA-SCHEMA
  37. +14
    -0
      fmt-my-stuff
  38. +177
    -0
      utils/schema-check/log.py
  39. +1145
    -0
      utils/schema-check/nx3_schema.py
  40. +1462
    -1462
      utils/schema-check/nx3_schema_local.py

+ 21
- 0
.gitignore View File

@ -0,0 +1,21 @@
_MTN
lib/
whoisd/
__pycache__
/data/.rpsl
# ---> Emacs
# -*- mode: gitignore; -*-
*~
\#*\#
.\#*
# ---> macOS
# General
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*

+ 18
- 0
check-my-stuff View File

@ -0,0 +1,18 @@
#!/bin/sh
if [ "$#" -eq "0" ]
then
echo "Usage: $0 YOUR-MNT"
exit
fi
BASE="$(readlink -f "$0" 2>/dev/null || python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' "$0")"
BASE="$(dirname "$BASE")"
cd "$BASE" || exit 1
if [ "$1" = "--all" ]; then
utils/schema-check/nx3_schema.py -v scan data/ || ( echo "Schema validation failed, please check above!" ; exit 1 )
else
utils/schema-check/nx3_schema.py -v scan data/ -f "data/mntner/$1" || ( echo "Schema validation for mntner object failed, please check above!" ; exit 1 )
utils/schema-check/nx3_schema.py -v scan data/ -m "$1" || ( echo "Schema validation for related objects failed, please check above!" ; exit 1 )
fi

+ 1
- 1
data/as-block/AS1-AS4294967294 View File

@ -4,4 +4,4 @@ remarks: This block is reserved to delegate access for sub-allocation
remarks: You can not freely register any ASN in this block. remarks: You can not freely register any ASN in this block.
mnt-by: NX3-MNT mnt-by: NX3-MNT
policy: closed policy: closed
source: NX3
source: NX3

+ 1
- 1
data/as-block/AS4266030000-AS4266033999 View File

@ -4,4 +4,4 @@ remarks: This block is reserved for end-user allocation.
remarks: You can freely register any ASN in this block. remarks: You can freely register any ASN in this block.
mnt-by: NX3-MNT mnt-by: NX3-MNT
policy: open policy: open
source: NX3
source: NX3

+ 13
- 13
data/inet6num/::_0 View File

@ -1,13 +1,13 @@
inet6num: 0000:0000:0000:0000:0000:0000:0000:0000 - ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
netname: IANA-RESERVED
descr: IANA Reserved Space
remarks: This space is reserved by RFC4291.
remarks:
remarks: Because portions are not routable inside nx3
remarks: reservations are not allowed at this level.
remarks:
remarks: Open policy can be found inside fd00::/8
mnt-by: NX3-MNT
policy: reserved
cidr: ::/0
source: NX3
inet6num: 0000:0000:0000:0000:0000:0000:0000:0000 - ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
netname: IANA-RESERVED
descr: IANA Reserved Space
remarks: This space is reserved by RFC4291.
remarks:
remarks: Because portions are not routable inside nx3
remarks: reservations are not allowed at this level.
remarks:
remarks: Open policy can be found inside fd00::/8
mnt-by: NX3-MNT
policy: reserved
cidr: ::/0
source: NX3

+ 10
- 10
data/inet6num/fd00::_8 View File

@ -1,10 +1,10 @@
inet6num: fd00:0000:0000:0000:0000:0000:0000:0000 - fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
cidr: fd00::/8
netname: ROOT-NX3-ULA
descr: NX3 ULA Address Space
remarks: Only /48 prefixes may be allocated out of this range.
status: ALLOCATED
policy: open
org: ORG-NX3
mnt-by: NX3-MNT
source: NX3
inet6num: fd00:0000:0000:0000:0000:0000:0000:0000 - fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
cidr: fd00::/8
netname: ROOT-NX3-ULA
descr: NX3 ULA Address Space
remarks: Only /48 prefixes may be allocated out of this range.
status: ALLOCATED
policy: open
org: ORG-NX3
mnt-by: NX3-MNT
source: NX3

+ 1
- 1
data/inetnum/0.0.0.0_0 View File

@ -5,4 +5,4 @@ policy: reserved
descr: * The entire IPv4 address space descr: * The entire IPv4 address space
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.24.0.0_14 View File

@ -4,4 +4,4 @@ netname: NET-BLK414-NX3
policy: reserved policy: reserved
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.24.0.0_16 View File

@ -6,4 +6,4 @@ remarks: Not free for direct assignment, see sub-allocated blocks
policy: reserved policy: reserved
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.24.0.0_18 View File

@ -6,4 +6,4 @@ remarks: * Defined this way for future policies
policy: open policy: open
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.24.0.0_24 View File

@ -6,4 +6,4 @@ remarks: * Reserved for anycast services, typically a /32 for each se
policy: ask policy: ask
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.24.64.0_18 View File

@ -6,4 +6,4 @@ remarks: * Defined this way for future policies
policy: open policy: open
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.25.0.0_16 View File

@ -6,4 +6,4 @@ remarks: Not free for direct assignment, see sub-allocated blocks
policy: reserved policy: reserved
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.25.0.0_24 View File

@ -6,4 +6,4 @@ remarks: * Reserved for anycast services, typically a /32 for each se
policy: ask policy: ask
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.26.0.0_16 View File

@ -6,4 +6,4 @@ remarks: Not free for direct assignment, see sub-allocated blocks
policy: reserved policy: reserved
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.26.0.0_24 View File

@ -6,4 +6,4 @@ remarks: * Reserved for anycast services, typically a /32 for each se
policy: ask policy: ask
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.27.0.0_16 View File

@ -6,4 +6,4 @@ remarks: Not free for direct assignment, see sub-allocated blocks
policy: reserved policy: reserved
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/inetnum/172.27.0.0_24 View File

@ -6,4 +6,4 @@ remarks: * Reserved for anycast services, typically a /32 for each se
policy: ask policy: ask
mnt-by: NX3-MNT mnt-by: NX3-MNT
status: ALLOCATED status: ALLOCATED
source: NX3
source: NX3

+ 1
- 1
data/mntner/NX3-MNT View File

@ -1,4 +1,4 @@
mntner: NX3-MNT mntner: NX3-MNT
descr: mntner for owning objects in the name of whole nx3. descr: mntner for owning objects in the name of whole nx3.
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 4
- 4
data/registry/NX3 View File

@ -1,4 +1,4 @@
registry: NX3
url: https://git.brettb.xyz/nx3/registry
mnt-by: NX3-MNT
source: NX3
registry: NX3
url: https://git.brettb.xyz/nx3/registry
mnt-by: NX3-MNT
source: NX3

+ 1
- 1
data/schema/AS-BLOCK-SCHEMA View File

@ -10,4 +10,4 @@ key: tech-c optional multiple lookup=nx3.person,nx3.role
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/AS-SET-SCHEMA View File

@ -11,4 +11,4 @@ key: tech-c optional multiple lookup=nx3.person,nx3.role
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/AUT-NUM-SCHEMA View File

@ -21,4 +21,4 @@ key: geo-loc optional multiple > [lat-c] [long-c] [name]
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/DNS-SCHEMA View File

@ -13,4 +13,4 @@ key: ds-rdata optional multiple
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/INET6NUM-SCHEMA View File

@ -21,4 +21,4 @@ key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
network-owner: inet6num network-owner: inet6num
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/INETNUM-SCHEMA View File

@ -22,4 +22,4 @@ key: source required single lookup=nx3.registry
network-owner: inet6num network-owner: inet6num
network-owner: inetnum network-owner: inetnum
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/KEY-CERT-SCHEMA View File

@ -13,4 +13,4 @@ key: tech-c optional multiple lookup=nx3.person,nx3.role
key: mnt-by required multiple lookup=nx3.mntner key: mnt-by required multiple lookup=nx3.mntner
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/MNTNER-SCHEMA View File

@ -12,4 +12,4 @@ key: abuse-mailbox optional single
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/ORGANISATION-SCHEMA View File

@ -20,4 +20,4 @@ key: remarks optional multiple
key: address optional multiple key: address optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/PERSON-SCHEMA View File

@ -17,4 +17,4 @@ key: address optional multiple
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/REGISTRY-SCHEMA View File

@ -9,4 +9,4 @@ key: admin-c optional multiple lookup=nx3.person,nx3.role
key: tech-c optional multiple lookup=nx3.person,nx3.role key: tech-c optional multiple lookup=nx3.person,nx3.role
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/ROLE-SCHEMA View File

@ -13,4 +13,4 @@ key: descr optional single
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/ROUTE-SCHEMA View File

@ -14,4 +14,4 @@ key: pingable optional multiple
key: max-length optional single key: max-length optional single
network-owner: inetnum network-owner: inetnum
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/ROUTE-SET-SCHEMA View File

@ -12,4 +12,4 @@ key: tech-c optional multiple lookup=nx3.person,nx3.role
key: remarks optional multiple key: remarks optional multiple
key: source required single lookup=nx3.registry key: source required single lookup=nx3.registry
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 1
data/schema/ROUTE6-SCHEMA View File

@ -14,4 +14,4 @@ key: pingable optional multiple
key: max-length optional single key: max-length optional single
network-owner: inet6num network-owner: inet6num
mnt-by: NX3-MNT mnt-by: NX3-MNT
source: NX3
source: NX3

+ 1
- 10
data/schema/SCHEMA-SCHEMA View File

@ -23,39 +23,30 @@ mnt-by: NX3-MNT
source: NX3 source: NX3
remarks: # option descriptions remarks: # option descriptions
Attribute names must match /[a-zA-Z]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?/. Attribute names must match /[a-zA-Z]([a-zA-Z0-9_\-]*[a-zA-Z0-9])?/.
+
required required
: object required to have at least one : object required to have at least one
optional optional
: object not required to have at least one : object not required to have at least one
+
single single
: only one of this type allowed : only one of this type allowed
multiple multiple
: more than one of this type allowed : more than one of this type allowed
+
primary primary
: use field as lookup key for lookup : use field as lookup key for lookup
* only one allowed per schema * only one allowed per schema
* does not allow newlines * does not allow newlines
+
schema schema
: use field name as the name of the schema : use field name as the name of the schema
* only one allowed per schema * only one allowed per schema
* does not allow newlines * does not allow newlines
+
lookup lookup
: schema match to use for related record : schema match to use for related record
+
\> option specs \> option specs
: defines the option specifications for the key. : defines the option specifications for the key.
* must come last in option list * must come last in option list
+
[label] string value. A positional string argument required. [label] string value. A positional string argument required.
Text inside brackets represent a label for the string and must match the same rules as attribute names. Text inside brackets represent a label for the string and must match the same rules as attribute names.
If follwed by '...' values are gathered as an array. If follwed by '...' values are gathered as an array.
+
{enum1|enum2|} enumeration. One option in pipe('|') deliniation is allowed. {enum1|enum2|} enumeration. One option in pipe('|') deliniation is allowed.
If there is a trailing pipe it means the enum is optional. Enum values must match the same rules as attribute names. If there is a trailing pipe it means the enum is optional. Enum values must match the same rules as attribute names.
+
'literal' Literal value. literal text value which must not contain any whitespace or single quotes.
'literal' Literal value. literal text value which must not contain any whitespace or single quotes.

+ 14
- 0
fmt-my-stuff View File

@ -0,0 +1,14 @@
#!/bin/sh
if [ "$#" -eq "0" ]
then
echo "Usage: $0 YOUR-MNT"
exit
fi
BASE="$(readlink -f "$0" 2>/dev/null || python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' "$0")"
BASE="$(dirname "$BASE")"
grep -lrE "(\s|:)$1(\s|\$)" "$BASE/data/" | while read -r line; do
utils/schema-check/nx3_schema.py fmt -i "$line"
done

+ 177
- 0
utils/schema-check/log.py View File

@ -0,0 +1,177 @@
from __future__ import print_function
import os
import sys
import inspect
import datetime
OUTPUT = sys.stderr
LEVEL = ["CRIT", "ERR ", "WARN", "NOTE", "INFO", "DBUG", "...."]
CLEVEL = ["\x1B[41mCRIT\x1B[0m",
"\x1B[31mERR \x1B[0m",
"\x1B[33mWARN\x1B[0m",
"\x1B[32mNOTE\x1B[0m",
"\x1B[34mINFO\x1B[0m",
"\x1B[90mDBUG\x1B[0m",
"\x1B[90m....\x1B[0m"]
MSG = "{0} {1} {2} {3} {4} {5} :: {6}"
CMSG = "[{1}]\x1B[90m {2} {3}:{5} [{4}]\x1B[0m {6}\x1B[0m"
CMULTI = "[{1}]\x1B[90m {2}\x1B[0m"
VERB_CRITICAL = 0
VERB_ERROR = 1
VERB_WARN = 2
VERB_NOTICE = 3
VERB_INFO = 4
VERB_DEBUG = 5
VERB_NONE = -1
class Log:
log_dir = ""
log_pfx = "main"
level_console = VERB_ERROR
level_file = VERB_NONE
level_full = False
count = [0, 0, 0, 0, 0, 0]
def __init__(self):
self.prog_name = sys.argv[0].rsplit("/", 1)[-1]
self.prog_name = self.prog_name.split(".", 1)[0]
self.log_pfx = self.prog_name
def __del__(self):
if self.level_console >= 5:
os.write(1, b"[\x1B[90m\x1B[90mDBUG\x1B[90m] Log Counters crit:%d err:%d warn:%d note:%d info:%d dbug:%d\x1B[0m\n" % tuple(self.count))
def set_dir(self, name):
if not os.path.isdir(name):
os.makedirs(name)
self.log_dir = name
# Write a message to console or log, conditionally.
def output(self, level, message, frame=1):
if level < 0 or level > 5:
level = 5
self.count[level] += 1
# function_name = inspect.stack()[1][3]
cur_date = datetime.datetime.now()
(frame, file, ln, fn, lines, index) = inspect.getouterframes(
inspect.currentframe())[frame]
message = str(message).split("\n")
cmsg = CMSG if self.level_full else CMULTI
if self.level_console >= level:
if len(message) == 1:
if self.level_full:
arg = str(cur_date), CLEVEL[
level], self.prog_name, file, fn, ln, message[0]
else:
arg = str(cur_date), CLEVEL[level], message[0]
print(cmsg.format(*arg), file=OUTPUT)
else:
if self.level_full:
arg = str(cur_date), CLEVEL[
level], self.prog_name, file, fn, ln, ""
print(cmsg.format(*arg), file=OUTPUT)
for line in message:
print(CMULTI.format(str(cur_date), CLEVEL[
VERB_NONE], line), file=OUTPUT)
if self.level_file >= level:
self.set_dir("./logs")
log_file_name = os.path.join(
self.log_dir, self.log_pfx + str(cur_date.strftime('%Y-%m-%d')) + ".txt")
with open(log_file_name, "a") as logger:
logger.write(MSG.format(str(cur_date), LEVEL[
level], self.prog_name, file, fn, ln, message[0]) + "\n")
for line in message[1:]:
logger.write(MSG.format(str(cur_date), LEVEL[
VERB_NONE], self.prog_name, file, fn, ln, line) + "\n")
def fatal(self, message):
self.output(VERB_CRITICAL, message, 2)
sys.exit(1)
def critical(self, message):
self.output(VERB_CRITICAL, message, 2)
def error(self, message):
self.output(VERB_ERROR, message, 2)
def warning(self, message):
self.output(VERB_WARN, message, 2)
def notice(self, message):
self.output(VERB_NOTICE, message, 2)
def info(self, message):
self.output(VERB_INFO, message, 2)
def debug(self, message):
self.output(VERB_DEBUG, message, 2)
def fmt_exception(exc_type, exc_value, exc_traceback):
import traceback
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
log_string = ''.join(line for line in lines)
email_string = ''.join('<br />' + line for line in lines)
return log_string, email_string
default = Log()
fatal = default.fatal
critical = default.critical
error = default.error
warning = default.warning
notice = default.notice
info = default.info
debug = default.debug
class LogException:
stop = None
def __init__(self, stop=True):
self.stop = stop
def __enter__(self, stop=True):
pass
def __exit__(self, exc_type, value, traceback):
if exc_type is None:
return True
if exc_type is SystemExit and value.args == (0,):
return True
log_string, email_string = fmt_exception(exc_type, value, traceback)
default.output(VERB_CRITICAL, 'Failure\n\n' + log_string, 2)
if self.stop is False:
return False
from . import email
email.send(default.prog_name + ' FAILURE', email_string)
fatal("ABORTING EXECUTION")
exception = LogException

+ 1145
- 0
utils/schema-check/nx3_schema.py
File diff suppressed because it is too large
View File


+ 1462
- 1462
utils/schema-check/nx3_schema_local.py
File diff suppressed because it is too large
View File


Loading…
Cancel
Save