/etc/init.d/ruantiblock: fixed dnsmasq confdir issue.

This commit is contained in:
gSpot
2025-04-28 18:15:04 +03:00
parent ba8011c8ba
commit 53dfb1ffeb
6 changed files with 35 additions and 27 deletions
+5 -3
View File
@@ -10,9 +10,9 @@ LUCI_APP=1
HTTPS_DNS_PROXY=1 HTTPS_DNS_PROXY=1
OWRT_VERSION="current" OWRT_VERSION="current"
RUAB_VERSION="2.1.5-r1" RUAB_VERSION="2.1.6-r1"
RUAB_MOD_LUA_VERSION="2.1.5-r1" RUAB_MOD_LUA_VERSION="2.1.6-r1"
RUAB_LUCI_APP_VERSION="2.1.5-r1" RUAB_LUCI_APP_VERSION="2.1.6-r1"
BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master" BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master"
PKG_DIR="/tmp" PKG_DIR="/tmp"
@@ -219,6 +219,7 @@ InstallTorConfig() {
TorrcSettings TorrcSettings
$UCI_CMD set ruantiblock.config.proxy_mode="1" $UCI_CMD set ruantiblock.config.proxy_mode="1"
$UCI_CMD commit ruantiblock $UCI_CMD commit ruantiblock
# dnsmasq rebind protection
$UCI_CMD add_list dhcp.@dnsmasq[0].rebind_domain='onion' $UCI_CMD add_list dhcp.@dnsmasq[0].rebind_domain='onion'
$UCI_CMD commit dhcp $UCI_CMD commit dhcp
} }
@@ -387,6 +388,7 @@ ConfirmProcessing() {
ConfirmProxyMode ConfirmProxyMode
ConfirmBlacklist ConfirmBlacklist
#ConfirmLuaModule
ConfirmLuciApp ConfirmLuciApp
ConfirmHttpsDnsProxy ConfirmHttpsDnsProxy
ConfirmProcessing ConfirmProcessing
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ruantiblock PKG_NAME:=luci-app-ruantiblock
PKG_VERSION:=2.1.5 PKG_VERSION:=2.1.6
PKG_RELEASE:=1 PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for ruantiblock LUCI_TITLE:=LuCI support for ruantiblock
LUCI_DEPENDS:=+ruantiblock LUCI_DEPENDS:=+ruantiblock
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock-mod-lua PKG_NAME:=ruantiblock-mod-lua
PKG_VERSION:=2.1.5 PKG_VERSION:=2.1.6
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock-mod-py PKG_NAME:=ruantiblock-mod-py
PKG_VERSION:=2.1.5 PKG_VERSION:=2.1.6
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
+1 -1
View File
@@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=ruantiblock PKG_NAME:=ruantiblock
PKG_VERSION:=2.1.5 PKG_VERSION:=2.1.6
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/ruantiblock_openwrt>
+26 -20
View File
@@ -6,31 +6,37 @@ STOP=01
APP_NAME="ruantiblock" APP_NAME="ruantiblock"
APP_EXEC="/usr/bin/${APP_NAME}" APP_EXEC="/usr/bin/${APP_NAME}"
VAR_DIR="/tmp" VAR_DIR="/tmp"
UBUS_ATTEMPTS=10
get_dnsmasq_confdir() { 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 if [ -d "${VAR_DIR}/dnsmasq.d" ]; then
printf "${VAR_DIR}/dnsmasq.d" printf "${VAR_DIR}/dnsmasq.d"
return 0 return 0
else else
_first_instance_dir=$(ubus call service list | jsonfilter -e "VAR=$.dnsmasq.instances.*.mount" | awk -v CUR_DIR="$_current_dir" ' while [ $_i -lt $UBUS_ATTEMPTS ]
BEGIN { do
RS = " "; _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)) { sub("VAR=", "", $0);
a[length(a)] = $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]; }
}') END {
if [ -n "$_first_instance_dir" ]; then print (CUR_DIR in a) ? CUR_DIR : a[0];
printf "$_first_instance_dir" }')
return 0 if [ -n "$_first_instance_dir" ]; then
fi printf "$_first_instance_dir"
return 0
fi
_i=$(($_i + 1))
sleep 1
done
fi fi
return 1 return 1
} }
@@ -51,7 +57,7 @@ start() {
fi fi
$APP_EXEC start $APP_EXEC start
if [ $? -eq 0 -a "$_update_at_startup" = "1" ]; then if [ $? -eq 0 -a "$_update_at_startup" = "1" ]; then
$APP_EXEC update $APP_EXEC update > /dev/null &
else else
/etc/init.d/dnsmasq restart /etc/init.d/dnsmasq restart
fi fi