Add luci for new feature, and fix some bugs

This commit is contained in:
Nick Peng
2018-12-25 01:55:37 +08:00
parent 11552f906f
commit 9398573e6f
10 changed files with 114 additions and 36 deletions

View File

@@ -113,11 +113,16 @@ load_server()
{
local section="$1"
local ADDITIONAL_ARGS=""
config_get_bool "enabled" "$section" "enabled" "1"
config_get "port" "$section" "port" "53"
config_get "type" "$section" "type" "udp"
config_get "ip" "$section" "ip" ""
config_get "blacklist_ip" "$section" "blacklist_ip" "0"
if [ "$enabled" = "0" ]; then
return
fi
if [ -z "$port" ] || [ -z "$ip" ] || [ -z "$type" ]; then
return
fi
@@ -167,6 +172,11 @@ start_service() {
conf_append "bind-tcp" ":$port"
fi
fi
config_get "dualstack_ip_selection" "$section" "dualstack_ip_selection" "0"
if [ "$dualstack_ip_selection" = "1" ]; then
conf_append "dualstack-ip-selection" "yes"
fi
SMARTDNS_PORT="$port"
mkdir -p $SMARTDNS_CONF_DIR
@@ -215,15 +225,26 @@ start_service() {
config_get "old_redirect" "$section" "old_redirect" "none"
config_get "old_port" "$section" "old_port" "0"
if [ "$old_redirect" != "none" ] && [ "$old_port" != "0" ]; then
if [ "$old_port" != "$SMARTDNS_PORT" ]; then
clear_iptable "$old_port" "$ipv6_server"
stop_forward_dnsmasq "$old_port"
if [ "$redirect" = "redirect" ]; then
set_iptable $ipv6_server $tcp_server
fi
fi
if [ "$redirect" = "redirect" ]; then
set_iptable $ipv6_server $tcp_server
elif [ "$redirect" = "dnsmasq-upstream" ]; then
set_forward_dnsmasq "$SMARTDNS_PORT"
if [ "$old_redirect" != "$redirect" ]; then
if [ "$old_redirect" != "none" ]; then
if [ "$old_port" != "0" ]; then
clear_iptable "$old_port" "$ipv6_server"
fi
stop_forward_dnsmasq "$old_port"
fi
if [ "$redirect" = "redirect" ]; then
set_iptable $ipv6_server $tcp_server
elif [ "$redirect" = "dnsmasq-upstream" ]; then
set_forward_dnsmasq "$SMARTDNS_PORT"
fi
fi
uci delete smartdns.@smartdns[0].old_redirect 2>/dev/null