Re: [squid-users] More than one type of redirector

From: Daniel Barron <squidusers@dont-contact.us>
Date: Wed, 11 Jul 2001 14:55:19 +0100

After a huge amount of help from Colin Campbell, my problem is finally
solved. Follows is the redirector script used to solve the problem:

#!/usr/bin/perl
# The idea is to for this process to be run by squid as the redirector and
# this process to fork a child running squidGuard. We then receive input
# from squid and either massage and "return" it (by printing it) or hand
# it off to squidGuard to see what it wants to do with it. SquidGuard will
# read its data from the filehandle TO_SG (connected to its STDIN) and
# we get the output from squidGuard's STDOUT on the filehandle FROM_SG.
# Note that squidGuard will just return a blank line on URLs it deems okay.
# Written by Colin Campbell 2001
# Modified by Daniel Barron 2001

use IPC::Open2;

# program to run (insert correct options)
$sg = "/usr/local/bin/squidGuard -c /etc/squidGuard/conf/squidGuard.conf";

# connect to squidGuard
open2(*FROM_SG, *TO_SG, $sg) or die "can't start squidGuard: $!";

# unbuffer output
$| = 1;

# now do our stuff
while (<>) {
       if ($_ =~ m|http://www.bedmod.org.uk/\s|) {
              # we know this'll never be changed by squidguard
              # so don't send it, just return the modified
              print "http://www.bedmod.org.uk/index2.html\n";
       }
       else { # see what squidGuard thinks
              # send what we read (in $_) to squidGuard
              print TO_SG $_;
              $url = <FROM_SG>;
              print $url;
       }
}

A massive thank you!

-- 
Daniel Barron
Received on Wed Jul 11 2001 - 07:55:36 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:01:06 MST