geblockte ausgehende erfassen
This commit is contained in:
90
ban2mysql.pl
90
ban2mysql.pl
@@ -191,6 +191,96 @@ for my $l ( @file ) {
|
|||||||
"$h:$m:$s"
|
"$h:$m:$s"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
( $month, $day, $h, $m, $s, $kat, $src, $dst, $port ) = $l =~ /(.*?) (.*?) (..):(..):(..) 192.*banIP\/...-lan\/reject\/(.*?):.*SRC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) DST=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*DPT=(\d+)/;
|
||||||
|
|
||||||
|
$dt = '';
|
||||||
|
if ( $month ) {
|
||||||
|
$month = $month2int->{lc $month};
|
||||||
|
my $mysqldt = "$year-$month-$day $h:$m:$s";
|
||||||
|
my $dt1 = DateTime->new(
|
||||||
|
year => $year,
|
||||||
|
month => $month,
|
||||||
|
day => $day,
|
||||||
|
hour => $h,
|
||||||
|
minute => $m,
|
||||||
|
second => $s
|
||||||
|
);
|
||||||
|
|
||||||
|
my $id;
|
||||||
|
|
||||||
|
my $da = $dbh->selectrow_hashref('SELECT * FROM banip_blockout WHERE src = ? and dst = ? and port = ?', undef, $src, $dst, $port );
|
||||||
|
if ( $da ) {
|
||||||
|
$id = $da->{id};
|
||||||
|
my ( $year2, $month2, $day2, $h2, $m2, $s2) = $da->{updated} =~ /(....)-(..)-(..) (..):(..):(..)/;
|
||||||
|
my $dt2 = DateTime->new(
|
||||||
|
year => $year2,
|
||||||
|
month => $month2,
|
||||||
|
day => $day2,
|
||||||
|
hour => $h2,
|
||||||
|
minute => $m2,
|
||||||
|
second => $s2
|
||||||
|
);
|
||||||
|
|
||||||
|
my $cmp = DateTime->compare( $dt1, $dt2 );
|
||||||
|
if ( $cmp == 1 ) {
|
||||||
|
$dbh->do('UPDATE banip_blockout set count = count + 1, updated = ? WHERE src = ? and dst = ? and port = ?', undef, $mysqldt, $src, $dst, $port );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $nolandforip{$dst} ) {
|
||||||
|
if ( !$da->{cid} ) {
|
||||||
|
$nolandforip{$dst} = 1;
|
||||||
|
|
||||||
|
if ( $hundred == 100 ) {
|
||||||
|
$first ++;
|
||||||
|
$nolandips{$first} = ();
|
||||||
|
$hundred = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
push @{$nolandips{$first}}, {"query"=> $dst, "fields"=> "country,countryCode,query", "lang"=> "de"};
|
||||||
|
$hundred ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$dbh->do(
|
||||||
|
'INSERT INTO banip_blockout (
|
||||||
|
created,
|
||||||
|
updated,
|
||||||
|
src,
|
||||||
|
dst,
|
||||||
|
port,
|
||||||
|
kat)
|
||||||
|
VALUES (
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
?)', undef,
|
||||||
|
$mysqldt,
|
||||||
|
$mysqldt,
|
||||||
|
$src,
|
||||||
|
$dst,
|
||||||
|
$port,
|
||||||
|
$kat
|
||||||
|
);
|
||||||
|
$id = $dbh->last_insert_id();
|
||||||
|
|
||||||
|
$nolandforip{$dst} = 1;
|
||||||
|
|
||||||
|
if ( $hundred == 100 ) {
|
||||||
|
$first ++;
|
||||||
|
$nolandips{$first} = ();
|
||||||
|
$hundred = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
push @{$nolandips{$first}}, {"query"=> $dst, "fields"=> "country,countryCode,query", "lang"=> "de"};
|
||||||
|
$hundred ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user