From b66b824e736511af5c206bc1d0adcf6b78c4d173 Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Mon, 18 Dec 2006 21:40:54 +0000 Subject: Well poke me with a stick and set me on fire! Hurrah! Please Test --- packages/squid.inc | 121 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 40 deletions(-) (limited to 'packages/squid.inc') diff --git a/packages/squid.inc b/packages/squid.inc index 6a7a4396..7264e5e5 100644 --- a/packages/squid.inc +++ b/packages/squid.inc @@ -94,13 +94,9 @@ function squid_install_command() { $rc['file'] = 'squid.sh'; $rc['start'] = '/usr/local/sbin/squid -D'; $rc['stop'] = <</dev/null -sleep 1 -killall squid 2>/dev/null +sleep 5 killall -9 squid 2>/dev/null killall pinger 2>/dev/null @@ -166,9 +162,20 @@ function squid_before_form_general($pkg) { } function squid_validate_general($post, $input_errors) { + global $config; $icp_port = trim($post['icp_port']); if (!empty($icp_port) && !is_port($icp_port)) $input_errors[] = 'You must enter a valid port number in the \'ICP port\' field'; + if (($post['transparent_proxy'] == 'on')) { + $port = 80; + } else { + $port = trim($post['proxy_port']); + } + $webgui_port = $config['system']['webgui']['port']; + + if ($port == $webgui_port) { + $input_errors[] = "You can not run squid on the same port as the webgui"; + } } function squid_validate_upstream($post, $input_errors) { @@ -208,11 +215,14 @@ function squid_validate_cache($post, $input_errors) { if (!is_numeric($value) || ($value < 0)) $input_errors[] = 'You must enter a valid value for \'Minimum object size\''; - foreach (explode(',', $post['donotcache']) as $host) { - $host = trim($host); - if (!is_ipaddr($host) && !is_domain($host)) - $input_errors[] = "$host is not a valid IP or host name"; + if ($post['donotcache'] != "") { + foreach (explode(',', $post['donotcache']) as $host) { + $host = trim($host); + if (!is_ipaddr($host) && !is_domain($host)) + $input_errors[] = "The host '$host' is not a valid IP or host name"; + } } + } function squid_validate_nac($post, $input_errors) { @@ -220,14 +230,14 @@ function squid_validate_nac($post, $input_errors) { foreach ($allowed_subnets as $subnet) { $subnet = trim($subnet); if (!empty($subnet) && !is_subnet($subnet)) - $input_errors[] = "'$subnet' is not a valid CIDR range"; + $input_errors[] = "The subnet '$subnet' is not a valid CIDR range"; } foreach (array( 'unrestricted_hosts', 'banned_hosts') as $hosts) { foreach (explode(',', $post[$hosts]) as $host) { $host = trim($host); if (!empty($host) && !is_ipaddr($host)) - $input_errors[] = "'$host' is not a valid IP address"; + $input_errors[] = "The host '$host' is not a valid IP address"; } } @@ -235,14 +245,14 @@ function squid_validate_nac($post, $input_errors) { foreach (explode(',', $post[$macs]) as $mac) { $mac = trim($mac); if (!empty($mac) && !is_macaddr($mac)) - $input_errors[] = "'$mac' is not a valid MAC address"; + $input_errors[] = "The mac '$mac' is not a valid MAC address"; } } foreach (explode(',', $post['timelist']) as $time) { $time = trim($time); if (!empty($time) && !squid_is_timerange($time)) - $input_errors[] = "'$time' is not a valid time range"; + $input_errors[] = "The time range '$time' is not a valid time range"; } } @@ -297,7 +307,7 @@ function squid_validate_auth($post, $input_errors) { case 'msnt': foreach (explode(trim($post['msnt_secondary'])) as $server) { if (!empty($server) && !is_ipaddr($server) && !is_domain($server)) - $input_errors[] = "'$server' isn't a valid IP address or domain name"; + $input_errors[] = "The host '$server' is not a valid IP address or domain name"; } break; } @@ -306,7 +316,7 @@ function squid_validate_auth($post, $input_errors) { foreach ($no_auth as $host) { $host = trim($host); if (!empty($host) && !is_subnet($host)) - $input_errors[] = "'$host' isn't a valid CIDR range"; + $input_errors[] = "The host '$host' is not a valid CIDR range"; } } } @@ -317,23 +327,18 @@ function squid_resync_general() { $settings = $config['installedpackages']['squid']['config'][0]; $conf = ''; - if ($settings['transparent_proxy'] == 'on') { - $conf .= << $iface) { $real_ifaces[] = squid_get_real_interface_address($iface); if($real_ifaces[$i][0]) - $conf .= "http_port {$real_ifaces[$i][0]}:$port\n"; + $conf .= "http_port {$real_ifaces[$i][0]}"; + if (($settings['transparent_proxy'] == 'on')) { + $conf .= ":80 transparent\n"; + } else { + $conf .= ":$port\n"; + } } $icp_port = ($settings['icp_port'] ? $settings['icp_port'] : 0); @@ -360,6 +365,7 @@ cache_mgr $email cache_access_log $logdir_access cache_log $logdir_cache cache_store_log none +shutdown_lifetime 3 seconds EOD; @@ -372,6 +378,14 @@ EOD; } $conf .= "acl localnet src $src\n"; $valid_acls[] = 'localnet'; + $conf .= <<