Gestione separata conf conntrack

This commit is contained in:
cmaffio
2016-03-23 09:58:00 +01:00
parent 3ff2f8dc30
commit 0e421a3956
3 changed files with 22 additions and 10 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
proxy/conntrack.pl
proxy/conntrack.conf
core/config.php

View File

@@ -2,19 +2,23 @@
$|=1;
use DBI;
use FindBin qw($Bin);
my $proxy_IP = '192.168.1.3';
my $proxy_PORT = 3128;
my $param = shift @ARGV;
$verbose = 0;
if ($param eq '-v') {
$verbose = 1;
}
require "$Bin/conntrack.conf";
`sysctl -w net.netfilter.nf_conntrack_acct=1`;
my $dbmysql = DBI->connect("DBI:mysql:;host=127.0.0.1", "pannello_proxy", "CuQlM1lfF4VZDCIP") or die ($DBI::errstr);
$sts = $dbmysql->prepare("use pannello_vbc");
my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die ($DBI::errstr);
$sts = $dbmysql->prepare("use $DBname");
$sts->execute ();
#/usr/sbin/conntrack -E -p tcp --dport 3128 -oextended,id,timestamp -eDESTROY
open CT, "/usr/sbin/conntrack -E -eNEW,DESTROY -otimestamp,id -p tcp --dport $proxy_PORT |" or die "non va\n";
while (<CT>) {
@@ -41,7 +45,6 @@ while (<CT>) {
# print "$riga";
}
if ( $riga =~ /^\s*\[(\d+)\.\d+\]\s+\[DESTROY\] tcp\s+\d+ src=(\S+) dst=(\S+) sport=\d+ dport=(\d+) packets=\d+ bytes=(\d+) src=\S+ dst=\S+ sport=\d+ dport=\d+ packets=\d+ bytes=(\d+) \[\w+\] id=(\d+)/) {
# next if ($2 != $proxy_IP);
# next if ($3 != $proxy_PORT);
@@ -54,7 +57,7 @@ while (<CT>) {
my $remote_RECEIVE = $6;
my $thread_ID = $7;
print "IP: $remote_IP - ID: $thread_ID - Invati: $remote_SEND - Ricevuti: $remote_RECEIVE\n";
print "IP: $remote_IP - ID: $thread_ID - Invati: $remote_SEND - Ricevuti: $remote_RECEIVE\n" if ($verbose);
my $query = " UPDATE
proxy_dati

View File

@@ -0,0 +1,9 @@
$proxy_IP = '';
$proxy_PORT = 3128;
$DBhost = '';
$DBname = '';
$DBuser = '';
$DBpass = '';
return 1;