Merge pull request #425 from aa65535/master
[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 -- Global Setting
13 s = m:section(TypedSection, "shadowsocks-libev", translate("Global Setting"))
14 s.anonymous = true
15
16 o = s:option(Flag, "enable", translate("Enable"))
17 o.default = 1
18 o.rmempty = false
19
20 o = s:option(Value, "server", translate("Server Address"))
21 o.datatype = "host"
22 o.rmempty = false
23
24 o = s:option(Value, "server_port", translate("Server Port"))
25 o.datatype = "port"
26 o.rmempty = false
27
28 o = s:option(Value, "local_port", translate("Local Port"))
29 o.datatype = "port"
30 o.default = 1080
31 o.rmempty = false
32
33 o = s:option(Value, "timeout", translate("Connection Timeout"))
34 o.datatype = "uinteger"
35 o.default = 60
36 o.rmempty = false
37
38 o = s:option(Value, "password", translate("Password"))
39 o.password = true
40 o.rmempty = false
41
42 e = {
43         "table",
44         "rc4",
45         "rc4-md5",
46         "aes-128-cfb",
47         "aes-192-cfb",
48         "aes-256-cfb",
49         "bf-cfb",
50         "camellia-128-cfb",
51         "camellia-192-cfb",
52         "camellia-256-cfb",
53         "cast5-cfb",
54         "des-cfb",
55         "idea-cfb",
56         "rc2-cfb",
57         "seed-cfb",
58         "salsa20",
59         "chacha20",
60 }
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 -- Proxy Setting
69 s = m:section(TypedSection, "shadowsocks-libev", translate("Proxy Setting"))
70 s.anonymous = true
71
72 o = s:option(ListValue, "udp_relay", translate("Proxy Protocol"))
73 o:value("0", translate("TCP only"))
74 o:value("1", translate("TCP+UDP"))
75 o.default = 1
76 o.rmempty = false
77
78 o = s:option(Value, "ignore_list", translate("Ignore List"))
79 o:value("/dev/null", translate("Disabled"))
80 o.default = "/dev/null"
81 o.rmempty = false
82
83 -- UDP Forward
84 s = m:section(TypedSection, "shadowsocks-libev", translate("UDP Forward"))
85 s.anonymous = true
86
87 o = s:option(Flag, "tunnel_enable", translate("Enable"))
88 o.default = 1
89 o.rmempty = false
90
91 o = s:option(Value, "tunnel_port", translate("UDP Local Port"))
92 o.datatype = "port"
93 o.default = 5300
94
95 o = s:option(Value, "tunnel_forward", translate("Forwarding Tunnel"))
96 o.default = "8.8.4.4:53"
97
98 -- Access Control
99 s = m:section(TypedSection, "shadowsocks-libev", translate("Access Control"))
100 s.anonymous = true
101
102 s:tab("lan_ac", translate("LAN"))
103
104 o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("Access Control"))
105 o:value("0", translate("Disabled"))
106 o:value("1", translate("Allow listed only"))
107 o:value("2", translate("Allow all except listed"))
108 o.default = 0
109 o.rmempty = false
110
111 a = luci.sys.net.arptable() or {}
112
113 o = s:taboption("lan_ac", DynamicList, "lan_ac_ip", translate("LAN IP List"))
114 o.datatype = "ipaddr"
115 for i,v in ipairs(a) do
116         o:value(v["IP address"])
117 end
118
119 s:tab("wan_ac", translate("WAN"))
120
121 o = s:taboption("wan_ac", DynamicList, "wan_bp_ip", translate("Bypassed IP"))
122 o.datatype = "ip4addr"
123
124 o = s:taboption("wan_ac", DynamicList, "wan_fw_ip", translate("Forwarded IP"))
125 o.datatype = "ip4addr"
126
127 return m