diff options
author | Nick Peng <pymumu@gmail.com> | 2022-09-14 23:43:57 +0800 |
---|---|---|
committer | Nick Peng <pymumu@gmail.com> | 2022-09-14 23:43:57 +0800 |
commit | bc7ef5d5417168e689bdfb65fa6b2c6f71a54698 (patch) | |
tree | 843f2b924d321d32df8d6ed39bf577306ee64138 /applications/luci-app-smartdns/htdocs/luci-static/resources/view | |
parent | 0db66851e23992300a7b1494bcd9309513d01162 (diff) |
luci-app-smartdns: bump to 1.2022.38
Signed-off-by: Nick Peng <pymumu@gmail.com>
Diffstat (limited to 'applications/luci-app-smartdns/htdocs/luci-static/resources/view')
-rw-r--r-- | applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js | 135 |
1 files changed, 64 insertions, 71 deletions
diff --git a/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js b/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js index da0b974420..6f3f0ac16e 100644 --- a/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js +++ b/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js @@ -21,8 +21,9 @@ 'require fs'; 'require uci'; 'require form'; -'require rpc'; 'require view'; +'require poll'; +'require rpc'; var conf = 'smartdns'; var callServiceList = rpc.declare({ @@ -32,7 +33,7 @@ var callServiceList = rpc.declare({ expect: { '': {} } }); -function getPidOfSmartdns() { +function getServiceStatus() { return L.resolveDefault(callServiceList(conf), {}) .then(function (res) { var isrunning = false; @@ -43,43 +44,20 @@ function getPidOfSmartdns() { }); } -function getIPTablesRedirect() { - return fs.exec('/usr/sbin/iptables', ['-t', 'nat', '-nL', 'PREROUTING']).then(function (res) { - if (res.code === 0) { - return res.stdout.trim(); - } else { - return ""; - } - }); -} - -function getIP6TablesRedirect() { - return fs.exec('/usr/sbin/ip6tables', ['-t', 'nat', '-nL', 'PREROUTING']).then(function (res) { - if (res.code === 0) { - return res.stdout.trim(); - } else { - return ""; - } - }); -} - function smartdnsServiceStatus() { return Promise.all([ - getPidOfSmartdns(), - getIPTablesRedirect(), - getIP6TablesRedirect() + getServiceStatus() ]); } function smartdnsRenderStatus(res) { var renderHTML = ""; var isRunning = res[0]; - var ipt = res[1]; - var ip6t = res[2]; - var serverPort = uci.get_first('smartdns', 'smartdns', 'port'); - var redirectMode = uci.get_first('smartdns', 'smartdns', 'redirect'); - var ipv6Enabled = uci.get_first('smartdns', 'smartdns', 'ipv6_server'); + var autoSetDnsmasq = uci.get_first('smartdns', 'smartdns', 'auto_set_dnsmasq'); + var smartdnsPort = uci.get_first('smartdns', 'smartdns', 'port'); + var dnsmasqServer = uci.get_first('dhcp', 'dnsmasq', 'server'); + uci.unload('dhcp'); if (isRunning) { renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>"; @@ -88,29 +66,13 @@ function smartdnsRenderStatus(res) { return renderHTML; } - if (redirectMode === "dnsmasq-upstream") { - var matchLine = "127.0.0.1#" + serverPort; + if (autoSetDnsmasq === '1' && smartdnsPort != '53') { + var matchLine = "127.0.0.1#" + smartdnsPort; var dnsmasqServer = uci.get_first('dhcp', 'dnsmasq', 'server') || ""; if (dnsmasqServer.indexOf(matchLine) < 0) { renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("Dnsmasq Forwared To Smartdns Failure") + "</span>"; } - } else if (redirectMode === "redirect") { - var redirectRules = (ipt || '').split(/\n/).filter(function (rule) { - return rule.match(/REDIRECT/) && rule.match(/dpt:53/) && rule.match("ports " + serverPort); - }); - - if (redirectRules.length <= 0) { - renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("IPV4 53 Port Redirect Failure") + "</span>"; - if (ipv6Enabled) { - var redirectRules = (ip6t || '').split(/\n/).filter(function (rule) { - return rule.match(/REDIRECT/) && rule.match(/dpt:53/) && rule.match("ports " + serverPort); - }); - if (redirectRules.length <= 0) { - renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("IPV6 53 Port Redirect Failure") + "</span>"; - } - } - } } return renderHTML; @@ -119,8 +81,8 @@ function smartdnsRenderStatus(res) { return view.extend({ load: function () { return Promise.all([ + uci.load('dhcp'), uci.load('smartdns'), - uci.load('dhcp') ]); }, render: function (stats) { @@ -134,12 +96,18 @@ return view.extend({ s = m.section(form.NamedSection, '_status'); s.anonymous = true; s.render = function (section_id) { - L.Poll.add(function () { + var renderStatus = function () { return L.resolveDefault(smartdnsServiceStatus()).then(function (res) { var view = document.getElementById("service_status"); + if (view == null) { + return; + } + view.innerHTML = smartdnsRenderStatus(res); }); - }); + } + poll.add(renderStatus); + setTimeout(renderStatus, 1000); return E('div', { class: 'cbi-map' }, E('div', { class: 'cbi-section' }, [ @@ -157,10 +125,9 @@ return view.extend({ s.tab("seconddns", _("Second Server Settings")); s.tab("custom", _("Custom Settings")); - // Eanble; o = s.taboption("settings", form.Flag, "enabled", _("Enable"), _("Enable or disable smartdns server")); + o.rmempty = false; o.default = o.disabled; - o.rempty = false; // server name; o = s.taboption("settings", form.Value, "server_name", _("Server Name"), _("Smartdns server name")); @@ -169,9 +136,10 @@ return view.extend({ o.rempty = false; // Port; - o = s.taboption("settings", form.Value, "port", _("Local Port"), _("Smartdns local server port")); - o.placeholder = 6053; - o.default = 6053; + o = s.taboption("settings", form.Value, "port", _("Local Port"), + _("Smartdns local server port, smartdns will be automatically set as main dns when the port is 53.")); + o.placeholder = 53; + o.default = 53; o.datatype = "port"; o.rempty = false; @@ -189,7 +157,7 @@ return view.extend({ o = s.taboption("settings", form.Flag, "dualstack_ip_selection", _("Dual-stack IP Selection"), _("Enable IP selection between IPV4 and IPV6")); o.rmempty = false; - o.default = o.disabled; + o.default = o.enabled; // Domain prefetch load ; o = s.taboption("settings", form.Flag, "prefetch_domain", _("Domain prefetch"), @@ -201,21 +169,32 @@ return view.extend({ o = s.taboption("settings", form.Flag, "serve_expired", _("Serve expired"), _("Attempts to serve old responses from cache with a TTL of 0 in the response without waiting for the actual resolution to finish.")); o.rmempty = false; - o.default = o.disabled; - - // Redirect; - o = s.taboption("settings", form.ListValue, "redirect", _("Redirect"), _("SmartDNS redirect mode")); - o.placeholder = "none"; - o.value("none", _("none")); - o.value("dnsmasq-upstream", _("Run as dnsmasq upstream server")); - o.value("redirect", _("Redirect 53 port to SmartDNS")); - o.default = "none"; - o.rempty = false; + o.default = o.enabled; // cache-size; 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; + + // auto-conf-dnsmasq; + o = s.taboption("settings", form.Flag, "auto_set_dnsmasq", _("Automatically Set Dnsmasq"), _("Automatically set as upstream of dnsmasq when port changes.")); + 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; @@ -224,16 +203,21 @@ return view.extend({ o = s.taboption("settings", form.Value, "rr_ttl_min", _("Domain TTL Min"), _("Minimum TTL for all domain result.")); o.rempty = true; - o.placeholder = "300"; - o.default = 300; + o.placeholder = "600"; + o.default = 600; o.optional = true; - // second dns server; // rr-ttl-max; o = s.taboption("settings", form.Value, "rr_ttl_max", _("Domain TTL Max"), _("Maximum TTL for all domain result.")); o.rempty = true; + // rr-ttl-reply-max; + o = s.taboption("settings", form.Value, "rr_ttl_reply_max", _("Reply Domain TTL Max"), + _("Reply maximum TTL for all domain result.")); + o.rempty = true; + + // second dns server; // Eanble; o = s.taboption("seconddns", form.Flag, "seconddns_enabled", _("Enable"), _("Enable or disable second DNS server.")); @@ -300,7 +284,7 @@ return view.extend({ o.default = o.disabled; // Force AAAA SOA - o = s.taboption("seconddns", form.Flag, "force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA.")); + o = s.taboption("seconddns", form.Flag, "seconddns_force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA.")); o.rmempty = false; o.default = o.disabled; @@ -390,6 +374,15 @@ return view.extend({ o.depends("type", "tls") o.depends("type", "https") + // certificate verify + o = s.taboption("advanced", form.Flag, "no_check_certificate", _("No check certificate"), + _("Do not check certificate.")) + o.rmempty = false + o.default = o.disabled + o.modalonly = true; + o.depends("type", "tls") + o.depends("type", "https") + // SNI host name o = s.taboption("advanced", form.Value, "host_name", _("TLS SNI name"), _("Sets the server name indication for query.")) |