jsommers / pytricia

A library for fast IP address lookup in Python.
GNU Lesser General Public License v3.0
216 stars 22 forks source link

Prefix size is not taken into account for lookups #16

Closed tristan-ovh closed 7 years ago

tristan-ovh commented 7 years ago

Hi, I don't know if it is an expected behaviour, but it does not seem to be when reading the doc.

It seems that the prefix size is not taken into account when doing a lookup:

>>> tree = pytricia.PyTricia()
>>> tree["0.0.0.0/0"] = 1
>>> tree["1.0.0.0/16"] = 2
>>> tree["1.0.0.0/8"]   
2
>>> tree["1.1.0.0/8"]
1

I would expect the two last lines to return 1, as an 8 bits prefix cannot match a 16 bits prefix.

tristan-ovh commented 7 years ago

Just to reference the small fix I found, I created PR #17

jsommers commented 7 years ago

Thanks -- just merged this.