build!: Drop maxmind IP database (#29213)
1. It's severly outdated and free version isn't that accurate to begin
with.
2. I replaced country detection using timezone a long time ago: c8ec528aa7/frappe/desk/page/setup_wizard/setup_wizard.js (L664-L676)
This is good enough for setup wizard for most popular countries. Use
IP-API if you need better guarantees (we have a license).
This commit is contained in:
parent
4e4972fe2d
commit
daa52b8802
5 changed files with 0 additions and 49 deletions
|
|
@ -23,10 +23,6 @@ The following 3rd-party software packages may be used by or distributed with <ht
|
|||
- Code License: MIT (<http://choosealicense.com/licenses/mit/>)
|
||||
- Inter - SIL Open Font License, 1.1 (c) 2020 Rasmus Andersson (<https://github.com/rsms/inter>)
|
||||
|
||||
### IP Address Database
|
||||
|
||||
- GeoIP: (c) 2014 MaxMind, <http://dev.maxmind.com/geoip/geoip2/downloadable/>
|
||||
|
||||
---
|
||||
|
||||
Last updated: 4th July 2022
|
||||
|
|
|
|||
|
|
@ -320,13 +320,6 @@ def load_languages():
|
|||
}
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def load_country():
|
||||
from frappe.sessions import get_geo_ip_country
|
||||
|
||||
return get_geo_ip_country(frappe.local.request_ip) if frappe.local.request_ip else None
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def load_user_details():
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -457,26 +457,3 @@ def get_expiry_period():
|
|||
exp_sec = exp_sec + ":00"
|
||||
|
||||
return exp_sec
|
||||
|
||||
|
||||
def get_geo_from_ip(ip_addr):
|
||||
try:
|
||||
from geolite2 import geolite2
|
||||
|
||||
with geolite2 as f:
|
||||
reader = f.reader()
|
||||
data = reader.get(ip_addr)
|
||||
|
||||
return frappe._dict(data)
|
||||
except ImportError:
|
||||
return
|
||||
except ValueError:
|
||||
return
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
|
||||
def get_geo_ip_country(ip_addr):
|
||||
match = get_geo_from_ip(ip_addr)
|
||||
if match:
|
||||
return match.country
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
from frappe.tests import IntegrationTestCase
|
||||
|
||||
|
||||
class TestGeoIP(IntegrationTestCase):
|
||||
def test_geo_ip(self):
|
||||
return
|
||||
from frappe.sessions import get_geo_ip_country
|
||||
|
||||
self.assertEqual(get_geo_ip_country("223.29.223.255"), "India")
|
||||
self.assertEqual(get_geo_ip_country("4.18.32.80"), "United States")
|
||||
self.assertEqual(get_geo_ip_country("217.194.147.25"), "United States")
|
||||
|
|
@ -43,7 +43,6 @@ dependencies = [
|
|||
"ldap3~=2.9",
|
||||
"markdown2~=2.4.8",
|
||||
"MarkupSafe>=2.1.0,<3",
|
||||
"maxminddb-geolite2==2018.703",
|
||||
"num2words~=0.5.12",
|
||||
"oauthlib~=3.2.2",
|
||||
"openpyxl~=3.1.2",
|
||||
|
|
@ -263,7 +262,6 @@ module = [
|
|||
"dropbox",
|
||||
"email_reply_parser",
|
||||
"filetype",
|
||||
"geolite2",
|
||||
"google",
|
||||
"googleapiclient.discovery",
|
||||
"googleapiclient.errors",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue