Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to queries IP prefixes #253

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

romain-fontugne
Copy link

This allows to query an IP prefix, for example 8.8.8.0/24 or 8.0.0.0/9
The is_defined check is done with the first IP in the range.

fixes #250

@coveralls
Copy link

coveralls commented Mar 2, 2020

Coverage Status

Coverage increased (+0.003%) to 99.648% when pulling 72bb764 on romain-fontugne:dev into 11f7632 on secynic:dev.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 99.217% when pulling 8391fcb on romain-fontugne:dev into 282fb01 on secynic:dev.

@secynic secynic self-requested a review March 4, 2020 22:50
Copy link
Owner

@secynic secynic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix 2.7 build


self.assertRaises(IPDefinedError, Net, '192.168.0.1')
self.assertRaises(IPDefinedError, Net, 'fe80::')
self.assertRaises(IPDefinedError, Net, IPv4Address('192.168.0.1'))
self.assertRaises(IPDefinedError, Net, IPv6Address('fe80::'))
self.assertRaises(IPDefinedError, Net, '192.168.0.0/16')
self.assertRaises(IPDefinedError, Net, 'fe80::/10')
self.assertRaises(IPDefinedError, Net, IPv4Network('192.168.0.0/16'))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not building on Python 2.7. I think it has to do with your addition of unicode() which seems unnecessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed that, the problem was that the test used ipaddr.IPv4Network but now the net.py code check for ipaddress.IPv4Network. ipaddr has been superseded by ipaddress for both python3 and python2. It might be better to replace all the instances of ipaddr to ipaddress across all the files?

@secynic
Copy link
Owner

secynic commented Sep 1, 2020

@romain-fontugne Still not building for 2.7. ipaddress is not built in on Python 2.7

@secynic
Copy link
Owner

secynic commented Sep 2, 2020

@romain-fontugne Actually, after I have reviewed this, I don't see the point in this if it only uses the first address in a range. Can you explain why this is needed?

@romain-fontugne
Copy link
Author

@secynic sorry, I haven't take the time to look at that. Only the is_defined check is done with the first IP in the range. The query is done with the prefix. Prefix 1.2.0.0/16 and 1.2.0.0/24 have the same first IP but could have different whois info.

@alistairking
Copy link

I could really make use of this feature too.
What still needs to happen before it can be merged?

@romain-fontugne
Copy link
Author

Hey Alistair,
The code works for python3 but it seems to break some python2.7 tests. I never took the time to debug this... so I am not sure what's the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants