aboutsummaryrefslogtreecommitdiff
path: root/modules/ip_addresses.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-10-16 15:09:58 +0100
committerGravatar jesopo2018-10-16 15:09:58 +0100
commit773d11f6cbaa8da91185547b0ab67f3706d735c2 (patch)
treec46eb6709985ef7cdfb5bfe9b035fdbdedc4f91f /modules/ip_addresses.py
parentOnly log exceptions when they're not unsafe (diff)
Change all instances of stdout.write+return to `raise utils.EventError` in
modules
Diffstat (limited to 'modules/ip_addresses.py')
-rw-r--r--modules/ip_addresses.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/modules/ip_addresses.py b/modules/ip_addresses.py
index 84d25aa7..2877e000 100644
--- a/modules/ip_addresses.py
+++ b/modules/ip_addresses.py
@@ -20,8 +20,8 @@ class Module(ModuleManager.BaseModule):
address_info = socket.getaddrinfo(hostname, 1, 0,
socket.SOCK_DGRAM)
except socket.gaierror:
- event["stderr"].write("Failed to find hostname")
- return
+ raise utils.EventError("Failed to find hostname")
+
ips = []
for _, _, _, _, address in address_info:
ips.append(address[0])
@@ -68,13 +68,10 @@ class Module(ModuleManager.BaseModule):
match = REGEX_IP.search(line.message)
ip = match.group(1) or match.group(2)
if not ip:
- event["stderr"].write("No IP provided")
- return
+ raise utils.EventError("No IP provided")
- print(ip)
try:
hostname, alias, ips = socket.gethostbyaddr(ip)
except (socket.herror, socket.gaierror) as e:
- event["stderr"].write(e.strerror)
- return
+ raise utils.EventError(e.strerror)
event["stdout"].write("(%s) %s" % (ips[0], hostname))