🍓 Sync 2025-11-12 00:12:28
This commit is contained in:
@@ -5,9 +5,6 @@ USE_PROCD=1
|
||||
START=95
|
||||
STOP=01
|
||||
|
||||
ipt=$(command -v iptables-legacy || command -v iptables)
|
||||
ip6t=$(command -v ip6tables-legacy || command -v ip6tables)
|
||||
bin_nft=$(command -v nft || which nft)
|
||||
CONFIGURATION=AdGuardHome
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
GFWSET="gfwlist"
|
||||
@@ -20,47 +17,47 @@ EXTRA_HELP=" do_redirect 0 or 1\
|
||||
|
||||
set_forward_dnsmasq()
|
||||
{
|
||||
local PORT="$1"
|
||||
addr="127.0.0.1#$PORT"
|
||||
OLD_SERVER="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
addr="127.0.0.1#$AdGuardHome_PORT"
|
||||
OLD_SERVER="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
echo $OLD_SERVER | grep "^$addr" >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
|
||||
uci add_list dhcp.@dnsmasq[0].server=$addr
|
||||
uci add_list dhcp.@dnsmasq[0].server="$addr"
|
||||
for server in $OLD_SERVER; do
|
||||
if [ "$server" = "$addr" ]; then
|
||||
continue
|
||||
fi
|
||||
# uci add_list dhcp.@dnsmasq[0].server=$server
|
||||
uci add_list dhcp.@dnsmasq[0].server=$server
|
||||
done
|
||||
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
|
||||
uci set dhcp.@dnsmasq[0].noresolv=1
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
}
|
||||
|
||||
stop_forward_dnsmasq()
|
||||
{
|
||||
local OLD_PORT="$1"
|
||||
addr="127.0.0.1#$OLD_PORT"
|
||||
OLD_SERVER="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
OLD_SERVER="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
echo $OLD_SERVER | grep "^$addr" >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
|
||||
addrlist="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
if [ -z "$addrlist" ] ; then
|
||||
uci del_list dhcp.@dnsmasq[0].server="$addr" 2>/dev/null
|
||||
|
||||
addrlist="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
if [ -z "$addrlist" ]; then
|
||||
resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
[ ! -f "$resolvfile" ] && resolvfile="/tmp/resolv.conf.auto"
|
||||
uci set dhcp.@dnsmasq[0].resolvfile="$resolvfile" 2>/dev/null
|
||||
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
|
||||
fi
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
}
|
||||
|
||||
set_firewall()
|
||||
@@ -453,7 +450,7 @@ start_service() {
|
||||
procd_set_param file "$configpath" "/etc/hosts" "/etc/config/AdGuardHome"
|
||||
procd_close_instance
|
||||
if [ -f "$configpath" ]; then
|
||||
_do_redirect 1
|
||||
(sleep 5 && _do_redirect 1) &
|
||||
else
|
||||
_do_redirect 0
|
||||
config_get "redirect" $CONFIGURATION "redirect" "none"
|
||||
@@ -465,13 +462,7 @@ start_service() {
|
||||
fi
|
||||
fi
|
||||
echo "AdGuardHome service enabled"
|
||||
# echo "luci enable switch=$enabled"
|
||||
(sleep 10 && [ -z "$(pgrep $binpath)" ] && logger "AdGuardHome" "no process in 10s cancel redirect" && _do_redirect 0 )&
|
||||
if [[ "`uci -q get bypass.@global[0].global_server`" && "`uci -q get bypass.@global[0].adguardhome 2>/dev/null`" == 1 && "$(uci -q get dhcp.@dnsmasq[0].port)" == "53" ]]; then
|
||||
uci -q set AdGuardHome.AdGuardHome.redirect='exchange'
|
||||
uci commit AdGuardHome
|
||||
do_redirect 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
reload_service()
|
||||
@@ -574,6 +565,7 @@ do_crontab(){
|
||||
}
|
||||
|
||||
crontab_editor(){
|
||||
[ ! -f "$CRON_FILE" ] && mkdir -p ${CRON_FILE%/*} && touch "$CRON_FILE" && chmod 600 "$CRON_FILE"
|
||||
#usage input:
|
||||
#findstr=
|
||||
#default=
|
||||
|
||||
Reference in New Issue
Block a user