From 6f0d5c1ffa96519159408c8ef32c2108ca3d0ddd Mon Sep 17 00:00:00 2001 From: mickael Date: Wed, 9 Jan 2019 19:01:55 +0000 Subject: [PATCH] modify and rename should_i_... function > remove :port from D > check if octets are within a correct range --- ppf.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ppf.py b/ppf.py index 0774aac..87ecee4 100755 --- a/ppf.py +++ b/ppf.py @@ -126,15 +126,16 @@ def proxyfind(sqlite = None): sqlite.commit() -def should_i_append_this_item(ip): - octets = ip.split('.') +def is_usable_proxy(proxy): + octets = proxy.split(':')[0].split('.') A = int(octets[0]) B = int(octets[1]) - if (octets[0] < 1 or octets[0] > 254) or \ - (octets[1] < 0 or octets[1] > 255) or \ - (octets[2] < 0 or octets[2] > 255) or \ - (octets[3] < 1 or octets[3] > 254): return False - if A == 10 or A == 127 or A == 0 or \ + C = int(octets[2]) + D = int(octets[3]) + + if (A < 1 or A > 254) or \ + (B > 255 or C > 255 or D > 255) or \ + (A == 10 or A == 127 or A == 0) or \ (A == 192 and B == 168) or \ (A == 172 and B >= 16 and B <= 31): return False return True @@ -153,7 +154,7 @@ def proxyleech(sqlite, rows): uniques = [] for p in uniques_dict.keys(): - if should_i_append_this_item(p): uniques.append(p) + if is_usable_proxy(p): uniques.append(p) hash = hashlib.md5(''.join(uniques)).hexdigest()