v0.9.7. BLLIST_IP_FILTER_TYPE, BLLIST_FQDN_FILTER_TYPE

This commit is contained in:
gSpot
2023-01-14 15:53:19 +03:00
parent dec209e12c
commit 76a5240891
15 changed files with 111 additions and 39 deletions
+3 -3
View File
@@ -9,9 +9,9 @@ LUA_MODULE=0
LUCI_APP=1
OWRT_VERSION="current"
RUAB_VERSION="0.9.6-0"
RUAB_MOD_LUA_VERSION="0.9.6-0"
RUAB_LUCI_APP_VERSION="0.9.6-0"
RUAB_VERSION="0.9.7-0"
RUAB_MOD_LUA_VERSION="0.9.7-0"
RUAB_LUCI_APP_VERSION="0.9.7-0"
BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master"
PKG_DIR="/tmp"
+1 -1
View File
@@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk
PKG_VERSION:=0.9.6-0
PKG_VERSION:=0.9.7-0
LUCI_TITLE:=LuCI support for ruantiblock
LUCI_DEPENDS:=+ruantiblock
LUCI_PKGARCH:=all
@@ -263,12 +263,25 @@ return view.extend({
s.tab('parser_settings_tab', _('Module settings'));
// BLLIST_MIN_ENTRIES
o = s.taboption('parser_settings_tab', form.Value, 'bllist_min_entries',
_("Minimum allowed number of entries"));
o.description = _('If less than the specified number of entries are received from the source, then the lists are not updated');
o.rmempty = false;
o.datatype = 'uinteger';
// BLLIST_FQDN_FILTER
o = s.taboption('parser_settings_tab', form.Flag, 'bllist_fqdn_filter',
_("Enable FQDN filter"));
o.description = _('Exclude domains from blacklist by FQDN filter patterns');
o.description = _('Pick domains from blacklist by FQDN filter patterns');
o.rmempty = false;
// BLLIST_FQDN_FILTER_TYPE
o = s.taboption('parser_settings_tab', form.ListValue, 'bllist_fqdn_filter_type',
_('FQDN filter type'));
o.value('0', _('All entries except matching expressions'));
o.value('1', _('Only entries matching expressions'));
// BLLIST_FQDN_FILTER_FILE edit dialog
o = s.taboption('parser_settings_tab', form.Button, '_fqdn_filter_btn',
_("FQDN filter"));
@@ -309,9 +322,15 @@ return view.extend({
// BLLIST_IP_FILTER
o = s.taboption('parser_settings_tab', form.Flag, 'bllist_ip_filter',
_("Enable IP filter"));
o.description = _('Exclude IP addresses from blacklist by IP filter patterns');
o.description = _('Pick IP addresses from blacklist by IP filter patterns');
o.rmempty = false;
// BLLIST_IP_FILTER_TYPE
o = s.taboption('parser_settings_tab', form.ListValue, 'bllist_ip_filter_type',
_('IP filter type'));
o.value('0', _('All entries except matching expressions'));
o.value('1', _('Only entries matching expressions'));
// BLLIST_IP_FILTER_FILE edit dialog
o = s.taboption('parser_settings_tab', form.Button, '_ip_filter_btn',
_("IP filter"));
+26 -8
View File
@@ -25,6 +25,9 @@ msgstr "Тревога"
msgid "All"
msgstr "Все"
msgid "All entries except matching expressions"
msgstr "Все записи, кроме соответствующих выражениям"
msgid "All hosts except listed"
msgstr "Все хосты, кроме перечисленных"
@@ -114,10 +117,10 @@ msgid "Enable"
msgstr "Включить"
msgid "Enable FQDN filter"
msgstr "Включить фильтр FQDN"
msgstr "Включить FQDN фильтр"
msgid "Enable IP filter"
msgstr "Включить фильтр IP"
msgstr "Включить IP фильтр"
msgid "Enabled"
msgstr "Включено"
@@ -128,18 +131,15 @@ msgstr "Записи"
msgid "Error"
msgstr "Ошибка"
msgid "Exclude IP addresses from blacklist by IP filter patterns"
msgstr "Исключение IP адресов из блэклиста по шаблонам фильтра IP"
msgid "Exclude domains from blacklist by FQDN filter patterns"
msgstr "Исключение доменов из блэклиста по шаблонам фильтра FQDN"
msgid "Expecting:"
msgstr "Ожидается:"
msgid "FQDN filter"
msgstr "Фильтр FQDN"
msgid "FQDN filter type"
msgstr "Тип FQDN фильтра"
msgid "Facility"
msgstr "Категория"
@@ -158,6 +158,9 @@ msgstr "Фильтр хостов"
msgid "Hour"
msgstr "Час"
msgid "If less than the specified number of entries are received from the source, then the lists are not updated"
msgstr "Если от источника получено меньше указанного количества записей, то списки не обновляются"
msgid "IP address"
msgstr "IP-адрес"
@@ -167,6 +170,9 @@ msgstr "IP-адреса хостов"
msgid "IP filter"
msgstr "Фильтр IP"
msgid "IP filter type"
msgstr "Тип IP фильтра"
msgid "IP limit"
msgstr "Лимит IP адресов"
@@ -224,6 +230,9 @@ msgstr "Сообщение"
msgid "Message filter"
msgstr "Фильтр сообщений"
msgid "Minimum allowed number of entries"
msgstr "Минимально возможное количество записей"
msgid "Minute"
msgstr "Минута"
@@ -264,6 +273,9 @@ msgstr ""
msgid "One of the following:"
msgstr "Одно из следующих значений:"
msgid "Only entries matching expressions"
msgstr "Только записи, соответствующие выражениям"
msgid "Only listed hosts"
msgstr "Только перечисленные хосты"
@@ -291,6 +303,12 @@ msgstr ""
"отдельной строке, символ <code>#</code> в первой позиции строки - "
"комментирует строку.<br />Примеры:"
msgid "Pick IP addresses from blacklist by IP filter patterns"
msgstr "Отбор IP адресов из блэклиста по шаблонам фильтра IP"
msgid "Pick domains from blacklist by FQDN filter patterns"
msgstr "Отбор доменов из блэклиста по шаблонам фильтра FQDN"
msgid "Proxy mode"
msgstr "Режим прокси"
@@ -13,6 +13,9 @@ msgstr ""
msgid "All"
msgstr ""
msgid "All entries except matching expressions"
msgstr ""
msgid "All hosts except listed"
msgstr ""
@@ -111,18 +114,15 @@ msgstr ""
msgid "Error"
msgstr ""
msgid "Exclude IP addresses from blacklist by IP filter patterns"
msgstr ""
msgid "Exclude domains from blacklist by FQDN filter patterns"
msgstr ""
msgid "Expecting:"
msgstr ""
msgid "FQDN filter"
msgstr ""
msgid "FQDN filter type"
msgstr ""
msgid "Facility"
msgstr ""
@@ -141,6 +141,9 @@ msgstr ""
msgid "Hour"
msgstr ""
msgid "If less than the specified number of entries are received from the source, then the lists are not updated"
msgstr ""
msgid "IP address"
msgstr ""
@@ -150,6 +153,9 @@ msgstr ""
msgid "IP filter"
msgstr ""
msgid "IP filter type"
msgstr ""
msgid "IP limit"
msgstr ""
@@ -204,6 +210,9 @@ msgstr ""
msgid "Message filter"
msgstr ""
msgid "Minimum allowed number of entries"
msgstr ""
msgid "Minute"
msgstr ""
@@ -241,6 +250,9 @@ msgstr ""
msgid "One of the following:"
msgstr ""
msgid "Only entries matching expressions"
msgstr ""
msgid "Only listed hosts"
msgstr ""
@@ -262,6 +274,12 @@ msgid ""
"on the line.<br />Examples:"
msgstr ""
msgid "Pick IP addresses from blacklist by IP filter patterns"
msgstr ""
msgid "Pick domains from blacklist by FQDN filter patterns"
msgstr ""
msgid "Proxy mode"
msgstr ""
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock-mod-lua
PKG_VERSION:=0.9.6
PKG_VERSION:=0.9.7
PKG_RELEASE:=0
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
@@ -43,8 +43,10 @@ local Config = Class(nil, {
["BLLIST_GR_EXCLUDED_SLD"] = true,
["BLLIST_GR_EXCLUDED_MASKS"] = true,
["BLLIST_FQDN_FILTER"] = true,
["BLLIST_FQDN_FILTER_TYPE"] = true,
["BLLIST_FQDN_FILTER_FILE"] = true,
["BLLIST_IP_FILTER"] = true,
["BLLIST_IP_FILTER_TYPE"] = true,
["BLLIST_IP_FILTER_FILE"] = true,
["BLLIST_SD_LIMIT"] = true,
["BLLIST_IP_LIMIT"] = true,
@@ -130,6 +132,8 @@ end
Config.BLLIST_ALT_NSLOOKUP = remap_bool(Config.BLLIST_ALT_NSLOOKUP)
Config.BLLIST_ENABLE_IDN = remap_bool(Config.BLLIST_ENABLE_IDN)
Config.BLLIST_FQDN_FILTER_TYPE = remap_bool(Config.BLLIST_FQDN_FILTER_TYPE)
Config.BLLIST_IP_FILTER_TYPE = remap_bool(Config.BLLIST_IP_FILTER_TYPE)
Config.BLLIST_STRIP_WWW = remap_bool(Config.BLLIST_STRIP_WWW)
Config.BLLIST_FQDN_FILTER = remap_bool(Config.BLLIST_FQDN_FILTER)
Config.BLLIST_IP_FILTER = remap_bool(Config.BLLIST_IP_FILTER)
@@ -257,15 +261,15 @@ function BlackListParser:convert_to_punycode(input)
return input and (idn.encode(input))
end
function BlackListParser:check_filter(str, filter_patterns)
function BlackListParser:check_filter(str, filter_patterns, reverse)
if filter_patterns and str then
for pattern in pairs(filter_patterns) do
if str:match(pattern) then
return true
return not reverse
end
end
end
return false
return reverse
end
function BlackListParser:get_subnet(ip)
@@ -275,7 +279,7 @@ end
function BlackListParser:fill_ip_tables(val)
if val and val ~= "" then
for ip_entry in val: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)) then
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
@@ -301,7 +305,7 @@ function BlackListParser:fill_domain_tables(val)
if self.BLLIST_STRIP_WWW then
val = val:gsub("^www[0-9]?%.", "")
end
if not self.BLLIST_FQDN_FILTER or (self.BLLIST_FQDN_FILTER and not self:check_filter(val, self.BLLIST_FQDN_FILTER_PATTERNS)) then
if not self.BLLIST_FQDN_FILTER or (self.BLLIST_FQDN_FILTER and not self:check_filter(val, self.BLLIST_FQDN_FILTER_PATTERNS, self.BLLIST_FQDN_FILTER_TYPE)) then
if val:match("^" .. self.fqdn_pattern .. "+$") then
elseif self.BLLIST_ENABLE_IDN and val:match("^[^\\/&%?]-[^\\/&%?%.]+%.[^\\/&%?%.]+%.?$") then
val = self:convert_to_punycode(val)
@@ -461,7 +465,7 @@ end
function BlackListParser:run()
local return_code = 0
if self:get_http_data(self.url) then
if (self.fqdn_count + self.ip_count + self.cidr_count) > self.BLLIST_MIN_ENTRIES then
if (self.fqdn_count + self.ip_count + self.cidr_count) >= self.BLLIST_MIN_ENTRIES then
self:optimize_fqdn_table()
self:optimize_ip_table()
if self.BLLIST_SUMMARIZE_IP then
@@ -576,7 +580,6 @@ local AfIp = Class(Af, {
url = Config.AF_IP_URL,
ip_string_pattern = "(.-)\n",
sink = ip_sink,
BLLIST_MIN_ENTRIES = 100,
})
-- ruantiblock
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock-mod-py
PKG_VERSION:=0.9.6
PKG_VERSION:=0.9.7
PKG_RELEASE:=0
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
@@ -27,8 +27,10 @@ class Config:
"BLLIST_GR_EXCLUDED_SLD",
"BLLIST_GR_EXCLUDED_MASKS",
"BLLIST_FQDN_FILTER",
"BLLIST_FQDN_FILTER_TYPE",
"BLLIST_FQDN_FILTER_FILE",
"BLLIST_IP_FILTER",
"BLLIST_IP_FILTER_TYPE",
"BLLIST_IP_FILTER_FILE",
"BLLIST_SD_LIMIT",
"BLLIST_IP_LIMIT",
@@ -234,12 +236,12 @@ class BlackListParser(Config):
pass
@staticmethod
def _check_filter(string, filter_patterns):
def _check_filter(string, filter_patterns, reverse=False):
if filter_patterns and string:
for pattern in filter_patterns:
if pattern and pattern.search(string):
return True
return False
return not reverse
return reverse
def _get_subnet(self, ip_addr):
regexp_obj = self.ip_pattern.fullmatch(ip_addr)
@@ -247,7 +249,8 @@ class BlackListParser(Config):
def ip_field_processing(self, string):
for i in string.split(self.ips_separator):
if self.BLLIST_IP_FILTER and self._check_filter(i, self.BLLIST_IP_FILTER_PATTERNS):
if self.BLLIST_IP_FILTER and self._check_filter(
i, self.BLLIST_IP_FILTER_PATTERNS, self.BLLIST_IP_FILTER_TYPE):
continue
if self.ip_pattern.fullmatch(i) and i not in self.ip_set:
subnet = self._get_subnet(i)
@@ -284,7 +287,8 @@ class BlackListParser(Config):
if self.BLLIST_STRIP_WWW:
string = self.www_pattern.sub("", string)
if not self.BLLIST_FQDN_FILTER or (
self.BLLIST_FQDN_FILTER and not self._check_filter(string, self.BLLIST_FQDN_FILTER_PATTERNS)
self.BLLIST_FQDN_FILTER and not self._check_filter(
string, self.BLLIST_FQDN_FILTER_PATTERNS, self.BLLIST_FQDN_FILTER_TYPE)
):
if self.fqdn_pattern.fullmatch(string):
string = self._convert_to_punycode(string)
@@ -447,7 +451,6 @@ class AfIp(BlackListParser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.url = self.AF_IP_URL
self.BLLIST_MIN_ENTRIES = 100
def parser_func(self):
for entry in self._split_entries():
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock
PKG_VERSION:=0.9.6
PKG_VERSION:=0.9.7
PKG_RELEASE:=0
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
+3
View File
@@ -13,10 +13,12 @@ config main 'config'
option t_proxy_allow_udp '0'
option add_user_entries '0'
option enable_logging '1'
option bllist_min_entries '3000'
option bllist_ip_limit '0'
option bllist_summarize_ip '1'
option bllist_summarize_cidr '1'
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'
@@ -31,6 +33,7 @@ config main 'config'
list bllist_gr_excluded_sld 'co.uk'
list bllist_gr_excluded_sld 'amazonaws.com'
option bllist_fqdn_filter '1'
option bllist_fqdn_filter_type '0'
option bllist_enable_idn '0'
option bllist_alt_nslookup '0'
option bllist_alt_dns_addr '8.8.8.8'
@@ -69,7 +69,7 @@ BLLIST_MODULE=""
### Режим обхода блокировок: ruantiblock-ip, ruantiblock-fqdn, zapret-info-ip, zapret-info-fqdn, rublacklist-ip, rublacklist-fqdn, antifilter-ip
BLLIST_PRESET=""
### В случае если из источника получено менее указанного кол-ва записей, то обновления списков не происходит
BLLIST_MIN_ENTRIES=30000
BLLIST_MIN_ENTRIES=3000
### Лимит ip адресов. При достижении, в конфиг ipset будет добавлена вся подсеть /24 вместо множества ip-адресов пренадлежащих этой сети (0 - off)
BLLIST_IP_LIMIT=0
### Подсети класса C (/24). IP адреса из этих подсетей не группируются при оптимизации (записи д.б. в виде: 68.183.221. 149.154.162. и пр.). Прим.: "68.183.221. 149.154.162."
@@ -80,6 +80,8 @@ BLLIST_SUMMARIZE_IP=0
BLLIST_SUMMARIZE_CIDR=0
### Фильтрация записей блэклиста по шаблонам из файла BLLIST_IP_FILTER_FILE. Записи (IP, CIDR) попадающие под шаблоны исключаются из кофига ipset (0 - off, 1 - on)
BLLIST_IP_FILTER=0
### Тип фильтра IP (0 - все записи, кроме совпадающих с выражениями; 1 - только записи, совпадающие с выражениями)
BLLIST_IP_FILTER_TYPE=0
### Файл с шаблонами ip для опции BLLIST_IP_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку)
BLLIST_IP_FILTER_FILE="/etc/ruantiblock/ip_filter"
### Лимит субдоменов для группировки. При достижении, в конфиг dnsmasq будет добавлен весь домен 2-го ур-ня вместо множества субдоменов (0 - off)
@@ -90,6 +92,8 @@ BLLIST_GR_EXCLUDED_SLD="livejournal.com facebook.com vk.com blog.jp msk.ru net.r
BLLIST_GR_EXCLUDED_MASKS=""
### Фильтрация записей блэклиста по шаблонам из файла ENTRIES_FILTER_FILE. Записи (FQDN) попадающие под шаблоны исключаются из кофига dnsmasq (0 - off, 1 - on)
export BLLIST_FQDN_FILTER=0
### Тип фильтра FQDN (0 - все записи, кроме совпадающих с выражениями; 1 - только записи, совпадающие с выражениями)
BLLIST_FQDN_FILTER_TYPE=0
### Файл с шаблонами FQDN для опции BLLIST_FQDN_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку)
export BLLIST_FQDN_FILTER_FILE="/etc/ruantiblock/fqdn_filter"
### Обрезка www[0-9]. в FQDN (0 - off, 1 - on)
@@ -1,6 +1,6 @@
AWK_CMD="awk"
UCI_SECTION="ruantiblock.config"
UCI_VARS="proxy_mode proxy_local_clients ipset_clear_sets allowed_hosts_mode allowed_hosts_list if_vpn tor_trans_port tor_allow_udp onion_dns_addr t_proxy_port_tcp t_proxy_port_udp t_proxy_allow_udp add_user_entries user_entries_dns enable_logging bllist_module bllist_preset bllist_ip_limit bllist_gr_excluded_nets bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_sd_limit bllist_gr_excluded_sld bllist_fqdn_filter bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr update_at_startup"
UCI_VARS="proxy_mode proxy_local_clients ipset_clear_sets allowed_hosts_mode allowed_hosts_list if_vpn tor_trans_port tor_allow_udp onion_dns_addr t_proxy_port_tcp t_proxy_port_udp t_proxy_allow_udp add_user_entries user_entries_dns 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"
eval `uci show "$UCI_SECTION" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" '
BEGIN {
+5 -1
View File
@@ -83,7 +83,7 @@ export BLLIST_MODULE=""
### Режим обхода блокировок: ruantiblock-fqdn, ruantiblock-ip, zapret-info-fqdn, zapret-info-ip, rublacklist-fqdn, rublacklist-ip, antifilter-ip
export BLLIST_PRESET=""
### В случае если из источника получено менее указанного кол-ва записей, то обновления списков не происходит
export BLLIST_MIN_ENTRIES=30000
export BLLIST_MIN_ENTRIES=3000
### Лимит IP адресов. При достижении, в конфиг ipset будет добавлена вся подсеть /24 вместо множества IP адресов пренадлежащих этой сети (0 - off)
export BLLIST_IP_LIMIT=0
### Подсети класса C (/24). IP адреса из этих подсетей не группируются при оптимизации (записи д.б. в виде: 68.183.221. 149.154.162. и пр.). Прим.: "68.183.221. 149.154.162."
@@ -94,6 +94,8 @@ export BLLIST_SUMMARIZE_IP=0
export BLLIST_SUMMARIZE_CIDR=0
### Фильтрация записей блэклиста по шаблонам из файла BLLIST_IP_FILTER_FILE. Записи (IP, CIDR) попадающие под шаблоны исключаются из кофига ipset (0 - off, 1 - on)
export BLLIST_IP_FILTER=0
### Тип фильтра IP (0 - все записи, кроме совпадающих с выражениями; 1 - только записи, совпадающие с выражениями)
export BLLIST_IP_FILTER_TYPE=0
### Файл с шаблонами IP для опции BLLIST_IP_FILTER (каждый шаблон в отдельной строке. # в первом символе строки - комментирует строку)
export BLLIST_IP_FILTER_FILE="${CONFIG_DIR}/ip_filter"
### Лимит субдоменов для группировки. При достижении, в конфиг dnsmasq будет добавлен весь домен 2-го ур-ня вместо множества субдоменов (0 - off)
@@ -104,6 +106,8 @@ export BLLIST_GR_EXCLUDED_SLD="livejournal.com facebook.com vk.com blog.jp msk.r
export BLLIST_GR_EXCLUDED_MASKS=""
### Фильтрация записей блэклиста по шаблонам из файла ENTRIES_FILTER_FILE. Записи (FQDN) попадающие под шаблоны исключаются из кофига dnsmasq (0 - off, 1 - on)
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"
### Обрезка www[0-9]. в FQDN (0 - off, 1 - on)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 193 KiB