From 8184a68fe85d5301b8331f0c4ffc5ae211538fd4 Mon Sep 17 00:00:00 2001 From: gSpot Date: Mon, 23 Sep 2024 00:52:58 +0300 Subject: [PATCH] v1.6. Refactoring. Some improvements. --- autoinstall/current/autoinstall.sh | 10 +- autoinstall/current/uninstall.sh | 6 +- luci-app-ruantiblock/Makefile | 2 +- .../resources/view/ruantiblock/settings.js | 41 +++-- .../resources/view/ruantiblock/tools.js | 32 ++-- luci-app-ruantiblock/po/ru/ruantiblock.po | 13 ++ .../po/templates/ruantiblock.pot | 10 ++ .../rpcd/acl.d/luci-app-ruantiblock.json | 4 + ruantiblock-mod-lua/Makefile | 4 +- .../usr/libexec/ruantiblock/ruab_parser.lua | 134 ++++++++++------- ruantiblock-mod-py/Makefile | 2 +- .../usr/libexec/ruantiblock/ruab_parser.py | 137 ++++++++++------- ruantiblock/Makefile | 9 +- ruantiblock/files/etc/config/ruantiblock | 15 -- ruantiblock/files/etc/ruantiblock/fqdn_filter | 43 +++++- .../files/etc/ruantiblock/gr_excluded_nets | 0 .../files/etc/ruantiblock/gr_excluded_sld | 15 ++ .../files/etc/ruantiblock/ruantiblock.conf | 41 ++--- ruantiblock/files/usr/bin/ruantiblock | 141 +++++------------- .../usr/share/ruantiblock/blacklist_sources | 73 +++++++++ .../files/usr/share/ruantiblock/config_script | 3 +- 21 files changed, 432 insertions(+), 303 deletions(-) create mode 100644 ruantiblock/files/etc/ruantiblock/gr_excluded_nets create mode 100644 ruantiblock/files/etc/ruantiblock/gr_excluded_sld create mode 100644 ruantiblock/files/usr/share/ruantiblock/blacklist_sources diff --git a/autoinstall/current/autoinstall.sh b/autoinstall/current/autoinstall.sh index 236017b..7d004bf 100755 --- a/autoinstall/current/autoinstall.sh +++ b/autoinstall/current/autoinstall.sh @@ -9,9 +9,9 @@ LUA_MODULE=0 LUCI_APP=1 OWRT_VERSION="current" -RUAB_VERSION="1.5.0-2" -RUAB_MOD_LUA_VERSION="1.5.0-2" -RUAB_LUCI_APP_VERSION="1.5.0-r2" +RUAB_VERSION="1.6.0-1" +RUAB_MOD_LUA_VERSION="1.6.0-1" +RUAB_LUCI_APP_VERSION="1.6.0-r1" BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master" PKG_DIR="/tmp" @@ -48,6 +48,8 @@ FILE_FQDN_FILTER="${RUAB_CFG_DIR}/fqdn_filter" FILE_IP_FILTER="${RUAB_CFG_DIR}/ip_filter" FILE_USER_ENTRIES="${RUAB_CFG_DIR}/user_entries" FILE_BYPASS_ENTRIES="${RUAB_CFG_DIR}/bypass_entries" +FILE_GR_EXCLUDED_SLD="${RUAB_CFG_DIR}/gr_excluded_sld" +FILE_GR_EXCLUDED_NETS="${RUAB_CFG_DIR}/gr_excluded_nets" FILE_UCI_CONFIG="${PREFIX}/etc/config/ruantiblock" FILE_INIT_SCRIPT="${PREFIX}/etc/init.d/ruantiblock" FILE_MAIN_SCRIPT="${EXEC_DIR}/ruantiblock" @@ -122,7 +124,7 @@ BackupFile() { BackupCurrentConfig() { local _file MakeDir "$BACKUP_DIR" - for _file in "$FILE_CONFIG" "$FILE_FQDN_FILTER" "$FILE_IP_FILTER" "$FILE_USER_ENTRIES" "$FILE_BYPASS_ENTRIES" "$FILE_UCI_CONFIG" "$FILE_TORRC" + for _file in "$FILE_CONFIG" "$FILE_FQDN_FILTER" "$FILE_IP_FILTER" "$FILE_USER_ENTRIES" "$FILE_BYPASS_ENTRIES" "$FILE_GR_EXCLUDED_NETS" "$FILE_GR_EXCLUDED_SLD" "$FILE_UCI_CONFIG" "$FILE_TORRC" do [ -e "$_file" ] && cp -f "$_file" "${BACKUP_DIR}/`basename ${_file}`" done diff --git a/autoinstall/current/uninstall.sh b/autoinstall/current/uninstall.sh index 2f06f2c..cb86498 100755 --- a/autoinstall/current/uninstall.sh +++ b/autoinstall/current/uninstall.sh @@ -22,6 +22,8 @@ FILE_FQDN_FILTER="${RUAB_CFG_DIR}/fqdn_filter" FILE_IP_FILTER="${RUAB_CFG_DIR}/ip_filter" FILE_USER_ENTRIES="${RUAB_CFG_DIR}/user_entries" FILE_BYPASS_ENTRIES="${RUAB_CFG_DIR}/bypass_entries" +FILE_GR_EXCLUDED_SLD="${RUAB_CFG_DIR}/gr_excluded_sld" +FILE_GR_EXCLUDED_NETS="${RUAB_CFG_DIR}/gr_excluded_nets" FILE_UCI_CONFIG="${PREFIX}/etc/config/ruantiblock" FILE_INIT_SCRIPT="${PREFIX}/etc/init.d/ruantiblock" FILE_MAIN_SCRIPT="${EXEC_DIR}/ruantiblock" @@ -57,7 +59,7 @@ RemoveFile() { BackupCurrentConfig() { local _file MakeDir "$BACKUP_DIR" - for _file in "$FILE_CONFIG" "$FILE_FQDN_FILTER" "$FILE_IP_FILTER" "$FILE_USER_ENTRIES" "$FILE_BYPASS_ENTRIES" "$FILE_UCI_CONFIG" "$FILE_TORRC" + for _file in "$FILE_CONFIG" "$FILE_FQDN_FILTER" "$FILE_IP_FILTER" "$FILE_USER_ENTRIES" "$FILE_BYPASS_ENTRIES" "$FILE_GR_EXCLUDED_NETS" "$FILE_GR_EXCLUDED_SLD" "$FILE_UCI_CONFIG" "$FILE_TORRC" do [ -e "$_file" ] && cp -f "$_file" "${BACKUP_DIR}/`basename ${_file}`" done @@ -98,6 +100,8 @@ RemoveAppFiles() { RemoveFile "$FILE_IP_FILTER" RemoveFile "$FILE_USER_ENTRIES" RemoveFile "$FILE_BYPASS_ENTRIES" + RemoveFile "$FILE_GR_EXCLUDED_SLD" + RemoveFile "$FILE_GR_EXCLUDED_NETS" RemoveFile "${FILE_UCI_CONFIG}.opkg" RemoveFile "${FILE_CONFIG}.opkg" RemoveFile "${FILE_FQDN_FILTER}.opkg" diff --git a/luci-app-ruantiblock/Makefile b/luci-app-ruantiblock/Makefile index 65bded4..70ee674 100644 --- a/luci-app-ruantiblock/Makefile +++ b/luci-app-ruantiblock/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk -PKG_VERSION:=1.5.0-r2 +PKG_VERSION:=1.6.0-r1 LUCI_TITLE:=LuCI support for ruantiblock LUCI_DEPENDS:=+ruantiblock LUCI_PKGARCH:=all diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js index 73ae0bf..b10f7b2 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/settings.js @@ -115,6 +115,20 @@ return view.extend({ } ); + let gr_excluded_nets_edit = new tools.fileEditDialog( + tools.grExcludedNetsFile, + _('IP subnet patterns (/24) that are excluded from optimization'), + _('One IP subnet pattern (/24) per line. You can also comment on lines (# is the first character of a line).
Examples:') + + '
#comment
74.125.131.
74.125.0.
' + ); + + let gr_excluded_sld_edit = new tools.fileEditDialog( + tools.grExcludedSldFile, + _('2nd level domains that are excluded from optimization'), + _('One FQDN entry per line. You can also comment on lines (# is the first character of a line).
Examples:') + + '
#comment
domain.net
anotherdomain.com
' + ); + let m, s, o; m = new form.Map(tools.appName, _('Ruantiblock') + ' - ' + _('Settings')); @@ -381,12 +395,13 @@ return view.extend({ o.rmempty = false; o.datatype = 'uinteger'; - // BLLIST_GR_EXCLUDED_SLD - o = s.taboption('parser_settings_tab', form.DynamicList, 'bllist_gr_excluded_sld', + // BLLIST_GR_EXCLUDED_SLD_FILE edit dialog + o = s.taboption('parser_settings_tab', form.Button, '_gr_excluded_sld_btn', _('2nd level domains that are excluded from optimization')); - o.description = _('e.g:') + ' livejournal.com'; - o.placeholder = _('e.g:') + ' livejournal.com'; - o.datatype = 'hostname'; + o.onclick = () => gr_excluded_sld_edit.show(); + o.inputtitle = _('Edit'); + o.inputstyle = 'edit btn'; + //o.description = _('e.g:') + ' livejournal.com'; // BLLIST_ENABLE_IDN o = s.taboption('parser_settings_tab', form.Flag, 'bllist_enable_idn', @@ -429,15 +444,13 @@ return view.extend({ o.rmempty = false; o.datatype = 'uinteger'; - // BLLIST_GR_EXCLUDED_NETS - o = s.taboption('parser_settings_tab', form.DynamicList, 'bllist_gr_excluded_nets'); - o.title = _('IP subnet patterns (/24) that are excluded from optimization'); - o.description = _('e.g:') + ' 192.168.1.'; - o.placeholder = _('e.g:') + ' 192.168.1.'; - o.validate = (section, value) => { - return (/^$|^([0-9]{1,3}[.]){3}$/.test(value)) ? true : _('Expecting:') - + ' ' + _('net pattern') + ' (' + _('e.g:') + ' 192.168.3.)\n'; - }; + // BLLIST_GR_EXCLUDED_NETS_FILE edit dialog + o = s.taboption('parser_settings_tab', form.Button, '_gr_excluded_nets_btn', + _('IP subnet patterns (/24) that are excluded from optimization')); + o.onclick = () => gr_excluded_nets_edit.show(); + o.inputtitle = _('Edit'); + o.inputstyle = 'edit btn'; + //o.description = _('e.g:') + ' 192.168.1.'; // BLLIST_SUMMARIZE_IP o = s.taboption('parser_settings_tab', form.Flag, 'bllist_summarize_ip', diff --git a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/tools.js b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/tools.js index 1a8f2c7..15b9a70 100644 --- a/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/tools.js +++ b/luci-app-ruantiblock/htdocs/luci-static/resources/view/ruantiblock/tools.js @@ -34,21 +34,23 @@ document.head.append(E('style', {'type': 'text/css'}, `)); return baseclass.extend({ - appName : 'ruantiblock', - execPath : '/usr/bin/ruantiblock', - tokenFile : '/var/run/ruantiblock.token', - parsersDir : '/usr/libexec/ruantiblock', - torrcFile : '/etc/tor/torrc', - userEntriesFile : '/etc/ruantiblock/user_entries', - bypassEntriesFile: '/etc/ruantiblock/bypass_entries', - fqdnFilterFile : '/etc/ruantiblock/fqdn_filter', - ipFilterFile : '/etc/ruantiblock/ip_filter', - crontabFile : '/etc/crontabs/root', - infoLabelStarting: '' + _('Starting') + '', - infoLabelRunning : '' + _('Enabled') + '', - infoLabelUpdating: '' + _('Updating') + '', - infoLabelStopped : '' + _('Disabled') + '', - infoLabelError : '' + _('Error') + '', + appName : 'ruantiblock', + execPath : '/usr/bin/ruantiblock', + tokenFile : '/var/run/ruantiblock.token', + parsersDir : '/usr/libexec/ruantiblock', + torrcFile : '/etc/tor/torrc', + userEntriesFile : '/etc/ruantiblock/user_entries', + bypassEntriesFile : '/etc/ruantiblock/bypass_entries', + fqdnFilterFile : '/etc/ruantiblock/fqdn_filter', + ipFilterFile : '/etc/ruantiblock/ip_filter', + grExcludedNetsFile: '/etc/ruantiblock/gr_excluded_nets', + grExcludedSldFile : '/etc/ruantiblock/gr_excluded_sld', + crontabFile : '/etc/crontabs/root', + infoLabelStarting : '' + _('Starting') + '', + infoLabelRunning : '' + _('Enabled') + '', + infoLabelUpdating : '' + _('Updating') + '', + infoLabelStopped : '' + _('Disabled') + '', + infoLabelError : '' + _('Error') + '', blacklistPresets: { 'ruantiblock-fqdn': [ 'ruantiblock', 'fqdn', 'https://github.com/gSpotx2f/ruantiblock_blacklist' ], diff --git a/luci-app-ruantiblock/po/ru/ruantiblock.po b/luci-app-ruantiblock/po/ru/ruantiblock.po index afd2a0c..d4b5221 100644 --- a/luci-app-ruantiblock/po/ru/ruantiblock.po +++ b/luci-app-ruantiblock/po/ru/ruantiblock.po @@ -321,6 +321,19 @@ msgstr "" "сервер для разрешения данного домена (через пробел). Также, можно " "комментировать строки (# - первый символ строки).
Примеры:" +msgid "" +"One FQDN entry per line. You can also comment on lines " +"(# is the first character of a line).
Examples:" +msgstr "Одна запись FQDN на строку. Также, можно " +"комментировать строки (# - первый символ строки).
Примеры:" + +msgid "" +"One IP subnet pattern (/24) per line. You can also comment on lines " +"(# is the first character of a line).
Examples:" +msgstr "" +"Один шаблон IP подсети (/24) на строку Также, можно комментировать " +"строки (# - первый символ строки).
Примеры:" + msgid "One of the following:" msgstr "Одно из следующих значений:" diff --git a/luci-app-ruantiblock/po/templates/ruantiblock.pot b/luci-app-ruantiblock/po/templates/ruantiblock.pot index 353a11c..fff608e 100644 --- a/luci-app-ruantiblock/po/templates/ruantiblock.pot +++ b/luci-app-ruantiblock/po/templates/ruantiblock.pot @@ -299,6 +299,16 @@ msgid "" ">Examples:" msgstr "" +msgid "" +"One FQDN entry per line. You can also comment on lines " +"(# is the first character of a line).
Examples:" +msgstr "" + +msgid +"One IP subnet pattern (/24) per line. You can also comment on lines " +"(# is the first character of a line).
Examples:" +msgstr "" + msgid "One of the following:" msgstr "" diff --git a/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json b/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json index 9dd3814..ad22748 100644 --- a/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json +++ b/luci-app-ruantiblock/root/usr/share/rpcd/acl.d/luci-app-ruantiblock.json @@ -9,6 +9,8 @@ "/etc/ruantiblock/ip_filter": [ "read" ], "/etc/ruantiblock/user_entries": [ "read" ], "/etc/ruantiblock/bypass_entries": [ "read" ], + "/etc/ruantiblock/gr_excluded_nets": [ "read" ], + "/etc/ruantiblock/gr_excluded_sld": [ "read" ], "/var/run/ruantiblock.token": [ "read" ], "/etc/tor/torrc": [ "read" ], "/etc/crontabs/root": [ "read" ], @@ -27,6 +29,8 @@ "/etc/ruantiblock/ip_filter": [ "write" ], "/etc/ruantiblock/user_entries": [ "write" ], "/etc/ruantiblock/bypass_entries": [ "write" ], + "/etc/ruantiblock/gr_excluded_nets": [ "write" ], + "/etc/ruantiblock/gr_excluded_sld": [ "write" ], "/etc/tor/torrc": [ "write" ], "/etc/crontabs/root": [ "write" ] }, diff --git a/ruantiblock-mod-lua/Makefile b/ruantiblock-mod-lua/Makefile index 1c345d0..82ec6ae 100644 --- a/ruantiblock-mod-lua/Makefile +++ b/ruantiblock-mod-lua/Makefile @@ -5,8 +5,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-lua -PKG_VERSION:=1.5.0 -PKG_RELEASE:=2 +PKG_VERSION:=1.6.0 +PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot include $(INCLUDE_DIR)/package.mk diff --git a/ruantiblock-mod-lua/files/usr/libexec/ruantiblock/ruab_parser.lua b/ruantiblock-mod-lua/files/usr/libexec/ruantiblock/ruab_parser.lua index a7e2f52..fe34241 100755 --- a/ruantiblock-mod-lua/files/usr/libexec/ruantiblock/ruab_parser.lua +++ b/ruantiblock-mod-lua/files/usr/libexec/ruantiblock/ruab_parser.lua @@ -40,8 +40,8 @@ local Config = Class(nil, { ["BLLIST_ALT_NSLOOKUP"] = true, ["BLLIST_ALT_DNS_ADDR"] = true, ["BLLIST_ENABLE_IDN"] = true, - ["BLLIST_GR_EXCLUDED_SLD"] = true, - ["BLLIST_GR_EXCLUDED_MASKS"] = true, + ["BLLIST_GR_EXCLUDED_SLD_FILE"] = true, + ["BLLIST_GR_EXCLUDED_SLD_MASKS_FILE"] = true, ["BLLIST_FQDN_FILTER"] = true, ["BLLIST_FQDN_FILTER_TYPE"] = true, ["BLLIST_FQDN_FILTER_FILE"] = true, @@ -50,7 +50,7 @@ local Config = Class(nil, { ["BLLIST_IP_FILTER_FILE"] = true, ["BLLIST_SD_LIMIT"] = true, ["BLLIST_IP_LIMIT"] = true, - ["BLLIST_GR_EXCLUDED_NETS"] = true, + ["BLLIST_GR_EXCLUDED_NETS_FILE"] = true, ["BLLIST_MIN_ENTRIES"] = true, ["BLLIST_STRIP_WWW"] = true, ["NFT_TABLE"] = true, @@ -71,22 +71,27 @@ local Config = Class(nil, { ["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, + ["DL_IPSET_URL"] = true, + ["DL_DMASK_URL"] = true, + ["DL_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, + ["BLLIST_FQDN_EXCLUDED_ENABLE"] = true, + ["BLLIST_FQDN_EXCLUDED_FILE"] = true, + ["BLLIST_IP_EXCLUDED_ENABLE"] = true, + ["BLLIST_IP_EXCLUDED_FILE"] = true, }, BLLIST_FQDN_FILTER_PATTERNS = {}, BLLIST_IP_FILTER_PATTERNS = {}, + BLLIST_GR_EXCLUDED_SLD_PATTERNS = {}, + BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS = {}, + BLLIST_GR_EXCLUDED_NETS_PATTERNS = {}, + BLLIST_FQDN_EXCLUDED_ITEMS = {}, + BLLIST_IP_EXCLUDED_ITEMS = {}, -- iconv type: standalone iconv or lua-iconv (standalone, lua) ICONV_TYPE = "standalone", -- standalone iconv @@ -95,7 +100,7 @@ local Config = Class(nil, { encoding = "UTF-8", site_encoding = "", http_send_headers = { - ["User-Agent"] = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0", + ["User-Agent"] = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0", }, connect_timeout = nil, }) @@ -104,10 +109,7 @@ Config.wget_user_agent = (Config.http_send_headers["User-Agent"]) and ' -U "' .. -- Loading external config function Config:load_config(t) - local config_sets = { - ["BLLIST_GR_EXCLUDED_SLD"] = true, - ["BLLIST_GR_EXCLUDED_NETS"] = true, - } + local config_sets = {} local config_arrays = { ["RBL_ALL_URL"] = true, ["RBL_IP_URL"] = true, @@ -116,12 +118,9 @@ function Config:load_config(t) ["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, + ["DL_IPSET_URL"] = true, + ["DL_DMASK_URL"] = true, + ["DL_STAT_URL"] = true, } for k, v in pairs(t) do if config_sets[k] then @@ -168,16 +167,22 @@ Config.BLLIST_FQDN_FILTER = remap_bool(Config.BLLIST_FQDN_FILTER) Config.BLLIST_IP_FILTER = remap_bool(Config.BLLIST_IP_FILTER) Config.BLLIST_SUMMARIZE_IP = remap_bool(Config.BLLIST_SUMMARIZE_IP) Config.BLLIST_SUMMARIZE_CIDR = remap_bool(Config.BLLIST_SUMMARIZE_CIDR) +Config.BLLIST_FQDN_EXCLUDED_ENABLE = remap_bool(Config.BLLIST_FQDN_EXCLUDED_ENABLE) +Config.BLLIST_IP_EXCLUDED_ENABLE = remap_bool(Config.BLLIST_IP_EXCLUDED_ENABLE) -- Loading filters function Config:load_filter_files() - function load_file(file, t) + function load_file(file, t, is_array) local file_handler = io.open(file, "r") if file_handler then for line in file_handler:lines() do if #line > 0 and line:match("^[^#]") then - t[line] = true + if is_array then + t[#t + 1] = line + else + t[line] = true + end end end file_handler:close() @@ -189,6 +194,32 @@ function Config:load_filter_files() if self.BLLIST_IP_FILTER then load_file(self.BLLIST_IP_FILTER_FILE, self.BLLIST_IP_FILTER_PATTERNS) end + if self.BLLIST_GR_EXCLUDED_SLD_FILE then + load_file(self.BLLIST_GR_EXCLUDED_SLD_FILE, self.BLLIST_GR_EXCLUDED_SLD_PATTERNS) + end + if self.BLLIST_GR_EXCLUDED_SLD_MASKS_FILE then + load_file(self.BLLIST_GR_EXCLUDED_SLD_MASKS_FILE, self.BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS, true) + end + if self.BLLIST_GR_EXCLUDED_NETS_FILE then + load_file(self.BLLIST_GR_EXCLUDED_NETS_FILE, self.BLLIST_GR_EXCLUDED_NETS_PATTERNS) + end + if self.BLLIST_FQDN_EXCLUDED_ENABLE then + load_file(self.BLLIST_FQDN_EXCLUDED_FILE, self.BLLIST_FQDN_EXCLUDED_ITEMS) + end + if self.BLLIST_IP_EXCLUDED_ENABLE then + load_file(self.BLLIST_IP_EXCLUDED_FILE, self.BLLIST_IP_EXCLUDED_ITEMS) + end +end + +function Config:check_sld_masks(sld) + if #self.BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS > 0 then + for _, pattern in ipairs(self.BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS) do + if sld:find(pattern) then + return true + end + end + end + return false end Config:load_filter_files() @@ -305,17 +336,20 @@ end function BlackListParser:ip_value_processing(value) if value and value ~= "" then for ip_entry in value:gmatch(self.ip_pattern .. "/?%d?%d?") do - if not self.BLLIST_IP_FILTER or (self.BLLIST_IP_FILTER and not self:check_filter(ip_entry, self.BLLIST_IP_FILTER_PATTERNS, self.BLLIST_IP_FILTER_TYPE)) then - if ip_entry:match("^" .. self.ip_pattern .. "$") and not self.ip_table[ip_entry] then - local subnet = self:get_subnet(ip_entry) - if subnet and (self.BLLIST_GR_EXCLUDED_NETS[subnet] or ((not self.BLLIST_IP_LIMIT or self.BLLIST_IP_LIMIT == 0) or (not self.ip_subnet_table[subnet] or self.ip_subnet_table[subnet] <= self.BLLIST_IP_LIMIT))) then - self.ip_table[ip_entry] = subnet - self.ip_subnet_table[subnet] = (self.ip_subnet_table[subnet] or 0) + 1 - self.ip_count = self.ip_count + 1 + if self.BLLIST_IP_EXCLUDED_ENABLE and self.BLLIST_IP_EXCLUDED_ITEMS[ip_entry] then + else + if not self.BLLIST_IP_FILTER or (self.BLLIST_IP_FILTER and not self:check_filter(ip_entry, self.BLLIST_IP_FILTER_PATTERNS, self.BLLIST_IP_FILTER_TYPE)) then + if ip_entry:match("^" .. self.ip_pattern .. "$") and not self.ip_table[ip_entry] then + local subnet = self:get_subnet(ip_entry) + if subnet and (self.BLLIST_GR_EXCLUDED_NETS_PATTERNS[subnet] or ((not self.BLLIST_IP_LIMIT or self.BLLIST_IP_LIMIT == 0) or (not self.ip_subnet_table[subnet] or self.ip_subnet_table[subnet] <= self.BLLIST_IP_LIMIT))) then + self.ip_table[ip_entry] = subnet + self.ip_subnet_table[subnet] = (self.ip_subnet_table[subnet] or 0) + 1 + self.ip_count = self.ip_count + 1 + end + elseif ip_entry:match("^" .. self.cidr_pattern .. "$") and not self.cidr_table[ip_entry] then + self.cidr_table[ip_entry] = true + self.cidr_count = self.cidr_count + 1 end - elseif ip_entry:match("^" .. self.cidr_pattern .. "$") and not self.cidr_table[ip_entry] then - self.cidr_table[ip_entry] = true - self.cidr_count = self.cidr_count + 1 end end end @@ -331,6 +365,9 @@ function BlackListParser:fqdn_value_processing(value) if self.BLLIST_STRIP_WWW then value = value:gsub("^www[0-9]?%.", "") end + if self.BLLIST_FQDN_EXCLUDED_ENABLE and self.BLLIST_FQDN_EXCLUDED_ITEMS[value] then + return true + end if not self.BLLIST_FQDN_FILTER or (self.BLLIST_FQDN_FILTER and not self:check_filter(value, self.BLLIST_FQDN_FILTER_PATTERNS, self.BLLIST_FQDN_FILTER_TYPE)) then if value:match("^" .. self.fqdn_pattern .. "$") then elseif self.BLLIST_ENABLE_IDN and value:match("^[^\\/&%?]-[^\\/&%?%.]+%.[^\\/&%?%.]+%.?$") then @@ -342,7 +379,7 @@ function BlackListParser:fqdn_value_processing(value) return false end local sld = self:get_sld(value) - if sld and (self.BLLIST_GR_EXCLUDED_SLD[sld] or ((not self.BLLIST_SD_LIMIT or self.BLLIST_SD_LIMIT == 0) or (not self.sld_table[sld] or self.sld_table[sld] < self.BLLIST_SD_LIMIT))) then + if sld and ((self.BLLIST_GR_EXCLUDED_SLD_PATTERNS[sld] or self:check_sld_masks(sld)) or ((not self.BLLIST_SD_LIMIT or self.BLLIST_SD_LIMIT == 0) or (not self.sld_table[sld] or self.sld_table[sld] < self.BLLIST_SD_LIMIT))) then self.fqdn_table[value] = sld self.sld_table[sld] = (self.sld_table[sld] or 0) + 1 self.fqdn_count = self.fqdn_count + 1 @@ -663,7 +700,7 @@ function OptimizeConfig:_optimize_ip_table() local optimized_table = {} for ipaddr, subnet in pairs(self.ip_table) do if self.ip_subnet_table[subnet] then - if (self.BLLIST_IP_LIMIT and self.BLLIST_IP_LIMIT > 0 and not self.BLLIST_GR_EXCLUDED_NETS[subnet]) and self.ip_subnet_table[subnet] >= self.BLLIST_IP_LIMIT then + if (self.BLLIST_IP_LIMIT and self.BLLIST_IP_LIMIT > 0 and not self.BLLIST_GR_EXCLUDED_NETS_PATTERNS[subnet]) and self.ip_subnet_table[subnet] >= self.BLLIST_IP_LIMIT then self.cidr_table[string.format("%s0/24", subnet)] = true self.ip_subnet_table[subnet] = nil self.cidr_count = self.cidr_count + 1 @@ -678,20 +715,10 @@ end function OptimizeConfig:_optimize_fqdn_table() local optimized_table = {} - if self.BLLIST_GR_EXCLUDED_MASKS and #self.BLLIST_GR_EXCLUDED_MASKS > 0 then - for sld in pairs(self.sld_table) do - for _, pattern in ipairs(self.BLLIST_GR_EXCLUDED_MASKS) do - if sld:find(pattern) then - self.sld_table[sld] = 0 - break - end - end - end - end for fqdn, sld in pairs(self.fqdn_table) do local key_value = fqdn if (not self.fqdn_table[sld] or fqdn == sld) and self.sld_table[sld] then - if (self.BLLIST_SD_LIMIT and self.BLLIST_SD_LIMIT > 0 and not self.BLLIST_GR_EXCLUDED_SLD[sld]) and self.sld_table[sld] >= self.BLLIST_SD_LIMIT then + if (self.BLLIST_SD_LIMIT and self.BLLIST_SD_LIMIT > 0 and not self.BLLIST_GR_EXCLUDED_SLD_PATTERNS[sld] and not self:check_sld_masks(sld)) and self.sld_table[sld] >= self.BLLIST_SD_LIMIT then key_value = sld self.sld_table[sld] = nil end @@ -973,9 +1000,9 @@ end -- ruantiblock local Ra = Class(BlackListParser, { - url_ipset = Config.RA_FQDN_IPSET_URL, - url_dnsmasq = Config.RA_FQDN_DMASK_URL, - url_stat = Config.RA_FQDN_STAT_URL, + url_ipset = Config.DL_IPSET_URL, + url_dnsmasq = Config.DL_DMASK_URL, + url_stat = Config.DL_STAT_URL, }) function Ra:download_config(url, file) @@ -1032,16 +1059,10 @@ function Ra:run() return return_code end -local RaIp = Class(Ra, { - url_ipset = Config.RA_IP_IPSET_URL, - url_dnsmasq = Config.RA_IP_DMASK_URL, - url_stat = Config.RA_IP_STAT_URL, -}) - ----------------------------- Main section ------------------------------ local parsers_table = { - ["ip"] = {["rublacklist"] = {RblIp}, ["zapret-info"] = {ZiIp}, ["antifilter"] = {AfIp}, ["fz"] = {FzIp}, ["ruantiblock"] = {RaIp}}, + ["ip"] = {["rublacklist"] = {RblIp}, ["zapret-info"] = {ZiIp}, ["antifilter"] = {AfIp}, ["fz"] = {FzIp}, ["ruantiblock"] = {Ra}}, ["fqdn"] = {["rublacklist"] = {Rbl, RblDPI}, ["zapret-info"] = {Zi}, ["antifilter"] = {Af}, ["fz"] = {Fz}, ["ruantiblock"] = {Ra}}, } @@ -1070,4 +1091,5 @@ if parser_classes then else error("Wrong configuration! (Config.BLLIST_MODE, Config.BLLIST_SOURCE)") end + os.exit(ret_list[1] and 1 or (ret_list[2] and 2 or 0)) diff --git a/ruantiblock-mod-py/Makefile b/ruantiblock-mod-py/Makefile index 2c81aec..9e550e1 100644 --- a/ruantiblock-mod-py/Makefile +++ b/ruantiblock-mod-py/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-py -PKG_VERSION:=1.5.0 +PKG_VERSION:=1.6.0 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/ruantiblock-mod-py/files/usr/libexec/ruantiblock/ruab_parser.py b/ruantiblock-mod-py/files/usr/libexec/ruantiblock/ruab_parser.py index e7e412a..b6a1009 100755 --- a/ruantiblock-mod-py/files/usr/libexec/ruantiblock/ruab_parser.py +++ b/ruantiblock-mod-py/files/usr/libexec/ruantiblock/ruab_parser.py @@ -24,8 +24,8 @@ class Config: "BLLIST_ALT_NSLOOKUP", "BLLIST_ALT_DNS_ADDR", "BLLIST_ENABLE_IDN", - "BLLIST_GR_EXCLUDED_SLD", - "BLLIST_GR_EXCLUDED_MASKS", + "BLLIST_GR_EXCLUDED_SLD_FILE", + "BLLIST_GR_EXCLUDED_SLD_MASKS_FILE", "BLLIST_FQDN_FILTER", "BLLIST_FQDN_FILTER_TYPE", "BLLIST_FQDN_FILTER_FILE", @@ -34,7 +34,7 @@ class Config: "BLLIST_IP_FILTER_FILE", "BLLIST_SD_LIMIT", "BLLIST_IP_LIMIT", - "BLLIST_GR_EXCLUDED_NETS", + "BLLIST_GR_EXCLUDED_NETS_FILE", "BLLIST_MIN_ENTRIES", "BLLIST_STRIP_WWW", "NFT_TABLE", @@ -55,22 +55,27 @@ class Config: "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", + "DL_IPSET_URL", + "DL_DMASK_URL", + "DL_STAT_URL", "RBL_ENCODING", "ZI_ENCODING", "AF_ENCODING", "FZ_ENCODING", - "RA_ENCODING", "BLLIST_SUMMARIZE_IP", "BLLIST_SUMMARIZE_CIDR", + "BLLIST_FQDN_EXCLUDED_ENABLE", + "BLLIST_FQDN_EXCLUDED_FILE", + "BLLIST_IP_EXCLUDED_ENABLE", + "BLLIST_IP_EXCLUDED_FILE", ] BLLIST_FQDN_FILTER_PATTERNS = set() BLLIST_IP_FILTER_PATTERNS = set() + BLLIST_GR_EXCLUDED_SLD_PATTERNS = set() + BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS = [] + BLLIST_GR_EXCLUDED_NETS_PATTERNS = set() + BLLIST_FQDN_EXCLUDED_ITEMS = set() + BLLIST_IP_EXCLUDED_ITEMS = set() @classmethod def _load_config(cls, cfg_dict): @@ -78,10 +83,7 @@ class Config: def normalize_string(string): return re.sub('"', '', string) - config_sets = { - "BLLIST_GR_EXCLUDED_SLD", - "BLLIST_GR_EXCLUDED_NETS", - } + config_sets = set() config_arrays = { "RBL_ALL_URL", "RBL_IP_URL", @@ -90,12 +92,9 @@ class Config: "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", + "DL_IPSET_URL", + "DL_DMASK_URL", + "DL_STAT_URL", } try: for k, v in cfg_dict.items(): @@ -120,24 +119,66 @@ class Config: }) @classmethod - def _load_filter(cls, file_path, filter_patterns): + def _load_filter(cls, file_path, filter_patterns, is_array=False): try: with open(file_path, "rt") as file_handler: for line in file_handler: if line and re.match("[^#]", line): - filter_patterns.add(line.strip()) + if is_array: + filter_patterns.append(line.strip()) + else: + filter_patterns.add(line.strip()) except OSError: pass @classmethod def load_fqdn_filter(cls, file_path=None): if cls.BLLIST_FQDN_FILTER: - cls._load_filter(file_path or cls.BLLIST_FQDN_FILTER_FILE, cls.BLLIST_FQDN_FILTER_PATTERNS) + cls._load_filter(file_path or cls.BLLIST_FQDN_FILTER_FILE, + cls.BLLIST_FQDN_FILTER_PATTERNS) @classmethod def load_ip_filter(cls, file_path=None): if cls.BLLIST_IP_FILTER: - cls._load_filter(file_path or cls.BLLIST_IP_FILTER_FILE, cls.BLLIST_IP_FILTER_PATTERNS) + cls._load_filter(file_path or cls.BLLIST_IP_FILTER_FILE, + cls.BLLIST_IP_FILTER_PATTERNS) + + @classmethod + def load_gr_excluded_sld(cls, file_path=None): + if cls.BLLIST_GR_EXCLUDED_SLD_FILE: + cls._load_filter(file_path or cls.BLLIST_GR_EXCLUDED_SLD_FILE, + cls.BLLIST_GR_EXCLUDED_SLD_PATTERNS) + + @classmethod + def load_gr_excluded_sld_masks(cls, file_path=None): + if cls.BLLIST_GR_EXCLUDED_SLD_MASKS_FILE: + cls._load_filter(file_path or cls.BLLIST_GR_EXCLUDED_SLD_MASKS_FILE, + cls.BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS, is_array=True) + + @classmethod + def load_gr_excluded_nets(cls, file_path=None): + if cls.BLLIST_GR_EXCLUDED_NETS_FILE: + cls._load_filter(file_path or cls.BLLIST_GR_EXCLUDED_NETS_FILE, + cls.BLLIST_GR_EXCLUDED_NETS_PATTERNS) + + @classmethod + def load_fqdn_excluded(cls, file_path=None): + if cls.BLLIST_FQDN_EXCLUDED_ENABLE: + cls._load_filter(file_path or cls.BLLIST_FQDN_EXCLUDED_FILE, + cls.BLLIST_FQDN_EXCLUDED_ITEMS) + + @classmethod + def load_ip_excluded(cls, file_path=None): + if cls.BLLIST_IP_EXCLUDED_ENABLE: + cls._load_filter(file_path or cls.BLLIST_IP_EXCLUDED_FILE, + cls.BLLIST_IP_EXCLUDED_ITEMS) + + def check_sld_masks(self, sld): + if self.BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS: + for pattern in self.BLLIST_GR_EXCLUDED_SLD_MASKS_PATTERNS: + if re.fullmatch(pattern, sld): + return True + return False class ParserError(Exception): @@ -171,7 +212,7 @@ class BlackListParser(Config): self.output_fqdn_count = 0 self.ssl_unverified = False self.send_headers_dict = { - "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0", + "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0", } ### Proxies (ex.: self.proxies = {"http": "http://192.168.0.1:8080", "https": "http://192.168.0.1:8080"}) self.proxies = None @@ -271,12 +312,14 @@ class BlackListParser(Config): return regexp_obj.group(1) if regexp_obj else None def ip_value_processing(self, value): + if self.BLLIST_IP_EXCLUDED_ENABLE and value in self.BLLIST_IP_EXCLUDED_ITEMS: + return if self.BLLIST_IP_FILTER and self._check_filter( value, self.BLLIST_IP_FILTER_PATTERNS, self.BLLIST_IP_FILTER_TYPE): return if self.ip_pattern.fullmatch(value) and value not in self.ip_dict: subnet = self._get_subnet(value) - if subnet in self.BLLIST_GR_EXCLUDED_NETS or ( + if subnet in self.BLLIST_GR_EXCLUDED_NETS_PATTERNS or ( not self.BLLIST_IP_LIMIT or ( subnet not in self.ip_subnet_dict or self.ip_subnet_dict[subnet] < self.BLLIST_IP_LIMIT ) @@ -308,6 +351,8 @@ class BlackListParser(Config): value = value.strip("*.").lower() if self.BLLIST_STRIP_WWW: value = self.www_pattern.sub("", value) + if self.BLLIST_FQDN_EXCLUDED_ENABLE and value in self.BLLIST_FQDN_EXCLUDED_ITEMS: + return if not self.BLLIST_FQDN_FILTER or ( self.BLLIST_FQDN_FILTER and not self._check_filter( value, self.BLLIST_FQDN_FILTER_PATTERNS, self.BLLIST_FQDN_FILTER_TYPE) @@ -315,7 +360,7 @@ class BlackListParser(Config): if self.fqdn_pattern.fullmatch(value): value = self._convert_to_punycode(value) sld = self._get_sld(value) - if sld in self.BLLIST_GR_EXCLUDED_SLD or ( + if (sld in self.BLLIST_GR_EXCLUDED_SLD_PATTERNS or self.check_sld_masks(sld)) or ( not self.BLLIST_SD_LIMIT or ( sld not in self.sld_dict or self.sld_dict[sld] < self.BLLIST_SD_LIMIT ) @@ -462,19 +507,12 @@ class OptimizeConfig(Config): self.ip_count = 0 self.output_fqdn_count = 0 - def _check_sld_masks(self, sld): - if self.BLLIST_GR_EXCLUDED_MASKS: - for pattern in self.BLLIST_GR_EXCLUDED_MASKS: - if re.fullmatch(pattern, sld): - return True - return False - def _optimize_fqdn_dict(self): optimized_set = set() for fqdn, sld in self.fqdn_dict.items(): if sld and (fqdn == sld or sld not in self.fqdn_dict) and self.sld_dict.get(sld): - if (not self._check_sld_masks(sld) and ( - self.BLLIST_SD_LIMIT and sld not in self.BLLIST_GR_EXCLUDED_SLD + if (not self.check_sld_masks(sld) and ( + self.BLLIST_SD_LIMIT and sld not in self.BLLIST_GR_EXCLUDED_SLD_PATTERNS )) and (self.sld_dict[sld] >= self.BLLIST_SD_LIMIT): record_value = sld del(self.sld_dict[sld]) @@ -488,7 +526,7 @@ class OptimizeConfig(Config): optimized_set = set() for ip_addr, subnet in self.ip_dict.items(): if subnet in self.ip_subnet_dict: - if subnet not in self.BLLIST_GR_EXCLUDED_NETS and ( + if subnet not in self.BLLIST_GR_EXCLUDED_NETS_PATTERNS and ( self.BLLIST_IP_LIMIT and self.ip_subnet_dict[subnet] >= self.BLLIST_IP_LIMIT ): self.cidr_set.add(f"{subnet}0/24") @@ -722,12 +760,12 @@ class FzIp(FzFQDN): self.ip_value_processing(i.group(1)) -class RaFQDN(BlackListParser): +class Ra(BlackListParser): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.url_ipset = self.RA_FQDN_IPSET_URL - self.url_dnsmasq = self.RA_FQDN_DMASK_URL - self.url_stat = self.RA_FQDN_STAT_URL + self.url_ipset = self.DL_IPSET_URL + self.url_dnsmasq = self.DL_DMASK_URL + self.url_stat = self.DL_STAT_URL def download_config(self, url, cfg_file): self.url = url @@ -758,21 +796,18 @@ class RaFQDN(BlackListParser): return ret_value -class RaIp(RaFQDN): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.url_ipset = self.RA_IP_IPSET_URL - self.url_dnsmasq = self.RA_IP_DMASK_URL - self.url_stat = self.RA_IP_STAT_URL - - if __name__ == "__main__": Config.load_environ_config() Config.load_fqdn_filter() Config.load_ip_filter() + Config.load_gr_excluded_sld() + Config.load_gr_excluded_sld_masks() + Config.load_gr_excluded_nets() + Config.load_fqdn_excluded() + Config.load_ip_excluded() parsers_dict = { - "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]}, + "ip": {"rublacklist": [RblIp], "zapret-info": [ZiIp], "antifilter": [AfIp], "fz": [FzIp], "ruantiblock": [Ra]}, + "fqdn": {"rublacklist": [RblFQDN, RblDPI], "zapret-info": [ZiFQDN], "antifilter": [AfFQDN], "fz": [FzFQDN], "ruantiblock": [Ra]}, } try: parser_classes = parsers_dict[Config.BLLIST_MODE][Config.BLLIST_SOURCE] diff --git a/ruantiblock/Makefile b/ruantiblock/Makefile index b44e860..8db4dc4 100644 --- a/ruantiblock/Makefile +++ b/ruantiblock/Makefile @@ -5,8 +5,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock -PKG_VERSION:=1.5.0 -PKG_RELEASE:=2 +PKG_VERSION:=1.6.0 +PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot include $(INCLUDE_DIR)/package.mk @@ -30,6 +30,8 @@ define Package/$(PKG_NAME)/conffiles /etc/ruantiblock/ip_filter /etc/ruantiblock/user_entries /etc/ruantiblock/bypass_entries +/etc/ruantiblock/gr_excluded_nets +/etc/ruantiblock/gr_excluded_sld endef define Build/Configure @@ -51,10 +53,13 @@ define Package/$(PKG_NAME)/install $(INSTALL_DATA) ./files/etc/ruantiblock/ip_filter $(1)/etc/ruantiblock/ip_filter $(INSTALL_DATA) ./files/etc/ruantiblock/user_entries $(1)/etc/ruantiblock/user_entries $(INSTALL_DATA) ./files/etc/ruantiblock/bypass_entries $(1)/etc/ruantiblock/bypass_entries + $(INSTALL_DATA) ./files/etc/ruantiblock/gr_excluded_nets $(1)/etc/ruantiblock/gr_excluded_nets + $(INSTALL_DATA) ./files/etc/ruantiblock/gr_excluded_sld $(1)/etc/ruantiblock/gr_excluded_sld $(INSTALL_DIR) $(1)/usr/share/ruantiblock $(INSTALL_DATA) ./files/usr/share/ruantiblock/config_script $(1)/usr/share/ruantiblock/config_script $(INSTALL_DATA) ./files/usr/share/ruantiblock/info_output $(1)/usr/share/ruantiblock/info_output $(INSTALL_DATA) ./files/usr/share/ruantiblock/nft_functions $(1)/usr/share/ruantiblock/nft_functions + $(INSTALL_DATA) ./files/usr/share/ruantiblock/blacklist_sources $(1)/usr/share/ruantiblock/blacklist_sources $(INSTALL_DIR) $(1)/usr/libexec/ruantiblock $(INSTALL_BIN) ./files/usr/libexec/ruantiblock/ruab_route_check $(1)/usr/libexec/ruantiblock/ruab_route_check $(INSTALL_DIR) $(1)/usr/bin diff --git a/ruantiblock/files/etc/config/ruantiblock b/ruantiblock/files/etc/config/ruantiblock index c5def4d..86b59e7 100644 --- a/ruantiblock/files/etc/config/ruantiblock +++ b/ruantiblock/files/etc/config/ruantiblock @@ -25,21 +25,6 @@ config main 'config' option bllist_ip_filter '0' option bllist_ip_filter_type '0' option bllist_sd_limit '16' - list bllist_gr_excluded_sld 'livejournal.com' - list bllist_gr_excluded_sld 'facebook.com' - list bllist_gr_excluded_sld 'vk.com' - list bllist_gr_excluded_sld 'blog.jp' - list bllist_gr_excluded_sld 'msk.ru' - list bllist_gr_excluded_sld 'net.ru' - list bllist_gr_excluded_sld 'org.ru' - list bllist_gr_excluded_sld 'net.ua' - list bllist_gr_excluded_sld 'com.ua' - list bllist_gr_excluded_sld 'org.ua' - list bllist_gr_excluded_sld 'co.uk' - list bllist_gr_excluded_sld 'amazonaws.com' - list bllist_gr_excluded_sld 'spb.ru' - list bllist_gr_excluded_sld 'appspot.com' - list bllist_gr_excluded_sld 'googleusercontent.com' option bllist_fqdn_filter '1' option bllist_fqdn_filter_type '0' option bllist_enable_idn '0' diff --git a/ruantiblock/files/etc/ruantiblock/fqdn_filter b/ruantiblock/files/etc/ruantiblock/fqdn_filter index c9b700a..55a5c3a 100644 --- a/ruantiblock/files/etc/ruantiblock/fqdn_filter +++ b/ruantiblock/files/etc/ruantiblock/fqdn_filter @@ -5,8 +5,8 @@ paripartners marathon pm[-][0-9] fbmetrix -[ck]?a[sz]+ino? -[vw]ul[ck]an +[ck]?a[sz]+[iy]no? +[vw][ouy]l[ck]an slots? nar[ck] st[au]f @@ -15,7 +15,7 @@ al[ck]o bets? igr[ova]+ olimp -poker +p[o0]ker leon jackpot spin @@ -41,12 +41,45 @@ apteka drop rasta smok -semen +sem[ey]a?n seed steroid diplom medic -prostitutk +prostitut individualk dosug putan +intim +escort +feya +^1[-]?win +vegas +gamble +fishka +vavada +gold +avtomat +[.]win +pin[-]?up +stav[ko] +luck +xn[-][-]p1ai +prava +propiska +udostov +spra[vw] +cheki +[.]trade +invest +capital +profit +bank +broker +money +drag +birds +forex +kraken +zerkalo +#lord diff --git a/ruantiblock/files/etc/ruantiblock/gr_excluded_nets b/ruantiblock/files/etc/ruantiblock/gr_excluded_nets new file mode 100644 index 0000000..e69de29 diff --git a/ruantiblock/files/etc/ruantiblock/gr_excluded_sld b/ruantiblock/files/etc/ruantiblock/gr_excluded_sld new file mode 100644 index 0000000..3f7480f --- /dev/null +++ b/ruantiblock/files/etc/ruantiblock/gr_excluded_sld @@ -0,0 +1,15 @@ +livejournal.com +facebook.com +vk.com +blog.jp +msk.ru +net.ru +org.ru +net.ua +com.ua +org.ua +co.uk +amazonaws.com +spb.ru +appspot.com +googleusercontent.com diff --git a/ruantiblock/files/etc/ruantiblock/ruantiblock.conf b/ruantiblock/files/etc/ruantiblock/ruantiblock.conf index 4d6db4a..ce0b7d6 100644 --- a/ruantiblock/files/etc/ruantiblock/ruantiblock.conf +++ b/ruantiblock/files/etc/ruantiblock/ruantiblock.conf @@ -121,8 +121,8 @@ BLLIST_PRESET="" BLLIST_MIN_ENTRIES=3000 ### Лимит ip адресов. При достижении, в конфиг ipset будет добавлена вся подсеть /24 вместо множества ip-адресов пренадлежащих этой сети (0 - выкл) BLLIST_IP_LIMIT=0 -### Подсети класса C (/24). IP адреса из этих подсетей не группируются при оптимизации (записи д.б. в виде: 68.183.221. 149.154.162. и пр.). Прим.: "68.183.221. 149.154.162." -BLLIST_GR_EXCLUDED_NETS="" +### Файл с подсетями класса C (/24). IP адреса из этих подсетей не группируются при оптимизации (записи д.б. в виде: 68.183.221. 149.154.162. и пр. Одна запись на строку) +BLLIST_GR_EXCLUDED_NETS_FILE="/etc/ruantiblock/gr_excluded_nets" ### Группировать идущие подряд IP адреса в подсетях /24 в диапазоны CIDR BLLIST_SUMMARIZE_IP=0 ### Группировать идущие подряд подсети /24 в диапазоны CIDR @@ -133,18 +133,26 @@ BLLIST_IP_FILTER=0 BLLIST_IP_FILTER_TYPE=0 ### Файл с шаблонами ip для опции BLLIST_IP_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку) BLLIST_IP_FILTER_FILE="/etc/ruantiblock/ip_filter" +### Включение опции исключения IP/CIDR из блэклиста +BLLIST_IP_EXCLUDED_ENABLE=0 +### Файл с записями IP/CIDR для опции BLLIST_IP_EXCLUDED_ENABLE +BLLIST_IP_EXCLUDED_FILE="/etc/ruantiblock/ip_excluded" ### Лимит субдоменов для группировки. При достижении, в конфиг dnsmasq будет добавлен весь домен 2-го ур-ня вместо множества субдоменов (0 - выкл) BLLIST_SD_LIMIT=16 -### SLD не подлежащие группировке при оптимизации (через пробел) -BLLIST_GR_EXCLUDED_SLD="livejournal.com facebook.com vk.com blog.jp msk.ru net.ru org.ru net.ua com.ua org.ua co.uk amazonaws.com spb.ru appspot.com googleusercontent.com" -### Не группировать SLD попадающие под выражения (через пробел) -BLLIST_GR_EXCLUDED_MASKS="" +### Файл с SLD не подлежащими группировке при оптимизации (одна запись на строку) +BLLIST_GR_EXCLUDED_SLD_FILE="/etc/ruantiblock/gr_excluded_sld" +### Файл с масками SLD не подлежащими группировке при оптимизации (одна запись на строку) +BLLIST_GR_EXCLUDED_SLD_MASKS_FILE="/etc/ruantiblock/gr_excluded_sld_mask" ### Фильтрация записей блэклиста по шаблонам из файла ENTRIES_FILTER_FILE. Записи (FQDN) попадающие под шаблоны исключаются из кофига dnsmasq (0 - выкл, 1 - вкл) BLLIST_FQDN_FILTER=0 ### Тип фильтра FQDN (0 - все записи, кроме совпадающих с шаблонами; 1 - только записи, совпадающие с шаблонами) BLLIST_FQDN_FILTER_TYPE=0 ### Файл с шаблонами FQDN для опции BLLIST_FQDN_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку) BLLIST_FQDN_FILTER_FILE="/etc/ruantiblock/fqdn_filter" +### Включение опции исключения FQDN из блэклиста +BLLIST_FQDN_EXCLUDED_ENABLE=0 +### Файл с записями FQDN для опции BLLIST_FQDN_EXCLUDED_ENABLE +BLLIST_FQDN_EXCLUDED_FILE="/etc/ruantiblock/fqdn_excluded" ### Обрезка www[0-9]. в FQDN (0 - выкл, 1 - вкл) BLLIST_STRIP_WWW=1 ### Преобразование кириллических доменов в punycode (0 - выкл, 1 - вкл) @@ -153,24 +161,3 @@ BLLIST_ENABLE_IDN=0 BLLIST_ALT_NSLOOKUP=0 ### Альтернативный DNS-сервер BLLIST_ALT_DNS_ADDR="8.8.8.8" - -### Источники блэклиста -RBL_ALL_URL="https://reestr.rublacklist.net/api/v3/snapshot/" -RBL_IP_URL="https://reestr.rublacklist.net/api/v3/ips/" -RBL_DPI_URL="https://reestr.rublacklist.net/api/v3/dpi/" -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" -RA_FQDN_IPSET_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/ruantiblock.ip" -RA_FQDN_DMASK_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/ruantiblock.dnsmasq" -RA_FQDN_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/update_status" -RBL_ENCODING="" -ZI_ENCODING="CP1251" -AF_ENCODING="" -FZ_ENCODING="CP1251" -RA_ENCODING="" diff --git a/ruantiblock/files/usr/bin/ruantiblock b/ruantiblock/files/usr/bin/ruantiblock index 51176ab..899137d 100755 --- a/ruantiblock/files/usr/bin/ruantiblock +++ b/ruantiblock/files/usr/bin/ruantiblock @@ -138,8 +138,8 @@ export BLLIST_PRESET="" export BLLIST_MIN_ENTRIES=3000 ### Лимит IP адресов. При достижении, в конфиг ipset будет добавлена вся подсеть /24 вместо множества IP адресов пренадлежащих этой сети (0 - выкл) export BLLIST_IP_LIMIT=0 -### Подсети класса C (/24). IP адреса из этих подсетей не группируются при оптимизации (записи д.б. в виде: 68.183.221. 149.154.162. и пр.). Прим.: "68.183.221. 149.154.162." -export BLLIST_GR_EXCLUDED_NETS="" +### Файл с подсетями класса C (/24). IP адреса из этих подсетей не группируются при оптимизации (записи д.б. в виде: 68.183.221. 149.154.162. и пр. Одна запись на строку) +export BLLIST_GR_EXCLUDED_NETS_FILE="${CONFIG_DIR}/gr_excluded_nets" ### Группировать идущие подряд IP адреса в подсетях /24 в диапазоны CIDR export BLLIST_SUMMARIZE_IP=0 ### Группировать идущие подряд подсети /24 в диапазоны CIDR @@ -150,18 +150,26 @@ export BLLIST_IP_FILTER=0 export BLLIST_IP_FILTER_TYPE=0 ### Файл с шаблонами IP для опции BLLIST_IP_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку) export BLLIST_IP_FILTER_FILE="${CONFIG_DIR}/ip_filter" +### Включение опции исключения IP/CIDR из блэклиста +export BLLIST_IP_EXCLUDED_ENABLE=0 +### Файл с записями IP/CIDR для опции BLLIST_IP_EXCLUDED_ENABLE +export BLLIST_IP_EXCLUDED_FILE="${CONFIG_DIR}/ip_excluded" ### Лимит субдоменов для группировки. При достижении, в конфиг dnsmasq будет добавлен весь домен 2-го ур-ня вместо множества субдоменов (0 - выкл) export BLLIST_SD_LIMIT=0 -### SLD не подлежащие группировке при оптимизации (через пробел) -export BLLIST_GR_EXCLUDED_SLD="" -### Не группировать SLD попадающие под выражения (через пробел) -export BLLIST_GR_EXCLUDED_MASKS="" +### Файл с SLD не подлежащими группировке при оптимизации (одна запись на строку) +export BLLIST_GR_EXCLUDED_SLD_FILE="${CONFIG_DIR}/gr_excluded_sld" +### Файл с масками SLD не подлежащими группировке при оптимизации (одна запись на строку) +export BLLIST_GR_EXCLUDED_SLD_MASKS_FILE="${CONFIG_DIR}/gr_excluded_sld_mask" ### Фильтрация записей блэклиста по шаблонам из файла ENTRIES_FILTER_FILE. Записи (FQDN) попадающие под шаблоны исключаются из кофига dnsmasq (0 - выкл, 1 - вкл) export BLLIST_FQDN_FILTER=0 ### Тип фильтра FQDN (0 - все записи, кроме совпадающих с шаблонами; 1 - только записи, совпадающие с шаблонами) export BLLIST_FQDN_FILTER_TYPE=0 ### Файл с шаблонами FQDN для опции BLLIST_FQDN_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку) export BLLIST_FQDN_FILTER_FILE="${CONFIG_DIR}/fqdn_filter" +### Включение опции исключения FQDN из блэклиста +export BLLIST_FQDN_EXCLUDED_ENABLE=0 +### Файл с записями FQDN для опции BLLIST_FQDN_EXCLUDED_ENABLE +export BLLIST_FQDN_EXCLUDED_FILE="${CONFIG_DIR}/fqdn_excluded" ### Обрезка www[0-9]. в FQDN (0 - выкл, 1 - вкл) export BLLIST_STRIP_WWW=1 ### Преобразование кириллических доменов в punycode (0 - выкл, 1 - вкл) @@ -171,27 +179,6 @@ export BLLIST_ALT_NSLOOKUP=0 ### Альтернативный DNS-сервер export BLLIST_ALT_DNS_ADDR="8.8.8.8" -### Источники блэклиста -export RBL_ALL_URL="https://reestr.rublacklist.net/api/v3/snapshot/" -export RBL_IP_URL="https://reestr.rublacklist.net/api/v3/ips/" -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 ZI_ALL_URL="https://app.assembla.com/spaces/z-i/git/source/master/dump.csv?_format=raw" -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" -export RA_FQDN_IPSET_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/ruantiblock.ip" -export RA_FQDN_DMASK_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/ruantiblock.dnsmasq" -export RA_FQDN_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/update_status" -export RBL_ENCODING="" -export ZI_ENCODING="CP1251" -export AF_ENCODING="" -export FZ_ENCODING="CP1251" -export RA_ENCODING="" - ############################ Configuration ############################# ### External config @@ -200,6 +187,7 @@ export RA_ENCODING="" CONFIG_SCRIPT="${SCRIPTS_DIR}/config_script" START_SCRIPT="${SCRIPTS_DIR}/start_script" STOP_SCRIPT="${SCRIPTS_DIR}/stop_script" +BLLIST_SOURCES_SCRIPT="${SCRIPTS_DIR}/blacklist_sources" ### Config script [ -f "$CONFIG_SCRIPT" ] && . "$CONFIG_SCRIPT" @@ -271,6 +259,9 @@ export IP_DATA_FILE_TMP="${IP_DATA_FILE}.tmp" export DNSMASQ_DATA_FILE_TMP="${DNSMASQ_DATA_FILE}.tmp" export UPDATE_STATUS_FILE_TMP="${UPDATE_STATUS_FILE}.tmp" export USER_ENTRIES_STATUS_FILE_TMP="${USER_ENTRIES_STATUS_FILE}.tmp" +DL_IPSET_URL="" +DL_DMASK_URL="" +DL_STAT_URL="" ######################### External functions ########################### @@ -330,7 +321,7 @@ Download() { fi } -DownloadRuabBlacklist() { +DownloadNativeBlacklist() { local _ip_data_file _dnsmasq_data_file _update_status_file _return_code=0 if [ "$ENABLE_TMP_DOWNLOADS" = "1" ]; then _ip_data_file="$IP_DATA_FILE_TMP" @@ -342,45 +333,26 @@ DownloadRuabBlacklist() { _dnsmasq_data_file="$DNSMASQ_DATA_FILE" _update_status_file="$UPDATE_STATUS_FILE" fi - case "$1" in - "ip") - Download "$_ip_data_file" "$RA_IP_IPSET_URL" + if [ -n "$DL_IPSET_URL" -a -n "$DL_DMASK_URL" -a -n "$DL_STAT_URL" ]; then + Download "$_ip_data_file" "$DL_IPSET_URL" + if [ $? -ne 0 ]; then + _return_code=1 + else + Download "$_dnsmasq_data_file" "$DL_DMASK_URL" if [ $? -ne 0 ]; then _return_code=1 else - Download "$_dnsmasq_data_file" "$RA_IP_DMASK_URL" + Download "$_update_status_file" "$DL_STAT_URL" if [ $? -ne 0 ]; then _return_code=1 - else - Download "$_update_status_file" "$RA_IP_STAT_URL" - if [ $? -ne 0 ]; then - _return_code=1 - fi fi fi - ;; - "fqdn") - Download "$_dnsmasq_data_file" "$RA_FQDN_DMASK_URL" - if [ $? -ne 0 ]; then - _return_code=1 - else - Download "$_ip_data_file" "$RA_FQDN_IPSET_URL" - if [ $? -ne 0 ]; then - _return_code=1 - else - Download "$_update_status_file" "$RA_FQDN_STAT_URL" - if [ $? -ne 0 ]; then - _return_code=1 - fi - fi - fi - ;; - *) - echo " Blacklist configuration error (${1})" >&2 - MakeLogRecord "err" "Blacklist configuration error (${1})" - exit 1 - ;; - esac + fi + else + echo " Native blacklist configuration error (${1})" >&2 + MakeLogRecord "err" "Native blacklist configuration error (${1})" + exit 1 + fi if [ "$ENABLE_TMP_DOWNLOADS" = "1" ]; then if [ $_return_code -eq 0 ]; then mv -f "$_ip_data_file" "$IP_DATA_FILE" @@ -961,53 +933,8 @@ StatusOutput() { ############################ Main section ############################## -### Blacklist source and mode -case "$BLLIST_PRESET" in - zapret-info-ip) - ### Источник для обновления списка блокировок (zapret-info, rublacklist, antifilter, fz, ruantiblock) - export BLLIST_SOURCE="zapret-info" - ### Режим обхода блокировок: ip, fqdn - export BLLIST_MODE="ip" - ;; - zapret-info-fqdn) - export BLLIST_SOURCE="zapret-info" - export BLLIST_MODE="fqdn" - ;; - rublacklist-ip) - export BLLIST_SOURCE="rublacklist" - export BLLIST_MODE="ip" - ;; - rublacklist-fqdn) - export BLLIST_SOURCE="rublacklist" - export BLLIST_MODE="fqdn" - ;; - antifilter-ip) - 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" - BLLIST_MODULE="DownloadRuabBlacklist $BLLIST_MODE" - ;; - ruantiblock-fqdn) - export BLLIST_SOURCE="ruantiblock" - export BLLIST_MODE="fqdn" - BLLIST_MODULE="DownloadRuabBlacklist $BLLIST_MODE" - ;; - *) - export BLLIST_SOURCE="" - export BLLIST_MODE="" - ;; -esac +### Blacklist sources +. "$BLLIST_SOURCES_SCRIPT" return_code=1 case "$1" in diff --git a/ruantiblock/files/usr/share/ruantiblock/blacklist_sources b/ruantiblock/files/usr/share/ruantiblock/blacklist_sources new file mode 100644 index 0000000..603cf95 --- /dev/null +++ b/ruantiblock/files/usr/share/ruantiblock/blacklist_sources @@ -0,0 +1,73 @@ +### Blacklist sources +## rublacklist +export RBL_ALL_URL="https://reestr.rublacklist.net/api/v3/snapshot/" +export RBL_IP_URL="https://reestr.rublacklist.net/api/v3/ips/" +export RBL_DPI_URL="https://reestr.rublacklist.net/api/v3/dpi/" +export RBL_ENCODING="" +## zapret-info +export ZI_ALL_URL="https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv" +#export ZI_ALL_URL="https://app.assembla.com/spaces/z-i/git/source/master/dump.csv?_format=raw" +export ZI_ENCODING="CP1251" +## antifilter +export AF_IP_URL="https://antifilter.download/list/allyouneed.lst" +export AF_FQDN_URL="https://antifilter.download/list/domains.lst" +export AF_ENCODING="" +## fz +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 FZ_ENCODING="CP1251" + +### Blacklist presets +case "$BLLIST_PRESET" in + zapret-info-ip) + ### Источник для обновления списка блокировок (zapret-info, rublacklist, antifilter, fz, ruantiblock) + export BLLIST_SOURCE="zapret-info" + ### Режим обхода блокировок: ip, fqdn + export BLLIST_MODE="ip" + ;; + zapret-info-fqdn) + export BLLIST_SOURCE="zapret-info" + export BLLIST_MODE="fqdn" + ;; + rublacklist-ip) + export BLLIST_SOURCE="rublacklist" + export BLLIST_MODE="ip" + ;; + rublacklist-fqdn) + export BLLIST_SOURCE="rublacklist" + export BLLIST_MODE="fqdn" + ;; + antifilter-ip) + 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" + BLLIST_MODULE="DownloadNativeBlacklist" + # github + DL_IPSET_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/ruantiblock.ip" + DL_DMASK_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/ruantiblock.dnsmasq" + DL_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/ip/update_status" + ;; + ruantiblock-fqdn) + export BLLIST_SOURCE="ruantiblock" + export BLLIST_MODE="fqdn" + BLLIST_MODULE="DownloadNativeBlacklist" + # github + DL_IPSET_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/ruantiblock.ip" + DL_DMASK_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/ruantiblock.dnsmasq" + DL_STAT_URL="https://raw.githubusercontent.com/gSpotx2f/ruantiblock_blacklist/master/blacklist-1.1/fqdn/update_status" + ;; + *) + export BLLIST_SOURCE="" + export BLLIST_MODE="" + ;; +esac diff --git a/ruantiblock/files/usr/share/ruantiblock/config_script b/ruantiblock/files/usr/share/ruantiblock/config_script index c023ad4..309d15c 100644 --- a/ruantiblock/files/usr/share/ruantiblock/config_script +++ b/ruantiblock/files/usr/share/ruantiblock/config_script @@ -1,6 +1,5 @@ - UCI_SECTION="ruantiblock.config" -UCI_VARS="proxy_mode proxy_local_clients nftset_clear_sets allowed_hosts_mode allowed_hosts_list bypass_mode bypass_entries_dns enable_fproxy fproxy_list enable_bllist_proxy if_vpn vpn_gw_ip vpn_route_check tor_trans_port onion_dns_addr t_proxy_port_tcp t_proxy_port_udp t_proxy_allow_udp add_user_entries user_entries_dns user_entries_remote enable_logging bllist_min_entries bllist_module bllist_preset bllist_ip_limit bllist_gr_excluded_nets bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_ip_filter_type bllist_sd_limit bllist_gr_excluded_sld bllist_fqdn_filter bllist_fqdn_filter_type bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr update_at_startup enable_tmp_downloads" +UCI_VARS="proxy_mode proxy_local_clients nftset_clear_sets allowed_hosts_mode allowed_hosts_list bypass_mode bypass_entries_dns enable_fproxy fproxy_list enable_bllist_proxy if_vpn vpn_gw_ip vpn_route_check tor_trans_port onion_dns_addr t_proxy_port_tcp t_proxy_port_udp t_proxy_allow_udp add_user_entries user_entries_dns user_entries_remote enable_logging bllist_min_entries bllist_module bllist_preset bllist_ip_limit bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_ip_filter_type bllist_sd_limit bllist_fqdn_filter bllist_fqdn_filter_type bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr update_at_startup enable_tmp_downloads" UCI_CMD=`which uci` if [ $? -ne 0 ]; then echo " Error! UCI doesn't exists" >&2