Fix script per squid

This commit is contained in:
Claudio Maffioletti
2017-05-23 10:20:39 +02:00
parent d6f3443ad8
commit d0cc3f4d25
7 changed files with 78 additions and 30 deletions

View File

@@ -6,10 +6,11 @@ use Switch;
use FindBin qw($Bin);
require "$Bin/../script/conntrack.conf";
require "$Bin/shellwords.pl";
local $SIG{ALRM} = sub {
my $time = localtime; # scalar context
# print LOG "$$ - $time - Exit\n";
print LOG "$$ - $time - Exit\n";
exit 1;
};
@@ -21,31 +22,26 @@ my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die (
$sts = $dbmysql->prepare("use $DBname");
$sts->execute ();
#open LOG, ">> /srv/www/htdocs/pannello_vbc/proxy/squid_acl/squid_pool.log";
#LOG->autoflush(1);
open LOG, ">> /usr/local/mybin/proxy/squid_acl/squid_pool.log";
LOG->autoflush(1);
while($limit) {
alarm $timeout;
my $query = "";
my $input = <>;
chop $input;
my $time = localtime; # scalar context
print LOG "$$ - $time - Start\n";
my @param = split / /, $input;
my $ritorno = cerca ($param[1],$param[2], -1);
$limit--;
if ($ritorno) {
# print LOG "$param[0] - $param[1] - $param[2] - ERR\n";
print "DENY\n";
while (<>) {
print LOG "$$ - $time - $_\n";
my ($name, $ip, $host) = &shellwords;
if (cerca($ip,$host, -1)) {
print LOG "$ip, $host, -1 - ERR\n";
print "ERR\n";
} else {
$ritorno = cerca ($param[1],$param[2], 1);
if ($ritorno) {
# print LOG "$param[0] - $param[1] - $param[2] - OK\n";
if (cerca($ip,$host, 1)) {
print LOG "$ip, $host, -1 - OK\n";
print "OK\n";
} else {
# print LOG "$param[0] - $param[1] - $param[2] - ERR\n";
# print "DENY\n";
print "\n";
print LOG "$ip, $host, -1 - ERR\n";
print "ERR\n";
}
}
}
@@ -131,9 +127,10 @@ sub cerca {
WHERE
proxy_pool.ip = '$ip'
)
";
# print "$query\n";
# print LOG "$query\n";
$sts = $dbmysql->prepare($query);
$sts->execute ();