forked from 0x2620/pandora
dbip-city-lite url changes, get latest url from download page
This commit is contained in:
parent
6f4bdebd88
commit
4cce468dae
1 changed files with 15 additions and 8 deletions
|
@ -1,12 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import division, print_function, absolute_import
|
from __future__ import division, print_function, absolute_import
|
||||||
|
|
||||||
|
import codecs
|
||||||
import os
|
import os
|
||||||
import sys
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import codecs
|
|
||||||
from os.path import dirname, exists, join
|
from os.path import dirname, exists, join
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
|
@ -399,12 +400,18 @@ def update_geoip(force=False):
|
||||||
path = os.path.join(settings.GEOIP_PATH, 'GeoLite2-City.mmdb')
|
path = os.path.join(settings.GEOIP_PATH, 'GeoLite2-City.mmdb')
|
||||||
if not os.path.exists(path) or force:
|
if not os.path.exists(path) or force:
|
||||||
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'
|
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'
|
||||||
url = 'https://download.db-ip.com/free/dbip-city-lite-2020-01.mmdb.gz'
|
index = ox.net.read_url('https://db-ip.com/db/download/ip-to-country-lite').decode()
|
||||||
print('download', url)
|
match = re.compile('href=[\'"](http.*.mmdb.gz)').findall(index)
|
||||||
ox.net.save_url(url, "%s.gz" % path)
|
if match:
|
||||||
if os.path.exists(path):
|
url = match[0]
|
||||||
os.unlink(path)
|
print(url)
|
||||||
os.system('gunzip "%s.gz"' % path)
|
print('download', url)
|
||||||
|
ox.net.save_url(url, "%s.gz" % path)
|
||||||
|
if os.path.exists(path):
|
||||||
|
os.unlink(path)
|
||||||
|
os.system('gunzip "%s.gz"' % path)
|
||||||
|
else:
|
||||||
|
print('failed to download dbip-country-lite-2020-03.mmdb.gz')
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
if not settings.RELOADER_RUNNING:
|
if not settings.RELOADER_RUNNING:
|
||||||
|
|
Loading…
Reference in a new issue