From c7b1432ce5e49d061a182df0b09db5de36d787f5 Mon Sep 17 00:00:00 2001 From: Marcello Coutinho Date: Sun, 22 Apr 2012 04:11:38 +0000 Subject: squid3 - version 2.0.5 with transparent proxy fix and integration with captive portal for non transparent use. --- config/squid-reverse/squid.inc | 37 +++++- config/squid-reverse/squid.xml | 11 +- config/squid-reverse/squid_monitor.php | 167 ++++++++++++++++++++++++++++ config/squid-reverse/squid_monitor_data.php | 136 ++++++++++++++++++++++ 4 files changed, 349 insertions(+), 2 deletions(-) create mode 100644 config/squid-reverse/squid_monitor.php create mode 100644 config/squid-reverse/squid_monitor_data.php (limited to 'config/squid-reverse') diff --git a/config/squid-reverse/squid.inc b/config/squid-reverse/squid.inc index db3aafca..70127510 100644 --- a/config/squid-reverse/squid.inc +++ b/config/squid-reverse/squid.inc @@ -1525,7 +1525,42 @@ function squid_generate_rules($type) { global $config; $squid_conf = $config['installedpackages']['squid']['config'][0]; - + + //check captive portal option + $cp_file='/etc/inc/captiveportal.inc'; + $pfsense_version=preg_replace("/\s/","",file_get_contents("/etc/version")); + $port = ($settings['proxy_port'] ? $settings['proxy_port'] : 3128); + $cp_inc = file($cp_file); + $new_cp_inc=""; + $found_rule=0; + foreach ($cp_inc as $line){ + $new_line=$line; + //remove applied squid patch + if (preg_match('/} set 1 skipto 65314/',$line)){ + $found_rule++; + $new_line =""; + } + //add squid patch option based on current config + if (preg_match('/set 1 pass ip from any to/',$line) && $squid_conf['patch_cp']){ + $found_rule++; + $new_line = "\t".'$cprules .= "add {$rulenum} set 1 skipto 65314 ip from any to {$ips} '.$port.' in\n";'."\n"; + $new_line .= $line; + } + if (preg_match('/set 1 pass ip from {/',$line) && $squid_conf['patch_cp']){ + $found_rule++; + $new_line = "\t".'$cprules .= "add {$rulenum} set 1 skipto 65314 ip from {$ips} '.$port.' to any out\n";'."\n"; + $new_line .= $line; + } + $new_cp_inc .= $new_line; + } + if (!file_exists('/root/'.$pfsense_version.'.captiveportal.inc.backup')) { + copy ($cp_file,'/root/'.$pfsense_version.'.captiveportal.inc.backup'); + } + if($found_rule > 0){ + file_put_contents($cp_file,$new_cp_inc, LOCK_EX); + } + + //normal squid rule check if (($squid_conf['transparent_proxy'] != 'on') || ($squid_conf['allow_interface'] != 'on')) { return; } diff --git a/config/squid-reverse/squid.xml b/config/squid-reverse/squid.xml index 981c256c..764011ea 100644 --- a/config/squid-reverse/squid.xml +++ b/config/squid-reverse/squid.xml @@ -236,11 +236,20 @@ Transparent proxy transparent_proxy - If transparent mode is enabled, all requests for destination port 80 will be forwarded to the proxy server without any additional configuration necessary. + + NOTE: Transparent mode does not filter ssl(port 443) or any other http/https port.
+ To filter both http and https protocol without touching user config, enable WPAD/PAC options on your dns/dhcp.]]>
checkbox private_subnet_proxy_off,defined_ip_proxy_off,defined_ip_proxy_off_dest
+ + Patch captive portal + patch_cp + + NOTE: You may need to reapply captive portal config after changing this option.]]> + checkbox + Bypass proxy for Private Address Space (RFC 1918) destination private_subnet_proxy_off diff --git a/config/squid-reverse/squid_monitor.php b/config/squid-reverse/squid_monitor.php new file mode 100644 index 00000000..cbcc8918 --- /dev/null +++ b/config/squid-reverse/squid_monitor.php @@ -0,0 +1,167 @@ + + + + + + +

+ + + + + + + + + + + + +
+
+
+
+ + + + + + + + + +
+ +
+ + + +
+ +
+ + + +
+
+
+ +
+ + + + + + + + + + + + + +
+
+ Squid Proxy +
+
+ + +
+
+
+ SquidGuard +
+
+ + +
+
+
+
+
+ + + + + + diff --git a/config/squid-reverse/squid_monitor_data.php b/config/squid-reverse/squid_monitor_data.php new file mode 100644 index 00000000..46280446 --- /dev/null +++ b/config/squid-reverse/squid_monitor_data.php @@ -0,0 +1,136 @@ +"; + echo "Date"; + echo "IP"; + echo "Status"; + echo "Address"; + echo "User"; + echo "Destination"; + echo ""; + + // Get Data from form post + $lines = $_POST['maxlines']; + $filter = $_POST['strfilter']; + + if ($filter != "") { + $exprfilter = "| grep -i $filter"; + } else { + $exprfilter = ""; + } + + // TODO FIX: + // Remove the hard link (maybe, get from config) + // + exec("tail -r -n $lines /var/squid/logs/access.log $exprfilter",$logarr); + + foreach ($logarr as $logent) { + $logline = preg_split("/\s+/", $logent); + + if ($filter != "") + $logline = preg_replace("/$filter/","$filter",$logline); + + echo "\n"; + echo "".date("d/m/y H:i:s",$logline[0])."\n"; + echo "".$logline[2]."\n"; + echo "".$logline[3]."\n"; + echo "".$logline[6]."\n"; + echo "".$logline[7]."\n"; + echo "".$logline[8]."\n"; + echo "\n"; + } +} + +// Show SquidGuard Logs +function showSGuard() { + + + echo ""; + echo "Date"; + echo "Hour"; + echo "ACL"; + echo "Address"; + echo "Host"; + echo "User"; + echo ""; + + + // Get Data from form post + $lines = $_POST['maxlines']; + $filter = $_POST['strfilter']; + + if ($filter != "") { + $exprfilter = "| grep -i $filter"; + } else { + $exprfilter = ""; + } + + // TODO FIX: + // Remove the hard link (maybe, get from config) + // + exec("tail -r -n $lines /var/squidGuard/log/block.log $exprfilter",$logarr); + + foreach ($logarr as $logent) { + $logline = preg_split("/\s+/", $logent); + + if ($filter != "") + $logline = preg_replace("/$filter/","$filter",$logline); + + echo "\n"; + echo "".$logline[0]."\n"; + echo "".$logline[1]."\n"; + echo "".$logline[3]."\n"; + echo "".$logline[4]."\n"; + echo "".$logline[5]."\n"; + echo "".$logline[6]."\n"; + echo "\n"; + } +} + +?> -- cgit v1.2.3