3 # A form for editing cache options
5 require './squid-lib.pl';
6 $access{'copts'} || &error($text{'ec_ecannot'});
7 &ui_print_header(undef, $text{'ec_header'}, "", "edit_cache", 0, 0, 0, &restart_button());
10 print "<form action=save_cache.cgi>\n";
11 print "<table border width=100%>\n";
12 print "<tr $tb> <td><b>$text{'ec_cro'}</b></td> </tr>\n";
13 print "<tr $cb> <td><table width=100%>\n";
16 @dirs = &find_config("cache_dir", $conf);
17 print "<td valign=top><b>$text{'ec_cdirs'}</b></td> <td colspan=3>\n";
18 printf "<input type=radio name=cache_dir_def value=1 %s> $text{'ec_default'} ($config{'cache_dir'})\n",
19 @dirs ? "" : "checked";
20 printf "<input type=radio name=cache_dir_def value=0 %s> $text{'ec_listed'}<br>\n",
21 @dirs ? "checked" : "";
22 print "<table border>\n";
23 if ($squid_version >= 2) {
24 print "<tr $tb> <td><b>$text{'ec_directory'}</b></td>\n";
25 if ($squid_version >= 2.3) {
26 print "<td><b>$text{'ec_type'}</b></td>\n";
28 print "<td><b>$text{'ec_size'}</b></td>\n";
29 print "<td><b>$text{'ec_1dirs'}</b></td>\n";
30 print "<td><b>$text{'ec_2dirs'}</b></td>\n";
31 if ($squid_version >= 2.4) {
32 print "<td><b>$text{'ec_opts'}</b></td>\n";
36 for($i=0; $i<=@dirs; $i++) {
37 @dv = $i<@dirs ? @{$dirs[$i]->{'values'}} : ();
39 if ($squid_version >= 2.4) {
40 print "<td><input name=cache_dir_$i size=30 ",
41 "value=\"$dv[1]\"></td>\n";
42 print "<td><select name=cache_type_$i>\n";
43 printf "<option value=ufs %s>$text{'ec_u'}\n",
44 $dv[0] eq 'ufs' ? 'selected' : '';
45 printf "<option value=diskd %s>$text{'ec_diskd'}\n",
46 $dv[0] eq 'diskd' ? 'selected' : '';
47 printf "<option value=aufs %s>$text{'ec_ua'}\n",
48 $dv[0] eq 'aufs' ? 'selected' : '';
49 printf "<option value=coss %s>$text{'ec_coss'}\n",
50 $dv[0] eq 'coss' ? 'selected' : '';
51 print "</select></td>\n";
52 print "<td><input name=cache_size_$i size=8 ",
53 "value=\"$dv[2]\"></td>\n";
54 print "<td><input name=cache_lv1_$i size=8 ",
55 "value=\"$dv[3]\"></td>\n";
56 print "<td><input name=cache_lv2_$i size=8 ",
57 "value=\"$dv[4]\"></td>\n";
58 print "<td><input name=cache_opts_$i size=10 ",
59 "value=\"",join(" ",@dv[5..$#dv]),"\"></td>\n";
61 elsif ($squid_version >= 2.3) {
62 print "<td><input name=cache_dir_$i size=30 ",
63 "value=\"$dv[1]\"></td>\n";
64 print "<td><select name=cache_type_$i>\n";
65 printf "<option value=ufs %s>$text{'ec_u'}\n",
66 $dv[0] eq 'ufs' ? 'selected' : '';
67 printf "<option value=asyncufs %s>$text{'ec_ua'}\n",
68 $dv[0] eq 'asyncufs' ? 'selected' : '';
69 print "</select></td>\n";
70 print "<td><input name=cache_size_$i size=8 ",
71 "value=\"$dv[2]\"></td>\n";
72 print "<td><input name=cache_lv1_$i size=8 ",
73 "value=\"$dv[3]\"></td>\n";
74 print "<td><input name=cache_lv2_$i size=8 ",
75 "value=\"$dv[4]\"></td>\n";
77 elsif ($squid_version >= 2) {
78 print "<td><input name=cache_dir_$i size=30 ",
79 "value=\"$dv[0]\"></td>\n";
80 print "<td><input name=cache_size_$i size=8 ",
81 "value=\"$dv[1]\"></td>\n";
82 print "<td><input name=cache_lv1_$i size=8 ",
83 "value=\"$dv[2]\"></td>\n";
84 print "<td><input name=cache_lv2_$i size=8 ",
85 "value=\"$dv[3]\"></td>\n";
88 print "<td><input name=cache_dir_$i size=30 ",
89 "value=\"$dv[0]\"></td>\n";
93 print "</table></td> </tr>\n";
94 print "<tr> <td colspan=4><hr></td> </tr>\n";
96 if ($squid_version < 2) {
98 print &opt_input($text{'ec_1dirs1'}, "swap_level1_dirs", $conf,
99 $text{'ec_default'}, 6);
100 print &opt_input($text{'ec_2dirs2'}, "swap_level2_dirs", $conf,
101 $text{'ec_default'}, 6);
106 if ($squid_version < 2) {
107 print &opt_input($text{'ec_aos'}, "store_avg_object_size", $conf,
108 $text{'ec_default'}, 6, $text{'ec_kb'});
111 print &opt_bytes_input($text{'ec_aos'}, "store_avg_object_size",
112 $conf, $text{'ec_default'}, 6);
114 print &opt_input($text{'ec_opb'}, "store_objects_per_bucket", $conf,
115 $text{'ec_default'}, 6);
118 if ($squid_version < 2) {
120 print &list_input($text{'ec_ncuc'}, "cache_stoplist",
121 $conf, 1, $text{'ec_default'});
125 print &list_input($text{'ec_ncum'}, "cache_stoplist_pattern",
126 $conf, 1, $text{'ec_default'});
131 print "<tr> <td valign=top><b>$text{'ec_ncua'}</b></td> <td>\n";
133 @acls = grep { !$acldone{$_->{'values'}->[0]}++ } &find_config("acl", $conf);
134 unshift(@acls, { 'values' => [ 'all' ] }) if ($squid_version >= 3);
135 if ($squid_version >= 2.6) {
136 # 2.6+ plus uses "cache deny"
137 @v = &find_config("cache", $conf);
140 # Older versions use cache
141 @v = &find_config("no_cache", $conf);
144 foreach $ncv (@{$v->{'values'}}) {
149 foreach $acl (@acls) {
150 print "<tr>\n" if ($i%3 == 0);
151 $aclv = $acl->{'values'}->[0];
152 printf "<td nowrap><input type=checkbox name=no_cache value=$aclv %s>$aclv</td>\n",
153 $noca{$aclv} ? "checked" : "";
154 print "</tr>\n" if ($i++%3 == 2);
156 print "</table></td>\n";
158 print &opt_time_input($text{'ec_mct'}, "reference_age", $conf,
159 $text{'default'}, 6);
163 if ($squid_version >= 2) {
164 if ($squid_version >= 2.3) {
165 print &opt_bytes_input($text{'ec_mrbs'},
166 "request_body_max_size", $conf, $text{'default'}, 6);
167 print &opt_bytes_input($text{'ec_mrhs'},
168 "request_header_max_size", $conf, $text{'default'}, 6);
172 if ($squid_version < 2.5) {
173 print &opt_bytes_input($text{'ec_mrbs1'},
174 "reply_body_max_size", $conf, $text{'default'}, 6);
177 print &opt_bytes_input($text{'ec_gap'},
178 "read_ahead_gap", $conf, $text{'default'}, 6);
182 print &opt_bytes_input($text{'ec_mrs'}, "request_size",
183 $conf, $text{'default'}, 6);
185 print &opt_time_input($text{'ec_frct'},
186 "negative_ttl", $conf, $text{'default'}, 4);
189 print &opt_input($text{'ec_mrs'}, "request_size", $conf,
190 $text{'default'}, 8, $text{'ec_kb'});
191 print &opt_input($text{'ec_frct'}, "negative_ttl", $conf,
192 $text{'default'}, 4, $text{'ec_mins'});
196 if ($squid_version >= 2.5) {
197 # Max reply size can be limited by ACL
199 print "<td valign=top><b>$text{'ec_maxreplies'}</b></td>\n";
200 print "<td colspan=3><table border>\n";
201 print "<tr $tb> <td><b>$text{'ec_maxrn'}</b></td> ",
202 "<td><b>$text{'ec_maxracls'}</b></td> </tr>\n";
203 @maxrs = &find_config("reply_body_max_size", $conf);
205 foreach $m (@maxrs, { }) {
206 local ($s, @a) = @{$m->{'values'}};
208 printf "<td><input name=reply_body_max_size_%d size=8 value='%s'></td>\n",
210 printf "<td><input name=reply_body_max_acls_%d size=50 value='%s'></td>\n",
215 print "</table></tr>\n";
219 if ($squid_version < 2) {
220 print &opt_input($text{'ec_dlct'}, "positive_dns_ttl", $conf,
221 $text{'default'}, 4, $text{'ec_mins'});
222 print &opt_input($text{'ec_fdct'}, "negative_dns_ttl", $conf,
223 $text{'default'}, 4, $text{'ec_mins'});
226 print &opt_time_input($text{'ec_dlct'}, "positive_dns_ttl",
227 $conf, $text{'default'}, 4);
228 print &opt_time_input($text{'ec_fdct'}, "negative_dns_ttl",
229 $conf, $text{'default'}, 4);
233 if ($squid_version < 2) {
235 print &opt_input($text{'ec_ct'}, "connect_timeout", $conf,
236 $text{'default'}, 4, $text{'ec_secs'});
237 print &opt_input($text{'ec_rt'}, "read_timeout", $conf,
238 $text{'default'}, 4, $text{'ec_secs'});
242 print &opt_input($text{'ec_mcct'}, "client_lifetime", $conf,
243 $text{'default'}, 4, $text{'ec_mins'});
244 print &opt_input($text{'ec_mst'}, "shutdown_lifetime", $conf,
245 $text{'default'}, 4, $text{'ec_mins'});
250 print &opt_time_input($text{'ec_ct'}, "connect_timeout", $conf,
251 $text{'default'}, 4);
252 print &opt_time_input($text{'ec_rt'}, "read_timeout", $conf,
253 $text{'default'}, 4);
257 print &opt_time_input($text{'ec_sst'}, "siteselect_timeout",
258 $conf, $text{'default'}, 4);
259 print &opt_time_input($text{'ec_crt'}, "request_timeout",
260 $conf, $text{'default'}, 4);
264 print &opt_time_input($text{'ec_mcct'}, "client_lifetime",
265 $conf, $text{'default'}, 4);
266 print &opt_time_input($text{'ec_mst'}, "shutdown_lifetime",
267 $conf, $text{'default'}, 4);
271 print &choice_input($text{'ec_hcc'}, "half_closed_clients",
272 $conf, "on", $text{'on'},"on", $text{'off'},"off");
273 print &opt_time_input($text{'ec_pt'}, "pconn_timeout",
274 $conf, $text{'default'}, 4);
278 if ($squid_version < 2) {
279 print "<tr> <td><b>$text{'ec_wr'}</b></td> <td colspan=3>\n";
280 $v = &find_config("wais_relay", $conf);
281 printf "<input type=radio name=wais_relay_def value=1 %s> $text{'none'}\n",
283 printf "<input type=radio name=wais_relay_def value=0 %s> $text{'ec_host'}\n",
285 @wrv = $v ? @{$v->{'values'}} : ();
286 print "<input size=20 name=wais_relay1 value=\"$wrv[0]\"> $text{'ec_port'}\n";
287 print "<input size=6 name=wais_relay2 value=\"$wrv[1]\"></td>\n";
292 print &opt_input($text{'ec_wrh'}, "wais_relay_host",
293 $conf, $text{'none'}, 20);
294 print &opt_input($text{'ec_wrp'}, "wais_relay_port",
295 $conf, $text{'default'}, 6);
299 print "</table></td></tr></table>\n";
300 print "<input type=submit value=$text{'buttsave'}></form>\n";
302 &ui_print_footer("", $text{'ec_return'});