Question

Am using Squid 3.3.8 and I need to check clients ip/mac from Mysql. I heard about external_acl_types and wrote a little python script. This script takes one argument [ip/mac] and checks it with mysql table, if there is no result it prints "ERR", if there is record with this IP it prints "OK". I read that helper program must return "ERR" or "OK", that's why designed in this way. But now I don't know how can I get ip/mac address of the client for passing to script as argument.. Can anybody explain? Or maybe somebody knows where can I get such type helper program for Squid..

Regards,

Was it helpful?

Solution

I also use squid_db_auth for authentication, kindly use

    sub ip_check_client()

  {
 my %hostname;

while (<>) {
    my $line = $_;
    my($host, $rest) = split / /, $line, 2;
    if ($host =~ /^\d+\.\d+\.\d+\.\d+$/) {
       unless (exists $hostname{$host}) {
       $hostname{$host} = gethostbyaddr(inet_aton($host), AF_INET);
        }
        if ($hostname{$host}) {
        $line = "$hostname{$host} $rest";
        }
        }
           return $line;
     }
  }

kindly use for only ip capture

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top