From 76de03b167e1705e4cf8ef5d4388509b6ac8d4fe Mon Sep 17 00:00:00 2001 From: firefart <105281+firefart@users.noreply.github.com> Date: Sat, 19 Aug 2023 16:49:29 +0200 Subject: [PATCH] more parsing --- create_db.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/create_db.py b/create_db.py index 8807569..f94c464 100755 --- a/create_db.py +++ b/create_db.py @@ -68,7 +68,7 @@ def parse_property(block: str, name: str) -> str: return None -def parse_property_inetnum(block: str) -> str: +def parse_property_inetnum(block: str): # IPv4 match = re.findall( rb'^inetnum:[\s]*((?:\d{1,3}\.){3}\d{1,3})[\s]*-[\s]*((?:\d{1,3}\.){3}\d{1,3})', block, re.MULTILINE) @@ -88,6 +88,11 @@ def parse_property_inetnum(block: str) -> str: if match: tmp = match[0].split(b"/") return f"{tmp[0]}.0/{tmp[1]}".encode("utf-8") + # inetnum: 148.204/16 + match = re.findall(rb'^inetnum:[\s]*((?:\d{1,3}\.){1}\d{1,3}/\d+)', block, re.MULTILINE) + if match: + tmp = match[0].split(b"/") + return f"{tmp[0]}.0.0/{tmp[1]}".encode("utf-8") # IPv6 match = re.findall( rb'^inet6num:[\s]*([0-9a-fA-F:\/]{1,43})', block, re.MULTILINE)