remote API - basic send of bad IPs

This commit is contained in:
bunkerity
2021-10-07 12:00:20 +02:00
parent fb799765a4
commit fdc02be051
10 changed files with 37 additions and 29 deletions

View File

@@ -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"] :

View File

@@ -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"]

View File

@@ -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"]]