r547@jpeacock: jpeacock | 2005-07-02 07:20:17 -0400
Replace pithy comment with something more neutral. Thanks Gordon Rowell <gordonr@gormand.com.au> r548@jpeacock: jpeacock | 2005-07-02 07:24:21 -0400 Example patterns for badrcptto plugin - Gordon Rowell <gordonr@gormand.com.au> r586@jpeacock: jpeacock | 2005-07-09 06:54:47 -0400 Don't use varlog() directly unless you are passing all parameters. Don't try to log() anything during loading of logging plugins. r587@jpeacock: jpeacock | 2005-07-09 06:59:57 -0400 Cannot use new-style hooking with logging plugins (yet). git-svn-id: https://svn.perl.org/qpsmtpd/trunk@490 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
fac8cd7a30
commit
00c53652c9
5
config.sample/badrcptto_patterns
Normal file
5
config.sample/badrcptto_patterns
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Format is pattern\s+Response
|
||||||
|
# Don't forget to anchor the pattern if required
|
||||||
|
! Sorry, bang paths not accepted here
|
||||||
|
@.*@ Sorry, multiple at signs not accepted here
|
||||||
|
% Sorry, percent hack not accepted here
|
@ -20,7 +20,8 @@ sub register_hook {
|
|||||||
|
|
||||||
die $plugin->plugin_name . " : Invalid hook: $hook" unless $hooks{$hook};
|
die $plugin->plugin_name . " : Invalid hook: $hook" unless $hooks{$hook};
|
||||||
|
|
||||||
$plugin->{_qp}->varlog(LOGDEBUG, $plugin->plugin_name, " hooking ", $hook);
|
$plugin->{_qp}->log(LOGDEBUG, $plugin->plugin_name, "hooking", $hook)
|
||||||
|
unless $hook =~ /logging/; # can't log during load_logging()
|
||||||
|
|
||||||
# I can't quite decide if it's better to parse this code ref or if
|
# I can't quite decide if it's better to parse this code ref or if
|
||||||
# we should pass the plugin object and method name ... hmn.
|
# we should pass the plugin object and method name ... hmn.
|
||||||
|
@ -23,7 +23,7 @@ sub hook_helo {
|
|||||||
for my $bad ($self->qp->config('badhelo')) {
|
for my $bad ($self->qp->config('badhelo')) {
|
||||||
if ($host eq lc $bad) {
|
if ($host eq lc $bad) {
|
||||||
$self->log(LOGDEBUG, "Denying HELO from host claiming to be $bad");
|
$self->log(LOGDEBUG, "Denying HELO from host claiming to be $bad");
|
||||||
return (DENY, "Uh-huh. You're $host, and I'm a boil on the bottom of the Marquess of Queensbury's great-aunt.");
|
return (DENY, "Sorry, I don't believe that you are $host.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DECLINED;
|
return DECLINED;
|
||||||
|
@ -30,12 +30,16 @@ sub register {
|
|||||||
$self->{_prefix} = $1;
|
$self->{_prefix} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->register_hook( 'logging', 'wlog' );
|
||||||
|
$self->register_hook( 'deny', 'dlog' );
|
||||||
|
$self->register_hook( 'reset_transaction', 'slog' );
|
||||||
|
|
||||||
# If you want to capture this log entry with this plugin, you need to
|
# If you want to capture this log entry with this plugin, you need to
|
||||||
# wait until after you register the plugin
|
# wait until after you register the plugin
|
||||||
$self->log( LOGINFO, 'Initializing logging::adaptive plugin' );
|
$self->log( LOGINFO, 'Initializing logging::adaptive plugin' );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hook_logging { # wlog
|
sub wlog {
|
||||||
my ( $self, $transaction, $trace, $hook, $plugin, @log ) = @_;
|
my ( $self, $transaction, $trace, $hook, $plugin, @log ) = @_;
|
||||||
|
|
||||||
# Don't log your own log entries! If this is the only logging plugin
|
# Don't log your own log entries! If this is the only logging plugin
|
||||||
@ -62,12 +66,12 @@ sub hook_logging { # wlog
|
|||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hook_deny { # dlog
|
sub dlog {
|
||||||
my ( $self, $transaction, $prev_hook, $return, $return_text ) = @_;
|
my ( $self, $transaction, $prev_hook, $return, $return_text ) = @_;
|
||||||
$self->{_denied} = 1;
|
$self->{_denied} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hook_reset_transaction { # slog
|
sub slog {
|
||||||
|
|
||||||
# fires when a message is accepted
|
# fires when a message is accepted
|
||||||
my ( $self, $transaction, @args ) = @_;
|
my ( $self, $transaction, @args ) = @_;
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
# this is a simple 'drop packets on the floor' plugin
|
# this is a simple 'drop packets on the floor' plugin
|
||||||
|
|
||||||
sub hook_logging {
|
sub register {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->register_hook('logging', 'wlog');
|
||||||
|
}
|
||||||
|
|
||||||
|
sub wlog {
|
||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,13 +16,14 @@ sub register {
|
|||||||
$self->{_level} = log_level($loglevel);
|
$self->{_level} = log_level($loglevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$self->register_hook('logging', 'wlog');
|
||||||
|
|
||||||
# If you want to capture this log entry with this plugin, you need to
|
# If you want to capture this log entry with this plugin, you need to
|
||||||
# wait until after you register the plugin
|
# wait until after you register the plugin
|
||||||
$self->log(LOGINFO,'Initializing logging::warn plugin');
|
$self->log(LOGINFO,'Initializing logging::warn plugin');
|
||||||
}
|
}
|
||||||
|
|
||||||
sub hook_logging {
|
sub wlog {
|
||||||
my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
|
my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
|
||||||
|
|
||||||
# Don't log your own log entries! If this is the only logging plugin
|
# Don't log your own log entries! If this is the only logging plugin
|
||||||
|
Loading…
Reference in New Issue
Block a user