fix missing import in generator, expand networks to ips in jobs and init work on a generic checker with shared dict and redis support
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from Job import Job
|
||||
|
||||
import re, ipaddress
|
||||
|
||||
class Abusers(Job) :
|
||||
|
||||
def __init__(self, redis_host=None, copy_cache=False) :
|
||||
@@ -9,3 +11,13 @@ class Abusers(Job) :
|
||||
type = "line"
|
||||
regex = r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/?[0-9]*$"
|
||||
super().__init__(name, data, filename, redis_host=redis_host, type=type, regex=regex, copy_cache=copy_cache)
|
||||
|
||||
def _Job__edit(self, chunk) :
|
||||
if self.__redis != None :
|
||||
network = chunk.decode("utf-8")
|
||||
if re.match(network, r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/?[0-9]+$") :
|
||||
ips = []
|
||||
for ip in ipaddress.IPv4Network(network) :
|
||||
ips.append(str(ip).encode("utf-8"))
|
||||
return [chunk]
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from Job import Job
|
||||
|
||||
import re, ipaddress
|
||||
|
||||
class ExitNodes(Job) :
|
||||
|
||||
def __init__(self, redis_host=None, copy_cache=False) :
|
||||
@@ -9,3 +11,12 @@ class ExitNodes(Job) :
|
||||
type = "line"
|
||||
regex = r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/?[0-9]*$"
|
||||
super().__init__(name, data, filename, redis_host=redis_host, type=type, regex=regex, copy_cache=copy_cache)
|
||||
|
||||
def _Job__edit(self, chunk) :
|
||||
if self.__redis != None :
|
||||
network = chunk.decode("utf-8")
|
||||
if re.match(network, r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/?[0-9]+$") :
|
||||
ips = []
|
||||
for ip in ipaddress.IPv4Network(network) :
|
||||
ips.append(str(ip).encode("utf-8"))
|
||||
return [chunk]
|
||||
|
||||
10
jobs/Job.py
10
jobs/Job.py
@@ -61,13 +61,17 @@ class Job(abc.ABC) :
|
||||
if self.__type == "line" :
|
||||
if not re.match(self.__regex, chunk.decode("utf-8")) :
|
||||
continue
|
||||
chunk = self.__edit(chunk)
|
||||
chunks = self.__edit(chunk)
|
||||
if self.__redis == None :
|
||||
if self.__type == "line" :
|
||||
chunk += b"\n"
|
||||
file.write(chunk)
|
||||
else :
|
||||
pipe.set(self.__name + "_" + chunk, "1")
|
||||
if self.__type == "line" :
|
||||
for chunk in chunks :
|
||||
pipe.set(self.__name + "_" + chunk, "1")
|
||||
else :
|
||||
pipe.set(self.__name + "_" + chunk, "1")
|
||||
count += 1
|
||||
|
||||
if self.__redis == None :
|
||||
@@ -106,7 +110,7 @@ class Job(abc.ABC) :
|
||||
return JobRet.OK_RELOAD
|
||||
|
||||
def __edit(self, chunk) :
|
||||
return chunk
|
||||
return [chunk]
|
||||
|
||||
def __from_cache(self) :
|
||||
if not os.path.isfile("/opt/bunkerized-nginx/cache/" + self.__filename) :
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from Job import Job
|
||||
|
||||
import re, ipaddress
|
||||
|
||||
class Proxies(Job) :
|
||||
|
||||
def __init__(self, redis_host=None, copy_cache=False) :
|
||||
@@ -9,3 +11,12 @@ class Proxies(Job) :
|
||||
type = "line"
|
||||
regex = r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/?[0-9]*$"
|
||||
super().__init__(name, data, filename, redis_host=redis_host, type=type, regex=regex, copy_cache=copy_cache)
|
||||
|
||||
def _Job__edit(self, chunk) :
|
||||
if self.__redis != None :
|
||||
network = chunk.decode("utf-8")
|
||||
if re.match(network, r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/?[0-9]+$") :
|
||||
ips = []
|
||||
for ip in ipaddress.IPv4Network(network) :
|
||||
ips.append(str(ip).encode("utf-8"))
|
||||
return [chunk]
|
||||
|
||||
Reference in New Issue
Block a user