3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-04-28 02:37:52 +02:00

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

This commit is contained in:
Pragmatic Software 2011-02-14 06:23:22 +00:00
parent 735da9ec05
commit 438b62552f
3 changed files with 22 additions and 13 deletions

View File

@ -393,10 +393,14 @@ sub check_nickserv_accounts {
my ($self, $nick, $account) = @_; my ($self, $nick, $account) = @_;
my @banned_channels; my @banned_channels;
my @account_masks;
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}) {
# has nickserv account
if(lc $self->{message_history}->{$mask}->{nickserv_account} eq lc $account) { if(lc $self->{message_history}->{$mask}->{nickserv_account} eq lc $account) {
# pre-existing mask found using this account previously, check for bans
$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);
@ -409,21 +413,28 @@ sub check_nickserv_accounts {
} }
} }
else { else {
# no nickserv account set yet
if($mask =~ m/^\Q$nick\E!/i) { if($mask =~ m/^\Q$nick\E!/i) {
# nick matches, must belong to account
$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;
push @account_masks, $mask;
}
}
}
foreach my $banned_channel (@banned_channels) { foreach my $banned_channel (@banned_channels) {
foreach my $account_mask (@account_masks) {
my $banmask; my $banmask;
$mask =~ m/[^@]+\@(.*)/; $account_mask =~ m/[^@]+\@(.*)/;
$banmask = "*!*\@$1"; $banmask = "*!*\@$1";
$self->{pbot}->logger->log("anti-flood: [check-bans] Ban detected on account $account 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);
} }
} }
}
}
} }
sub on_whoisaccount { sub on_whoisaccount {

View File

@ -69,9 +69,7 @@ sub get_baninfo {
$banmask =~ s/\\\*/.*?/g; $banmask =~ s/\\\*/.*?/g;
$banmask =~ s/\\\?/./g; $banmask =~ s/\\\?/./g;
$self->{pbot}->logger->log("get-baninfo: $channel banmask regex: $banmask\n"); if($mask =~ m/$banmask/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];

View File

@ -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 => 316, BUILD_REVISION => 318,
BUILD_DATE => "2011-02-13", BUILD_DATE => "2011-02-13",
}; };