From 9340615d38caf1a5926cc50fc2b0cd606083b78b Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Wed, 23 May 2018 22:53:06 +0800 Subject: [PATCH] using new style for luci ssr pro --- package/lean/luci-app-ssr-pro/Makefile | 2 +- .../luasrc/controller/ssrpro.lua | 8 +++++++ .../luasrc/model/cbi/ssrpro.lua | 17 ++------------ .../luasrc/view/ssrpro/ssrpro_status.htm | 22 +++++++++++++++++++ 4 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 package/lean/luci-app-ssr-pro/luasrc/view/ssrpro/ssrpro_status.htm diff --git a/package/lean/luci-app-ssr-pro/Makefile b/package/lean/luci-app-ssr-pro/Makefile index 108210d34..343c6f744 100644 --- a/package/lean/luci-app-ssr-pro/Makefile +++ b/package/lean/luci-app-ssr-pro/Makefile @@ -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 diff --git a/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua b/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua index 324c266a4..94e882d90 100644 --- a/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua +++ b/package/lean/luci-app-ssr-pro/luasrc/controller/ssrpro.lua @@ -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 diff --git a/package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua b/package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua index dfbca61e1..cff95b232 100644 --- a/package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua +++ b/package/lean/luci-app-ssr-pro/luasrc/model/cbi/ssrpro.lua @@ -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("ShadowsocksR is Running") -else - Status = translate("ShadowsocksR is Not Running") -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

", 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 diff --git a/package/lean/luci-app-ssr-pro/luasrc/view/ssrpro/ssrpro_status.htm b/package/lean/luci-app-ssr-pro/luasrc/view/ssrpro/ssrpro_status.htm new file mode 100644 index 000000000..c42cfccca --- /dev/null +++ b/package/lean/luci-app-ssr-pro/luasrc/view/ssrpro/ssrpro_status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+