Martijn Pieters <m...@python.org> added the comment:
> Private is a subset of special use. Should a "_special_use" constant be > created. This would include multicast, link_local, private_use, and a few > more. There are already dedicated tests for those other special use networks in ipaddress. 192.0.0.0/24 is the block reserved for "IETF Protocol Assignments", which really means: private use. https://datatracker.ietf.org/doc/html/rfc6890#section-2.2.2 marks the block as "Not usable unless by virtue of a more specific reservation.". The registry at https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml lists those specific reservations, and only 2 to date are *globally reachable*, which means they are probably not private: - 192.0.0.9/32, Port Control Protocol Anycast, RFC 7723 - 192.0.0.10/32, Traversal Using Relays around NAT Anycast, RFC 8155 I strongly feel that _any other IP address in the reserved range_ should be treated as private unless marked, by IANA, as globally reachable, at some future date. That would require the list of networks for IPv4Address / IPv4Network is_private to include all of 192.0.0.0/24 _minus those two exceptions_; calculating the network masks for these: >>> def exclude_all(network, *excluded): ... try: ... for sub in network.address_exclude(excluded[0]): ... yield from exclude_all(sub, *excluded[1:]) ... except (IndexError, ValueError): ... yield network ... >>> iana_reserved = IPv4Network("192.0.0.0/24") >>> to_remove = IPv4Network("192.0.0.9/32"), IPv4Network("192.0.0.10/32") >>> for sub in exclude_all(iana_reserved, *to_remove): ... print(sub) ... 192.0.0.128/25 192.0.0.64/26 192.0.0.32/27 192.0.0.16/28 192.0.0.0/29 192.0.0.12/30 192.0.0.11/32 192.0.0.8/32 The module could trivially do this on import, or we could hard-code the above list. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42937> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com