Closed sebschrader closed 3 months ago
And I totally forgot, netaddr
supports the very important RFC 1924
😉.
This would also remove one more library which does not provide wheels (netaddr
does).
@sebschrader I'm in the process of doing that. However, I am confused as to the difference fo the following two functions:
Both functions are unused and seem to want create the reverse record, but ptr_name
does some odd thing relative to the netowrk.
The first function clearly does the same thing as netaddr.IPAddress.reverse_dns
, but what does ptr_name
do?
In [1]: from netaddr import *
In [2]: i = IPAddress("141.30.228.39")
In [3]: i.reverse_dns
Out[3]: '39.228.30.141.in-addr.arpa.'
The
ipaddr
module we use, was the original basis for theipadress
module that was included in Python 3.3 and backported. The modules are not API-compatible however, so we can't just replace theipaddr
imports withipaddress
.ipaddr
will die, we're currently even using the git master version instead of a PyPI release. We should replace it. I suggest we use the popularnetaddr
library used by e.g. Ansible and Hades, instead of the standard libraryipaddress
.netaddr
is much easier to use and provides features thatipaddress
doesn't, for example mac address types.The main advantage of
netaddr
is the handling of IP networks that have hosts bits set. Withipaddress
you have to use three different types:IPv4Address
(no prefix),IPv4Network
(with subnet prefix, but hosts bits must be zero),IPv4Interface
(with prefix and host bits may be non-zero). Secondly you have to use different types for IPv6.netaddr
has combined types for IPv4 and IPv6, but you can use specific ones if you want to and it's much easier to use addresses with non-zero host bits. There are many more goodies, such as IP range types, supernets and subnets, iteration over IP address and subnets, etc.Hades already includes custom SQLAlchemy types for PostgreSQL's
inet
andmacaddr
types.This is not a high priority task, but it should be tracked.