little tweak to not throw an exception on RFC1918 IP address
This commit is contained in:
parent
b0abb5d7ae
commit
f4dbb626c8
2 changed files with 3 additions and 1 deletions
|
@ -14,6 +14,7 @@ import geoip2.database
|
||||||
import Geohash
|
import Geohash
|
||||||
import configparser
|
import configparser
|
||||||
from influxdb import InfluxDBClient
|
from influxdb import InfluxDBClient
|
||||||
|
from IPy import IP as ipadd
|
||||||
|
|
||||||
def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSERPASS, MEASUREMENT, GEOIPDB, INODE): # NOQA
|
def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSERPASS, MEASUREMENT, GEOIPDB, INODE): # NOQA
|
||||||
# Preparing variables and params
|
# Preparing variables and params
|
||||||
|
@ -52,7 +53,7 @@ def logparse(LOGPATH, INFLUXHOST, INFLUXPORT, INFLUXDBDB, INFLUXUSER, INFLUXUSER
|
||||||
m = re_IPV6.match(LINE)
|
m = re_IPV6.match(LINE)
|
||||||
IP = m.group(1)
|
IP = m.group(1)
|
||||||
|
|
||||||
if IP:
|
if ipadd(IP).iptype() == 'PUBLIC' and IP:
|
||||||
INFO = GI.city(IP)
|
INFO = GI.city(IP)
|
||||||
if INFO is not None:
|
if INFO is not None:
|
||||||
HASH = Geohash.encode(INFO.location.latitude, INFO.location.longitude) # NOQA
|
HASH = Geohash.encode(INFO.location.latitude, INFO.location.longitude) # NOQA
|
||||||
|
|
|
@ -2,3 +2,4 @@ configparser==3.5.0
|
||||||
influxdb==5.2.0
|
influxdb==5.2.0
|
||||||
Geohash==1.0
|
Geohash==1.0
|
||||||
geoip2==2.9.0
|
geoip2==2.9.0
|
||||||
|
IPy==1.00
|
||||||
|
|
Loading…
Reference in a new issue