luci-app-shadowsocks-libev: update package
[project/luci.git] / applications / luci-app-shadowsocks-libev / luasrc / model / cbi / shadowsocks-libev.lua
1 -- Copyright 2015 Jian Chang <aa65535@live.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local m, s, o, e, a
5
6 if luci.sys.call("pidof ss-redir >/dev/null") == 0 then
7         m = Map("shadowsocks-libev", translate("ShadowSocks-libev"), translate("ShadowSocks-libev is running"))
8 else
9         m = Map("shadowsocks-libev", translate("ShadowSocks-libev"), translate("ShadowSocks-libev is not running"))
10 end
11
12 e = {
13         "table",
14         "rc4",
15         "rc4-md5",
16         "aes-128-cfb",
17         "aes-192-cfb",
18         "aes-256-cfb",
19         "bf-cfb",
20         "camellia-128-cfb",
21         "camellia-192-cfb",
22         "camellia-256-cfb",
23         "cast5-cfb",
24         "des-cfb",
25         "idea-cfb",
26         "rc2-cfb",
27         "seed-cfb",
28         "salsa20",
29         "chacha20",
30 }
31
32 -- Global Setting
33 s = m:section(TypedSection, "shadowsocks-libev", translate("Global Setting"))
34 s.anonymous = true
35
36 o = s:option(Flag, "enable", translate("Enable"))
37 o.default = 1
38 o.rmempty = false
39
40 o = s:option(Value, "server", translate("Server Address"))
41 o.datatype = "ipaddr"
42 o.rmempty = false
43
44 o = s:option(Value, "server_port", translate("Server Port"))
45 o.datatype = "port"
46 o.rmempty = false
47
48 o = s:option(Value, "local_port", translate("Local Port"))
49 o.datatype = "port"
50 o.default = 1080
51 o.rmempty = false
52
53 o = s:option(Value, "timeout", translate("Connection Timeout"))
54 o.datatype = "uinteger"
55 o.default = 60
56 o.rmempty = false
57
58 o = s:option(Value, "password", translate("Password"))
59 o.password = true
60 o.rmempty = false
61
62 o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
63 for i,v in ipairs(e) do
64         o:value(v)
65 end
66 o.rmempty = false
67
68 o = s:option(Value, "ignore_list", translate("Ignore List"))
69 o:value("/dev/null", translate("Disabled"))
70 o.default = "/dev/null"
71 o.rmempty = false
72
73 -- UDP Relay
74 s = m:section(TypedSection, "shadowsocks-libev", translate("UDP Relay"))
75 s.anonymous = true
76
77 o = s:option(ListValue, "udp_mode", translate("Relay Mode"))
78 o:value("0", translate("Disabled"))
79 o:value("1", translate("Enabled"))
80 o:value("2", translate("Custom"))
81 o.default = 0
82 o.rmempty = false
83
84 o = s:option(Value, "udp_server", translate("Server Address"))
85 o.datatype = "ipaddr"
86 o:depends("udp_mode", 2)
87
88 o = s:option(Value, "udp_server_port", translate("Server Port"))
89 o.datatype = "port"
90 o:depends("udp_mode", 2)
91
92 o = s:option(Value, "udp_local_port", translate("Local Port"))
93 o.datatype = "port"
94 o.default = 1081
95 o:depends("udp_mode", 2)
96
97 o = s:option(Value, "udp_timeout", translate("Connection Timeout"))
98 o.datatype = "uinteger"
99 o.default = 60
100 o:depends("udp_mode", 2)
101
102 o = s:option(Value, "udp_password", translate("Password"))
103 o.password = true
104 o:depends("udp_mode", 2)
105
106 o = s:option(ListValue, "udp_encrypt_method", translate("Encrypt Method"))
107 for i,v in ipairs(e) do
108         o:value(v)
109 end
110 o:depends("udp_mode", 2)
111
112 -- UDP Forward
113 s = m:section(TypedSection, "shadowsocks-libev", translate("UDP Forward"))
114 s.anonymous = true
115
116 o = s:option(Flag, "tunnel_enable", translate("Enable"))
117 o.default = 1
118 o.rmempty = false
119
120 o = s:option(Value, "tunnel_port", translate("UDP Local Port"))
121 o.datatype = "port"
122 o.default = 5300
123
124 o = s:option(Value, "tunnel_forward", translate("Forwarding Tunnel"))
125 o.default = "8.8.4.4:53"
126
127 -- Access Control
128 s = m:section(TypedSection, "shadowsocks-libev", translate("Access Control"))
129 s.anonymous = true
130
131 s:tab("lan_ac", translate("LAN"))
132
133 o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("Access Control"))
134 o:value("0", translate("Disabled"))
135 o:value("1", translate("Allow listed only"))
136 o:value("2", translate("Allow all except listed"))
137 o.default = 0
138 o.rmempty = false
139
140 a = luci.sys.net.arptable() or {}
141
142 o = s:taboption("lan_ac", DynamicList, "lan_ac_ip", translate("LAN IP List"))
143 o.datatype = "ipaddr"
144 for i,v in ipairs(a) do
145         o:value(v["IP address"])
146 end
147
148 s:tab("wan_ac", translate("WAN"))
149
150 o = s:taboption("wan_ac", DynamicList, "wan_bp_ip", translate("Bypassed IP"))
151 o.datatype = "ip4addr"
152
153 o = s:taboption("wan_ac", DynamicList, "wan_fw_ip", translate("Forwarded IP"))
154 o.datatype = "ip4addr"
155
156 return m