Rework LuCI build system
[project/luci.git] / applications / luci-app-tinyproxy / luasrc / model / cbi / tinyproxy.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 m = Map("tinyproxy", translate("Tinyproxy"),
17         translate("Tinyproxy is a small and fast non-caching HTTP(S)-Proxy"))
18
19 s = m:section(TypedSection, "tinyproxy", translate("Server Settings"))
20 s.anonymous = true
21
22 s:tab("general", translate("General settings"))
23 s:tab("privacy", translate("Privacy settings"))
24 s:tab("filter", translate("Filtering and ACLs"))
25 s:tab("limits", translate("Server limits"))
26
27
28 o = s:taboption("general", Flag, "enabled", translate("Enable Tinyproxy server"))
29 o.rmempty = false
30
31 function o.write(self, section, value)
32         if value == "1" then
33                 luci.sys.init.enable("tinyproxy")
34         else
35                 luci.sys.init.disable("tinyproxy")
36         end
37
38         return Flag.write(self, section, value)
39 end
40
41
42 o = s:taboption("general", Value, "Port", translate("Listen port"),
43         translate("Specifies the HTTP port Tinyproxy is listening on for requests"))
44
45 o.optional = true
46 o.datatype = "port"
47 o.placeholder = 8888
48
49
50 o = s:taboption("general", Value, "Listen", translate("Listen address"),
51         translate("Specifies the addresses Tinyproxy is listening on for requests"))
52
53 o.optional = true
54 o.datatype = "ipaddr"
55 o.placeholder = "0.0.0.0"
56
57
58 o = s:taboption("general", Value, "Bind", translate("Bind address"),
59         translate("Specifies the address Tinyproxy binds to for outbound forwarded requests"))
60
61 o.optional = true
62 o.datatype = "ipaddr"
63 o.placeholder = "0.0.0.0"
64
65
66 o = s:taboption("general", Value, "DefaultErrorFile", translate("Error page"),
67         translate("HTML template file to serve when HTTP errors occur"))
68
69 o.optional = true
70 o.default = "/usr/share/tinyproxy/default.html"
71
72
73 o = s:taboption("general", Value, "StatFile", translate("Statistics page"),
74         translate("HTML template file to serve for stat host requests"))
75
76 o.optional = true
77 o.default = "/usr/share/tinyproxy/stats.html"
78
79
80 o = s:taboption("general", Flag, "Syslog", translate("Use syslog"),
81         translate("Writes log messages to syslog instead of a log file"))
82
83
84 o = s:taboption("general", Value, "LogFile", translate("Log file"),
85         translate("Log file to use for dumping messages"))
86
87 o.default = "/var/log/tinyproxy.log"
88 o:depends("Syslog", "")
89
90
91 o = s:taboption("general", ListValue, "LogLevel", translate("Log level"),
92         translate("Logging verbosity of the Tinyproxy process"))
93
94 o:value("Critical")
95 o:value("Error")
96 o:value("Warning")
97 o:value("Notice")
98 o:value("Connect")
99 o:value("Info")
100
101
102 o = s:taboption("general", Value, "User", translate("User"),
103         translate("Specifies the user name the Tinyproxy process is running as"))
104
105 o.default = "nobody"
106
107
108 o = s:taboption("general", Value, "Group", translate("Group"),
109         translate("Specifies the group name the Tinyproxy process is running as"))
110
111 o.default = "nogroup"
112
113
114 --
115 -- Privacy
116 --
117
118 o = s:taboption("privacy", Flag, "XTinyproxy", translate("X-Tinyproxy header"),
119         translate("Adds an \"X-Tinyproxy\" HTTP header with the client IP address to forwarded requests"))
120
121
122 o = s:taboption("privacy", Value, "ViaProxyName", translate("Via hostname"),
123         translate("Specifies the Tinyproxy hostname to use in the Via HTTP header"))
124
125 o.placeholder = "tinyproxy"
126 o.datatype = "hostname"
127
128
129 s:taboption("privacy", DynamicList, "Anonymous", translate("Header whitelist"),
130         translate("Specifies HTTP header names which are allowed to pass-through, all others are discarded. Leave empty to disable header filtering"))
131
132
133 --
134 -- Filter
135 --
136
137 o = s:taboption("filter", DynamicList, "Allow", translate("Allowed clients"),
138         translate("List of IP addresses or ranges which are allowed to use the proxy server"))
139
140 o.placeholder = "0.0.0.0"
141 o.datatype = "ipaddr"
142
143
144 o = s:taboption("filter", DynamicList, "ConnectPort", translate("Allowed connect ports"),
145         translate("List of allowed ports for the CONNECT method. A single value \"0\" allows all ports"))
146
147 o.placeholder = 0
148 o.datatype = "port"
149
150
151 s:taboption("filter", FileUpload, "Filter", translate("Filter file"),
152         translate("Plaintext file with URLs or domains to filter. One entry per line"))
153
154
155 s:taboption("filter", Flag, "FilterURLs", translate("Filter by URLs"),
156         translate("By default, filtering is done based on domain names. Enable this to match against URLs instead"))
157
158
159 s:taboption("filter", Flag, "FilterExtended", translate("Filter by RegExp"),
160         translate("By default, basic POSIX expressions are used for filtering. Enable this to activate extended regular expressions"))
161
162
163  s:taboption("filter", Flag, "FilterCaseSensitive", translate("Filter case-sensitive"),
164         translate("By default, filter strings are treated as case-insensitive. Enable this to make the matching case-sensitive"))
165
166
167 s:taboption("filter", Flag, "FilterDefaultDeny", translate("Default deny"),
168         translate("By default, the filter rules act as blacklist. Enable this option to only allow matched URLs or domain names"))
169
170
171 --
172 -- Limits
173 --
174
175 o = s:taboption("limits", Value, "Timeout", translate("Connection timeout"),
176         translate("Maximum number of seconds an inactive connection is held open"))
177
178 o.optional = true
179 o.datatype = "uinteger"
180 o.default = 600
181
182
183 o = s:taboption("limits", Value, "MaxClients", translate("Max. clients"),
184         translate("Maximum allowed number of concurrently connected clients"))
185
186 o.datatype = "uinteger"
187 o.default = 10
188
189
190 o = s:taboption("limits", Value, "MinSpareServers", translate("Min. spare servers"),
191         translate("Minimum number of prepared idle processes"))
192
193 o.datatype = "uinteger"
194 o.default = 5
195
196
197 o = s:taboption("limits", Value, "MaxSpareServers", translate("Max. spare servers"),
198         translate("Maximum number of prepared idle processes"))
199
200 o.datatype = "uinteger"
201 o.default = 10
202
203
204 o = s:taboption("limits", Value, "StartServers", translate("Start spare servers"),
205         translate("Number of idle processes to start when launching Tinyproxy"))
206
207 o.datatype = "uinteger"
208 o.default = 5
209
210
211 o = s:taboption("limits", Value, "MaxRequestsPerChild", translate("Max. requests per server"),
212         translate("Maximum allowed number of requests per process. If it is exeeded, the process is restarted. Zero means unlimited."))
213
214 o.datatype = "uinteger"
215 o.default = 0
216
217
218 --
219 -- Upstream
220 --
221
222 s = m:section(TypedSection, "upstream", translate("Upstream Proxies"),
223         translate("Upstream proxy rules define proxy servers to use when accessing certain IP addresses or domains."))
224
225 s.anonymous = true
226 s.addremove = true
227
228
229 t = s:option(ListValue, "type", translate("Policy"),
230         translate("<em>Via proxy</em> routes requests to the given target via the specifed upstream proxy, <em>Reject access</em> disables any upstream proxy for the target"))
231
232 t:value("proxy", translate("Via proxy"))
233 t:value("reject", translate("Reject access"))
234
235
236 ta = s:option(Value, "target", translate("Target host"),
237         translate("Can be either an IP address or range, a domain name or \".\" for any host without domain"))
238
239 ta.rmempty = true
240 ta.placeholder = "0.0.0.0/0"
241 ta.datatype = "host"
242
243
244 v = s:option(Value, "via", translate("Via proxy"),
245         translate("Specifies the upstream proxy to use for accessing the target host. Format is <code>address:port</code>"))
246
247 v:depends({type="proxy"})
248 v.placeholder = "10.0.0.1:8080"
249
250 return m