dbaa9dbd6c
on files in plugins dir: fixed a number of POD errors formatted some # comments into POD removed bare 1; (these are plugins, not perl modules) most instances of this were copy/pasted from a previous plugin that had it removed instances of # vim ts=N ... they weren't consistent, many didn't match .perltidyrc on modules that failed perl -c tests, added 'use Qpsmtpd::Constants;' Conflicts: plugins/async/check_earlytalker plugins/async/dns_whitelist_soft plugins/async/dnsbl plugins/async/queue/smtp-forward plugins/async/require_resolvable_fromhost plugins/async/rhsbl plugins/async/uribl plugins/auth/auth_checkpassword plugins/auth/auth_cvm_unix_local plugins/auth/auth_flat_file plugins/auth/auth_ldap_bind plugins/auth/auth_vpopmail plugins/auth/auth_vpopmail_sql plugins/auth/authdeny plugins/check_badmailfromto plugins/check_badrcptto_patterns plugins/check_bogus_bounce plugins/check_earlytalker plugins/check_norelay plugins/check_spamhelo plugins/connection_time plugins/dns_whitelist_soft plugins/dnsbl plugins/domainkeys plugins/greylisting plugins/hosts_allow plugins/http_config plugins/logging/adaptive plugins/logging/apache plugins/logging/connection_id plugins/logging/transaction_id plugins/logging/warn plugins/milter plugins/queue/exim-bsmtp plugins/queue/maildir plugins/queue/postfix-queue plugins/queue/smtp-forward plugins/quit_fortune plugins/random_error plugins/rcpt_map plugins/rcpt_regexp plugins/relay_only plugins/require_resolvable_fromhost plugins/rhsbl plugins/sender_permitted_from plugins/spamassassin plugins/tls plugins/tls_cert plugins/uribl plugins/virus/aveclient plugins/virus/bitdefender plugins/virus/clamav plugins/virus/clamdscan plugins/virus/hbedv plugins/virus/kavscanner plugins/virus/klez_filter plugins/virus/sophie plugins/virus/uvscan
63 lines
1.7 KiB
Perl
63 lines
1.7 KiB
Perl
#!perl -Tw
|
|
|
|
=head1 NAME
|
|
|
|
noop_counter - disconnect after too many consecutive NOOPs, example plugin for the hook_noop()
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
The B<noop_counter> counts the number of consecutive C<NOOP> commands given
|
|
by a client and disconnects after a given number.
|
|
|
|
Any other command than a C<NOOP> resets the counter.
|
|
|
|
One argument may be given: the number of C<NOOP>s after which the client will
|
|
be disconnected.
|
|
|
|
=head1 NOTE
|
|
|
|
This plugin should be loaded early to be able to reset the counter on any other
|
|
command.
|
|
|
|
=cut
|
|
|
|
sub register {
|
|
my ($self, $qp, @args) = @_;
|
|
$self->{_noop_count} = 0;
|
|
$self->{_max_noop} = 3;
|
|
if ($args[0] && $args[0] =~ /^\d+$/) {
|
|
$self->{_max_noop} = shift @args;
|
|
}
|
|
}
|
|
|
|
sub hook_noop {
|
|
my ($self, $transaction, @args) = @_;
|
|
++$self->{_noop_count};
|
|
### the following block is not used, RFC 2821 says we SHOULD ignore
|
|
### any arguments... so we MAY return an error if we want to :-)
|
|
# return (DENY, "Syntax error, NOOP does not take any arguments")
|
|
# if $args[0];
|
|
|
|
if ($self->{_noop_count} >= $self->{_max_noop}) {
|
|
return (DENY_DISCONNECT,
|
|
"Stop wasting my time, too many consecutive NOOPs");
|
|
}
|
|
return (DECLINED);
|
|
}
|
|
|
|
sub reset_noop_counter {
|
|
$_[0]->{_noop_count} = 0;
|
|
return (DECLINED);
|
|
}
|
|
|
|
# and bind the counter reset to the hooks, QUIT not useful here:
|
|
*hook_helo = *hook_ehlo = # HELO / EHLO
|
|
*hook_mail = # MAIL FROM:
|
|
*hook_rcpt = # RCPT TO:
|
|
*hook_data = # DATA
|
|
*hook_reset_transaction = # RSET
|
|
*hook_vrfy = # VRFY
|
|
*hook_help = # HELP
|
|
\&reset_noop_counter;
|
|
|