shadowsocks-libev.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. -- Copyright 2017 Yousong Zhou <yszhou4tech@gmail.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. --
  4. module("luci.controller.shadowsocks-libev", package.seeall)
  5. function index()
  6. entry({"admin", "services", "shadowsocks-libev"},
  7. alias("admin", "services", "shadowsocks-libev", "instances"),
  8. _("Shadowsocks-libev"), 59)
  9. entry({"admin", "services", "shadowsocks-libev", "instances"},
  10. arcombine(cbi("shadowsocks-libev/instances"), cbi("shadowsocks-libev/instance-details")),
  11. _("Local Instances"), 10).leaf = true
  12. entry({"admin", "services", "shadowsocks-libev", "servers"},
  13. cbi("shadowsocks-libev/servers"),
  14. _("Remote Servers"), 20).leaf = true
  15. entry({"admin", "services", "shadowsocks-libev", "rules"},
  16. cbi("shadowsocks-libev/rules"),
  17. _("Redir Rules"), 30).leaf = true
  18. entry({"admin", "services", "shadowsocks-libev", "status"}, call("ss_status"), nil).leaf = true
  19. end
  20. function ss_status()
  21. local ut = require "luci.util"
  22. local rv = ut.ubus("service", "list", {name = "shadowsocks-libev"})["shadowsocks-libev"] or {_=0}
  23. luci.http.prepare_content("application/json")
  24. luci.http.write_json(rv)
  25. end