From 59a6d8ab2a22d1ab7e8bf67b7089947174dbfdef Mon Sep 17 00:00:00 2001 From: rscmbbng Date: Mon, 9 Sep 2013 17:05:40 +0200 Subject: [PATCH] added a regex for filtering local ip address ranges --- main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 4b050c0..469d7f7 100644 --- a/main.py +++ b/main.py @@ -352,7 +352,8 @@ class bc(object): except: print "Error: Browser is not responding correctly.\n" # run traceroutes - if self.url[0] == 'http://127.0.0.1:8080/': + match_ip = self.url[0].strip('http://').strip(':8080') + if re.match(r'^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$', match_ip) or re.match(r'^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$', match_ip) or re.match(r'^192.168\.\d{1,3}$', match_ip) or re.match(r'^172.(1[6-9]|2[0-9]|3[0-1]).[0-9]{1,3}.[0-9]{1,3}$', match_ip): pass else: traces = self.try_running(self.traces, "\nInternal error tracerouting.") @@ -362,8 +363,9 @@ class bc(object): while True: url = urlparse(self.getURL()).netloc url = url.replace('www.','') + match_ip = url.strip('http://').strip(':8080') if url != self.old_url: - if self.url[0] == 'http://127.0.0.1:8080/': + if re.match(r'^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$', match_ip) or re.match(r'^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$', match_ip) or re.match(r'^192.168\.\d{1,3}$', match_ip) or re.match(r'^172.(1[6-9]|2[0-9]|3[0-1]).[0-9]{1,3}.[0-9]{1,3}$', match_ip): pass else: traces = self.try_running(self.traces, "\nInternal error tracerouting.")