Merge pull request #1250 from dibdot/luci-app-travelmate
[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
28 if stype == "ss_server" then
29         ss.options_server(s, "general")
30         o = s:taboption("general", Value, "bind_address",
31                 translate("Bind address"),
32                 translate("The address ss-server will initiate connection from"))
33         o.datatype = "ipaddr"
34         o.placeholder = "0.0.0.0"
35         ss.values_ipaddr(o)
36         o = s:taboption("general", Value, "manager_address", translate("Manager address"))
37         o.datatype = "hostport"
38 else
39         ss.options_client(s, "general")
40         if stype == "ss_tunnel" then
41                 o = s:taboption("general", Value, "tunnel_address",
42                         translate("Tunnel address"),
43                         translate("The address ss-tunnel will forward traffic to"))
44                 o.datatype = "hostport"
45         end
46 end
47 ss.options_common(s, "advanced")
48
49 return m