do not save invalid IPs
This commit is contained in:
12
ppf.py
12
ppf.py
@@ -126,14 +126,18 @@ def proxyfind(sqlite = None):
|
|||||||
|
|
||||||
sqlite.commit()
|
sqlite.commit()
|
||||||
|
|
||||||
def is_reserved_ipv4(ip):
|
def should_i_append_this_item(ip):
|
||||||
octets = ip.split('.')
|
octets = ip.split('.')
|
||||||
A = int(octets[0])
|
A = int(octets[0])
|
||||||
B = int(octets[1])
|
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 \
|
if A == 10 or A == 127 or A == 0 or \
|
||||||
(A == 192 and B == 168) or \
|
(A == 192 and B == 168) or \
|
||||||
(A == 172 and B >= 16 and B <= 31): return True
|
(A == 172 and B >= 16 and B <= 31): return False
|
||||||
return False
|
return True
|
||||||
|
|
||||||
def proxyleech(sqlite, rows):
|
def proxyleech(sqlite, rows):
|
||||||
for row in rows:
|
for row in rows:
|
||||||
@@ -149,7 +153,7 @@ def proxyleech(sqlite, rows):
|
|||||||
|
|
||||||
uniques = []
|
uniques = []
|
||||||
for p in uniques_dict.keys():
|
for p in uniques_dict.keys():
|
||||||
if not is_reserved_ipv4(p): uniques.append(p)
|
if should_i_append_this_item(p): uniques.append(p)
|
||||||
|
|
||||||
hash = hashlib.md5(''.join(uniques)).hexdigest()
|
hash = hashlib.md5(''.join(uniques)).hexdigest()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user