Bug#302499: adzapper: please support Apache2 as well

2005-04-07 Thread Johannes Berg
On Thu, 2005-04-07 at 21:52 +1000, Cameron Simpson wrote:

> I like this patch, with one small change. I would like $NO_CHANGE_VALUE
> to be $ZAP_NO_CHANGE to reduce the likelihood of name conflict by making
> it more "adzapper specific". I'll be applying it, using $ZAP_NO_CHANGE,
> to the master adzapper source.

Sure. I actually thought about that but I have to admit that after it
was working I was too lazy. Sorry about that. Ludovic, do you want a new
patch for the debian specific files?

> Johannes, thanks for the code!

Thanks for incorporating it :)

johannes

PS: You might have accidentally opened a new bug by replying to my email
which was CC'ed to [EMAIL PROTECTED], but I suppose since this mail
had no pseudo-headers you'd have gotten an error. If you did get an
error please just ignore it, if not then you can let me know the bug
number and I'll instruct the bug tracking system to close the other bug
or merge with this one. I've changed the CC on this mail to the correct
one, sorry for the trouble and the double mail that went to you, I
shouldn't have CC'ed you on the bug submission but relied on debbugs to
mail you after creating the bug.


signature.asc
Description: This is a digitally signed message part


Bug#302499: adzapper: please support Apache2 as well

2005-03-31 Thread Johannes Berg
Package: adzapper
Version: 20050316-1
Severity: wishlist
Tags: patch

The attached patch contains documentation and a small patch to adzapper and
adzapper.wrapper to support proxying with Apache2. This has the advantage of
being IPv6 friendly. Maybe this could be added to adzapper itself as it's
only a small patch.
Probably works with Apache 1.3 as well but since I haven't tested that I
only changed the package dependency for Apache 2.

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: powerpc (ppc)
Kernel: Linux 2.6.11.6
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages adzapper depends on:
ii  perl  5.8.4-8Larry Wall's Practical Extraction 
ii  squid 2.5.9-2Internet Object Cache (WWW proxy c

-- no debconf information
--- orig/scripts/squid_redirect
+++ mod/scripts/squid_redirect
@@ -47,6 +47,9 @@
 # restart hook
 $SIG{HUP}=sub { exec($0,@ARGV) };
 
+# what to do if we don't change anything
+$::NoChangeValue=( defined $ENV{NO_CHANGE_VALUE} ? $ENV{NO_CHANGE_VALUE} : '' );
+
 # where to find the replacement URLs
 $::StubBase=( defined $ENV{ZAP_BASE} && length $ENV{ZAP_BASE}
 	? $ENV{ZAP_BASE}
@@ -283,6 +286,9 @@
   if ( ! length $nurl && defined $::PostMatch)
   { $nurl=&$::PostMatch(@words);
   }
+  if ( ! length $nurl )
+  { $nurl=$::NoChangeValue; 
+  }
 
   return pcnt($nurl);
 }
--- orig/debian/adzapper.wrapper
+++ mod/debian/adzapper.wrapper
@@ -25,7 +25,7 @@
 export ZAP_MODE ZAP_BASE ZAP_BASE_SSL ZAP_PREMATCH ZAP_POSTMATCH
 export STUBURL_AD STUBURL_ADSSL STUBURL_ADJS STUBURL_ADHTML STUBURL_ADMP3 \
 	STUBURL_ADPOPUP STUBURL_ADSWF STUBURL_COUNTER STUBURL_COUNTERJS \
-	STUBURL_WEBBUG STUBURL_WEBBUGJS STUBURL_PRINT
+	STUBURL_WEBBUG STUBURL_WEBBUGJS STUBURL_PRINT NO_CHANGE_VALUE
 
 # Here, having arranged the environment, we exec the real zapper:
 
--- orig/debian/README.Debian
+++ mod/debian/README.Debian
@@ -28,3 +28,24 @@
 overwrite the main adzapper program (/usr/bin/adzapper) !
 
  -- Ludovic Drolez <[EMAIL PROTECTED]>, Fri, 13 Dec 2002 17:37:42 +0100
+
+
+-
+
+Alternatively, you can also use adzapper with Apache2. This has the advantage of
+being IPv6 compatible. To do this, make Apache2 load mod_proxy and mod_redirect
+and configure it as follows:
+
+ProxyRequests On
+RewriteEngine On
+RewriteLock /var/lock/apache2/rewrite-adzapper
+RewriteMap adzap prg:/usr/bin/adzapper.wrapper
+
+Order deny,allow
+Deny from all
+Allow from localhost
+RewriteRule ^proxy:(.*)$ proxy:${adzap:$1|$1} [L]
+
+
+Also, edit the new "NO_CHANGE_VALUE" configuration variable and set it to NULL:
+NO_CHANGE_VALUE="NULL".
--- orig/debian/adzapper.conf
+++ mod/debian/adzapper.conf
@@ -55,3 +55,9 @@
 STUBURL_WEBBUG=$ZAP_BASE/webbug.gif
 STUBURL_WEBBUGJS=$ZAP_BASE/webbug.js
 
+# NO_CHANGE_VALUE
+#
+#   This defines what adzapper outputs when nothing should be redirected.
+#   For squid, this must be empty or undefined (default is empty).
+#   For Apache2's mod_rewrite RewriteMap directive, set this to NULL:
+#NO_CHANGE_VALUE="NULL"
--- orig/debian/control	2005-04-01 04:20:37.629166048 +0200
+++ mod/debian/control	2005-04-01 04:16:40.695185488 +0200
@@ -7,7 +7,7 @@
 
 Package: adzapper
 Architecture: all
-Depends: ${perl:Depends}, squid | polipo
+Depends: ${perl:Depends}, squid | polipo | apache2
 Suggests: apache | httpd, wget
 Enhances: squid
 Description: squid advertisement zapper


signature.asc
Description: This is a digitally signed message part