-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
[Feature Request] Requesting the support of IPinfo Free IP to Country ASN dataset #862
Comments
Hi there @abdullahdevrel thanks for following up! Trippy currently reads I tried downloading the sample in Test code: use std::net::{IpAddr, Ipv4Addr};
use maxminddb::geoip2::City;
fn main() {
let reader = maxminddb::Reader::open_readfile("ip_geolocation_extended_ipv4_sample.mmdb").unwrap();
let addr = IpAddr::V4(Ipv4Addr::from([50, 220, 147, 113]));
let city_data = reader.lookup::<City<'_>>(addr);
println!("{city_data:?}");
} Fails with (I tried decoding as Perhaps this is what you mean by the data being "flat"? Perhaps I have to deserialise to a custom struct with the "flat" structure? Is there a recommend
I'd prefer to allow user to bring their own files rather than bundle it, to keep size down and also to prevent stale data being used.
I'm not quite sure what this is for, presumably the token is used for looking up the ipinfo API? I see you have an API for that. Would the token be something that could be bundled in Trippy for all users or just for development use? I prefer user-provided
Just to note that Trippy currently get ASN data from the IP to ASN Mapping Service provided by Team Cymru via DNS TXT records, so it's mostly GeoIp (country, city, lat/long) that are needed. |
With some trial and error I was able to figure out it is a
Doing that works:
So that looks great. The question now is, how does Trippy know if a given |
I see that the mmdb files have a MaxMind (
IpInfo (
So unlike the MaxMind file, the IpInfo file has a |
WIP impl: #871 |
@abdullahdevrel I would like Trippy to be able to consume either the free "IP to Country + ASN Database" One quirk I notice is that the free "IP to Country + ASN Database" From https://ipinfo.io/developers/ip-to-country-asn-database:
From https://ipinfo.io/developers/ip-to-geolocation-extended:
Same story for |
Hey @fujiapple852 My apologies for the late response. I really appreciate you considering our data for Trippy. Just an FYI, my Rust skill is not very good.
That is a very good question. MaxMind uses a nested data structure for their MMDB databases, while IPinfo uses a flat data structure. MaxMind data structure for MMDB: IPinfo data structure for MMDB: As you have seen in MaxMind's MMDB reader library, they have declared the IPinfo has a flat and predictable data structure. The key will return an empty string even if the value does not exist. And boolean values are strings with For Rust, this is usually what I send to users: https://gist.github.com/abdullahdevrel/ace2c80bd53a7323a18bbf8c8ae6a4d2
Yes. The $ mmdbctl metadata ipinfo_country_asn.mmdb
- Binary Format 2.0
- Database Type ipinfo country_asn.mmdb
- IP Version 6
- Record Size 32
- Node Count 5458524
- Description
en ipinfo country_asn.mmdb
- Languages en
- Build Epoch 1702629871 I think this
The access token is for downloading the IPinfo database. To download the database, users need to run a command like this:
Although our API supports 1,000 tokenless requests/day and 50,000 requests/month with a token. Compared to our free IP database, free API does provide city and zip code level information.
We would love if you could use the "IP to Country + ASN Database". It is free and easily accessible for the project and the users, but it does not compromise accuracy at all. Support for this database would be incredible. Here is the mmdb version of that database: https://www.transfernow.net/dl/20231218MUeQ39J8 (available for 7 days)
We wanted to make the free IP to Country ASN database as accessible as possible. In our geolocation database, we do not provide the full country name or continent name, and we usually recommend users to use a reference object/dictionary for the full country name, currency, continent, isEu, etc. For posterity You have addressed this issue, but admittedly, I have not prepared the best Rust documentation. I am addressing it here in case someone stumbles upon this.
This is due to IPinfo not having package native struct declarations. The user has to declare their own structs, and they should not declare a "generic argument" to the
Yes, this is spot on. The mmdb reader crate does its job of reading the mmdb files perfectly, however, as MaxMind developed this crate they have native support for their database through declaring the structs within the package. IPinfo and MaxMind's databases are structured differently. So, when using IPinfo's database with mmdb reader crate, users need to declare the structs based on the database schema of the IPinfo database they are using. Example: |
Hi again @abdullahdevrel and thank you for the comprehensive reply!
That is good to know, i'll adjust my impl accordingly to treat empty string as
As yes, that works well.
Nit: note that these are equivalent (the latter infers the type parameter let record = reader.lookup::<IpinfoCountryASN>(ip_address).unwrap()
let record: IpinfoCountryASN = reader.lookup(ip_address).unwrap()
Perfect, that was the key thing I needed to know.
Trippy can certainly support that (it would use the country and continent names from that file, the AS data is not needed as it comes from elsewhere already). Trippy can also support the extra attributes (city, postcode, lat/log/radius etc) provided by the premium files in a way where Trippy will look for and use these fields if available in the file provided. To put it another way, A user can provide either the "IP to Country + ASN Database" or the "IP to Geolocation Extended Database" mmdb file and Trippy will pick out the data is needs from either. Does that work?
Thank you, I have downloaded the file. Is this the same as the file I can download from https://ipinfo.io/account/data-downloads? (I registered account |
@abdullahdevrel if you could help check the tests I added in #871 then we should be able to merge this. |
Merged. This will be included in the 0.10.0 release of Trippy and will be mentioned in the release note. |
Thank you very much @fujiapple852!! Really appreciate it!! |
I am the DevRel of IPinfo. I would like to request supporting the IPinfo free IP to Country dataset in Trippy. Features of the database:
The database comes in MMDB format, so I believe it can be easily ingested in the project. Also, the data structure is flat and predictable. You can package our free IP to the Country ASN database with the project. For that, we will provide an access token that you can use. By using the IPinfo dataset, you can get both country-level geolocation information and ASN information from a single source.
Please let me know what you what you think. If you need any assistance, please let me know. Thanks.
Schema: https://ipinfo.io/developers/ip-to-country-asn-database
The text was updated successfully, but these errors were encountered: