mirror of
https://github.com/PurpleI2P/i2pd-tools.git
synced 2025-03-22 00:59:09 +01:00
update geoip related stuff
This commit is contained in:
parent
fb77e988e5
commit
e548512f1e
1 changed files with 7 additions and 3 deletions
|
@ -7,9 +7,12 @@
|
||||||
import os,sys,struct,time,hashlib,fnmatch,io
|
import os,sys,struct,time,hashlib,fnmatch,io
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
import pygeoip
|
|
||||||
|
|
||||||
geo = pygeoip.GeoIP('/usr/share/GeoIP/GeoIPCity.dat')
|
try:
|
||||||
|
import pygeoip
|
||||||
|
geo = pygeoip.GeoIP('/usr/share/GeoIP/GeoIPCity.dat')
|
||||||
|
except:
|
||||||
|
geo = None
|
||||||
|
|
||||||
b64encode = lambda x : base64.b64encode(x, b'~-').decode('ascii')
|
b64encode = lambda x : base64.b64encode(x, b'~-').decode('ascii')
|
||||||
|
|
||||||
|
@ -156,7 +159,8 @@ class Entry:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def geolookup(entry):
|
def geolookup(entry):
|
||||||
return geo.record_by_addr(entry)
|
if geo:
|
||||||
|
return geo.record_by_addr(entry)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _read_addr(fd):
|
def _read_addr(fd):
|
||||||
|
|
Loading…
Add table
Reference in a new issue