using new style for luci ssr pro

This commit is contained in:
coolsnowwolf 2018-05-23 22:53:06 +08:00
parent 715088d014
commit 9340615d38
4 changed files with 33 additions and 16 deletions

View File

@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for SSR Pro
LUCI_DEPENDS:=+iptables-mod-tproxy +kmod-ipt-tproxy +ip +ipset-lists +shadowsocksr-libev-alt +pdnsd-alt +coreutils +coreutils-base64 +coreutils-nohup +dnsmasq-full
LUCI_PKGARCH:=all
PKG_VERSION:=2
PKG_RELEASE:=22
PKG_RELEASE:=23
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -6,4 +6,12 @@ function index()
local page
page = entry({"admin", "services", "ssrpro"}, cbi("ssrpro"), _("ShadowsocksR Pro"))
page.dependent = true
entry({"admin","services","ssrpro","status"},call("act_status")).leaf=true
end
function act_status()
local e={}
e.running=luci.sys.call("pgrep ssr-redir >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -8,21 +8,14 @@ local conf = "/etc/shadowsocksr/base-gfwlist.txt"
local watch = "/tmp/shadowsocksr_watchdog.log"
local dog = "/tmp/ssrpro.log"
local Status
if SYS.call("pidof ssr-redir > /dev/null") == 0 then
Status = translate("<strong><font color=\"green\">ShadowsocksR is Running</font></strong>")
else
Status = translate("<strong><font color=\"red\">ShadowsocksR is Not Running</font></strong>")
end
m = Map("ssrpro")
m.title = translate("Shadowsocksr Transparent Proxy")
m.description = translate("A fast secure tunnel proxy that help you get through firewalls on your router")
m:section(SimpleSection).template = "ssrpro/ssrpro_status"
s = m:section(TypedSection, "ssrpro")
s.anonymous = true
s.description = translate(string.format("%s<br /><br />", Status))
-- ---------------------------------------------------
@ -222,10 +215,4 @@ e:value("disable",translate("No Proxy"))
e:value("global",translate("Global Proxy"))
e:value("game",translate("Game Mode"))
-- ---------------------------------------------------
-- local apply = luci.http.formvalue("cbi.apply")
-- if apply then
-- os.execute("/etc/init.d/ssrpro restart >/dev/null 2>&1 &")
-- end
return m

View File

@ -0,0 +1,22 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[ssrpro]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('ssrpro_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>ShadowsocksR Pro<%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>ShadowsocksR Pro<%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="ssrpro_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>