mirror of
https://github.com/gSpotx2f/ruantiblock_openwrt.git
synced 2026-05-13 22:20:59 +00:00
ruantiblock-mod-lua, ruantiblock-mod-py: new blacklist source fz139.
This commit is contained in:
@@ -9,8 +9,8 @@ LUA_MODULE=0
|
||||
LUCI_APP=1
|
||||
|
||||
OWRT_VERSION="current"
|
||||
RUAB_VERSION="1.4-2"
|
||||
RUAB_MOD_LUA_VERSION="1.4-2"
|
||||
RUAB_VERSION="1.4-3"
|
||||
RUAB_MOD_LUA_VERSION="1.4-3"
|
||||
RUAB_LUCI_APP_VERSION="1.4-2"
|
||||
BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master"
|
||||
PKG_DIR="/tmp"
|
||||
|
||||
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ruantiblock-mod-lua
|
||||
PKG_VERSION:=1.4
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@@ -70,15 +70,17 @@ local Config = Class(nil, {
|
||||
["ZI_ALL_URL"] = true,
|
||||
["AF_IP_URL"] = true,
|
||||
["AF_FQDN_URL"] = true,
|
||||
["RA_IP_NFTSET_URL"] = true,
|
||||
["FZ_URL"] = true,
|
||||
["RA_IP_IPSET_URL"] = true,
|
||||
["RA_IP_DMASK_URL"] = true,
|
||||
["RA_IP_STAT_URL"] = true,
|
||||
["RA_FQDN_NFTSET_URL"] = true,
|
||||
["RA_FQDN_IPSET_URL"] = true,
|
||||
["RA_FQDN_DMASK_URL"] = true,
|
||||
["RA_FQDN_STAT_URL"] = true,
|
||||
["RBL_ENCODING"] = true,
|
||||
["ZI_ENCODING"] = true,
|
||||
["AF_ENCODING"] = true,
|
||||
["FZ_ENCODING"] = true,
|
||||
["RA_ENCODING"] = true,
|
||||
["BLLIST_SUMMARIZE_IP"] = true,
|
||||
["BLLIST_SUMMARIZE_CIDR"] = true,
|
||||
@@ -101,15 +103,36 @@ Config.wget_user_agent = (Config.http_send_headers["User-Agent"]) and ' -U "' ..
|
||||
-- Loading external config
|
||||
|
||||
function Config:load_config(t)
|
||||
local config_arrays = {
|
||||
local config_sets = {
|
||||
["BLLIST_GR_EXCLUDED_SLD"] = true,
|
||||
["BLLIST_GR_EXCLUDED_NETS"] = true,
|
||||
}
|
||||
local config_arrays = {
|
||||
["RBL_ALL_URL"] = true,
|
||||
["RBL_IP_URL"] = true,
|
||||
["RBL_DPI_URL"] = true,
|
||||
["ZI_ALL_URL"] = true,
|
||||
["AF_IP_URL"] = true,
|
||||
["AF_FQDN_URL"] = true,
|
||||
["FZ_URL"] = true,
|
||||
["RA_IP_IPSET_URL"] = true,
|
||||
["RA_IP_DMASK_URL"] = true,
|
||||
["RA_IP_STAT_URL"] = true,
|
||||
["RA_FQDN_IPSET_URL"] = true,
|
||||
["RA_FQDN_DMASK_URL"] = true,
|
||||
["RA_FQDN_STAT_URL"] = true,
|
||||
}
|
||||
for k, v in pairs(t) do
|
||||
if config_arrays[k] then
|
||||
if config_sets[k] then
|
||||
local value_table = {}
|
||||
for v in v:gmatch('[^" ]+') do
|
||||
value_table[v] = true
|
||||
for i in v:gmatch('[^" ]+') do
|
||||
value_table[i] = true
|
||||
end
|
||||
self[k] = value_table
|
||||
elseif config_arrays[k] then
|
||||
local value_table = {}
|
||||
for i in v:gmatch('[^" ]+') do
|
||||
value_table[#value_table + 1] = i
|
||||
end
|
||||
self[k] = value_table
|
||||
else
|
||||
@@ -218,7 +241,7 @@ local BlackListParser = Class(Config, {
|
||||
ip_pattern = "%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?",
|
||||
cidr_pattern = "%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?/%d%d?",
|
||||
fqdn_pattern = "[a-z0-9_%.%-]-[a-z0-9_%-]+%.[a-z0-9%.%-]+",
|
||||
url = "http://127.0.0.1",
|
||||
url = {[1] = "http://127.0.0.1"},
|
||||
records_separator = "\n",
|
||||
})
|
||||
|
||||
@@ -239,6 +262,7 @@ function BlackListParser:new(t)
|
||||
instance.fqdn_records_count = 0
|
||||
instance.fqdn_table = {}
|
||||
instance.iconv_handler = iconv and iconv.open(instance.encoding, instance.site_encoding) or nil
|
||||
instance.buff = ""
|
||||
return instance
|
||||
end
|
||||
|
||||
@@ -331,7 +355,6 @@ function BlackListParser:parser_func()
|
||||
end
|
||||
|
||||
function BlackListParser:chunk_buffer()
|
||||
local buff = ""
|
||||
local ret_value = ""
|
||||
local last_chunk
|
||||
return function(chunk)
|
||||
@@ -339,16 +362,16 @@ function BlackListParser:chunk_buffer()
|
||||
return nil
|
||||
end
|
||||
if chunk then
|
||||
buff = buff .. chunk
|
||||
local last_rs_position = select(2, buff:find("^.*" .. self.records_separator))
|
||||
self.buff = self.buff .. chunk
|
||||
local last_rs_position = select(2, self.buff:find("^.*" .. self.records_separator))
|
||||
if last_rs_position then
|
||||
ret_value = buff:sub(1, last_rs_position)
|
||||
buff = buff:sub((last_rs_position + 1), -1)
|
||||
ret_value = self.buff:sub(1, last_rs_position)
|
||||
self.buff = self.buff:sub((last_rs_position + 1), -1)
|
||||
else
|
||||
ret_value = ""
|
||||
end
|
||||
else
|
||||
ret_value = buff
|
||||
ret_value = self.buff
|
||||
last_chunk = true
|
||||
end
|
||||
return (ret_value)
|
||||
@@ -372,9 +395,24 @@ function BlackListParser:get_http_data(url)
|
||||
return (ret_val == 1) and true or false
|
||||
end
|
||||
|
||||
function BlackListParser:download_files(url_list)
|
||||
local ret_list = {}
|
||||
for _, url in ipairs(url_list) do
|
||||
ret_list[#ret_list + 1] = self:get_http_data(url)
|
||||
end
|
||||
local ret_val = true
|
||||
for _, i in ipairs(ret_list) do
|
||||
if not i then
|
||||
ret_val = false
|
||||
break
|
||||
end
|
||||
end
|
||||
return ret_val
|
||||
end
|
||||
|
||||
function BlackListParser:run()
|
||||
local return_code = 0
|
||||
if self:get_http_data(self.url) then
|
||||
if self:download_files(self.url) then
|
||||
if (self.fqdn_count + self.ip_count + self.cidr_count) > self.BLLIST_MIN_ENTRIES then
|
||||
return_code = 0
|
||||
else
|
||||
@@ -383,6 +421,7 @@ function BlackListParser:run()
|
||||
else
|
||||
return_code = 1
|
||||
end
|
||||
self.buff = ""
|
||||
return return_code
|
||||
end
|
||||
|
||||
@@ -766,7 +805,7 @@ local function ip_parser_func(self)
|
||||
end
|
||||
|
||||
local function fqdn_parser_func(self, ip_str, fqdn_str)
|
||||
if #fqdn_str > 0 and not fqdn_str:match("^" .. self.ip_pattern .. "$") then
|
||||
if fqdn_str ~= nil and #fqdn_str > 0 and not fqdn_str:match("^" .. self.ip_pattern .. "$") then
|
||||
if self:fqdn_value_processing(fqdn_str) then
|
||||
return true
|
||||
end
|
||||
@@ -865,6 +904,53 @@ local AfIp = Class(Af, {
|
||||
parser_func = ip_parser_func,
|
||||
})
|
||||
|
||||
-- fz139
|
||||
|
||||
local Fz = Class(BlackListParser, {
|
||||
url = Config.FZ_URL,
|
||||
site_encoding = Config.FZ_ENCODING,
|
||||
records_separator = "</content>",
|
||||
})
|
||||
|
||||
function Fz:parser_func()
|
||||
return function(chunk)
|
||||
if chunk and chunk ~= "" then
|
||||
for entry in chunk:gmatch("(.-)" .. self.records_separator) do
|
||||
local fqdn_str = entry:match("<domain><%!%[CDATA%[(.-)%]%]></domain>")
|
||||
if fqdn_str ~= nil and #fqdn_str > 0 and not fqdn_str:match("^" .. self.ip_pattern .. "$") and self:fqdn_value_processing(fqdn_str) then
|
||||
else
|
||||
for ip_str in entry:gmatch("<ip>(.-)</ip>") do
|
||||
self:ip_value_processing(ip_str)
|
||||
end
|
||||
for ip_str in entry:gmatch("<ipSubnet>(.-)</ipSubnet>") do
|
||||
self:ip_value_processing(ip_str)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local FzIp = Class(Fz, {
|
||||
})
|
||||
|
||||
function FzIp:parser_func()
|
||||
return function(chunk)
|
||||
if chunk and chunk ~= "" then
|
||||
for entry in chunk:gmatch("(.-)" .. self.records_separator) do
|
||||
for ip_str in entry:gmatch("<ip>(.-)</ip>") do
|
||||
self:ip_value_processing(ip_str)
|
||||
end
|
||||
for ip_str in entry:gmatch("<ipSubnet>(.-)</ipSubnet>") do
|
||||
self:ip_value_processing(ip_str)
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- ruantiblock
|
||||
|
||||
local Ra = Class(BlackListParser, {
|
||||
@@ -876,7 +962,7 @@ local Ra = Class(BlackListParser, {
|
||||
function Ra:download_config(url, file)
|
||||
local ret_val = false
|
||||
self.current_file_handler = assert(io.open(file, "w"), "Could not open file")
|
||||
if self:get_http_data(url) then
|
||||
if self:download_files(url) then
|
||||
ret_val = true
|
||||
end
|
||||
self.current_file_handler:close()
|
||||
@@ -919,8 +1005,8 @@ local RaIp = Class(Ra, {
|
||||
----------------------------- Main section ------------------------------
|
||||
|
||||
local parsers_table = {
|
||||
["ip"] = {["rublacklist"] = {RblIp}, ["zapret-info"] = {ZiIp}, ["antifilter"] = {AfIp}, ["ruantiblock"] = {RaIp}},
|
||||
["fqdn"] = {["rublacklist"] = {Rbl, RblDPI}, ["zapret-info"] = {Zi}, ["antifilter"] = {Af}, ["ruantiblock"] = {Ra}},
|
||||
["ip"] = {["rublacklist"] = {RblIp}, ["zapret-info"] = {ZiIp}, ["antifilter"] = {AfIp}, ["fz"] = {FzIp}, ["ruantiblock"] = {RaIp}},
|
||||
["fqdn"] = {["rublacklist"] = {Rbl, RblDPI}, ["zapret-info"] = {Zi}, ["antifilter"] = {Af}, ["fz"] = {Fz}, ["ruantiblock"] = {Ra}},
|
||||
}
|
||||
|
||||
local ret_list = {}
|
||||
@@ -933,7 +1019,7 @@ if parser_classes then
|
||||
for _, i in ipairs(parser_instances) do
|
||||
ret_list[i:run()] = true
|
||||
end
|
||||
return_sum = 0
|
||||
local return_sum = 0
|
||||
for i, _ in pairs(ret_list) do
|
||||
return_sum = return_sum + i
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ruantiblock-mod-py
|
||||
PKG_VERSION:=1.4
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@@ -54,15 +54,17 @@ class Config:
|
||||
"ZI_ALL_URL",
|
||||
"AF_IP_URL",
|
||||
"AF_FQDN_URL",
|
||||
"RA_IP_NFTSET_URL",
|
||||
"FZ_URL",
|
||||
"RA_IP_IPSET_URL",
|
||||
"RA_IP_DMASK_URL",
|
||||
"RA_IP_STAT_URL",
|
||||
"RA_FQDN_NFTSET_URL",
|
||||
"RA_FQDN_IPSET_URL",
|
||||
"RA_FQDN_DMASK_URL",
|
||||
"RA_FQDN_STAT_URL",
|
||||
"RBL_ENCODING",
|
||||
"ZI_ENCODING",
|
||||
"AF_ENCODING",
|
||||
"FZ_ENCODING",
|
||||
"RA_ENCODING",
|
||||
"BLLIST_SUMMARIZE_IP",
|
||||
"BLLIST_SUMMARIZE_CIDR",
|
||||
@@ -76,14 +78,31 @@ class Config:
|
||||
def normalize_string(string):
|
||||
return re.sub('"', '', string)
|
||||
|
||||
config_arrays = {
|
||||
config_sets = {
|
||||
"BLLIST_GR_EXCLUDED_SLD",
|
||||
"BLLIST_GR_EXCLUDED_NETS",
|
||||
}
|
||||
config_arrays = {
|
||||
"RBL_ALL_URL",
|
||||
"RBL_IP_URL",
|
||||
"RBL_DPI_URL",
|
||||
"ZI_ALL_URL",
|
||||
"AF_IP_URL",
|
||||
"AF_FQDN_URL",
|
||||
"FZ_URL",
|
||||
"RA_IP_IPSET_URL",
|
||||
"RA_IP_DMASK_URL",
|
||||
"RA_IP_STAT_URL",
|
||||
"RA_FQDN_IPSET_URL",
|
||||
"RA_FQDN_DMASK_URL",
|
||||
"RA_FQDN_STAT_URL",
|
||||
}
|
||||
try:
|
||||
for k, v in cfg_dict.items():
|
||||
if k in config_arrays:
|
||||
if k in config_sets:
|
||||
value = {normalize_string(i) for i in v.split(" ")}
|
||||
elif k in config_arrays:
|
||||
value = [normalize_string(i) for i in v.split(" ")]
|
||||
else:
|
||||
try:
|
||||
value = int(v)
|
||||
@@ -159,10 +178,11 @@ class BlackListParser(Config):
|
||||
self.proxies = None
|
||||
self.connect_timeout = None
|
||||
self.data_chunk = 2048
|
||||
self.url = "http://127.0.0.1"
|
||||
self.url = ["http://127.0.0.1"]
|
||||
self.records_separator = "\n"
|
||||
self.default_site_encoding = "utf-8"
|
||||
self.site_encoding = self.default_site_encoding
|
||||
self.rest = bytes()
|
||||
|
||||
@staticmethod
|
||||
def _compile_filter_patterns(filters_seq):
|
||||
@@ -201,14 +221,14 @@ class BlackListParser(Config):
|
||||
try:
|
||||
yield (conn_object, http_code, received_headers)
|
||||
except Exception as exception_object:
|
||||
raise ParserError(f"Parser error! {exception_object} ( {self.url} )")
|
||||
raise ParserError(f"Parser error! {exception_object} ( {url} )")
|
||||
finally:
|
||||
if conn_object:
|
||||
conn_object.close()
|
||||
|
||||
def _download_data(self):
|
||||
def _download_data(self, url):
|
||||
with self._make_connection(
|
||||
self.url,
|
||||
url,
|
||||
send_headers_dict=self.send_headers_dict,
|
||||
timeout=self.connect_timeout
|
||||
) as conn_params:
|
||||
@@ -220,17 +240,16 @@ class BlackListParser(Config):
|
||||
if not chunk:
|
||||
break
|
||||
|
||||
def _align_chunk(self):
|
||||
rest = bytes()
|
||||
for chunk in self._download_data():
|
||||
def _align_chunk(self, url):
|
||||
for chunk in self._download_data(url):
|
||||
if chunk is None:
|
||||
yield rest
|
||||
yield self.rest
|
||||
continue
|
||||
data, _, rest = (rest + chunk).rpartition(self.records_separator)
|
||||
data, _, self.rest = (self.rest + chunk).rpartition(self.records_separator)
|
||||
yield data
|
||||
|
||||
def _split_entries(self):
|
||||
for chunk in self._align_chunk():
|
||||
def _split_entries(self, url):
|
||||
for chunk in self._align_chunk(url):
|
||||
for entry in chunk.split(self.records_separator):
|
||||
try:
|
||||
yield entry.decode(
|
||||
@@ -331,6 +350,7 @@ class BlackListParser(Config):
|
||||
ret_value = 0
|
||||
else:
|
||||
ret_value = 2
|
||||
self.rest = bytes()
|
||||
return ret_value
|
||||
|
||||
|
||||
@@ -545,21 +565,22 @@ class RblFQDN(BlackListParser):
|
||||
self.ips_separator = ", "
|
||||
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
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_value_processing(fqdn_string)
|
||||
except FieldValueError:
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
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_value_processing(fqdn_string)
|
||||
except FieldValueError:
|
||||
for i in ip_string.split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
else:
|
||||
for i in ip_string.split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
else:
|
||||
for i in ip_string.split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
|
||||
class RblDPI(BlackListParser):
|
||||
def __init__(self):
|
||||
@@ -569,17 +590,18 @@ class RblDPI(BlackListParser):
|
||||
self.records_separator = '{"domains"'
|
||||
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
res = re.search(r': \[(.*?)\]', entry)
|
||||
if not res:
|
||||
continue
|
||||
fqdn_string = res.group(1)
|
||||
if fqdn_string:
|
||||
for i in fqdn_string.split(', "'):
|
||||
try:
|
||||
self.fqdn_value_processing(i.strip('"'))
|
||||
except FieldValueError:
|
||||
pass
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
res = re.search(r': \[(.*?)\]', entry)
|
||||
if not res:
|
||||
continue
|
||||
fqdn_string = res.group(1)
|
||||
if fqdn_string:
|
||||
for i in fqdn_string.split(', "'):
|
||||
try:
|
||||
self.fqdn_value_processing(i.strip('"'))
|
||||
except FieldValueError:
|
||||
pass
|
||||
|
||||
class RblIp(BlackListParser):
|
||||
def __init__(self):
|
||||
@@ -588,8 +610,9 @@ class RblIp(BlackListParser):
|
||||
self.records_separator = ","
|
||||
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
self.ip_value_processing(re.sub(r'[\[\]" ]', "", entry))
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
self.ip_value_processing(re.sub(r'[\[\]" ]', "", entry))
|
||||
|
||||
|
||||
class ZiFQDN(BlackListParser):
|
||||
@@ -601,28 +624,30 @@ class ZiFQDN(BlackListParser):
|
||||
self.ips_separator = "|"
|
||||
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
entry_list = entry.split(self.fields_separator)
|
||||
try:
|
||||
if entry_list[1]:
|
||||
try:
|
||||
self.fqdn_value_processing(entry_list[1])
|
||||
except FieldValueError:
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
entry_list = entry.split(self.fields_separator)
|
||||
try:
|
||||
if entry_list[1]:
|
||||
try:
|
||||
self.fqdn_value_processing(entry_list[1])
|
||||
except FieldValueError:
|
||||
for i in entry_list[0].split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
else:
|
||||
for i in entry_list[0].split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
else:
|
||||
for i in entry_list[0].split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
except IndexError:
|
||||
pass
|
||||
self.ip_value_processing(i)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
|
||||
class ZiIp(ZiFQDN):
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
entry_list = entry.split(self.fields_separator)
|
||||
for i in entry_list[0].split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
entry_list = entry.split(self.fields_separator)
|
||||
for i in entry_list[0].split(self.ips_separator):
|
||||
self.ip_value_processing(i)
|
||||
|
||||
|
||||
class AfFQDN(BlackListParser):
|
||||
@@ -631,11 +656,12 @@ class AfFQDN(BlackListParser):
|
||||
self.url = self.AF_FQDN_URL
|
||||
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
try:
|
||||
self.fqdn_value_processing(entry)
|
||||
except FieldValueError:
|
||||
self.ip_value_processing(entry)
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
try:
|
||||
self.fqdn_value_processing(entry)
|
||||
except FieldValueError:
|
||||
self.ip_value_processing(entry)
|
||||
|
||||
|
||||
class AfIp(BlackListParser):
|
||||
@@ -644,8 +670,50 @@ class AfIp(BlackListParser):
|
||||
self.url = self.AF_IP_URL
|
||||
|
||||
def parser_func(self):
|
||||
for entry in self._split_entries():
|
||||
self.ip_value_processing(entry)
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
self.ip_value_processing(entry)
|
||||
|
||||
|
||||
class FzFQDN(BlackListParser):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.url = self.FZ_URL
|
||||
self.site_encoding = self.FZ_ENCODING
|
||||
self.records_separator = "</content>"
|
||||
self.fqdn_value_regexp = re.compile(r"<domain><\!\[CDATA\[(.*?)\]\]></domain>", re.U)
|
||||
self.ip_value_regexp = re.compile(r"<ip>(.*?)</ip>")
|
||||
self.cidr_value_regexp = re.compile(r"<ipSubnet>(.*?)</ipSubnet>")
|
||||
|
||||
def parser_func(self):
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
res = self.fqdn_value_regexp.search(entry)
|
||||
if res and res.group(1):
|
||||
try:
|
||||
self.fqdn_value_processing(res.group(1))
|
||||
except FieldValueError:
|
||||
pass
|
||||
else:
|
||||
continue
|
||||
for i in self.ip_value_regexp.finditer(entry):
|
||||
if i.group(1):
|
||||
self.ip_value_processing(i.group(1))
|
||||
for i in self.cidr_value_regexp.finditer(entry):
|
||||
if i.group(1):
|
||||
self.ip_value_processing(i.group(1))
|
||||
|
||||
|
||||
class FzIp(FzFQDN):
|
||||
def parser_func(self):
|
||||
for url in self.url:
|
||||
for entry in self._split_entries(url):
|
||||
for i in self.ip_value_regexp.finditer(entry):
|
||||
if i.group(1):
|
||||
self.ip_value_processing(i.group(1))
|
||||
for i in self.cidr_value_regexp.finditer(entry):
|
||||
if i.group(1):
|
||||
self.ip_value_processing(i.group(1))
|
||||
|
||||
|
||||
class RaFQDN(BlackListParser):
|
||||
@@ -657,7 +725,7 @@ class RaFQDN(BlackListParser):
|
||||
self.current_file_handler = None
|
||||
|
||||
def parser_func(self):
|
||||
for chunk in self._download_data():
|
||||
for chunk in self._download_data(self.url[0]):
|
||||
if chunk:
|
||||
self.current_file_handler.write(chunk)
|
||||
|
||||
@@ -686,8 +754,8 @@ if __name__ == "__main__":
|
||||
Config.load_fqdn_filter()
|
||||
Config.load_ip_filter()
|
||||
parsers_dict = {
|
||||
"ip": {"rublacklist": [RblIp], "zapret-info": [ZiIp], "antifilter": [AfIp], "ruantiblock": [RaIp]},
|
||||
"fqdn": {"rublacklist": [RblFQDN, RblDPI], "zapret-info": [ZiFQDN], "antifilter": [AfFQDN], "ruantiblock": [RaFQDN]},
|
||||
"ip": {"rublacklist": [RblIp], "zapret-info": [ZiIp], "antifilter": [AfIp], "fz": [FzIp], "ruantiblock": [RaIp]},
|
||||
"fqdn": {"rublacklist": [RblFQDN, RblDPI], "zapret-info": [ZiFQDN], "antifilter": [AfFQDN], "fz": [FzFQDN], "ruantiblock": [RaFQDN]},
|
||||
}
|
||||
try:
|
||||
parser_classes = parsers_dict[Config.BLLIST_MODE][Config.BLLIST_SOURCE]
|
||||
|
||||
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ruantiblock
|
||||
PKG_VERSION:=1.4
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@@ -107,7 +107,7 @@ BLLIST_MODULE=""
|
||||
|
||||
### Настройки модулей-парсеров ###
|
||||
|
||||
### Режим обхода блокировок: ruantiblock-fqdn, ruantiblock-ip, zapret-info-fqdn, zapret-info-ip, rublacklist-fqdn, rublacklist-ip, antifilter-ip
|
||||
### Режим обхода блокировок: ruantiblock-fqdn, ruantiblock-ip, zapret-info-fqdn, zapret-info-ip, rublacklist-fqdn, rublacklist-ip, antifilter-ip, fz-fqdn, fz-ip
|
||||
BLLIST_PRESET=""
|
||||
### В случае если из источника получено менее указанного кол-ва записей, то обновления списков не происходит
|
||||
BLLIST_MIN_ENTRIES=3000
|
||||
@@ -154,6 +154,7 @@ ZI_ALL_URL="https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv"
|
||||
#ZI_ALL_URL="https://app.assembla.com/spaces/z-i/git/source/master/dump.csv?_format=raw"
|
||||
AF_IP_URL="https://antifilter.download/list/allyouneed.lst"
|
||||
AF_FQDN_URL="https://antifilter.download/list/domains.lst"
|
||||
FZ_URL="https://raw.githubusercontent.com/fz139/vigruzki/main/dump.xml.00 https://raw.githubusercontent.com/fz139/vigruzki/main/dump.xml.01 https://raw.githubusercontent.com/fz139/vigruzki/main/dump.xml.02"
|
||||
RA_IP_IPSET_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/ruantiblock.ip"
|
||||
RA_IP_DMASK_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/ruantiblock.dnsmasq"
|
||||
RA_IP_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/update_status"
|
||||
@@ -163,4 +164,5 @@ RA_FQDN_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blackli
|
||||
RBL_ENCODING=""
|
||||
ZI_ENCODING="CP1251"
|
||||
AF_ENCODING=""
|
||||
FZ_ENCODING="CP1251"
|
||||
RA_ENCODING=""
|
||||
|
||||
@@ -124,7 +124,7 @@ export BLLIST_MODULE=""
|
||||
|
||||
##############################
|
||||
|
||||
### Режим обхода блокировок: ruantiblock-fqdn, ruantiblock-ip, zapret-info-fqdn, zapret-info-ip, rublacklist-fqdn, rublacklist-ip, antifilter-ip
|
||||
### Режим обхода блокировок: ruantiblock-fqdn, ruantiblock-ip, zapret-info-fqdn, zapret-info-ip, rublacklist-fqdn, rublacklist-ip, antifilter-ip, fz-fqdn, fz-ip
|
||||
export BLLIST_PRESET=""
|
||||
### В случае если из источника получено менее указанного кол-ва записей, то обновления списков не происходит
|
||||
export BLLIST_MIN_ENTRIES=3000
|
||||
@@ -170,6 +170,7 @@ export RBL_DPI_URL="https://reestr.rublacklist.net/api/v3/dpi/"
|
||||
export ZI_ALL_URL="https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv"
|
||||
export AF_IP_URL="https://antifilter.download/list/allyouneed.lst"
|
||||
export AF_FQDN_URL="https://antifilter.download/list/domains.lst"
|
||||
export FZ_URL="https://raw.githubusercontent.com/fz139/vigruzki/main/dump.xml.00 https://raw.githubusercontent.com/fz139/vigruzki/main/dump.xml.01 https://raw.githubusercontent.com/fz139/vigruzki/main/dump.xml.02"
|
||||
export RA_IP_IPSET_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/ruantiblock.ip"
|
||||
export RA_IP_DMASK_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/ruantiblock.dnsmasq"
|
||||
export RA_IP_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/update_status"
|
||||
@@ -179,6 +180,7 @@ export RA_FQDN_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_
|
||||
export RBL_ENCODING=""
|
||||
export ZI_ENCODING="CP1251"
|
||||
export AF_ENCODING=""
|
||||
export FZ_ENCODING="CP1251"
|
||||
export RA_ENCODING=""
|
||||
|
||||
############################ Configuration #############################
|
||||
@@ -596,9 +598,9 @@ GetDataFiles() {
|
||||
if [ "$ENABLE_BLLIST_PROXY" = "1" ]; then
|
||||
FlushNftSets "$NFTSET_BLLIST_PROXY"
|
||||
fi
|
||||
AddUserEntries
|
||||
AddBypassEntries
|
||||
if [ $_return_code -eq 0 ]; then
|
||||
AddUserEntries
|
||||
AddBypassEntries
|
||||
_update_string=`$AWK_CMD '{
|
||||
printf "Received entries: %s\n", (NF < 3) ? "No data" : "CIDR: "$1", IP: "$2", FQDN: "$3;
|
||||
exit;
|
||||
@@ -828,6 +830,14 @@ case "$BLLIST_PRESET" in
|
||||
export BLLIST_SOURCE="antifilter"
|
||||
export BLLIST_MODE="ip"
|
||||
;;
|
||||
fz-ip)
|
||||
export BLLIST_SOURCE="fz"
|
||||
export BLLIST_MODE="ip"
|
||||
;;
|
||||
fz-fqdn)
|
||||
export BLLIST_SOURCE="fz"
|
||||
export BLLIST_MODE="fqdn"
|
||||
;;
|
||||
ruantiblock-ip)
|
||||
export BLLIST_SOURCE="ruantiblock"
|
||||
export BLLIST_MODE="ip"
|
||||
|
||||
Reference in New Issue
Block a user