luci: add hint when set dnsmasq failure.

This commit is contained in:
Nick Peng
2022-09-14 23:45:39 +08:00
parent 1f1fd118de
commit 1991a0b102
6 changed files with 482 additions and 446 deletions

View File

@@ -37,6 +37,20 @@ end
function act_status() function act_status()
local e={} local e={}
local ipv6_server;
local dnsmasq_server = luci.sys.exec("uci get dhcp.@dnsmasq[0].server")
local auto_set_dnsmasq = smartdns.get_config_option("smartdns", "smartdns", "auto_set_dnsmasq", nil);
e.auto_set_dnsmasq = auto_set_dnsmasq
e.dnsmasq_server = dnsmasq_server
e.local_port = smartdns.get_config_option("smartdns", "smartdns", "port", nil);
if e.local_port ~= nil and e.local_port ~= "53" and auto_set_dnsmasq ~= nil and auto_set_dnsmasq == "1" then
local str;
str = "127.0.0.1#" .. e.local_port
if string.sub(dnsmasq_server,1,string.len(str)) ~= str then
e.dnsmasq_redirect_failure = 1
end
end
e.running = is_running() e.running = is_running()
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json(e) luci.http.write_json(e)

View File

@@ -52,6 +52,9 @@ msgstr "协议类型"
msgid "DNS domain result cache size" msgid "DNS domain result cache size"
msgstr "缓存DNS的结果缓存大小配置零则不缓存" msgstr "缓存DNS的结果缓存大小配置零则不缓存"
msgid "Dnsmasq Forwared To Smartdns Failure"
msgstr "重定向dnsmasq到smartdns失败"
msgid "Do not check certificate." msgid "Do not check certificate."
msgstr "不校验证书的合法性。" msgstr "不校验证书的合法性。"

View File

@@ -6,6 +6,9 @@ XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "smartdns", "stat
var links = ""; var links = "";
if (data.running) { if (data.running) {
links = '<b><font color=green>SmartDNS - <%:RUNNING%></font></b></em>'; links = '<b><font color=green>SmartDNS - <%:RUNNING%></font></b></em>';
if (data.dnsmasq_redirect_failure == 1) {
links += "<br></br><b><font color=red><%:Dnsmasq Forwared To Smartdns Failure%></font></b>"
}
} else { } else {
links = '<b><font color=red>SmartDNS - <%:NOT RUNNING%></font></b>'; links = '<b><font color=red>SmartDNS - <%:NOT RUNNING%></font></b>';
} }

View File

@@ -52,6 +52,9 @@ msgstr "协议类型"
msgid "DNS domain result cache size" msgid "DNS domain result cache size"
msgstr "缓存DNS的结果缓存大小配置零则不缓存" msgstr "缓存DNS的结果缓存大小配置零则不缓存"
msgid "Dnsmasq Forwared To Smartdns Failure"
msgstr "重定向dnsmasq到smartdns失败"
msgid "Do not check certificate." msgid "Do not check certificate."
msgstr "不校验证书的合法性。" msgstr "不校验证书的合法性。"

View File

@@ -54,6 +54,11 @@
var renderHTML = ""; var renderHTML = "";
var isRunning = res[0]; var isRunning = res[0];
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) { if (isRunning) {
renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>"; renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>";
} else { } else {
@@ -61,14 +66,23 @@
return renderHTML; return renderHTML;
} }
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>";
}
}
return renderHTML; return renderHTML;
} }
return view.extend({ return view.extend({
load: function () { load: function () {
return Promise.all([ return Promise.all([
uci.load('dhcp'),
uci.load('smartdns'), uci.load('smartdns'),
uci.load('dhcp')
]); ]);
}, },
render: function (stats) { render: function (stats) {
@@ -461,4 +475,3 @@
return m.render(); return m.render();
} }
}); });

View File

@@ -23,9 +23,9 @@ ifndef CFLAGS
CFLAGS =-O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough CFLAGS =-O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough
endif endif
override CFLAGS +=-Iinclude override CFLAGS +=-Iinclude
override CFLAGS += -DBASE_FILE_NAME=\"$(notdir $<)\" override CFLAGS += -DBASE_FILE_NAME='"$(notdir $<)"'
ifdef VER ifdef VER
override CFLAGS += -DSMARTDNS_VERION=\"$(VER)\" override CFLAGS += -DSMARTDNS_VERION='"$(VER)"'
endif endif
CXXFLAGS=-O2 -g -Wall -std=c++11 CXXFLAGS=-O2 -g -Wall -std=c++11