8000 [IMPROVEMENT] Cache `ipasn.lookup()` result as an IPWhois attribute. · Issue #335 · secynic/ipwhois · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[IMPROVEMENT] Cache ipasn.lookup() result as an IPWhois attribute. #335
Open
@nil0x42

Description

@nil0x42

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0