3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 11:12:42 +01:00

anti-flood bantracker now more properly handles detection of proxying in multiple channels

This commit is contained in:
Pragmatic Software 2011-02-13 23:44:05 +00:00
parent cdaf433966
commit cb20ac607e
3 changed files with 16 additions and 12 deletions

View File

@ -392,17 +392,20 @@ sub address_to_mask {
sub check_nickserv_accounts {
my ($self, $nick, $account) = @_;
my $banned_channel = undef;
my @banned_channels;
foreach my $mask (keys %{ $self->{message_history} }) {
if(exists $self->{message_history}->{$mask}->{nickserv_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");
my $baninfo = $self->{pbot}->bantracker->get_baninfo($mask);
if(defined $baninfo) {
$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 {
@ -410,12 +413,12 @@ sub check_nickserv_accounts {
$self->{pbot}->logger->log("anti-flood: $mask: setting nickserv account to [$account]\n");
$self->message_history->{$mask}->{nickserv_account} = $account;
if(defined $banned_channel) {
foreach my $banned_channel (@banned_channels) {
my $banmask;
$mask =~ m/[^@]+\@(.*)/;
$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);
}
}

View File

@ -62,19 +62,20 @@ sub get_banlist {
sub get_baninfo {
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 $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) {
my $baninfo = {};
$baninfo->{channel} = $channel;
$baninfo->{owner} = $self->{banlist}{$channel}[0];
$self->{pbot}->logger->log("get-baninfo: dump: " . Dumper($baninfo) . "\n");
return $baninfo;
}
}

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 315,
BUILD_REVISION => 316,
BUILD_DATE => "2011-02-13",
};