Interfaccia gestione ACL
This commit is contained in:
@@ -7,6 +7,17 @@ view_top();
|
|||||||
|
|
||||||
<form name="" method="post">
|
<form name="" method="post">
|
||||||
<table cellpadding="0" cellspacing="0" border="0" width="90%">
|
<table cellpadding="0" cellspacing="0" border="0" width="90%">
|
||||||
|
<tr>
|
||||||
|
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="30%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="10%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="10%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
<td class="sep" width="30%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td ><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
<td ><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
<td width="5%"><a href="acl_edit.php"><img src="<?php print $CONF['base_url'] ?>/img/addresource.png"></a></td>
|
<td width="5%"><a href="acl_edit.php"><img src="<?php print $CONF['base_url'] ?>/img/addresource.png"></a></td>
|
||||||
@@ -27,6 +38,8 @@ $query = " SELECT
|
|||||||
proxy_acl
|
proxy_acl
|
||||||
ON
|
ON
|
||||||
proxy_acl_list.id = proxy_acl.idacllist
|
proxy_acl_list.id = proxy_acl.idacllist
|
||||||
|
GROUP BY
|
||||||
|
id
|
||||||
UNION DISTINCT SELECT
|
UNION DISTINCT SELECT
|
||||||
proxy_acl_list.id,
|
proxy_acl_list.id,
|
||||||
proxy_acl_list.sys,
|
proxy_acl_list.sys,
|
||||||
|
|||||||
@@ -22,11 +22,7 @@ if (isset($_POST['id'])) {
|
|||||||
data = NOW()
|
data = NOW()
|
||||||
";
|
";
|
||||||
$res = mysql_query( $query, $DB_ID );
|
$res = mysql_query( $query, $DB_ID );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} elseif (isset($_GET['id'])) {
|
} elseif (isset($_GET['id'])) {
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
}
|
}
|
||||||
@@ -81,7 +77,7 @@ function do_submit() {
|
|||||||
</script>
|
</script>
|
||||||
<form name="acl" method="post">
|
<form name="acl" method="post">
|
||||||
<table cellpadding="0" cellspacing="0" border="0" width="90%">
|
<table cellpadding="0" cellspacing="0" border="0" width="90%">
|
||||||
<input type="hidden" name="id" value="1">
|
<input type="hidden" name="id" value="<?php print $id ?>">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
<td class="sep" width="5%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
<td class="sep" width="20%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
<td class="sep" width="20%"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
|||||||
126
proxy/squid_acl/squid_acl.pl
Executable file
126
proxy/squid_acl/squid_acl.pl
Executable file
@@ -0,0 +1,126 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
$|=1;
|
||||||
|
|
||||||
|
use DBI;
|
||||||
|
use Switch;
|
||||||
|
use FindBin qw($Bin);
|
||||||
|
|
||||||
|
require "$Bin/../script/conntrack.conf";
|
||||||
|
|
||||||
|
local $SIG{ALRM} = sub {
|
||||||
|
my $time = localtime; # scalar context
|
||||||
|
print LOG "$$ - $time - Exit\n";
|
||||||
|
exit 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
srand($$);
|
||||||
|
$timeout = 60 * (int(rand(5))+61);
|
||||||
|
$limit = 50;
|
||||||
|
|
||||||
|
my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die ($DBI::errstr);
|
||||||
|
$sts = $dbmysql->prepare("use $DBname");
|
||||||
|
$sts->execute ();
|
||||||
|
|
||||||
|
open LOG, ">> /srv/www/htdocs/pannello_vbc/proxy/squid_acl/squid_pool.log";
|
||||||
|
LOG->autoflush(1);
|
||||||
|
|
||||||
|
alarm $timeout;
|
||||||
|
while($limit) {
|
||||||
|
my $query = "";
|
||||||
|
my $input = <>;
|
||||||
|
chop $input;
|
||||||
|
|
||||||
|
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";
|
||||||
|
} else {
|
||||||
|
$ritorno = cerca ($param[1],$param[2], 1);
|
||||||
|
if ($ritorno) {
|
||||||
|
print LOG "$param[0] - $param[1] - $param[2] - OK\n";
|
||||||
|
print "OK\n";
|
||||||
|
} else {
|
||||||
|
print LOG "$param[0] - $param[1] - $param[2] - ERR\n";
|
||||||
|
print "DENY\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# next if ($query eq "");
|
||||||
|
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
|
||||||
|
sub cerca {
|
||||||
|
my $ip = shift;
|
||||||
|
my $url = shift;
|
||||||
|
my $stato = shift;
|
||||||
|
|
||||||
|
if ($stato == 1) {
|
||||||
|
$tutto = "";
|
||||||
|
} else {
|
||||||
|
$tutto = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = " SELECT
|
||||||
|
1
|
||||||
|
FROM
|
||||||
|
proxy_pool
|
||||||
|
JOIN
|
||||||
|
proxy_acl_ip
|
||||||
|
ON
|
||||||
|
proxy_pool.id = proxy_acl_ip.idpool
|
||||||
|
AND
|
||||||
|
proxy_acl_ip.stato = $stato
|
||||||
|
JOIN
|
||||||
|
proxy_acl_list
|
||||||
|
ON
|
||||||
|
proxy_acl_ip.idacllist = proxy_acl_list.id
|
||||||
|
AND
|
||||||
|
proxy_acl_list.attivo = 1
|
||||||
|
JOIN
|
||||||
|
proxy_acl
|
||||||
|
ON
|
||||||
|
proxy_acl.idacllist = proxy_acl_list.id
|
||||||
|
AND
|
||||||
|
proxy_acl.attivo = 1
|
||||||
|
AND
|
||||||
|
LOCATE(proxy_acl.rif, '$url') > 0
|
||||||
|
WHERE
|
||||||
|
proxy_pool.ip = '$ip'
|
||||||
|
UNION DISTINCT SELECT
|
||||||
|
1
|
||||||
|
FROM
|
||||||
|
proxy_pool
|
||||||
|
JOIN
|
||||||
|
proxy_acl_ip
|
||||||
|
ON
|
||||||
|
proxy_pool.id = proxy_acl_ip.idpool
|
||||||
|
AND
|
||||||
|
proxy_acl_ip.stato = $stato
|
||||||
|
JOIN
|
||||||
|
proxy_acl_list
|
||||||
|
ON
|
||||||
|
proxy_acl_ip.idacllist = proxy_acl_list.id
|
||||||
|
AND
|
||||||
|
proxy_acl_list.nome = 'ALL'
|
||||||
|
WHERE
|
||||||
|
proxy_pool.ip = '$ip'
|
||||||
|
";
|
||||||
|
|
||||||
|
# print "$query\n";
|
||||||
|
$sts = $dbmysql->prepare($query);
|
||||||
|
$sts->execute ();
|
||||||
|
|
||||||
|
if ($ref = $sts->fetchrow_hashref ) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ require "$Bin/../script/conntrack.conf";
|
|||||||
|
|
||||||
local $SIG{ALRM} = sub {
|
local $SIG{ALRM} = sub {
|
||||||
my $time = localtime; # scalar context
|
my $time = localtime; # scalar context
|
||||||
print LOG "$$ - $time - Exit\n";
|
#print LOG "$$ - $time - Exit\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die (
|
|||||||
$sts = $dbmysql->prepare("use $DBname");
|
$sts = $dbmysql->prepare("use $DBname");
|
||||||
$sts->execute ();
|
$sts->execute ();
|
||||||
|
|
||||||
open LOG, ">> /srv/www/htdocs/pannello_vbc/proxy/squid_acl/squid_pool.log";
|
#open LOG, ">> /srv/www/htdocs/pannello_vbc/proxy/squid_acl/squid_pool.log";
|
||||||
LOG->autoflush(1);
|
#LOG->autoflush(1);
|
||||||
|
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
while($limit) {
|
while($limit) {
|
||||||
@@ -38,7 +38,7 @@ while($limit) {
|
|||||||
$query = "SELECT id FROM proxy_src WHERE ip = '".$param[1]."' AND attivo = 1";
|
$query = "SELECT id FROM proxy_src WHERE ip = '".$param[1]."' AND attivo = 1";
|
||||||
@reply = ("OK\n", "ERR\n");
|
@reply = ("OK\n", "ERR\n");
|
||||||
my $time = localtime; # scalar context
|
my $time = localtime; # scalar context
|
||||||
print LOG "$$ - $time - $limit - $input -\n";
|
#print LOG "$$ - $time - $limit - $input -\n";
|
||||||
$limit--;
|
$limit--;
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ while($limit) {
|
|||||||
$query = "SELECT id FROM proxy_utenti WHERE user = '".$param[1]."' AND pass = PASSWORD('".$param[2]."') AND attivo = 1";
|
$query = "SELECT id FROM proxy_utenti WHERE user = '".$param[1]."' AND pass = PASSWORD('".$param[2]."') AND attivo = 1";
|
||||||
@reply = ("OK\n", "ERR\n");
|
@reply = ("OK\n", "ERR\n");
|
||||||
my $time = localtime; # scalar context
|
my $time = localtime; # scalar context
|
||||||
print LOG "$$ - $time - $limit - $input -\n";
|
#print LOG "$$ - $time - $limit - $input -\n";
|
||||||
$limit--;
|
$limit--;
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user