diff --git a/etc/smartdns/smartdns.conf b/etc/smartdns/smartdns.conf index f11c3b0..3811a87 100644 --- a/etc/smartdns/smartdns.conf +++ b/etc/smartdns/smartdns.conf @@ -36,7 +36,9 @@ # IPV6: # bind [::]:53 # bind-tcp [::]:53 -bind [::]:53 +bind [::]:7053 + +force-AAAA-SOA yes # tcp connection idle timeout # tcp-idle-time [second] diff --git a/package/luci/files/luci/i18n/smartdns.zh-cn.po b/package/luci/files/luci/i18n/smartdns.zh-cn.po index 6a5a165..5a0ac52 100644 --- a/package/luci/files/luci/i18n/smartdns.zh-cn.po +++ b/package/luci/files/luci/i18n/smartdns.zh-cn.po @@ -109,6 +109,12 @@ msgstr "重定向53端口到SmartDNS" msgid "Cache Size" msgstr "缓存大小" +msgid "Resolve Local Hostnames" +msgstr "本地主机名解析" + +msgid "Resolve local hostnames by reading Dnsmasq lease file" +msgstr "读取Dnsmasq的DHCP Lease文件解析本地主机名" + msgid "DNS domain result cache size" msgstr "缓存DNS的结果,缓存大小,配置零则不缓存(单位:条)" @@ -193,8 +199,8 @@ msgstr "跳过cache。" msgid "Force AAAA SOA" msgstr "停用IPV6地址解析" -msgid "Force AAAA SOA." -msgstr "停用IPV6地址解析。" +msgid "Force HTTPS SOA." +msgstr "停用HTTPS解析。" msgid "Upstream Servers" msgstr "上游服务器" diff --git a/package/luci/files/root/www/luci-static/resources/view/smartdns/smartdns.js b/package/luci/files/root/www/luci-static/resources/view/smartdns/smartdns.js index 7d5224b..a148869 100644 --- a/package/luci/files/root/www/luci-static/resources/view/smartdns/smartdns.js +++ b/package/luci/files/root/www/luci-static/resources/view/smartdns/smartdns.js @@ -31,7 +31,7 @@ var callServiceList = rpc.declare({ expect: { '': {} } }); -function getPidOfSmartdns() { +function getServiceStatus() { return L.resolveDefault(callServiceList(conf), {}) .then(function (res) { var isrunning = false; @@ -49,6 +49,8 @@ function getIPTablesRedirect() { } else { return ""; } + }).catch(function (err) { + return ""; }); } @@ -59,12 +61,14 @@ function getIP6TablesRedirect() { } else { return ""; } - }); + }).catch(function (err) { + return ""; + });; } function smartdnsServiceStatus() { return Promise.all([ - getPidOfSmartdns(), + getServiceStatus(), getIPTablesRedirect(), getIP6TablesRedirect() ]); @@ -136,6 +140,10 @@ return L.view.extend({ L.Poll.add(function () { return L.resolveDefault(smartdnsServiceStatus()).then(function (res) { var view = document.getElementById("service_status"); + if (view == null) { + return; + } + view.innerHTML = smartdnsRenderStatus(res); }); }); @@ -215,6 +223,21 @@ return L.view.extend({ o = s.taboption("settings", form.Value, "cache_size", _("Cache Size"), _("DNS domain result cache size")); o.rempty = true; + // cache-size; + o = s.taboption("settings", form.Flag, "resolve_local_hostnames", _("Resolve Local Hostnames"), _("Resolve local hostnames by reading Dnsmasq lease file")); + o.rmempty = false; + o.default = o.enabled; + + // Force AAAA SOA + o = s.taboption("settings", form.Flag, "force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA.")); + o.rmempty = false; + o.default = o.disabled; + + // Force HTTPS SOA + o = s.taboption("settings", form.Flag, "force_https_soa", _("Force HTTPS SOA"), _("Force HTTPS SOA.")); + o.rmempty = false; + o.default = o.disabled; + // rr-ttl; o = s.taboption("settings", form.Value, "rr_ttl", _("Domain TTL"), _("TTL for all domain result.")); o.rempty = true; diff --git a/package/openwrt/files/etc/init.d/smartdns b/package/openwrt/files/etc/init.d/smartdns index fd312af..1cf5ece 100644 --- a/package/openwrt/files/etc/init.d/smartdns +++ b/package/openwrt/files/etc/init.d/smartdns @@ -260,6 +260,8 @@ load_service() { local section="$1" args="" + dnsmase_lease_file="$(uci get dhcp.@dnsmasq[0].leasefile 2>/dev/null)" + qtype_soa_list="" mkdir -p $SMARTDNS_VAR_CONF_DIR rm -f $SMARTDNS_CONF_TMP @@ -302,6 +304,15 @@ load_service() config_get cache_size "$section" "cache_size" "" [ -z "$cache_size" ] || conf_append "cache-size" "$cache_size" + config_get resolve_local_hostnames "$section" "resolve_local_hostnames" "1" + [ -z "$resolve_local_hostnames" ] || conf_append "dnsmasq-lease-file" "$dnsmase_lease_file" + + config_get force_aaaa_soa "$section" "force_aaaa_soa" "0" + [ "$force_aaaa_soa" = "1" ] && qtype_soa_list="$qtype_soa_list 28" + + config_get force_https_soa "$section" "force_https_soa" "0" + [ "$force_https_soa" = "1" ] && qtype_soa_list="$qtype_soa_list 65" + config_get rr_ttl "$section" "rr_ttl" "" [ -z "$rr_ttl" ] || conf_append "rr-ttl" "$rr_ttl" @@ -331,6 +342,8 @@ load_service() config_get old_port "$section" "old_port" "0" config_get old_enabled "$section" "old_enabled" "0" + [ -z "$qtype_soa_list" ] || conf_append "force-qtype-SOA" "$qtype_soa_list" + if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$SMARTDNS_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then [ "$old_redirect" = "none" ] || { [ "$old_port" = "0" ] || clear_iptable "$old_port" "$ipv6_server"