X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-app-shadowsocks-libev%2Fluasrc%2Fcontroller%2Fshadowsocks-libev.lua;h=05d12e38b25d198eebd3cae79241bce22029c29b;hp=ae968168f13585f4a963835bf48b22faefebd499;hb=06ad394dde572878c2a573e8ef81b94ae706b5d5;hpb=cfd8ad89c4afb46b6dab2529341c49fd7c091e22 diff --git a/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua b/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua index ae968168f..05d12e38b 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua +++ b/applications/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua @@ -1,12 +1,33 @@ --- Copyright 2015 Jian Chang +-- Copyright 2017 Yousong Zhou -- Licensed to the public under the Apache License 2.0. - +-- module("luci.controller.shadowsocks-libev", package.seeall) function index() - if not nixio.fs.access("/etc/config/shadowsocks-libev") then - return - end + entry({"admin", "services", "shadowsocks-libev"}, + alias("admin", "services", "shadowsocks-libev", "instances"), + _("Shadowsocks-libev"), 59) + + entry({"admin", "services", "shadowsocks-libev", "instances"}, + arcombine(cbi("shadowsocks-libev/instances"), cbi("shadowsocks-libev/instance-details")), + _("Local Instances"), 10).leaf = true + + entry({"admin", "services", "shadowsocks-libev", "servers"}, + cbi("shadowsocks-libev/servers"), + _("Remote Servers"), 20).leaf = true + + entry({"admin", "services", "shadowsocks-libev", "rules"}, + cbi("shadowsocks-libev/rules"), + _("Redir Rules"), 30).leaf = true + + entry({"admin", "services", "shadowsocks-libev", "status"}, call("ss_status"), nil).leaf = true + +end + +function ss_status() + local ut = require "luci.util" + local rv = ut.ubus("service", "list", {name = "shadowsocks-libev"})["shadowsocks-libev"] or {_=0} - entry({"admin", "services", "shadowsocks-libev"}, cbi("shadowsocks-libev"), _("ShadowSocks-libev"), 74).dependent = true + luci.http.prepare_content("application/json") + luci.http.write_json(rv) end