bogons 1.3.0
“Python Library for IP & ASN Bogons”
Registry package lists one maintainerRelease published within seven days
SHA-256f57fdc476f574acb6919be63af9ec08421c6a2e363553c1e26fd27b5351867a3
MaleculeH₂(CmDb)Md(Pa)
Evidence
1Metadata-Version: 2.4
2Name: bogons
3Version: 1.3.0
4Summary: Python Library for IP & ASN Bogons
5Home-page: https://github.com/mellowdrifter/python-bogons
6Author: Darren O'Connor
7Author-email: …
18:26… tem :: OS Independent
19Classifier: Topic :: System :: Networking
20Requires-Python: >=3.8
21Description-Content-Type: text/markdown
22License-File: LICENSE
23Dynamic: author
24Dynamic: home-page
⋯6 lines
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Python library to validate IP and ASN bogons, with modern RFC descriptions.
5"""
6
7from __future__ import annotations
8
9import ipaddress
10from typing import Tuple, Union
11
12# IPv4 bogon rules with RFC descriptions
13V4_BOGON_RULES: Tuple[Tuple[ipaddress.IPv4Network, str], ...] = (
14 (ipaddress.IPv4Network("0.0.0.0/8"), "RFC 1122 (This Host on This Network)"),
15 (ipaddress.IPv4Network("10.0.0.0/8"), "RFC 1918 (Private-Use)"),
16 (ipaddress.IPv4Network("100.64.0.0/10"), "RFC 6598 (Shared Address Space / CGNAT)"),
17 (ipaddress.IPv4Network("127.0.0.0/8"), "RFC 1122 (Loopback)"),
18 (ipaddress.IPv4Network("169.254.0.0/16"), "RFC 3927 (Link-Local)"),
19 (ipaddress.IPv4Network("172.16.0.0/12"), "RFC 1918 (Private-Use)"),
20 # Specific 192.0.0.0/24 sub-allocations
21 (ipaddress.IPv4Network("192.0.0.170/31"), "RFC 8880 (NAT64/DNS64 Discovery)"),
22 (ipaddress.IPv4Network("192.0.0.10/32"), "RFC 8155 (TURN Anycast)"),
23 (ipaddress.IPv4Network("192. …
26:50… 6890 (IETF Protocol Assignments)"),
27 (ipaddress.IPv4Network("192.0.2.0/24"), "RFC 5737 (Documentation TEST-NET-1)"),
28 (ipaddress.IPv4Network("192.31.196.0/24"), "RFC 7535 (AS112-v4)"),
29 (ipaddres …
106 try:
107 ip = ipaddress.IPv4Address(ip)
108 except Exception:
109 return False, "Invalid IPv4 address syntax"
110 elif not isinstance(ip, ipaddress.IPv4Address):
⋯7 lines
No evidence locations were recorded for this file. Raw result