diff --git a/geoparser.py b/geoparser.py index 95f8309..e991ea7 100755 --- a/geoparser.py +++ b/geoparser.py @@ -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 diff --git a/requirements.txt b/requirements.txt index fc2c632..ba2bd41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ configparser==3.5.0 influxdb==5.2.0 Geohash==1.0 geoip2==2.9.0 +IPy==1.00