Skip to content

Commit

Permalink
more parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
firefart committed Aug 19, 2023
1 parent 090bf32 commit 76de03b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion create_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 76de03b

Please sign in to comment.