little tweak to not throw an exception on RFC1918 IP address

This commit is contained in:
Mat Stace 2019-05-29 16:02:08 +01:00
parent b0abb5d7ae
commit f4dbb626c8
2 changed files with 3 additions and 1 deletions

View file

@ -14,6 +14,7 @@ import geoip2.database
import Geohash
import configparser
from influxdb import InfluxDBClient
from IPy import IP as ipadd
def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSERPASS, MEASUREMENT, GEOIPDB, INODE): # NOQA
# Preparing variables and params
@ -52,7 +53,7 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER
m = re_IPV6.match(LINE)
IP = m.group(1)
if IP:
if ipadd(IP).iptype() == 'PUBLIC' and IP:
INFO = GI.city(IP)
if INFO is not None:
HASH = Geohash.encode(INFO.location.latitude, INFO.location.longitude) # NOQA

View file

@ -2,3 +2,4 @@ configparser==3.5.0
influxdb==5.2.0
Geohash==1.0
geoip2==2.9.0
IPy==1.00