instance-details.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. -- Copyright 2017 Yousong Zhou <yszhou4tech@gmail.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local ds = require "luci.dispatcher"
  4. local ss = require "luci.model.shadowsocks-libev"
  5. local sname = arg[1]
  6. local redirect_url = ds.build_url("admin/services/shadowsocks-libev/instances")
  7. local s, o
  8. local m = Map("shadowsocks-libev")
  9. local sdata = m:get(sname)
  10. if not sdata then
  11. luci.http.redirect(redirect_url)
  12. return
  13. end
  14. local stype = sdata[".type"]
  15. m.redirect = redirect_url
  16. m.title = "shadowsocks-libev - %s - %s" % {stype, sname}
  17. s = m:section(NamedSection, sname, stype)
  18. s:tab("general", translate("General Settings"))
  19. s:tab("advanced", translate("Advanced Settings"))
  20. s:taboption("general", Flag, "disabled", translate("Disable"))
  21. ss.option_install_package(s, "general")
  22. ss.options_common(s, "advanced")
  23. if stype == "ss_server" then
  24. ss.options_server(s, "general")
  25. o = s:taboption("general", Value, "bind_address",
  26. translate("Bind address"),
  27. translate("The address ss-server will initiate connection from"))
  28. o.datatype = "ipaddr"
  29. o.placeholder = "0.0.0.0"
  30. ss.values_ipaddr(o)
  31. o = s:taboption("general", Value, "manager_address", translate("Manager address"))
  32. o.datatype = "hostport"
  33. else
  34. ss.options_client(s, "general")
  35. if stype == "ss_tunnel" then
  36. o = s:taboption("general", Value, "tunnel_address",
  37. translate("Tunnel address"),
  38. translate("The address ss-tunnel will forward traffic to"))
  39. o.datatype = "hostport"
  40. elseif stype == "ss_redir" then
  41. o = s:taboption("advanced", Flag, "disable_sni",
  42. translate("Disable SNI"),
  43. translate("Disable parsing HTTP/HTTPS payload to find then resolve hostname at remote server"))
  44. end
  45. end
  46. return m