diff --git a/package/luci/files/luci/model/cbi/smartdns/smartdns.lua b/package/luci/files/luci/model/cbi/smartdns/smartdns.lua index 3f2ead4..0822c41 100644 --- a/package/luci/files/luci/model/cbi/smartdns/smartdns.lua +++ b/package/luci/files/luci/model/cbi/smartdns/smartdns.lua @@ -80,12 +80,14 @@ o.rempty = true ---- rr-ttl-min o = s:taboption("settings", Value, "rr_ttl_min", translate("Domain TTL Min"), translate("Minimum TTL for all domain result.")) o.rempty = true +o.placeholder = "300" +o.default = 300 +o.optional = true ---- rr-ttl-max o = s:taboption("settings", Value, "rr_ttl_max", translate("Domain TTL Max"), translate("Maximum TTL for all domain result.")) o.rempty = true - ----- custom settings custom = s:taboption("custom", Value, "Custom Settings", translate(""), @@ -129,16 +131,17 @@ end ---- name s:option(Value, "name", translate("DNS Server Name"), translate("DNS Server Name")) + ---- IP address o = s:option(Value, "ip", translate("ip"), translate("DNS Server ip")) o.datatype = "ipaddr" o.rmempty = false ---- port o = s:option(Value, "port", translate("port"), translate("DNS Server port")) -o.placeholder = 53 -o.default = 53 +o.placeholder = "default" o.datatype = "port" -o.rempty = false +o.rempty = true + ---- type o = s:option(ListValue, "type", translate("type"), translate("DNS Server type")) o.placeholder = "udp" diff --git a/package/openwrt/files/etc/init.d/smartdns b/package/openwrt/files/etc/init.d/smartdns index 11e55b8..088cf25 100644 --- a/package/openwrt/files/etc/init.d/smartdns +++ b/package/openwrt/files/etc/init.d/smartdns @@ -130,8 +130,10 @@ load_server() { local section="$1" local ADDITIONAL_ARGS="" + local DNS_ADDRESS="" + config_get_bool "enabled" "$section" "enabled" "1" - config_get "port" "$section" "port" "53" + config_get "port" "$section" "port" "" config_get "type" "$section" "type" "udp" config_get "ip" "$section" "ip" "" config_get "blacklist_ip" "$section" "blacklist_ip" "0" @@ -141,7 +143,7 @@ load_server() return fi - if [ -z "$port" ] || [ -z "$ip" ] || [ -z "$type" ]; then + if [ -z "$ip" ] || [ -z "$type" ]; then return fi @@ -166,7 +168,13 @@ load_server() ADDITIONAL_ARGS="$ADDITIONAL_ARGS -check-edns" fi - conf_append "$SERVER" "$ip:$port $ADDITIONAL_ARGS" + if [ ! -z "$port" ]; then + DNS_ADDRESS="$ip:$port" + else + DNS_ADDRESS="$ip" + fi + + conf_append "$SERVER" "$DNS_ADDRESS $ADDITIONAL_ARGS" } load_service() { @@ -256,7 +264,7 @@ load_service() { config_get "old_port" "$section" "old_port" "0" config_get "old_enabled" "$section" "old_enabled" "0" - if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$SMARTDNS_PORT" ] || [ "$old_enabled" = "1" ]; then + if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$SMARTDNS_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then if [ "$old_redirect" != "none" ]; then if [ "$old_port" != "0" ]; then clear_iptable "$old_port" "$ipv6_server"