mirror of
https://github.com/openwrt/packages.git
synced 2026-11-29 03:23:20 +04:00
antiblock: update to 3.0.0
Update AntiBlock to 3.0.0 with a major core rewrite and improved DNS-based routing. - Rework DNS capture and processing using libpcap and poll. - Add automatic L2/L3 routing through network interfaces. - Support moving IPv4 destinations between routing rules. - Improve route state management, TTL handling, and cleanup. - Add order-independent CNAME propagation and HTTPS AliasMode. - Harden DNS parsing and HTTP source handling. - Improve procd integration, UCI validation, and service logging. - Preserve backward compatibility with legacy gateway settings. - Update the package TITLE to "DNS-based dynamic IPv4 routing". - Normalize the maintainer name to Karen Khachatryan. - Change the license from GPLv3 to AGPLv3. Regression tests for the OpenWrt service configuration are maintained in a separate repository, not in this package commit: https://github.com/karen07/antiblock-openwrt-package Testing: - 25 OpenWrt runtime tests passed. - 61 upstream integration tests passed across GCC Release, Clang Release, and Clang ASan/UBSan. Signed-off-by: Karen Khachatryan <karen0734@gmail.com>
This commit is contained in:
1 parent
4e019582d2
commit
6b04470bfa
4 files changed
+100
-52
No files matched your search
@@ -1,17 +1,17 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=antiblock
|
||||
PKG_VERSION:=2.1.2
|
||||
PKG_RELEASE:=2
|
||||
PKG_VERSION:=3.0.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/karen07/antiblock
|
||||
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
|
||||
PKG_MIRROR_HASH:=18b04ab99744160e91d032edc55bb171a9717cdd200a494d7af9fa3c9f0fdb48
|
||||
PKG_MIRROR_HASH:=8c01fb20f17b1624dd34af2ed538e49d069af173f0108132cc744e77c659a811
|
||||
|
||||
PKG_MAINTAINER:=Khachatryan Karen <karen0734@gmail.com>
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
PKG_LICENSE:=AGPL-3.0-or-later
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Karen Khachatryan <karen0734@gmail.com>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
@@ -25,9 +25,10 @@ define Package/antiblock
|
||||
endef
|
||||
|
||||
define Package/antiblock/description
|
||||
AntiBlock sniffer DNS requests. The IP addresses of the
|
||||
specified domains are added to the routing table for
|
||||
routing through the specified interfaces.
|
||||
AntiBlock monitors DNS responses for configured domains and
|
||||
dynamically installs IPv4 host routes through selected network
|
||||
interfaces. Supports both L3 interfaces and L2 interfaces
|
||||
with default gateways.
|
||||
endef
|
||||
|
||||
define Package/antiblock/conffiles
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
# AntiBlock UCI configuration
|
||||
#
|
||||
# AntiBlock 3.x uses an interface name as the first field of each -r rule.
|
||||
# The init script also accepts the legacy 'gateway' option for compatibility
|
||||
# with existing AntiBlock 2.x configurations.
|
||||
|
||||
#config main 'config'
|
||||
#Required parameters:
|
||||
#option enabled '0'
|
||||
#Optional parameters:
|
||||
#option log '1'
|
||||
#option stat '1'
|
||||
#list blacklist 'x.x.x.x/xx'
|
||||
#list blacklist 'x.x.x.x/xx'
|
||||
# config main 'config'
|
||||
# option enabled '0'
|
||||
# option listen '192.168.1.1:53' # optional; default: network.lan.ipaddr:53
|
||||
# option log '1'
|
||||
# option stat '1'
|
||||
# option test '0'
|
||||
# list blacklist 'x.x.x.x/xx'
|
||||
# list blacklist 'x.x.x.x/xx'
|
||||
|
||||
#It is necessary to enter from 1 to 32 values:
|
||||
#config route
|
||||
#option gateway 'gateway1'
|
||||
#option domains_path 'https://test1.com'
|
||||
# Enter from 1 to 32 route sections:
|
||||
# config route
|
||||
# option interface 'wg0'
|
||||
# option domains_path 'https://example.com/domains.txt'
|
||||
|
||||
#config route
|
||||
#option gateway 'gateway2'
|
||||
#option domains_path '/test1.txt'
|
||||
# config route
|
||||
# option interface 'eth1'
|
||||
# option domains_path '/etc/antiblock/domains.txt'
|
||||
|
||||
#config route
|
||||
#option gateway 'gateway2'
|
||||
#option domains_path '/test2.txt'
|
||||
|
||||
#config route
|
||||
#option gateway 'gateway1'
|
||||
#option domains_path 'https://test2.com'
|
||||
# Legacy AntiBlock 2.x form remains accepted:
|
||||
# config route
|
||||
# option gateway 'wg0'
|
||||
# option domains_path '/etc/antiblock/domains-legacy.txt'
|
||||
Regular → Executable
+64
-21
@@ -1,75 +1,118 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
|
||||
prog_name="antiblock"
|
||||
bin="/usr/bin/$prog_name"
|
||||
tmp_folder="/tmp/$prog_name"
|
||||
blacklist_file="$tmp_folder/blacklist"
|
||||
|
||||
routes_parse() {
|
||||
local _config="$1"
|
||||
local _enabled _interface _domains_path
|
||||
|
||||
local _enabled
|
||||
_enabled=""
|
||||
config_get_bool _enabled "${_config}" "enabled" "1"
|
||||
if [ "${_enabled}" -eq "1" ]; then
|
||||
local _gateway
|
||||
local _domains_path
|
||||
_interface=""
|
||||
_domains_path=""
|
||||
|
||||
config_get _gateway "${_config}" gateway
|
||||
# AntiBlock 3.x calls the first -r field an interface. Keep the old
|
||||
# 'gateway' UCI option as a fallback so existing configs still work.
|
||||
config_get _interface "${_config}" interface
|
||||
[ -z "${_interface}" ] && config_get _interface "${_config}" gateway
|
||||
config_get _domains_path "${_config}" domains_path
|
||||
|
||||
procd_append_param command -r "${_gateway} ${_domains_path}"
|
||||
[ -n "${_interface}" ] || return 0
|
||||
[ -n "${_domains_path}" ] || return 0
|
||||
|
||||
# Count usable rules before opening a procd instance.
|
||||
if [ "${_routes_check_only:-0}" -eq "1" ]; then
|
||||
_valid_routes=$((_valid_routes + 1))
|
||||
return 0
|
||||
fi
|
||||
|
||||
procd_append_param command -r "${_interface} ${_domains_path}"
|
||||
fi
|
||||
}
|
||||
|
||||
blacklist_parse() {
|
||||
[ "${_blacklist_count}" -eq "0" ] && mkdir -p $tmp_folder && >$blacklist_file
|
||||
_blacklist_count=$(expr "${_blacklist_count}" + 1)
|
||||
echo "$1" >>$blacklist_file
|
||||
[ "${_blacklist_count}" -eq "0" ] && true >"$blacklist_file"
|
||||
_blacklist_count=$((_blacklist_count + 1))
|
||||
echo "$1" >>"$blacklist_file"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local _enabled _valid_routes _routes_check_only
|
||||
local _log _stat _test _listen _blacklist_count
|
||||
|
||||
config_load "$prog_name"
|
||||
|
||||
local _enabled
|
||||
_enabled=""
|
||||
config_get_bool _enabled "config" "enabled" "0"
|
||||
[ "${_enabled}" -eq "0" ] && return 1
|
||||
[ "${_enabled}" -eq "0" ] && return 0
|
||||
|
||||
echo "AntiBlock start"
|
||||
_valid_routes=0
|
||||
_routes_check_only=1
|
||||
config_foreach routes_parse route
|
||||
_routes_check_only=0
|
||||
if [ "${_valid_routes}" -eq "0" ]; then
|
||||
logger -t "$prog_name" -p daemon.err \
|
||||
"No enabled route with both interface (or gateway) and domains_path"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local _log
|
||||
local _stat
|
||||
local _test
|
||||
logger -t "$prog_name" -p daemon.info "AntiBlock start requested"
|
||||
|
||||
_log=""
|
||||
_stat=""
|
||||
_test=""
|
||||
_listen=""
|
||||
|
||||
config_get_bool _log "config" "log" "0"
|
||||
config_get_bool _stat "config" "stat" "0"
|
||||
config_get_bool _test "config" "test" "0"
|
||||
config_get _listen "config" "listen"
|
||||
|
||||
if [ -z "${_listen}" ]; then
|
||||
_listen="$(uci -q get network.lan.ipaddr | cut -d/ -f1)"
|
||||
if [ -z "${_listen}" ]; then
|
||||
logger -t "$prog_name" -p daemon.err \
|
||||
"Cannot determine DNS address; set option listen"
|
||||
return 1
|
||||
fi
|
||||
_listen="${_listen}:53"
|
||||
fi
|
||||
|
||||
mkdir -p "$tmp_folder"
|
||||
|
||||
_blacklist_count=0
|
||||
config_list_foreach "config" blacklist blacklist_parse
|
||||
|
||||
procd_open_instance "$prog_name"
|
||||
|
||||
procd_set_param command "/usr/bin/$prog_name"
|
||||
procd_set_param command "$bin"
|
||||
procd_set_param file /etc/config/antiblock
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
||||
config_foreach routes_parse route
|
||||
|
||||
local _listen
|
||||
_listen="$(uci -q get network.lan.ipaddr):53"
|
||||
procd_append_param command -l "${_listen}"
|
||||
|
||||
procd_append_param command -o "$tmp_folder"
|
||||
[ "${_blacklist_count}" -ne "0" ] && procd_append_param command -b "$blacklist_file"
|
||||
[ "${_log}" -ne "0" ] && mkdir -p $tmp_folder && procd_append_param command --log
|
||||
[ "${_stat}" -ne "0" ] && mkdir -p $tmp_folder && procd_append_param command --stat
|
||||
[ "${_log}" -ne "0" ] && procd_append_param command --log
|
||||
[ "${_stat}" -ne "0" ] && procd_append_param command --stat
|
||||
[ "${_test}" -ne "0" ] && procd_append_param command --test
|
||||
|
||||
procd_close_instance
|
||||
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
if [ -x /etc/init.d/dnsmasq ] && /etc/init.d/dnsmasq running >/dev/null 2>&1; then
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
|
||||
Regular → Executable
+3
-1
@@ -1,3 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
antiblock | grep "AntiBlock $PKG_VERSION"
|
||||
# shellcheck disable=SC2154
|
||||
antiblock --help | grep -F "AntiBlock $PKG_VERSION"
|
||||
Reference in new issue
Block a user