|
@@ -94,7 +94,7 @@ clear_iptable()
|
|
|
if [ "$ipv6_server" == 0 ]; then
|
|
|
return
|
|
|
fi
|
|
|
-
|
|
|
+ echo "warn ip6tables nat mod is needed"
|
|
|
IPS="`ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}'`"
|
|
|
for IP in $IPS
|
|
|
do
|
|
@@ -132,13 +132,24 @@ get_tz()
|
|
|
|
|
|
SET_TZ=$tz
|
|
|
}
|
|
|
-
|
|
|
+exchange_port()
|
|
|
+{
|
|
|
+ dnsmasq_port=$(uci get dhcp.@dnsmasq[0].port)
|
|
|
+ if [ -z "$dnsmasq_port" ]; then
|
|
|
+ dnsmasq_port="53"
|
|
|
+ fi
|
|
|
+ AdGuardHome_PORT=$(awk '/ port:/{printf($2)}' $configpath)
|
|
|
+ config_editor "dns.port" "$dnsmasq_port" "$configpath"
|
|
|
+ uci set dhcp.@dnsmasq[0].port="$AdGuardHome_PORT"
|
|
|
+ uci commit dhcp
|
|
|
+ /etc/init.d/dnsmasq reload
|
|
|
+}
|
|
|
do_redirect()
|
|
|
{
|
|
|
config_load "${CONFIGURATION}"
|
|
|
local section="$CONFIGURATION"
|
|
|
args=""
|
|
|
- ipv6_server=0
|
|
|
+ ipv6_server=1
|
|
|
tcp_server=0
|
|
|
enabled=$1
|
|
|
config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
|
|
@@ -150,18 +161,25 @@ do_redirect()
|
|
|
config_get "old_redirect" "$section" "old_redirect" "none"
|
|
|
config_get "old_port" "$section" "old_port" "0"
|
|
|
config_get "old_enabled" "$section" "old_enabled" "0"
|
|
|
-
|
|
|
+ if [ "$old_redirect" == "exchange" -a "$AdGuardHome_PORT" == "53" ]; then
|
|
|
+ $AdGuardHome_PORT=$(uci get dhcp.@dnsmasq[0].port)
|
|
|
+ fi
|
|
|
+
|
|
|
if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$AdGuardHome_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then
|
|
|
if [ "$old_redirect" != "none" ]; then
|
|
|
- if [ "$old_port" != "0" ]; then
|
|
|
+ if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
|
|
clear_iptable "$old_port" "$ipv6_server"
|
|
|
- fi
|
|
|
- if [ "$old_redirect" == "dnsmasq-upstream" ]; then
|
|
|
+ elif [ "$old_redirect" == "dnsmasq-upstream" ]; then
|
|
|
stop_forward_dnsmasq "$old_port"
|
|
|
+ elif [ "$old_redirect" == "exchange" ]; then
|
|
|
+ exchange_port
|
|
|
fi
|
|
|
fi
|
|
|
+ elif [ "$old_enabled" = "1" -a "$enabled" = "1" ]; then
|
|
|
+ if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
|
|
+ clear_iptable "$old_port" "$ipv6_server"
|
|
|
+ fi
|
|
|
fi
|
|
|
-
|
|
|
uci delete AdGuardHome.@AdGuardHome[0].old_redirect 2>/dev/null
|
|
|
uci delete AdGuardHome.@AdGuardHome[0].old_port 2>/dev/null
|
|
|
uci delete AdGuardHome.@AdGuardHome[0].old_enabled 2>/dev/null
|
|
@@ -178,16 +196,9 @@ do_redirect()
|
|
|
set_iptable $ipv6_server $tcp_server
|
|
|
elif [ "$redirect" = "dnsmasq-upstream" ]; then
|
|
|
set_forward_dnsmasq "$AdGuardHome_PORT"
|
|
|
+ elif [ "$redirect" == "exchange" -a "$(uci get dhcp.@dnsmasq[0].port)" == "53" ]; then
|
|
|
+ exchange_port
|
|
|
fi
|
|
|
-
|
|
|
- #procd_open_instance "AdGuardHome"
|
|
|
-
|
|
|
- #get_tz
|
|
|
- #if [ ! -z "$SET_TZ" ]; then
|
|
|
- # procd_set_param env TZ="$SET_TZ"
|
|
|
- #fi
|
|
|
- #procd_set_param file "$AdGuardHome_CONF"
|
|
|
- #procd_close_instance
|
|
|
}
|
|
|
get_filesystem()
|
|
|
{
|
|
@@ -349,6 +360,9 @@ reload_service()
|
|
|
echo "AdGuardHome reloading"
|
|
|
config_get_bool enabled $CONFIGURATION enabled 0
|
|
|
procd_send_signal $CONFIGURATION
|
|
|
+ if [ "$enabled" == "0" ]; then
|
|
|
+ do_redirect 0
|
|
|
+ fi
|
|
|
start
|
|
|
echo "enabled=$enabled"
|
|
|
}
|