[svn:qpsmtpd] rev 490 - in trunk: . config.sample lib/Qpsmtpd plugins plugins/logging
[email protected] 9 Jul 2005 11:03:53 -0000
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Author: jpeacock Date: Sat Jul 9 04:03:53 2005 New Revision: 490 Added: trunk/config.sample/badrcptto_patterns Modified: trunk/ (props changed) trunk/lib/Qpsmtpd/Plugin.pm trunk/plugins/check_spamhelo trunk/plugins/logging/adaptive trunk/plugins/logging/devnull trunk/plugins/logging/warn Log: r547@jpeacock: jpeacock | 2005-07-02 07:20:17 -0400 Replace pithy comment with something more neutral. Thanks Gordon Rowell <[email protected]> r548@jpeacock: jpeacock | 2005-07-02 07:24:21 -0400 Example patterns for badrcptto plugin - Gordon Rowell <[email protected]> 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). Added: trunk/config.sample/badrcptto_patterns ============================================================================== --- (empty file) +++ trunk/config.sample/badrcptto_patterns Sat Jul 9 04:03:53 2005 @@ -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 Modified: trunk/lib/Qpsmtpd/Plugin.pm ============================================================================== --- trunk/lib/Qpsmtpd/Plugin.pm (original) +++ trunk/lib/Qpsmtpd/Plugin.pm Sat Jul 9 04:03:53 2005 @@ -20,7 +20,8 @@ sub register_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 # we should pass the plugin object and method name ... hmn. Modified: trunk/plugins/check_spamhelo ============================================================================== --- trunk/plugins/check_spamhelo (original) +++ trunk/plugins/check_spamhelo Sat Jul 9 04:03:53 2005 @@ -23,7 +23,7 @@ sub hook_helo { for my $bad ($self->qp->config('badhelo')) { if ($host eq lc $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; Modified: trunk/plugins/logging/adaptive ============================================================================== --- trunk/plugins/logging/adaptive (original) +++ trunk/plugins/logging/adaptive Sat Jul 9 04:03:53 2005 @@ -30,12 +30,16 @@ sub register { $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 # wait until after you register the plugin $self->log( LOGINFO, 'Initializing logging::adaptive plugin' ); } -sub hook_logging { # wlog +sub wlog { my ( $self, $transaction, $trace, $hook, $plugin, @log ) = @_; # Don't log your own log entries! If this is the only logging plugin @@ -62,12 +66,12 @@ sub hook_logging { # wlog return DECLINED; } -sub hook_deny { # dlog +sub dlog { my ( $self, $transaction, $prev_hook, $return, $return_text ) = @_; $self->{_denied} = 1; } -sub hook_reset_transaction { # slog +sub slog { # fires when a message is accepted my ( $self, $transaction, @args ) = @_; Modified: trunk/plugins/logging/devnull ============================================================================== --- trunk/plugins/logging/devnull (original) +++ trunk/plugins/logging/devnull Sat Jul 9 04:03:53 2005 @@ -1,7 +1,13 @@ #!/usr/bin/perl # 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; } Modified: trunk/plugins/logging/warn ============================================================================== --- trunk/plugins/logging/warn (original) +++ trunk/plugins/logging/warn Sat Jul 9 04:03:53 2005 @@ -16,13 +16,14 @@ sub register { $self->{_level} = log_level($loglevel); } } + $self->register_hook('logging', 'wlog'); # If you want to capture this log entry with this plugin, you need to # wait until after you register the plugin $self->log(LOGINFO,'Initializing logging::warn plugin'); } -sub hook_logging { +sub wlog { my ($self, $transaction, $trace, $hook, $plugin, @log) = @_; # Don't log your own log entries! If this is the only logging plugin