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