From 3904363c71e45f3d4bc6c9bb39a6906c42cd2414 Mon Sep 17 00:00:00 2001 From: Michael Heidelberger Date: Thu, 19 Apr 2018 11:49:08 -0500 Subject: [PATCH] Changed the logic to look for MX records of IPs and if there is none just return location data --- ip-api.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ip-api.py b/ip-api.py index 17d98bb..77e1cb5 100644 --- a/ip-api.py +++ b/ip-api.py @@ -33,6 +33,9 @@ def findMX(host): # append terminal output to variable std_out for line in p: + if re.search('not found', line): + query_api([host]) + break std_out.append(line) p.close @@ -50,8 +53,4 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("host", help="hostname to lookip") args = parser.parse_args() - # If the arg is an IP address go straight to API - if re.search('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}', args.host): - query_api([args.host]) - else: - findMX(args.host) + findMX(args.host)