Fixed transparent proxy setup in Squid 2.6
authorJamie Cameron <jcameron@webmin.com>
Mon, 16 Apr 2007 22:15:21 +0000 (22:15 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 16 Apr 2007 22:15:21 +0000 (22:15 +0000)
squid/CHANGELOG
squid/save_iptables.cgi

index 001d8c1..cf68ab7 100644 (file)
@@ -14,3 +14,5 @@ Added a form on the Clear and Rebuild Cache page for removing a single URL. This
 Added checkboxes and buttons for deleting multiple delay pools, refresh rules, other caches, proxy restrictions and ICP restrictions at once.
 ---- Changes since 1.290 ----
 Added support for Squid 2.6, including the new logformat and access_log directives for specifying multiple custom log files.
+---- Changes since 1.340 ----
+Fixed transparent proxy setup in Squid 2.6.
index 96e7adb..d530ade 100755 (executable)
@@ -65,12 +65,29 @@ else {
 if ($in{'enabled'}) {
        # Add appropriate httpd_accel directives
        &lock_file($config{'squid_conf'});
-       &save_directive($conf, "httpd_accel_port",
-                       [ { 'name' => 'httpd_accel_port',
-                           'values' => [ 80 ] } ]);
-       &save_directive($conf, "httpd_accel_host",
-                       [ { 'name' => 'httpd_accel_host',
-                           'values' => [ 'virtual' ] } ]);
+       if ($squid_version < 2.6) {
+               # Old directives
+               &save_directive($conf, "httpd_accel_port",
+                               [ { 'name' => 'httpd_accel_port',
+                                   'values' => [ 80 ] } ]);
+               &save_directive($conf, "httpd_accel_host",
+                               [ { 'name' => 'httpd_accel_host',
+                                   'values' => [ 'virtual' ] } ]);
+               }
+       else {
+               # In Squid 2.6, acceleration is a port option
+               @ports = &find_config("http_port", $conf);
+               foreach my $p (@ports) {
+                       local $trans = 0;
+                       foreach $v (@{$p->{'values'}}) {
+                               $trans++ if ($v eq "transparent");
+                               }
+                       if (!$trans) {
+                               push(@{$p->{'values'}}, "transparent");
+                               }
+                       }
+               &save_directive($conf, "http_port", \@ports);
+               }
        &flush_file_lines();
        &unlock_file($config{'squid_conf'});
        }