From 2866d3ae45fdea9e6066f523a1fb8ebdceba5e90 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 18 May 2011 11:57:21 -0400 Subject: Squid3 fixes from the forum. See http://forum.pfsense.org/index.php/topic,36806.msg190007.html#msg190007 --- config/squid3/squid.inc | 83 +++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/config/squid3/squid.inc b/config/squid3/squid.inc index 98192253..67eaecb6 100644 --- a/config/squid3/squid.inc +++ b/config/squid3/squid.inc @@ -4,7 +4,7 @@ squid.inc Copyright (C) 2006-2009 Scott Ullrich Copyright (C) 2006 Fernando Lemos - Copyright (C) 2008 Martin Fuchs + Copyright (C) 2008 Martin Fuchs All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,7 +36,7 @@ require_once('pfsense-utils.inc'); require_once('pkg-utils.inc'); require_once('service-utils.inc'); -if(!function_exists("filter_configure")) +if(!function_exists("filter_configure")) require_once("filter.inc"); define('SQUID_CONFBASE', '/usr/local/etc/squid'); @@ -188,9 +188,9 @@ function squid_install_command() { $config['installedpackages']['squidnac']['config'][0]['blacklist'] = $settingsnac['blacklist']; } } - + update_status("Writing configuration... One moment please..."); - + write_config(); /* create cache */ @@ -347,7 +347,7 @@ function squid_validate_general($post, $input_errors) { if (($post['transparent_proxy'] != 'on') && ($post['private_subnet_proxy_off'] == 'on')) { $input_errors[] = "You can not bypass traffic to private subnets without using the transparent proxy."; } - + if (($post['transparent_proxy'] != 'on') && !empty($post['defined_ip_proxy_off'])) { $input_errors[] = "You can not bypass traffic from specific IPs without using the transparent proxy."; } @@ -421,10 +421,10 @@ function squid_validate_cache($post, $input_errors) { $input_errors[] = 'You must enter a valid value for \'Low-water-mark\''; } - if (!empty($post['cache_swap_high'])) { + if (!empty($post['cache_swap_high'])) { $value = trim($post['cache_swap_high']); if (!is_numeric($value) || ($value > 100)) - $input_errors[] = 'You must enter a valid value for \'High-water-mark\''; + $input_errors[] = 'You must enter a valid value for \'High-water-mark\''; } if ($post['donotcache'] != "") { @@ -489,23 +489,23 @@ function squid_validate_traffic($post, $input_errors) { $input_errors[] = "The field '$name' must contain a positive number"; } - if (!empty($post['quick_abort_min'])) { + if (!empty($post['quick_abort_min'])) { $value = trim($post['quick_abort_min']); if (!is_numeric($value)) - $input_errors[] = "The field 'Finish when remaining KB' must contain a positive number"; - } - - if (!empty($post['quick_abort_max'])) { + $input_errors[] = "The field 'Finish when remaining KB' must contain a positive number"; + } + + if (!empty($post['quick_abort_max'])) { $value = trim($post['quick_abort_max']); if (!is_numeric($value)) - $input_errors[] = "The field 'Abort when remaining KB' must contain a positive number"; - } - - if (!empty($post['quick_abort_pct'])) { + $input_errors[] = "The field 'Abort when remaining KB' must contain a positive number"; + } + + if (!empty($post['quick_abort_pct'])) { $value = trim($post['quick_abort_pct']); if (!is_numeric($value) || ($value > 100)) - $input_errors[] = "The field 'Finish when remaining %' must contain a percentaged value"; - } + $input_errors[] = "The field 'Finish when remaining %' must contain a percentaged value"; + } } @@ -563,7 +563,7 @@ function squid_validate_auth($post, $input_errors) { function squid_install_cron($should_install) { global $config, $g; - if($g['booting']==true) + if($g['booting']==true) return; $is_installed = false; if(!$config['cron']['item']) @@ -587,7 +587,7 @@ function squid_install_cron($should_install) { $cron_item['month'] = "*"; $cron_item['wday'] = "*"; $cron_item['who'] = "root"; - $cron_item['command'] = "/usr/local/sbin/squid -k rotate"; + $cron_item['command'] = "/usr/local/sbin/squid -k rotate"; $config['cron']['item'][] = $cron_item; parse_config(true); write_config("Squid Log Rotation"); @@ -674,6 +674,7 @@ EOD; foreach ($real_ifaces as $iface) { list($ip, $mask) = $iface; $ip = long2ip(ip2long($ip) & ip2long($mask)); + $mask = 32-log((ip2long($mask) ^ ip2long('255.255.255.255'))+1,2); $src .= " $ip/$mask"; } $conf .= "# Allow local network(s) on interface(s)\n"; @@ -694,7 +695,7 @@ EOD; } // $conf .= "\n"; //Kill blank line after DNS-Servers } - + return $conf; } @@ -754,7 +755,7 @@ EOD; elseif (file_exists(SQUID_ACLDIR . '/donotcache.acl')) { unlink(SQUID_ACLDIR . '/donotcache.acl'); } - + return $conf; } @@ -768,7 +769,7 @@ function squid_resync_upstream() { if ($settings['icp_port'] == '7') $conf .= "{$settings['icp_port']} no-query"; else - $conf .= "{$settings['icp_port']}"; + $conf .= "{$settings['icp_port']}"; if (!empty($settings['username'])) $conf .= " login={$settings['username']}"; @@ -797,14 +798,16 @@ function squid_resync_nac() { $port = ($settings['proxy_port'] ? $settings['proxy_port'] : 3128); $settings = $config['installedpackages']['squidnac']['config'][0]; $webgui_port = $config['system']['webgui']['port']; + $addtl_ports = $settings['addtl_ports']; + $addtl_sslports = $settings['addtl_sslports']; $conf = <<