ExpressionEngine / IP-To-Nation

ExpressionEngine 7 Add-On
0 stars 0 forks source link

IP to Nation cannot populate its data due to datasource deprecation #1

Open kevincupp opened 5 years ago

kevincupp commented 5 years ago

Description of the problem IP to Nation uses the GeoLite Legacy database from MaxMind, but, it's been deprecated and taken down. As such, IP to Nation cannot populate its data.

Possible Solution Update the module to use GeoLite2 and note any schema changes in the new database. Also note it requires some license attribution.

kevincupp commented 5 years ago

Dumping some research into here:

Here is documentation on the legacy CSV format: https://dev.maxmind.com/geoip/legacy/csv/ And now the new CSV format: https://dev.maxmind.com/geoip/geoip2/geoip2-city-country-csv-databases/

The IP ranges are now in the Country-Blocks CSV files, which presents two problems:

  1. The IP ranges are no longer represented in upper and lower bounds, we'll need to manually calculate those if we want to keep that schema, which might be best for quick querying. I'm honestly not sure what the recommendation is for querying data in this new format when you need to find an IP range that matches an IP, whereas it was pretty clear before. There is a tool that converts the new format to the old format that while we can't really use in EE itself, might be helpful to see what's going on there.
  2. There aren't country codes in those CSV files, we have to map a geoname_id to figure out the contry code, which requires going through all of the Country-Locations files in the package. This may be difficult to do in a memory-efficient way if we need to insert the country code into the same table it is now, but maybe we just make a separate lookup table for country codes and let MySQL make the association.

So the database is not quite a drop-in replacement, will require quite a bit of extra massaging to make the transition.

dankingsley commented 5 years ago

Just wondering if it's possible to be provided database table exports of data before this broke so I can use this feature for the time being?

kevincupp commented 5 years ago

@dankingsley See if this works: ip2nation.sql.zip

dankingsley commented 5 years ago

Perfect @kevincupp Thanks!

litzinger commented 5 years ago

Has anyone considered switching EE to a free service such as https://ipstack.com/?

CloudFront can also add request headers https://aws.amazon.com/about-aws/whats-new/2014/06/26/amazon-cloudfront-device-detection-geo-targeting-host-header-cors/

dougblackjr commented 5 years ago

I had done something utilizing GeoPlugin for another CMS plugin: https://github.com/PrimitiveSocial/ip-country/blob/master/src/services/IpCountryService.php

@kevincupp If this is something that you think would fit EE, I can work on it and do a PR this week. Are there preferred specs on how this should work?

litzinger commented 5 years ago

TBH it might make a good add-on. An add-on that had the option of connecting to multiple different services, all implementing an interface that a single module tag can use. A set of config options for each endpoint so the user can choose which to use, and of course tie it into the Consent module somehow to see if the user has to consent to cookies or not depending on location.

kevincupp commented 5 years ago

Thanks, @dougblackjr. I think IP to Nation's current strategy of storing everything locally gives the advantage of quick look-ups. For instance, if you have a long list of members you want to display the location for, doing an HTTP request for each one might take a while or even hit up against some API limit. While it otherwise sounds nice, it may be seen as a regression for those who do something similar to what I described.

alexrubin commented 5 years ago

any chance someone has come up with a working solution yet?

anthony8bc commented 5 years ago

Hi. We had a similar problem and created a simple Geo Location add-on for our clients. Not sure if it's relevant here but thought I'd share in case it's of use. https://devot-ee.com/add-ons/ip-geo-locator

litzinger commented 5 years ago

Should add that add-on to the EE Store ;) https://expressionengine.com/add-ons

anthony8bc commented 5 years ago

Should add that add-on to the EE Store ;) https://expressionengine.com/add-ons

Yes, I have applied to be a vendor on the EE Store. Still waiting to hear back from them.

robinsowell commented 5 years ago

Oh- that was a nice find! And it is available in the store now. Thanks!

intoeetive commented 1 year ago

Moving this issue as Ip2Nation has been taken out of core in EE7 and is now separate add-on: https://github.com/ExpressionEngine/IP-To-Nation