mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
anti-flood bantracker now more properly handles detection of proxying in multiple channels
This commit is contained in:
parent
cdaf433966
commit
cb20ac607e
@ -392,17 +392,20 @@ sub address_to_mask {
|
|||||||
sub check_nickserv_accounts {
|
sub check_nickserv_accounts {
|
||||||
my ($self, $nick, $account) = @_;
|
my ($self, $nick, $account) = @_;
|
||||||
|
|
||||||
my $banned_channel = undef;
|
my @banned_channels;
|
||||||
|
|
||||||
foreach my $mask (keys %{ $self->{message_history} }) {
|
foreach my $mask (keys %{ $self->{message_history} }) {
|
||||||
if(exists $self->{message_history}->{$mask}->{nickserv_account}) {
|
if(exists $self->{message_history}->{$mask}->{nickserv_account}) {
|
||||||
if(lc $self->{message_history}->{$mask}->{nickserv_account} eq lc $account) {
|
if(lc $self->{message_history}->{$mask}->{nickserv_account} eq lc $account) {
|
||||||
$self->{pbot}->logger->log("anti-flood: [check-account] $nick [nickserv: $account] seen previously as $mask.\n");
|
$self->{pbot}->logger->log("anti-flood: [check-account] $nick [nickserv: $account] seen previously as $mask.\n");
|
||||||
|
|
||||||
my $baninfo = $self->{pbot}->bantracker->get_baninfo($mask);
|
my $baninfo = $self->{pbot}->bantracker->get_baninfo($mask);
|
||||||
|
|
||||||
if(defined $baninfo) {
|
if(defined $baninfo) {
|
||||||
$self->{pbot}->logger->log("anti-flood: [check-bans] $mask is banned in $baninfo->{channel} by $baninfo->{owner}\n");
|
$self->{pbot}->logger->log("anti-flood: [check-bans] $mask is banned in $baninfo->{channel} by $baninfo->{owner}\n");
|
||||||
$banned_channel = $baninfo->{channel};
|
push @banned_channels, $baninfo->{channel};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -410,12 +413,12 @@ sub check_nickserv_accounts {
|
|||||||
$self->{pbot}->logger->log("anti-flood: $mask: setting nickserv account to [$account]\n");
|
$self->{pbot}->logger->log("anti-flood: $mask: setting nickserv account to [$account]\n");
|
||||||
$self->message_history->{$mask}->{nickserv_account} = $account;
|
$self->message_history->{$mask}->{nickserv_account} = $account;
|
||||||
|
|
||||||
if(defined $banned_channel) {
|
foreach my $banned_channel (@banned_channels) {
|
||||||
my $banmask;
|
my $banmask;
|
||||||
$mask =~ m/[^@]+\@(.*)/;
|
$mask =~ m/[^@]+\@(.*)/;
|
||||||
$banmask = "*!*\@$1";
|
$banmask = "*!*\@$1";
|
||||||
|
|
||||||
$self->{pbot}->logger->log("anti-flood: [$account] is banned in $banned_channel, banning $banmask.\n");
|
$self->{pbot}->logger->log("anti-flood: [check-bans] Ban detected on account $account in $banned_channel, banning $banmask.\n");
|
||||||
$self->{pbot}->chanops->ban_user_timed($banmask, $banned_channel, 60 * 60 * 5);
|
$self->{pbot}->chanops->ban_user_timed($banmask, $banned_channel, 60 * 60 * 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,19 +62,20 @@ sub get_banlist {
|
|||||||
sub get_baninfo {
|
sub get_baninfo {
|
||||||
my ($self, $mask) = @_;
|
my ($self, $mask) = @_;
|
||||||
|
|
||||||
$mask = quotemeta $mask;
|
|
||||||
|
|
||||||
$mask =~ s/\\\*/.*?/g;
|
|
||||||
$mask =~ s/\\\?/./g;
|
|
||||||
|
|
||||||
$self->{pbot}->logger->log("get-baninfo: mask regex: $mask\n");
|
|
||||||
|
|
||||||
foreach my $channel (keys %{ $self->{banlist} }) {
|
foreach my $channel (keys %{ $self->{banlist} }) {
|
||||||
foreach my $banmask (keys %{ $self->{banlist}{$channel} }) {
|
foreach my $banmask (keys %{ $self->{banlist}{$channel} }) {
|
||||||
|
$banmask = quotemeta $banmask;
|
||||||
|
|
||||||
|
$banmask =~ s/\\\*/.*?/g;
|
||||||
|
$banmask =~ s/\\\?/./g;
|
||||||
|
|
||||||
|
$self->{pbot}->logger->log("get-baninfo: $channel banmask regex: $banmask\n");
|
||||||
|
|
||||||
if($banmask =~ m/$mask/i) {
|
if($banmask =~ m/$mask/i) {
|
||||||
my $baninfo = {};
|
my $baninfo = {};
|
||||||
$baninfo->{channel} = $channel;
|
$baninfo->{channel} = $channel;
|
||||||
$baninfo->{owner} = $self->{banlist}{$channel}[0];
|
$baninfo->{owner} = $self->{banlist}{$channel}[0];
|
||||||
|
$self->{pbot}->logger->log("get-baninfo: dump: " . Dumper($baninfo) . "\n");
|
||||||
return $baninfo;
|
return $baninfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 315,
|
BUILD_REVISION => 316,
|
||||||
BUILD_DATE => "2011-02-13",
|
BUILD_DATE => "2011-02-13",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user