Add status of process
This commit is contained in:
@@ -8,7 +8,18 @@ function index()
|
||||
end
|
||||
|
||||
local page
|
||||
|
||||
page = entry({"admin", "services", "smartdns"}, cbi("smartdns"), _("SmartDNS"), 60)
|
||||
page.dependent = true
|
||||
page = entry({"admin", "services", "smartdns", "status"}, call("act_status"))
|
||||
page.leaf = true
|
||||
end
|
||||
|
||||
local function is_running()
|
||||
return luci.sys.call("pidof smartdns >/dev/null") == 0
|
||||
end
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running = is_running()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
@@ -4,6 +4,15 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
msgid "SmartDNS"
|
||||
msgstr "SmartDNS"
|
||||
|
||||
msgid "SmartDNS is a local high-performance DNS server"
|
||||
msgstr "SmartDNS是一个本地高性能DNS服务器"
|
||||
|
||||
msgid "SmartDNS Server"
|
||||
msgstr "SmartDNS 服务器"
|
||||
|
||||
msgid "SmartDNS is a local high-performance DNS server, supports finding fastest IP, supports ad filtering, and supports avoiding DNS poisoning."
|
||||
msgstr "SmartDNS是一个本地高性能DNS服务器,支持避免域名污染,支持返回最快IP,支持广告过滤。"
|
||||
|
||||
msgid "Server Name"
|
||||
msgstr "服务器名称"
|
||||
|
||||
@@ -22,8 +31,8 @@ msgstr "SmartDNS本地服务端口"
|
||||
msgid "Redirect"
|
||||
msgstr "重定向"
|
||||
|
||||
msgid "Redirect standard dns query from 53 to smartdns"
|
||||
msgstr "将53端口的DNS请求重定向到SmartDNS"
|
||||
msgid "Redirect standard dns query from 53 to smartdns, as default DNS server"
|
||||
msgstr "将53端口的DNS请求重定向到SmartDNS, 替换默认DNS服务"
|
||||
|
||||
msgid "Cache Size"
|
||||
msgstr "缓存大小"
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
-- Copyright 2018 Nick Peng (pymumu@gmail.com)
|
||||
|
||||
require("nixio.fs")
|
||||
require("luci.http")
|
||||
require ("nixio.fs")
|
||||
require ("luci.http")
|
||||
require ("luci.dispatcher")
|
||||
require ("nixio.fs")
|
||||
|
||||
m = Map("smartdns", translate("SmartDNS"),
|
||||
translate("SmartDNS is a local dns server to find fastest ip."))
|
||||
m = Map("smartdns")
|
||||
m.title = translate("SmartDNS Server")
|
||||
m.description = translate("SmartDNS is a local high-performance DNS server, supports finding fastest IP, supports ad filtering, and supports avoiding DNS poisoning.")
|
||||
|
||||
if luci.sys.call("pidof smartdns >/dev/null") == 0 then
|
||||
m = Map("smartdns", translate("SmartDNS"), "%s - %s" %{translate("SmartDNS"), translate("RUNNING")})
|
||||
else
|
||||
m = Map("smartdns", translate("SmartDNS"), "%s - %s" %{translate("SmartDNS"), translate("NOT RUNNING")})
|
||||
end
|
||||
m:section(SimpleSection).template = "smartdns/smartdns_status"
|
||||
|
||||
-- Basic
|
||||
s = m:section(TypedSection, "smartdns", translate("Settings"), translate("General Settings"))
|
||||
@@ -18,6 +17,7 @@ s.anonymous = true
|
||||
|
||||
---- Eanble
|
||||
o = s:option(Flag, "enabled", translate("Enable"), translate("Enable or disable smartdns server"))
|
||||
o.default = o.disabled
|
||||
o.rempty = false
|
||||
|
||||
---- server name
|
||||
@@ -33,10 +33,12 @@ o.default = 5353
|
||||
o.datatype = "port"
|
||||
o.rempty = false
|
||||
|
||||
o = s:option(Flag, "redirect", translate("Redirect"), translate("Redirect standard dns query from 53 to smartdns"))
|
||||
o.default = true
|
||||
o.placeholder = "1"
|
||||
o.rempty = false
|
||||
o = s:option(Flag, "redirect", translate("Redirect"), translate("Redirect standard dns query from 53 to smartdns, as default DNS server"))
|
||||
o.rmempty = false
|
||||
o.default = o.enabled
|
||||
o.cfgvalue = function(...)
|
||||
return Flag.cfgvalue(...) or "1"
|
||||
end
|
||||
|
||||
---- cache-size
|
||||
o = s:option(Value, "cache_size", translate("Cache Size"), translate("DNS domain result cache size"))
|
||||
|
||||
22
package/luci/files/luci/view/smartdns/smartdns_status.htm
Normal file
22
package/luci/files/luci/view/smartdns/smartdns_status.htm
Normal file
@@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "smartdns", "status")%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('smartdns_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<b><font color=green>SmartDNS - <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<b><font color=red>SmartDNS - <%:NOT RUNNING%></font></b>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="smartdns_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user