luci: fix status section not working issue and add some options

This commit is contained in:
Nick Peng
2022-08-28 17:30:24 +08:00
parent f659cf3725
commit 64e5b326cc
4 changed files with 50 additions and 6 deletions

View File

@@ -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]

View File

@@ -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 "上游服务器"

View File

@@ -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;

View File

@@ -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"