v0.9.5. Changes for rublacklist API v3

This commit is contained in:
gSpot
2022-12-25 19:45:07 +03:00
parent 06131d3aca
commit 83918288f1
9 changed files with 34 additions and 26 deletions
@@ -372,14 +372,16 @@ class RblFQDN(BlackListParser):
def __init__(self):
super().__init__()
self.url = self.RBL_ALL_URL
self.fields_separator = "],"
self.ips_separator = ","
self.records_separator = '{"authority": '
self.ips_separator = ", "
def parser_func(self):
for entry in self._split_entries():
entry_list = entry.partition(self.fields_separator)
ip_string = re.sub(r"[' \]\[]", "", entry_list[0])
fqdn_string = re.sub(",.*$", "", entry_list[2])
res = re.search(r'"domains": \["?(.*?)"?\].*?"ips": \[([a-f0-9/.:", ]*)\]', entry)
if not res:
continue
ip_string = res.group(2).replace('"', "")
fqdn_string = res.group(1)
if fqdn_string:
try:
self.fqdn_field_processing(fqdn_string)
@@ -393,10 +395,11 @@ class RblIp(BlackListParser):
def __init__(self):
super().__init__()
self.url = self.RBL_IP_URL
self.records_separator = ","
def parser_func(self):
for entry in self._split_entries():
self.ip_field_processing(entry.rstrip(","))
self.ip_field_processing(re.sub(r'[\[\]" ]', "", entry))
class ZiFQDN(BlackListParser):
@@ -450,6 +453,7 @@ class AfIp(BlackListParser):
for entry in self._split_entries():
self.ip_field_processing(entry)
class RaFQDN(BlackListParser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -474,6 +478,7 @@ class RaFQDN(BlackListParser):
self.download_config(self.url_stat, self.UPDATE_STATUS_FILE)
return 0
class RaIp(RaFQDN):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -481,6 +486,7 @@ class RaIp(RaFQDN):
self.url_dnsmasq = self.RA_IP_DMASK_URL
self.url_stat = self.RA_IP_STAT_URL
class WriteConfigFiles(Config):
def __init__(self):
self.write_buffer = -1