From 6b553ad36fbfafe9b4f1ea3b42f3798ccc406187 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Thu, 18 Sep 2008 21:55:47 +0000 Subject: squid: add possibility to exempt IPs from transparent squid --- packages/squid3/squid.inc | 28 ++++++++++++++++++++++++++++ packages/squid3/squid.xml | 7 +++++++ 2 files changed, 35 insertions(+) (limited to 'packages/squid3') diff --git a/packages/squid3/squid.inc b/packages/squid3/squid.inc index 3c42f92e..1f3b5f7e 100644 --- a/packages/squid3/squid.inc +++ b/packages/squid3/squid.inc @@ -317,6 +317,18 @@ 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."; + } + + foreach (array('defined_ip_proxy_off') as $hosts) { + foreach (explode(";", $post[$hosts]) as $host) { + $host = trim($host); + if (!empty($host) && !is_ipaddr($host)) + $input_errors[] = "The entry '$host' is not a valid IP address"; + } + } if(!empty($post['dns_nameservers'])) { $altdns = explode(";", ($post['dns_nameservers'])); @@ -1214,6 +1226,22 @@ function squid_generate_rules($type) { $rules .= "no rdr on $iface proto tcp from any to { 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 } port 80\n"; } } + + if (!empty($squid_conf['defined_ip_proxy_off'])) { + $defined_ip_proxy_off = explode(";", $config['installedpackages']['squid']['config'][0]['defined_ip_proxy_off']); + $exempt_ip = ""; + foreach ($defined_ip_proxy_off as $ip_proxy_off) { + if(!empty($ip_proxy_off)) { + $ip_proxy_off = trim($ip_proxy_off); + $exempt_ip .= ", $ip_proxy_off"; + } + } + $exempt_ip = substr($exempt_ip,2); + foreach ($ifaces as $iface){ + $rules .= "no rdr on $iface proto tcp from { $exempt_ip } to any port 80\n"; + } + } + foreach ($ifaces as $iface){ $rules .= "rdr on $iface proto tcp from any to !($iface) port 80 -> 127.0.0.1 port 80\n"; }; diff --git a/packages/squid3/squid.xml b/packages/squid3/squid.xml index 5e0acf9b..8529526e 100644 --- a/packages/squid3/squid.xml +++ b/packages/squid3/squid.xml @@ -174,6 +174,13 @@ Do not forward traffic to Private Address Space (RFC 1918) <b>destination</b> through the proxy server. checkbox + + Do NOT proxy these IPs + defined_ip_proxy_off + Do not forward traffic from these <b>source</b> IPs through the proxy server. Separate by semi-colons (;). + input + 80 + Enabled logging log_enabled -- cgit v1.2.3