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