From cb20ac607e323632be53217d415c70f3e2c39d08 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 13 Feb 2011 23:44:05 +0000 Subject: [PATCH] anti-flood bantracker now more properly handles detection of proxying in multiple channels --- PBot/AntiFlood.pm | 11 +++++++---- PBot/BanTracker.pm | 15 ++++++++------- PBot/VERSION.pm | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/PBot/AntiFlood.pm b/PBot/AntiFlood.pm index bdd598bf..8dd5c844 100644 --- a/PBot/AntiFlood.pm +++ b/PBot/AntiFlood.pm @@ -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); } } diff --git a/PBot/BanTracker.pm b/PBot/BanTracker.pm index 9087ac90..6aa99f33 100644 --- a/PBot/BanTracker.pm +++ b/PBot/BanTracker.pm @@ -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; } } diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index fc9a2f92..7e309204 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -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", };