From f8f67617de77e7d68de137180c6ba20b4cfa4e37 Mon Sep 17 00:00:00 2001 From: Thomas Perkins Date: Sat, 24 Jun 2017 17:30:44 -0500 Subject: [PATCH] Fix for issue #6 --- cloudfail.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cloudfail.py b/cloudfail.py index e5209be..49dbb23 100644 --- a/cloudfail.py +++ b/cloudfail.py @@ -143,24 +143,25 @@ def init(target): print_out(Fore.CYAN + "Server IP: " + ip) print_out(Fore.CYAN + "Testing if " + args.target + " is on the Cloudflare network...") - ifIpIsWithin = inCloudFlare(ip) + try: + ifIpIsWithin = inCloudFlare(ip) - if ifIpIsWithin: - print_out(Style.BRIGHT + Fore.GREEN + args.target + " is part of the Cloudflare network!") - else: - print_out(Fore.RED + args.target + " is not part of the Cloudflare network, quitting...") + if ifIpIsWithin: + print_out(Style.BRIGHT + Fore.GREEN + args.target + " is part of the Cloudflare network!") + else: + print_out(Fore.RED + args.target + " is not part of the Cloudflare network, quitting...") + sys.exit(0) + except ValueError: + print_out(Fore.RED + "IP address does not appear to be within Cloudflare range, shutting down..") sys.exit(0) def inCloudFlare(ip): - with open('data/cf-subnet.txt') as f: + with open('{}/data/cf-subnet.txt'.format(os.getcwd())) as f: for line in f: isInNetwork = ip_in_subnetwork(ip, line) if isInNetwork: return True - else: - - continue return False