From e548512f1e84966a7f10643f76bf243e4f1c1347 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 24 Nov 2016 08:28:00 -0500 Subject: [PATCH] update geoip related stuff --- baddie-detector/netdb/netdb.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/baddie-detector/netdb/netdb.py b/baddie-detector/netdb/netdb.py index 8de54f6..ac735dd 100644 --- a/baddie-detector/netdb/netdb.py +++ b/baddie-detector/netdb/netdb.py @@ -7,9 +7,12 @@ import os,sys,struct,time,hashlib,fnmatch,io import base64 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') @@ -156,7 +159,8 @@ class Entry: @staticmethod def geolookup(entry): - return geo.record_by_addr(entry) + if geo: + return geo.record_by_addr(entry) @staticmethod def _read_addr(fd):