📄 edit_cache_host.cgi
字号:
#!/usr/local/bin/perl# edit_cache_host.cgi# Display a form for editing or creating a cache_host linerequire './squid-lib.pl';&ReadParse();$conf = &get_config();$cache_host = $squid_version >= 2 ? "cache_peer" : "cache_host";if ($in{'new'}) { &header("Create Cache Host", "", undef, 0, 0, 0, &restart_button()); }else { &header("Edit Cache Host", "", undef, 0, 0, 0, &restart_button()); @chl = &find_config($cache_host, $conf); @ch = @{$chl[$in{'num'}]->{'values'}}; for($i=4; $i<@ch; $i++) { if ($ch[$i] =~ /^(\S+)=(\S+)$/) { $opts{$1} = $2; } else { $opts{$ch[$i]} = 1; } } }print "<hr>\n";print "<form action=save_cache_host.cgi>\n";if ($in{'new'}) { print "<input type=hidden name=new value=1>\n"; }else { print "<input type=hidden name=num value=$in{'num'}>\n"; }print "<table border width=100%>\n";print "<tr $tb> <td><b>Cache Host Options</b></td> </tr>\n";print "<tr $cb> <td><table width=100%>\n";print "<tr> <td><b>Hostname</b></td>\n";print "<td><input name=host size=20 value=\"$ch[0]\"></td>\n";print "<td><b>Type</b></td>\n";print "<td><select name=type>\n";foreach $t ("parent", "sibling", "multicast") { printf "<option value=$t %s>$t\n", $t eq $ch[1] ? "selected" : ""; }print "</select></td> </tr>\n";print "<tr> <td><b>Proxy port</b></td>\n";print "<td><input name=proxy size=6 value=\"$ch[2]\"></td>\n";print "<td><b>ICP port</b></td>\n";print "<td><input name=icp size=6 value=\"$ch[3]\"></td> </tr>\n";print "<tr> <td><b>Proxy only?</b></td>\n";printf "<td><input type=radio name=proxy-only value=1 %s> Yes\n", $opts{'proxy-only'} ? "checked" : "";printf "<input type=radio name=proxy-only value=0 %s> No</td>\n", $opts{'proxy-only'} ? "" : "checked";print "<td><b>Send ICP queries?</b></td>\n";printf "<td><input type=radio name=no-query value=0 %s> Yes\n", $opts{'no-query'} ? "" : "checked";printf "<input type=radio name=no-query value=1 %s> No</td> </tr>\n", $opts{'no-query'} ? "checked" : "";print "<tr> <td><b>Default cache?</b></td>\n";printf "<td><input type=radio name=default value=1 %s> Yes\n", $opts{'default'} ? "checked" : "";printf "<input type=radio name=default value=0 %s> No</td>\n", $opts{'default'} ? "" : "checked";print "<td><b>Round-robin cache?</b></td>\n";printf "<td><input type=radio name=round-robin value=1 %s> Yes\n", $opts{'round-robin'} ? "checked" : "";printf "<input type=radio name=round-robin value=0 %s> No</td> </tr>\n", $opts{'round-robin'} ? "" : "checked";print "<tr> <td><b>ICP time-to-live</b></td>\n";printf "<td><input type=radio name=ttl_def value=1 %s> Default\n", $opts{'ttl'} ? "" : "checked";printf "<input type=radio name=ttl_def value=0 %s>\n", $opts{'ttl'} ? "checked" : "";print "<input name=ttl size=6 value=\"$opts{'ttl'}\"></td>\n";print "<td><b>Cache weighting</b></td>\n";printf "<td><input type=radio name=weight_def value=1 %s> Default\n", $opts{'weight'} ? "" : "checked";printf "<input type=radio name=weight_def value=0 %s>\n", $opts{'weight'} ? "checked" : "";print "<input name=weight size=6 value=\"$opts{'weight'}\"></td> </tr>\n";if ($squid_version >= 2) { print "<tr> <td><b>Closest only?</b></td>\n"; printf "<td><input type=radio name=closest-only value=1 %s> Yes\n", $opts{'closest-only'} ? "checked" : ""; printf "<input type=radio name=closest-only value=0 %s> No</td>\n", $opts{'closest-only'} ? "" : "checked"; print "<td><b>No digest?</b></td>\n"; printf "<td><input type=radio name=no-digest value=1 %s> Yes\n", $opts{'no-digest'} ? "checked" : ""; printf "<input type=radio name=no-digest value=0 %s> No</td> </tr>\n", $opts{'no-digest'} ? "" : "checked"; print "<tr> <td><b>No NetDB exchange?</b></td>\n"; printf "<td><input type=radio name=no-netdb-exchange value=1 %s> Yes\n", $opts{'no-netdb-exchange'} ? "checked" : ""; printf "<input type=radio name=no-netdb-exchange value=0 %s> No</td>\n", $opts{'no-netdb-exchange'} ? "" : "checked"; print "<td><b>No delay?</b></td>\n"; printf "<td><input type=radio name=no-delay value=1 %s> Yes\n", $opts{'no-delay'} ? "checked" : ""; printf "<input type=radio name=no-delay value=0 %s> No</td> </tr>\n", $opts{'no-delay'} ? "" : "checked"; if ($squid_version >= 2.1) { print "<td><b>Login to proxy</b></td> <td colspan=3>\n"; printf "<input type=radio name=login value=0 %s> No login\n", $opts{'login'} ? "" : "checked"; printf "<input type=radio name=login value=1 %s>\n", $opts{'login'} ? "checked" : ""; local ($user, $pass) = split(/:/, $opts{'login'}); print "User: <input name=login_user size=15 value=\"$user\">\n"; print "Pass: <input name=login_pass size=15 value=\"$pass\">\n"; print "</td> </tr>\n"; } }print "<tr> <td><b>Multicast responder?</b></td>\n";printf "<td><input type=radio name=multicast-responder value=1 %s> Yes\n", $opts{'multicast-responder'} ? "checked" : "";printf "<input type=radio name=multicast-responder value=0 %s> No</td>\n", $opts{'multicast-responder'} ? "" : "checked";print "</tr>\n";if (!$in{'new'}) { @chd = &find_config($cache_host."_domain", $conf); foreach $chd (@chd) { @chdv = @{$chd->{'values'}}; if ($chdv[0] eq $ch[0]) { # found a record for this host.. for($i=1; $i<@chdv; $i++) { if ($chdv[$i] =~ /^\!(\S+)$/) { push(@dontq, $1); } else { push(@doq, $chdv[$i]); } } } } }print "<tr> <td valign=top><b>Query host for domains</b></td>\n";print "<td><textarea name=doq rows=3 cols=15>",join("\n", @doq), "</textarea></td>\n";print "<td valign=top><b>Don't query for domains</b></td>\n";print "<td><textarea name=dontq rows=3 cols=15>",join("\n", @dontq), "</textarea></td> </tr>\n";print "</table></td></tr></table>\n";print "<table width=100%><tr>\n";print "<td><input type=submit value=Save></td> <td align=right>\n";if (!$in{'new'}) { print "<input type=submit value=Delete name=delete>\n"; }print "</td></tr></table>\n";print "</form>\n";print "<hr>\n";&footer("edit_icp.cgi", "cache list");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -