Ipaddr

Latest version: v2.2.0

Safety actively analyzes 629959 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 3 of 3

1.1.1.255

In [7]: int(ipaddr.IPv4Network("1.1.1.0/24").broadcast)
Out[7]: 16843263

In [8]: int(ipaddr.IPv4Network("1.1.1.0/24").network)
Out[8]: 16843008

In [9]: str(ipaddr.IPv4Network("1.1.1.0/24").network)

1.1.1

This release contains a single important bugfix. All users of 1.1.0 should upgrade.

* r77 A logical error caused ordering operators to behave incorrectly.

1.1.1.0

}}}

* IP() everything-constructor has been replaced by IPAddress() and IPNetwork() constructors. It seems reasonable to assume that an application programmer will know when they are dealing strictly with ip addresses vs. networks and making this separation de-clutters the code. IPNetwork still assumes a default prefixlength of 32 for IPv4 and 128 for IPv6 if none is supplied (just like IP() used to), so when in doubt, you can always use IPNetwork.
{{{
In [16]: ipaddr.IPNetwork('1.1.1.1')
Out[16]: IPv4Network('1.1.1.1/32')

In [17]: ipaddr.IPNetwork('1.1.1.1/12')
Out[17]: IPv4Network('1.1.1.1/12')

In [18]: ipaddr.IPNetwork('::1')
Out[18]: IPv6Network('::1/128')

In [19]: ipaddr.IPNetwork('::1/64')
Out[19]: IPv6Network('::1/64')
}}}

Some other (but no less important) bug fixes/improvements:

* __ contains __ accepts strings/ints as well as (IPv4|IPv6)Address objects.
{{{
In [9]: ipaddr.IPAddress('1.1.1.1') in ipaddr.IPNetwork('1.1.1.0/24')
Out[9]: True

In [10]: '1.1.1.1' in ipaddr.IPv4Network("1.1.1.0/24")
Out[10]: True

In [11]: '1' in ipaddr.IPv4Network("0.0.0.0/0")
Out[11]: True

In [12]: 1 in ipaddr.IPv4Network("0.0.0.0/0")
Out[12]: True
}}}
* summarize_address_range. You can now get a list of all of the networks between two distinct (IPv4|IPv6)Address'es (results in potentially huge speed boosts for address collapsing)
{{{
In [14]: ipaddr.summarize_address_range(ipaddr.IPAddress('1.1.0.0'), ipaddr.IPAddress('1.1.255.255'))
Out[14]: [IPv4Network('1.1.0.0/16')]

In [15]: ipaddr.summarize_address_range(ipaddr.IPAddress('1.1.0.0'), ipaddr.IPAddress('1.1.255.254'))
Out[15]:
[IPv4Network('1.1.0.0/17'),
IPv4Network('1.1.128.0/18'),
IPv4Network('1.1.192.0/19'),
IPv4Network('1.1.224.0/20'),
IPv4Network('1.1.240.0/21'),
IPv4Network('1.1.248.0/22'),
IPv4Network('1.1.252.0/23'),
IPv4Network('1.1.254.0/24'),
IPv4Network('1.1.255.0/25'),
IPv4Network('1.1.255.128/26'),
IPv4Network('1.1.255.192/27'),
IPv4Network('1.1.255.224/28'),
IPv4Network('1.1.255.240/29'),
IPv4Network('1.1.255.248/30'),
IPv4Network('1.1.255.252/31'),
IPv4Network('1.1.255.254/32')]
}}}

* network iterators. the (IPv4|IPv6)Network classes now implement iterators to help quickly access each member of a network in sequence:
{{{

In [24]: for addr in iter(ipaddr.IPNetwork('1.1.1.1/28')): addr
....:
Out[24]: IPv4Address('1.1.1.0')
Out[24]: IPv4Address('1.1.1.1')
Out[24]: IPv4Address('1.1.1.2')
Out[24]: IPv4Address('1.1.1.3')
Out[24]: IPv4Address('1.1.1.4')
Out[24]: IPv4Address('1.1.1.5')
Out[24]: IPv4Address('1.1.1.6')
Out[24]: IPv4Address('1.1.1.7')
Out[24]: IPv4Address('1.1.1.8')
Out[24]: IPv4Address('1.1.1.9')
Out[24]: IPv4Address('1.1.1.10')
Out[24]: IPv4Address('1.1.1.11')
Out[24]: IPv4Address('1.1.1.12')
Out[24]: IPv4Address('1.1.1.13')
Out[24]: IPv4Address('1.1.1.14')
Out[24]: IPv4Address('1.1.1.15')
}}}

* additionally, an iterhosts() method has been added to allow for iterating over all of the usable addresses on a network (everything except the network and broadcast addresses)
{{{
In [26]: for addr in ipaddr.IPNetwork('1.1.1.1/28').iterhosts(): addr
....:
Out[26]: IPv4Address('1.1.1.1')
Out[26]: IPv4Address('1.1.1.2')
Out[26]: IPv4Address('1.1.1.3')
Out[26]: IPv4Address('1.1.1.4')
Out[26]: IPv4Address('1.1.1.5')
Out[26]: IPv4Address('1.1.1.6')
Out[26]: IPv4Address('1.1.1.7')
Out[26]: IPv4Address('1.1.1.8')
Out[26]: IPv4Address('1.1.1.9')
Out[26]: IPv4Address('1.1.1.10')
Out[26]: IPv4Address('1.1.1.11')
Out[26]: IPv4Address('1.1.1.12')
Out[26]: IPv4Address('1.1.1.13')
Out[26]: IPv4Address('1.1.1.14')
}}}

Thanks to the python community and everyone who's made feature suggestions or submitted patches. Please continue to send bugs/enhancements/patches to the mailing list.

1.1.0

`ipaddr.py` is now part of the standard library in Python 2.7 and 3.1! This release is compatible with the `ipaddr` from future versions of Python.

Special thanks to Philipp Hagemeister for making most of the improvements to this release, and to Gregory P. Smith for shepherding this into the Python standard library.

* r59 Method names are now PEP-8 compliant, instead of Google-style camel case. The old method names remain, but are deprecated; you should use the lowercase names to be compatible with Python 2.7/3.1. (pmoody)
* r63 .prefixlen is now a property. (pmoody)
* r64 Stronger validation. (Philipp Hagemeister)
* r65 1.2.3.4 is not a valid v6 address, so we can simplify the constructor. (Philipp Hagemeister)
* r66 Expand rich comparison operations and their tests, with a goal of supporting 2to3. Add a new method .networks_key(). Add a new script to run through 2to3 and make sure tests pass under Python 3 with the converted version. (Philipp Hagemeister)
* r68 New method .packed(). (Philipp Hagemeister)
* r69 Add `is_multicast`, `is_unspecified`, `is_loopback`, `is_link_local`, `is_site_local`, and `is_private` for IPv6. Make more methods into properties. Improved documentation and tests for `is_*` properties for IPv4 and IPv6. Rename `networks_key()` to `_get_networks_key()`.
* r71 Fix off-by-one bug (issue 15). (gpsmith)

1.0.2

* r52 Force the return value in testHexRepresentation to uppercase to workaround Python version. (smart)
* r51 Fix testHexRepresentation(). Hex representations of longs are uppercase. (smart)
* r50 Remove trailing whitespace and update docstrings. (smart)
* r44. this makes the spacing and docstrings pep8 compliant. (pmoody)
* r43. When processing the IPv4 mapped address 16 bits at a time, the components are stored in the reverse order. Updated the test to use a non-symmetric IPv4 address, which exhibited the bug. (smart)
* r40. implment __int__ and __hex__. will need to be updated for py3k (to use __index__) (pmoody)
* r38 A cleanup from issue 9 : Make exception messages consistent for IP(''), IPv4(''), IPv6('') (smart)
* r37 Fix for issue 9 : ipaddr.IP('') should raise ValueError (mshields)

1.0.1

* str() now produces lowercase for IPv6 addresses, to match inet_pton(3). (http://codereview.appspot.com/7678)
* repr() now produces strings that can be pasted back into the interpreter.

Page 3 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.