From 53dfb1ffeb4151a236204a9637d6c03d84f0ed1e Mon Sep 17 00:00:00 2001 From: gSpot Date: Mon, 28 Apr 2025 18:15:04 +0300 Subject: [PATCH] /etc/init.d/ruantiblock: fixed dnsmasq confdir issue. --- autoinstall/2.x/autoinstall.sh | 8 +++-- luci-app-ruantiblock/Makefile | 2 +- ruantiblock-mod-lua/Makefile | 2 +- ruantiblock-mod-py/Makefile | 2 +- ruantiblock/Makefile | 2 +- ruantiblock/files/etc/init.d/ruantiblock | 46 +++++++++++++----------- 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/autoinstall/2.x/autoinstall.sh b/autoinstall/2.x/autoinstall.sh index 0496a54..104c265 100755 --- a/autoinstall/2.x/autoinstall.sh +++ b/autoinstall/2.x/autoinstall.sh @@ -10,9 +10,9 @@ LUCI_APP=1 HTTPS_DNS_PROXY=1 OWRT_VERSION="current" -RUAB_VERSION="2.1.5-r1" -RUAB_MOD_LUA_VERSION="2.1.5-r1" -RUAB_LUCI_APP_VERSION="2.1.5-r1" +RUAB_VERSION="2.1.6-r1" +RUAB_MOD_LUA_VERSION="2.1.6-r1" +RUAB_LUCI_APP_VERSION="2.1.6-r1" BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master" PKG_DIR="/tmp" @@ -219,6 +219,7 @@ InstallTorConfig() { TorrcSettings $UCI_CMD set ruantiblock.config.proxy_mode="1" $UCI_CMD commit ruantiblock + # dnsmasq rebind protection $UCI_CMD add_list dhcp.@dnsmasq[0].rebind_domain='onion' $UCI_CMD commit dhcp } @@ -387,6 +388,7 @@ ConfirmProcessing() { ConfirmProxyMode ConfirmBlacklist +#ConfirmLuaModule ConfirmLuciApp ConfirmHttpsDnsProxy ConfirmProcessing diff --git a/luci-app-ruantiblock/Makefile b/luci-app-ruantiblock/Makefile index 2729256..daa57f7 100644 --- a/luci-app-ruantiblock/Makefile +++ b/luci-app-ruantiblock/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ruantiblock -PKG_VERSION:=2.1.5 +PKG_VERSION:=2.1.6 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for ruantiblock LUCI_DEPENDS:=+ruantiblock diff --git a/ruantiblock-mod-lua/Makefile b/ruantiblock-mod-lua/Makefile index 9c0a465..c7c3a13 100644 --- a/ruantiblock-mod-lua/Makefile +++ b/ruantiblock-mod-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock-mod-lua -PKG_VERSION:=2.1.5 +PKG_VERSION:=2.1.6 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/ruantiblock-mod-py/Makefile b/ruantiblock-mod-py/Makefile index 47aa4af..224395a 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:=2.1.5 +PKG_VERSION:=2.1.6 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/ruantiblock/Makefile b/ruantiblock/Makefile index 4f45c4f..416d347 100644 --- a/ruantiblock/Makefile +++ b/ruantiblock/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ruantiblock -PKG_VERSION:=2.1.5 +PKG_VERSION:=2.1.6 PKG_RELEASE:=1 PKG_MAINTAINER:=gSpot diff --git a/ruantiblock/files/etc/init.d/ruantiblock b/ruantiblock/files/etc/init.d/ruantiblock index ff0bc48..b743f8d 100755 --- a/ruantiblock/files/etc/init.d/ruantiblock +++ b/ruantiblock/files/etc/init.d/ruantiblock @@ -6,31 +6,37 @@ STOP=01 APP_NAME="ruantiblock" APP_EXEC="/usr/bin/${APP_NAME}" VAR_DIR="/tmp" +UBUS_ATTEMPTS=10 get_dnsmasq_confdir() { - local _current_dir="$1" _first_instance_dir + local _current_dir="$1" _i=0 _first_instance_dir if [ -d "${VAR_DIR}/dnsmasq.d" ]; then printf "${VAR_DIR}/dnsmasq.d" return 0 else - _first_instance_dir=$(ubus call service list | jsonfilter -e "VAR=$.dnsmasq.instances.*.mount" | awk -v CUR_DIR="$_current_dir" ' - BEGIN { - RS = " "; - } - { - sub("VAR=", "", $0); - gsub(/[\047,\073,\\]/, "", $0); - if($0 ~ /^\/tmp\/dnsmasq\./ && !($0 in a)) { - a[length(a)] = $0; - }; - } - END { - print (CUR_DIR in a) ? CUR_DIR : a[0]; - }') - if [ -n "$_first_instance_dir" ]; then - printf "$_first_instance_dir" - return 0 - fi + while [ $_i -lt $UBUS_ATTEMPTS ] + do + _first_instance_dir=$(ubus call service list | jsonfilter -e "VAR=$.dnsmasq.instances.*.mount" | awk -v CUR_DIR="$_current_dir" ' + BEGIN { + RS = " "; + } + { + sub("VAR=", "", $0); + gsub(/[\047,\073,\\]/, "", $0); + if($0 ~ /^\/tmp\/dnsmasq\./ && !($0 in a)) { + a[length(a)] = $0; + }; + } + END { + print (CUR_DIR in a) ? CUR_DIR : a[0]; + }') + if [ -n "$_first_instance_dir" ]; then + printf "$_first_instance_dir" + return 0 + fi + _i=$(($_i + 1)) + sleep 1 + done fi return 1 } @@ -51,7 +57,7 @@ start() { fi $APP_EXEC start if [ $? -eq 0 -a "$_update_at_startup" = "1" ]; then - $APP_EXEC update + $APP_EXEC update > /dev/null & else /etc/init.d/dnsmasq restart fi