#!/usr/local/bin/perl # edit_cache_host.cgi # Display a form for editing or creating a cache_host line require './squid-lib.pl'; $access{'othercaches'} || &error($text{'eicp_ecannot'}); &ReadParse(); $conf = &get_config(); $cache_host = $squid_version >= 2 ? "cache_peer" : "cache_host"; if ($in{'new'}) { &ui_print_header(undef, $text{'ech_header'}, "", undef, 0, 0, 0, &restart_button()); } else { &ui_print_header(undef, $text{'ech_header1'}, "", 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 "
\n"; if ($in{'new'}) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "
$text{'ech_cho'}
\n"; print "\n"; print "\n"; %ts = ( "parent"=> $text{"ech_parent"}, "sibling"=>$text{"ech_sibling"}, "multicast"=>$text{"ech_multicast"} ); print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; printf "\n", $opts{'proxy-only'} ? "" : "checked"; print "\n"; printf "\n", $opts{'no-query'} ? "checked" : ""; print "\n"; printf "\n", $opts{'default'} ? "" : "checked"; print "\n"; printf "\n", $opts{'round-robin'} ? "" : "checked"; print "\n"; printf "\n"; print "\n"; printf "\n"; if ($squid_version >= 2) { print "\n"; printf "\n", $opts{'closest-only'} ? "" : "checked"; print "\n"; printf "\n", $opts{'no-digest'} ? "" : "checked"; print "\n"; printf "\n", $opts{'no-netdb-exchange'} ? "" : "checked"; print "\n"; printf "\n", $opts{'no-delay'} ? "" : "checked"; } if ($squid_version >= 2.1) { local $mode = $opts{'login'} eq 'PASS' ? 2 : $opts{'login'} =~ /^\*:\S+$/ ? 3 : $opts{'login'} ? 1 : 0; local @up = split(/:/, $opts{'login'}); print "\n"; print "\n"; } if ($squid_version >= 2.6) { print "\n"; printf "\n"; print "\n"; printf "\n"; print "\n"; printf "\n", $opts{'allow-miss'} ? "" : "checked"; print "\n"; printf "\n"; print "\n"; printf "\n", $opts{'htcp'} ? "" : "checked"; print "\n"; printf "\n"; print "\n"; printf "\n", $opts{'originserver'} ? "" : "checked"; print "\n"; printf "\n", $opts{'ssl'} ? "" : "checked"; } print "\n"; printf "\n", $opts{'multicast-responder'} ? "" : "checked"; print "\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 "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'ech_h'}$text{'ech_t'}
$text{'ech_pp'}$text{'ech_ip'}
$text{'ech_po'} $text{'ech_y'}\n", $opts{'proxy-only'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_siq'} $text{'ech_y'}\n", $opts{'no-query'} ? "" : "checked"; printf " $text{'ech_n'}
$text{'ech_dc'} $text{'ech_y'}\n", $opts{'default'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_rrc'} $text{'ech_y'}\n", $opts{'round-robin'} ? "checked" : ""; printf " $text{'ech_n'}
$text{'ech_ittl'} $text{'ech_d'}\n", $opts{'ttl'} ? "" : "checked"; printf "\n", $opts{'ttl'} ? "checked" : ""; print "$text{'ech_cw'} $text{'ech_d'}\n", $opts{'weight'} ? "" : "checked"; printf "\n", $opts{'weight'} ? "checked" : ""; print "
$text{'ech_co'} $text{'ech_y'}\n", $opts{'closest-only'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_nd'} $text{'ech_y'}\n", $opts{'no-digest'} ? "checked" : ""; printf " $text{'ech_n'}
$text{'ech_nne'} $text{'ech_y'}\n", $opts{'no-netdb-exchange'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_nd1'} $text{'ech_y'}\n", $opts{'no-delay'} ? "checked" : ""; printf " $text{'ech_n'}
$text{'ech_ltp'}\n"; printf " $text{'ech_nl'}
\n", $mode == 0 ? "checked" : ""; printf "\n", $mode == 1 ? "checked" : ""; printf "$text{'ech_u'} \n", $mode == 1 ? $up[0] : ""; printf "$text{'ech_p'}
\n", $mode == 1 ? $up[1] : ""; if ($squid_version >= 2.5 || $mode > 1) { printf " %s
\n", $mode == 2 ? "checked" : "", $text{'ech_pass'}; printf " %s\n", $mode == 3 ? "checked" : "", $text{'ech_upass'}; printf "\n", $mode == 3 ? $up[1] : ""; } print "
$text{'ech_timeo'} $text{'ech_d'}\n", $opts{'connect-timeout'} ? "" : "checked"; printf "\n", $opts{'connect-timeout'} ? "checked" : ""; print "$text{'ech_digest'} $text{'ech_d'}\n", $opts{'digest-url'} ? "" : "checked"; printf "\n", $opts{'digest-url'} ? "checked" : ""; print "
$text{'ech_miss'} $text{'ech_y'}\n", $opts{'allow-miss'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_maxconn'} $text{'ech_d'}\n", $opts{'max-conn'} ? "" : "checked"; printf "\n", $opts{'max-conn'} ? "checked" : ""; print "
$text{'ech_htcp'} $text{'ech_y'}\n", $opts{'htcp'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_force'} %s\n", $opts{'forceddomain'} ? "" : "checked", $text{'ech_same'}; printf "\n", $opts{'forceddomain'} ? "checked" : ""; print "
$text{'ech_origin'} $text{'ech_y'}\n", $opts{'originserver'} ? "checked" : ""; printf " $text{'ech_n'}$text{'ech_ssl'} $text{'ech_y'}\n", $opts{'ssl'} ? "checked" : ""; printf " $text{'ech_n'}
$text{'ech_mr'} $text{'ech_y'}\n", $opts{'multicast-responder'} ? "checked" : ""; printf " $text{'ech_n'}
$text{'ech_qhfd'}$text{'ech_dqfd'}
\n"; print "\n"; print "
\n"; if (!$in{'new'}) { print "\n"; } print "
\n"; print "
\n"; &ui_print_footer("edit_icp.cgi", $text{'ech_return'}, "", $text{'index_return'});