additional fixes to ipinfo/geoip
This commit is contained in:
parent
d8ba18a2dc
commit
24e073313c
1 changed files with 8 additions and 7 deletions
|
@ -30,7 +30,6 @@ class Module(ModuleManager.BaseModule):
|
|||
ip = line.match
|
||||
if not ip:
|
||||
raise utils.EventError("No IP provided")
|
||||
|
||||
return ip
|
||||
|
||||
def _ipinfo_get(self, url):
|
||||
|
@ -111,6 +110,7 @@ class Module(ModuleManager.BaseModule):
|
|||
page = utils.http.request(URL_GEOIP % ip).json()
|
||||
if page:
|
||||
if page["status"] == "success":
|
||||
hostname = None
|
||||
try:
|
||||
hostname, alias, ips = socket.gethostbyaddr(page["query"])
|
||||
except (socket.herror, socket.gaierror):
|
||||
|
@ -162,9 +162,10 @@ class Module(ModuleManager.BaseModule):
|
|||
else:
|
||||
data += " (%s)" % hostname if hostname else ""
|
||||
data += " (Anycast)" if page.get("anycast", False) == True else ""
|
||||
if page.get("country", False):
|
||||
data += " | City: %s" % page["city"]
|
||||
data += " | Region: %s (%s)" % (page["region"], page["country"])
|
||||
data += " | ISP: %s" % page["org"]
|
||||
data += " | ISP: %s" % page.get("org", "Unknown")
|
||||
data += " | Lon/Lat: %s" % page["loc"]
|
||||
data += " | Timezone: %s" % page["timezone"]
|
||||
event["stdout"].write(data)
|
||||
|
|
Loading…
Reference in a new issue