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

[IMPROVEMENT] Cache ipasn.lookup() result as an IPWhois attribute. #335

Open
nil0x42 opened this issue Nov 28, 2024 · 0 comments
Open

[IMPROVEMENT] Cache ipasn.lookup() result as an IPWhois attribute. #335

nil0x42 opened this issue Nov 28, 2024 · 0 comments

Comments

@nil0x42
Copy link

nil0x42 commented Nov 28, 2024

Hello,

First of all, thank you for this excellent library—it has been incredibly helpful in my workflow!

I have a routine where, for a list of IPs, I first try lookup_rdap() and, if not available, I fall back to lookup_whois(). While working with this setup, I noticed a potential improvement that could enhance performance.

Currently, when resolving ASN info using IPWhois.ipasn.lookup(), the result is not stored. This means that if both lookup_rdap() and lookup_whois() are called for the same IP, the ASN info is looked up multiple times unnecessarily. It would be great if the resolved ASN data could be stored as an attribute (e.g., IPWhois._ipasn_data) after the first call, so subsequent calls could reuse this data.

I came across this issue while trying to reorder my IP list to minimize consecutive RDAP calls to LACNIC (to avoid hitting their aggressive rate limits). My approach involves calling ipasn.lookup() first to determine the responsible RIR for each IP, which helps me reorganize the list accordingly. However, I noticed that even after doing this, the IPWhois object performs the same ipasn.lookup() again during calls to lookup_rdap() or lookup_whois(), which seems redundant.

Implementing a caching mechanism for ASN resolution within the IPWhois object would not only optimize this use case but likely benefit other workflows as well.

Thank you for considering this suggestion, and I really appreciate all the work you've put into this project!

Best regards

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

No branches or pull requests

1 participant