netaddr / netaddr

A network address manipulation library for Python

Home Page:https://netaddr.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reverse IP Range returns unexpected IPNetwork

skandaloptagon opened this issue · comments

In version 0.7.19:

I would expect this to raise an exception when trying to calculate a range from a higher IP to a lower IP. Instead it returns an unexpected network.

>>> ip1 = "192.168.0.1"
>>> ip10 = "192.168.0.10"
>>> ip1 = IPSet(ip1)
[IPNetwork('192.168.0.1/32'), IPNetwork('192.168.0.2/31'), IPNetwork('192.168.0.4/30'), IPNetwork('192.168.0.8/31'), IPNetwork('192.168.0.10/32')]
>>> iprange_to_cidrs(ip10,ip1)
[IPNetwork('192.168.0.10/31')]

This appears to interpret my input as starting at 192.168.0.10 and ending at 192.168.0.11. I Suspect this is a bug and should raise an exception.