remote API - basic send of bad IPs
This commit is contained in:
@@ -128,10 +128,11 @@ class Job(abc.ABC) :
|
||||
for url in self._data :
|
||||
data = self.__download_data(url)
|
||||
for chunk in data :
|
||||
if isinstance(chunk, bytes) :
|
||||
if isinstance(chunk, bytes) and self._type in ["line", "json"] :
|
||||
chunk = chunk.decode("utf-8")
|
||||
if self._type in ["line", "json"] :
|
||||
if not re.match(self._regex, chunk) :
|
||||
log(self._name, "WARN", chunk + " doesn't match regex " + self._regex)
|
||||
continue
|
||||
if self._redis == None :
|
||||
if self._type in ["line", "json"] :
|
||||
|
||||
@@ -7,9 +7,10 @@ class RemoteApiDatabase(Job) :
|
||||
data = [server + "/db"]
|
||||
filename = "remote-api.db"
|
||||
type = "json"
|
||||
redis_ex = 3600
|
||||
regex = r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
|
||||
json_data = {"version": version, "id": id}
|
||||
super().__init__(name, data, filename, type=type, redis_host=redis_host, redis_ex=redis_ex, regex=regex, copy_cache=copy_cache, json_data=json_data, method=method)
|
||||
super().__init__(name, data, filename, type=type, redis_host=redis_host, redis_ex=redis_ex, regex=regex, copy_cache=copy_cache, json_data=json_data)
|
||||
|
||||
def _json(self, data) :
|
||||
return data["data"]
|
||||
|
||||
@@ -13,4 +13,4 @@ class RemoteApiRegister(Job) :
|
||||
super().__init__(name, data, filename, type=type, regex=regex, copy_cache=True, json_data=json_data, method=method)
|
||||
|
||||
def _json(self, data) :
|
||||
return data["data"]
|
||||
return [data["data"]]
|
||||
|
||||
Reference in New Issue
Block a user