[svn:qpsmtpd] rev 479 - in trunk: . lib/Qpsmtpd plugins plugins/auth plugins/ident plugins/logging plugins/queue plugins/virus

[email protected] 7 Jul 2005 04:17:40 -0000
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
Author: robert
Date: Wed Jul  6 21:17:39 2005
New Revision: 479

Modified:
   trunk/   (props changed)
   trunk/README.plugins
   trunk/lib/Qpsmtpd/Plugin.pm
   trunk/plugins/auth/authdeny
   trunk/plugins/auth/authnull
   trunk/plugins/check_badmailfrom
   trunk/plugins/check_badmailfromto
   trunk/plugins/check_badrcptto
   trunk/plugins/check_badrcptto_patterns
   trunk/plugins/check_basicheaders
   trunk/plugins/check_loop
   trunk/plugins/check_norelay
   trunk/plugins/check_relay
   trunk/plugins/check_spamhelo
   trunk/plugins/content_log
   trunk/plugins/count_unrecognized_commands
   trunk/plugins/dns_whitelist_soft
   trunk/plugins/dnsbl
   trunk/plugins/greylisting
   trunk/plugins/http_config
   trunk/plugins/ident/geoip
   trunk/plugins/ident/p0f
   trunk/plugins/logging/adaptive
   trunk/plugins/logging/devnull
   trunk/plugins/logging/warn
   trunk/plugins/milter
   trunk/plugins/queue/maildir
   trunk/plugins/queue/postfix-queue
   trunk/plugins/queue/qmail-queue
   trunk/plugins/queue/smtp-forward
   trunk/plugins/quit_fortune
   trunk/plugins/rcpt_ok
   trunk/plugins/require_resolvable_fromhost
   trunk/plugins/rhsbl
   trunk/plugins/sender_permitted_from
   trunk/plugins/spamassassin
   trunk/plugins/virus/aveclient
   trunk/plugins/virus/bitdefender
   trunk/plugins/virus/check_for_hi_virus
   trunk/plugins/virus/clamav
   trunk/plugins/virus/clamdscan
   trunk/plugins/virus/hbedv
   trunk/plugins/virus/kavscanner
   trunk/plugins/virus/klez_filter
   trunk/plugins/virus/sophie
   trunk/plugins/virus/uvscan
Log:
 r483@dog:  rspier | 2005-07-06 21:17:00 -0700
 The great plugin renaming in the name of inheritance and standardization commit.
 
 1. new concept of standard hook_ names.
 2. Plugin::init
 3. renamed many subroutines in plugins (and cleaned up register subs)
 4. updated README.plugins
 


Modified: trunk/README.plugins
==============================================================================
--- trunk/README.plugins	(original)
+++ trunk/README.plugins	Wed Jul  6 21:17:39 2005
@@ -270,3 +270,82 @@ ended.
 Returns the configured system-wide spool directory.
 
 =back
+
+=head1 Naming Conventions
+
+Plugins should be written using standard named hook subroutines.  This
+allows them to be overloaded and extended easily.
+
+Because some of our callback names have characters invalid in
+subroutine names, they must be translated.  The current translation
+routine is: C< s/\W/_/g; >
+
+=head2 Naming Map
+
+ hook                          method
+ ----------                    ------------
+ config                        hook_config                      
+ queue                         hook_queue                       
+ data                          hook_data                        
+ data_post                     hook_data_post                   
+ quit                          hook_quit                        
+ rcpt                          hook_rcpt                        
+ mail                          hook_mail                        
+ ehlo                          hook_ehlo                        
+ helo                          hook_helo                        
+ auth                          hook_auth                        
+ auth-plain                    hook_auth_plain                  
+ auth-login                    hook_auth_login                  
+ auth-cram-md5                 hook_auth_cram_md5               
+ connect                       hook_connect                     
+ reset_transaction             hook_reset_transaction           
+ unrecognized_command          hook_unrecognized_command        
+                                                           
+=head1 Register
+
+If you choose not to use the default naming convention, you need to
+register the hooks in your plugin.  You do this with the C< register >
+method call on the plugin object.
+
+  sub register {
+    my ($self, $qp) = @_;
+
+    $self->register_hook('mail', 'mail_handler');
+    $self->register_hook('rcpt', 'rcpt_handler');
+    $self->register_hook('disconnect', 'disconnect_handler');
+  }
+
+  sub mail_handler { ... }
+  sub rcpt_handler { ... }
+  sub disconnect_handler { ... }
+
+A single plugin can register as many hooks as it wants, and can
+register a hook multiple times.
+
+The C< register > method is also often used for initialization and
+reading configuration.
+
+=head1 Init
+
+The 'init' method is the first method called after a plugin is
+loaded.  It's mostly for inheritance, below.
+
+=head1 Inheritance
+
+Instead of modifying @ISA directly in your plugin, use the 
+C< plugin_isa > method from the init subroutine.
+
+  # rcpt_ok_child
+  sub init {
+    my ($self, $qp) = @_;
+    $self->isa_plugin('rcpt_ok');
+  }
+
+  sub hook_rcpt {
+    my ($self, $transaction, $recipient) = @_;
+    # do something special here...
+    $self->SUPER::hook_rcpt( $transaction, $recipient );
+  }
+
+
+

Modified: trunk/lib/Qpsmtpd/Plugin.pm
==============================================================================
--- trunk/lib/Qpsmtpd/Plugin.pm	(original)
+++ trunk/lib/Qpsmtpd/Plugin.pm	Wed Jul  6 21:17:39 2005
@@ -1,4 +1,5 @@
 package Qpsmtpd::Plugin;
+use Qpsmtpd::Constants;
 use strict;
 
 our %hooks = map { $_ => 1 } qw(
@@ -16,9 +17,11 @@ sub new {
 
 sub register_hook {
   my ($plugin, $hook, $method, $unshift) = @_;
-  
+
   die $plugin->plugin_name . " : Invalid hook: $hook" unless $hooks{$hook};
 
+  $plugin->{_qp}->varlog(LOGDEBUG, $plugin->plugin_name, " hooking ", $hook);
+
   # 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.
   $plugin->qp->_register_hook($hook, { code => sub { local $plugin->{_qp} = shift; local $plugin->{_hook} = $hook; $plugin->$method(@_) },
@@ -32,7 +35,9 @@ sub _register {
   my $self = shift;
   my $qp = shift;
   local $self->{_qp} = $qp;
-  $self->register($qp, @_);
+  $self->init($qp, @_)     if $self->can('init');
+  $self->_register_standard_hooks($qp, @_);
+  $self->register($qp, @_) if $self->can('register');
 }
 
 sub qp {
@@ -74,7 +79,7 @@ sub temp_dir {
 
 # plugin inheritance:
 # usage:
-#  sub register {
+#  sub init {
 #    my $self = shift;
 #    $self->isa_plugin("rhsbl");
 #    $self->SUPER::register(@_);
@@ -82,18 +87,23 @@ sub temp_dir {
 sub isa_plugin {
   my ($self, $parent) = @_;
   my ($currentPackage) = caller;
-  my $newPackage = $currentPackage."::_isa_";
+
+  my $cleanParent = $parent;
+  $cleanParent =~ s/\W/_/g;
+  my $newPackage = $currentPackage."::_isa_$cleanParent";
+
 
   return if defined &{"${newPackage}::register"};
 
-  Qpsmtpd::_compile($self->plugin_name . "_isa",
+  $self->compile($self->plugin_name . "_isa_$cleanParent",
                     $newPackage,
                     "plugins/$parent"); # assumes Cwd is qpsmtpd root
-
+  warn "---- $newPackage\n";
   no strict 'refs';
   push @{"${currentPackage}::ISA"}, $newPackage;
 }
 
+# why isn't compile private?  it's only called from Plugin and Qpsmtpd.
 sub compile {
     my ($class, $plugin, $package, $file, $test_mode) = @_;
     
@@ -141,4 +151,16 @@ sub compile {
     die "eval $@" if $@;
 }
 
+sub _register_standard_hooks {
+  my ($plugin, $qp) = @_;
+
+  for my $hook (keys %hooks) {
+    my $hooksub = "hook_$hook";
+    $hooksub  =~ s/\W/_/g;
+    $plugin->register_hook( $hook, $hooksub )
+      if ($plugin->can($hooksub));
+  }
+}
+
+
 1;

Modified: trunk/plugins/auth/authdeny
==============================================================================
--- trunk/plugins/auth/authdeny	(original)
+++ trunk/plugins/auth/authdeny	Wed Jul  6 21:17:39 2005
@@ -5,12 +5,7 @@
 #  the Qpsmtpd::Auth module.  Don't run this in production!!!
 #
 
-sub register {
-    my ( $self, $qp ) = @_;
-    $self->register_hook( "auth", "authdeny" );
-}
-
-sub authdeny {
+sub hook_auth {
     my ( $self, $transaction, $method, $user, $passClear, $passHash, $ticket ) =
       @_;
 

Modified: trunk/plugins/auth/authnull
==============================================================================
--- trunk/plugins/auth/authnull	(original)
+++ trunk/plugins/auth/authnull	Wed Jul  6 21:17:39 2005
@@ -5,17 +5,7 @@
 #  the Qpsmtpd::Auth module.  Don't run this in production!!!
 #
 
-sub register {
-    my ( $self, $qp ) = @_;
-
-    #  $self->register_hook("auth-plain", "authnull");
-    #  $self->register_hook("auth-login", "authnull");
-    #  $self->register_hook("auth-cram-md5", "authnull");
-
-    $self->register_hook( "auth", "authnull" );
-}
-
-sub authnull {
+sub hook_auth {
     my ( $self, $transaction, $method, $user, $passClear, $passHash, $ticket ) =
       @_;
 

Modified: trunk/plugins/check_badmailfrom
==============================================================================
--- trunk/plugins/check_badmailfrom	(original)
+++ trunk/plugins/check_badmailfrom	Wed Jul  6 21:17:39 2005
@@ -20,13 +20,7 @@ stage, so store it until later.
 
 =cut
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("mail", "mail_handler");
-  $self->register_hook("rcpt", "rcpt_handler");
-}
-
-sub mail_handler {
+sub hook_mail {
   my ($self, $transaction, $sender) = @_;
 
   my @badmailfrom = $self->qp->config("badmailfrom")
@@ -49,7 +43,7 @@ sub mail_handler {
   return (DECLINED);
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
   my ($self, $transaction, $rcpt) = @_;
   my $note = $transaction->notes('badmailfrom');
   if ($note) {

Modified: trunk/plugins/check_badmailfromto
==============================================================================
--- trunk/plugins/check_badmailfromto	(original)
+++ trunk/plugins/check_badmailfromto	Wed Jul  6 21:17:39 2005
@@ -16,13 +16,7 @@ Based heavily on check_badmailfrom.
 
 =cut
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("mail", "mail_handler");
-  $self->register_hook("rcpt", "rcpt_handler");
-}
-
-sub mail_handler {
+sub hook_mail {
   my ($self, $transaction, $sender) = @_;
 
   my @badmailfromto = $self->qp->config("badmailfromto")
@@ -46,7 +40,7 @@ sub mail_handler {
   return (DECLINED);
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
   my ($self, $transaction, $rcpt) = @_;
   my $recipient = lc($rcpt->user) . '@' . lc($rcpt->host);
   my $sender = $transaction->notes('badmailfromto');

Modified: trunk/plugins/check_badrcptto
==============================================================================
--- trunk/plugins/check_badrcptto	(original)
+++ trunk/plugins/check_badrcptto	Wed Jul  6 21:17:39 2005
@@ -1,11 +1,6 @@
 # this plugin checks the badrcptto config (like badmailfrom for rcpt address)
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("rcpt", "check_for_badrcptto");
-}
-
-sub check_for_badrcptto {
+sub hook_rcpt {
   my ($self, $transaction, $recipient) = @_;
   my @badrcptto = $self->qp->config("badrcptto") or return (DECLINED);
   return (DECLINED) unless $recipient->host && $recipient->user;

Modified: trunk/plugins/check_badrcptto_patterns
==============================================================================
--- trunk/plugins/check_badrcptto_patterns	(original)
+++ trunk/plugins/check_badrcptto_patterns	Wed Jul  6 21:17:39 2005
@@ -26,13 +26,7 @@ terms as Perl itself.
 
 =cut
 
-sub register
-{
-  my ($self, $qp) = @_;
-  $self->register_hook("rcpt", "check_for_badrcptto_patterns");
-}
-
-sub check_for_badrcptto_patterns
+sub hook_rcpt
 {
   my ($self, $transaction, $recipient) = @_;
 

Modified: trunk/plugins/check_basicheaders
==============================================================================
--- trunk/plugins/check_basicheaders	(original)
+++ trunk/plugins/check_basicheaders	Wed Jul  6 21:17:39 2005
@@ -33,7 +33,6 @@ use Date::Parse qw(str2time);
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("data_post", "check_basic_headers");
 
   if (@args > 0) {
     $self->{_days} = $args[0];
@@ -41,7 +40,7 @@ sub register {
   }
 }
 
-sub check_basic_headers {
+sub hook_data_post {
   my ($self, $transaction) = @_;
 
   return (DENY, "You have to send some data first")

Modified: trunk/plugins/check_loop
==============================================================================
--- trunk/plugins/check_loop	(original)
+++ trunk/plugins/check_loop	Wed Jul  6 21:17:39 2005
@@ -28,7 +28,6 @@ Released to the public domain, 17 June 2
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("data_post", "check_loop");
 
   $self->{_max_hops} = $args[0] || 100;
 
@@ -38,7 +37,7 @@ sub register {
   $self->log(LOGWARN, "Ignoring additional arguments") if @args > 1;
 }
 
-sub check_loop {
+sub hook_data_post {
   my ($self, $transaction) = @_;
 
   my $hops = 0;

Modified: trunk/plugins/check_norelay
==============================================================================
--- trunk/plugins/check_norelay	(original)
+++ trunk/plugins/check_norelay	Wed Jul  6 21:17:39 2005
@@ -34,12 +34,7 @@ terms as Perl itself.
 
 =cut
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("connect", "check_norelay");
-}
-
-sub check_norelay {
+sub hook_connect {
   my ($self, $transaction) = @_;
   my $connection = $self->qp->connection;
 

Modified: trunk/plugins/check_relay
==============================================================================
--- trunk/plugins/check_relay	(original)
+++ trunk/plugins/check_relay	Wed Jul  6 21:17:39 2005
@@ -2,12 +2,7 @@
 # $ENV{RELAYCLIENT} to see if relaying is allowed.
 #
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("connect", "check_relay");
-}
-
-sub check_relay {
+sub hook_connect {
   my ($self, $transaction) = @_;
   my $connection = $self->qp->connection;
 

Modified: trunk/plugins/check_spamhelo
==============================================================================
--- trunk/plugins/check_spamhelo	(original)
+++ trunk/plugins/check_spamhelo	Wed Jul  6 21:17:39 2005
@@ -16,13 +16,7 @@ per line.
 
 =cut
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("helo", "check_helo");
-  $self->register_hook("ehlo", "check_helo");
-}
-
-sub check_helo {
+sub hook_helo {
   my ($self, $transaction, $host) = @_;
   ($host = lc $host) or return DECLINED;
   
@@ -35,3 +29,5 @@ sub check_helo {
   return DECLINED;
 }
 
+# also support EHLO
+*hook_ehlo = \&hook_helo;

Modified: trunk/plugins/content_log
==============================================================================
--- trunk/plugins/content_log	(original)
+++ trunk/plugins/content_log	Wed Jul  6 21:17:39 2005
@@ -6,12 +6,7 @@
 
 use POSIX qw:strftime:;
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("data_post", "mail_handler");
-}
-
-sub mail_handler {
+sub hook_data_post {
   my ($self, $transaction) = @_;
 
   # as a decent default, log on a per-day-basis

Modified: trunk/plugins/count_unrecognized_commands
==============================================================================
--- trunk/plugins/count_unrecognized_commands	(original)
+++ trunk/plugins/count_unrecognized_commands	Wed Jul  6 21:17:39 2005
@@ -17,7 +17,6 @@ before we disconnect the client.  Defaul
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("unrecognized_command", "check_unrec_cmd");
 
   if (@args > 0) {
     $self->{_unrec_cmd_max} = $args[0];
@@ -30,7 +29,7 @@ sub register {
 
 }
 
-sub check_unrec_cmd {
+sub hook_unrecognized_command {
   my ($self, $cmd) = @_[0,2];
   
   $self->log(LOGINFO, "Unrecognized command '$cmd'");

Modified: trunk/plugins/dns_whitelist_soft
==============================================================================
--- trunk/plugins/dns_whitelist_soft	(original)
+++ trunk/plugins/dns_whitelist_soft	Wed Jul  6 21:17:39 2005
@@ -41,14 +41,7 @@ based on the 'whitelist' plugin by Devin
 
 =cut
 
-sub register {
-  my ($self, $qp) = @_;
-
-  $self->register_hook("connect", "connect_handler");
-  $self->register_hook("rcpt", "rcpt_handler");
-}
-
-sub connect_handler {
+sub hook_connect {
   my ($self, $transaction) = @_;
 
   my $remote_ip = $self->qp->connection->remote_ip;
@@ -145,7 +138,7 @@ sub process_sockets {
 
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
   my ($self, $transaction, $rcpt) = @_;
   my $ip = $self->qp->connection->remote_ip || return (DECLINED);
   my $note = $self->process_sockets;
@@ -155,13 +148,4 @@ sub rcpt_handler {
   return DECLINED;
 }
 
-sub disconnect_handler {
-  my ($self, $transaction) = @_;
-
-  $self->qp->connection->notes('whitelist_sockets', undef);
-
-  return DECLINED;
-}
-
-
 1;

Modified: trunk/plugins/dnsbl
==============================================================================
--- trunk/plugins/dnsbl	(original)
+++ trunk/plugins/dnsbl	Wed Jul  6 21:17:39 2005
@@ -8,13 +8,10 @@ sub register {
   else {
     $self->{_dnsbl}->{DENY} = DENY;
   }
-		    
-  $self->register_hook("connect", "connect_handler");
-  $self->register_hook("rcpt", "rcpt_handler");
-  $self->register_hook("disconnect", "disconnect_handler");
+
 }
 
-sub connect_handler {
+sub hook_connect {
   my ($self, $transaction) = @_;
 
   my $remote_ip = $self->qp->connection->remote_ip;
@@ -151,7 +148,7 @@ sub process_sockets {
 
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
   my ($self, $transaction, $rcpt) = @_;
   my $connection = $self->qp->connection;
 
@@ -184,7 +181,7 @@ sub rcpt_handler {
 
 }
 
-sub disconnect_handler {
+sub hook_disconnect {
   my ($self, $transaction) = @_;
 
   $self->qp->connection->notes('dnsbl_sockets', undef);

Modified: trunk/plugins/greylisting
==============================================================================
--- trunk/plugins/greylisting	(original)
+++ trunk/plugins/greylisting	Wed Jul  6 21:17:39 2005
@@ -137,7 +137,6 @@ sub register {
   } else {
     $self->register_hook("rcpt", "rcpt_handler");
   }
-  $self->register_hook("data_post", "data_handler");
 }
 
 sub mail_handler {
@@ -167,7 +166,7 @@ sub rcpt_handler {
   return DECLINED;
 }
 
-sub data_handler {
+sub hook_data {
   my ($self, $transaction) = @_;
   my $note = $transaction->notes('denysoft_greylist');
   return DECLINED unless $note;

Modified: trunk/plugins/http_config
==============================================================================
--- trunk/plugins/http_config	(original)
+++ trunk/plugins/http_config	Wed Jul  6 21:17:39 2005
@@ -31,10 +31,9 @@ my @urls;
 sub register {
   my ($self, $qp, @args) = @_;
   @urls = @args;
-  $self->register_hook("config", "http_config");
 }
 
-sub http_config {
+sub hook_config {
   my ($self, $transaction, $config) = @_; 
   $self->log(LOGNOTICE, "http_config called with $config");
   for my $url (@urls) {

Modified: trunk/plugins/ident/geoip
==============================================================================
--- trunk/plugins/ident/geoip	(original)
+++ trunk/plugins/ident/geoip	Wed Jul  6 21:17:39 2005
@@ -17,13 +17,7 @@ use Geo::IP;
 
 my $geoip = Geo::IP->new(GEOIP_STANDARD);
 
-
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("connect", "lookup_geoip");
-}
-
-sub lookup_geoip {
+sub hook_connect {
   my ($self) = @_;
 
   my $country = 

Modified: trunk/plugins/ident/p0f
==============================================================================
--- trunk/plugins/ident/p0f	(original)
+++ trunk/plugins/ident/p0f	Wed Jul  6 21:17:39 2005
@@ -23,13 +23,12 @@ use Net::IP;
 
 sub register {
   my ($self, $qp, $p0f_socket) = @_;
-  $self->register_hook("connect", "lookup_p0f");
 
   $p0f_socket =~ /(.*)/; # untaint
   $self->{_args}->{p0f_socket} = $1;
 }
 
-sub lookup_p0f {
+sub hook_connect {
   my($self, $qp) = @_;
 
   eval {

Modified: trunk/plugins/logging/adaptive
==============================================================================
--- trunk/plugins/logging/adaptive	(original)
+++ trunk/plugins/logging/adaptive	Wed Jul  6 21:17:39 2005
@@ -30,16 +30,12 @@ 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 wlog {
+sub hook_logging { # wlog
     my ( $self, $transaction, $trace, $hook, $plugin, @log ) = @_;
 
     # Don't log your own log entries!  If this is the only logging plugin
@@ -66,12 +62,12 @@ sub wlog {
     return DECLINED;
 }
 
-sub dlog {
+sub hook_deny { # dlog
     my ( $self, $transaction, $prev_hook, $return, $return_text ) = @_;
     $self->{_denied} = 1;
 }
 
-sub slog {
+sub hook_reset_transaction { # 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	Wed Jul  6 21:17:39 2005
@@ -1,13 +1,7 @@
 #!/usr/bin/perl
 # this is a simple 'drop packets on the floor' plugin
 
-sub register {
-  my $self = shift;
-
-  $self->register_hook('logging', 'wlog');
-}
-
-sub wlog {
+sub hook_logging {
   return DECLINED;
 }
 

Modified: trunk/plugins/logging/warn
==============================================================================
--- trunk/plugins/logging/warn	(original)
+++ trunk/plugins/logging/warn	Wed Jul  6 21:17:39 2005
@@ -16,14 +16,13 @@ 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 wlog {
+sub hook_logging {
   my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
 
   # Don't log your own log entries!  If this is the only logging plugin

Modified: trunk/plugins/milter
==============================================================================
--- trunk/plugins/milter	(original)
+++ trunk/plugins/milter	Wed Jul  6 21:17:39 2005
@@ -42,15 +42,9 @@ sub register {
   $self->{host} = $host;
   $self->{port} = $port;
   
-  $self->register_hook("connect", "connect_handler");
-  $self->register_hook("helo", "helo_handler");
-  $self->register_hook("mail", "mail_handler");
-  $self->register_hook("rcpt", "rcpt_handler");
-  $self->register_hook("data_post", "data_handler");
-  $self->register_hook("disconnect", "disconnect_handler");
 }
 
-sub disconnect_handler {
+sub hook_disconnect {
     my ($self) = @_;
 
     my $milter = $self->qp->connection->notes('milter') || return DECLINED;
@@ -93,7 +87,7 @@ sub check_results {
     }
 }
 
-sub connect_handler {
+sub hook_connect {
     my ($self, $transaction) = @_;
     
     $self->log(LOGDEBUG, "milter $self->{name} opening connection to milter backend");
@@ -119,7 +113,7 @@ sub connect_handler {
     return DECLINED;
 }
 
-sub helo_handler {
+sub hook_helo {
     my ($self, $transaction) = @_;
 
     if (my $txt = $self->qp->connection->notes('spam')) {
@@ -140,7 +134,7 @@ sub helo_handler {
     return DECLINED;
 }
 
-sub mail_handler {
+sub hook_mail {
     my ($self, $transaction, $address) = @_;
     
     my $milter = $self->qp->connection->notes('milter');
@@ -153,7 +147,7 @@ sub mail_handler {
     return DECLINED;
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
     my ($self, $transaction, $address) = @_;
     
     my $milter = $self->qp->connection->notes('milter');
@@ -167,7 +161,7 @@ sub rcpt_handler {
     return DECLINED;
 }
 
-sub data_handler {
+sub hook_data {
     my ($self, $transaction) = @_;
 
     my $milter = $self->qp->connection->notes('milter');

Modified: trunk/plugins/queue/maildir
==============================================================================
--- trunk/plugins/queue/maildir	(original)
+++ trunk/plugins/queue/maildir	Wed Jul  6 21:17:39 2005
@@ -35,13 +35,11 @@ sub register {
   my $hostname = (hostname =~ m/([\w\._\-]+)/)[0];
   $self->{_hostname} = $hostname;
 
-  $self->register_hook("queue", "queue_handler");
-
 }
 
 my $maildir_counter = 0;
 
-sub queue_handler {
+sub hook_queue {
   my ($self, $transaction) = @_;
 
   my ($time, $microseconds) = gettimeofday;

Modified: trunk/plugins/queue/postfix-queue
==============================================================================
--- trunk/plugins/queue/postfix-queue	(original)
+++ trunk/plugins/queue/postfix-queue	Wed Jul  6 21:17:39 2005
@@ -18,7 +18,6 @@ use Qpsmtpd::Postfix;
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("queue", "queue_handler");
 
   if (@args > 0) {
     $self->{_queue_socket} = $args[0];
@@ -31,7 +30,7 @@ sub register {
 
 }
 
-sub queue_handler {
+sub hook_queue {
   my ($self, $transaction) = @_;
 
   my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);

Modified: trunk/plugins/queue/qmail-queue
==============================================================================
--- trunk/plugins/queue/qmail-queue	(original)
+++ trunk/plugins/queue/qmail-queue	Wed Jul  6 21:17:39 2005
@@ -23,7 +23,6 @@ use POSIX ();
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("queue", "queue_handler");
 
   if (@args > 0) {
     $self->{_queue_exec} = $args[0];
@@ -36,7 +35,7 @@ sub register {
   $self->{_queue_exec} = $ENV{QMAILQUEUE} if $ENV{QMAILQUEUE};
 }
 
-sub queue_handler {
+sub hook_queue {
   my ($self, $transaction) = @_;
 
   # these bits inspired by Peter Samuels "qmail-queue wrapper"

Modified: trunk/plugins/queue/smtp-forward
==============================================================================
--- trunk/plugins/queue/smtp-forward	(original)
+++ trunk/plugins/queue/smtp-forward	Wed Jul  6 21:17:39 2005
@@ -23,7 +23,6 @@ use Net::SMTP;
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("queue", "queue_handler");
 
   if (@args > 0) {
     if ($args[0] =~ /^([\.\w_-]+)$/) {
@@ -43,7 +42,7 @@ sub register {
 
 }
 
-sub queue_handler {
+sub hook_queue {
   my ($self, $transaction) = @_;
 
   $self->log(LOGINFO, "forwarding to $self->{_smtp_server}:$self->{_smtp_port}");

Modified: trunk/plugins/quit_fortune
==============================================================================
--- trunk/plugins/quit_fortune	(original)
+++ trunk/plugins/quit_fortune	Wed Jul  6 21:17:39 2005
@@ -1,9 +1,5 @@
 
-sub register {
-  shift->register_hook("quit", "quit_handler");
-}
-
-sub quit_handler {
+sub hook_quit {
   my $qp = shift->qp;
 
   # if she talks EHLO she is probably too sophisticated to enjoy the

Modified: trunk/plugins/rcpt_ok
==============================================================================
--- trunk/plugins/rcpt_ok	(original)
+++ trunk/plugins/rcpt_ok	Wed Jul  6 21:17:39 2005
@@ -3,12 +3,7 @@
 # It should be configured to be run _LAST_!
 #
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("rcpt", "rcpt_ok");
-}
-
-sub rcpt_ok {
+sub hook_rcpt {
   my ($self, $transaction, $recipient) = @_;
   my $host = lc $recipient->host;
 

Modified: trunk/plugins/require_resolvable_fromhost
==============================================================================
--- trunk/plugins/require_resolvable_fromhost	(original)
+++ trunk/plugins/require_resolvable_fromhost	Wed Jul  6 21:17:39 2005
@@ -1,11 +1,6 @@
 use Net::DNS qw(mx);
 
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("mail", "mail_handler");
-}
-
-sub mail_handler {
+sub hook_mail {
   my ($self, $transaction, $sender) = @_;
 
   return DECLINED

Modified: trunk/plugins/rhsbl
==============================================================================
--- trunk/plugins/rhsbl	(original)
+++ trunk/plugins/rhsbl	Wed Jul  6 21:17:39 2005
@@ -1,12 +1,5 @@
-sub register {
-  my ($self, $qp) = @_;
 
-  $self->register_hook('mail', 'mail_handler');
-  $self->register_hook('rcpt', 'rcpt_handler');
-  $self->register_hook('disconnect', 'disconnect_handler');
-}
-
-sub mail_handler {
+sub hook_mail {
   my ($self, $transaction, $sender) = @_;
 
   my $res = new Net::DNS::Resolver;
@@ -40,7 +33,7 @@ sub mail_handler {
   return DECLINED;
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
   my ($self, $transaction, $rcpt) = @_;
   my $host = $transaction->sender->host;
   my $hello = $self->qp->connection->hello_host;
@@ -111,7 +104,7 @@ sub process_sockets {
   return $trans->notes('rhsbl', $result);
 }
 
-sub disconnect_handler {
+sub hook_disconnect {
   my ($self, $transaction) = @_;
 
   $transaction->notes('rhsbl_sockets', undef);

Modified: trunk/plugins/sender_permitted_from
==============================================================================
--- trunk/plugins/sender_permitted_from	(original)
+++ trunk/plugins/sender_permitted_from	Wed Jul  6 21:17:39 2005
@@ -31,12 +31,9 @@ use Mail::SPF::Query 1.991;
 sub register {
   my ($self, $qp, @args) = @_;
   %{$self->{_args}} = @args;
-  $self->register_hook("mail", "mail_handler");
-  $self->register_hook("rcpt", "rcpt_handler");
-  $self->register_hook("data_post", "data_handler");
 }
 
-sub mail_handler {
+sub hook_mail {
   my ($self, $transaction, $sender) = @_;
 
   return (DECLINED) unless ($sender->format ne "<>"
@@ -73,7 +70,7 @@ sub mail_handler {
   return (DECLINED);
 }
 
-sub rcpt_handler {
+sub hook_rcpt {
   my ($self, $transaction, $rcpt) = @_;
   
   # special addresses don't get SPF-tested.
@@ -109,7 +106,7 @@ sub _uri_escape {
   return $str;
 }
 
-sub data_handler {
+sub hook_data {
   my ($self, $transaction) = @_;
 
   my $query = $transaction->notes('spfquery');

Modified: trunk/plugins/spamassassin
==============================================================================
--- trunk/plugins/spamassassin	(original)
+++ trunk/plugins/spamassassin	Wed Jul  6 21:17:39 2005
@@ -76,7 +76,6 @@ use IO::Handle;
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("data_post", "check_spam");
 
   $self->log(LOGERROR, "Bad parameters for the spamassassin plugin")
     if @_ % 2;
@@ -91,7 +90,7 @@ sub register {
 
 }
 
-sub check_spam {
+sub hook_data_post { # check_spam
   my ($self, $transaction) = @_;
 
   $self->log(LOGDEBUG, "check_spam");

Modified: trunk/plugins/virus/aveclient
==============================================================================
--- trunk/plugins/virus/aveclient	(original)
+++ trunk/plugins/virus/aveclient	Wed Jul  6 21:17:39 2005
@@ -96,9 +96,6 @@ use Mail::Address;
 sub register {
 	my ($self, $qp, @args) = @_;
 	
-	# where to be called
-	$self->register_hook("data_post", "avscan");
-	
 	# defaults to be used
 	$self->{_avclient_bin} 	= "/opt/kav/bin/aveclient";
 	$self->{_avdaemon_sock} = "/var/run/aveserver";
@@ -122,7 +119,7 @@ sub register {
 	}
 }
  
-sub avscan {
+sub hook_data_post {
 	my ($self, $transaction) = @_;
 	my ($temp_fh, $filename) = tempfile();
 	my $description = 'clean';

Modified: trunk/plugins/virus/bitdefender
==============================================================================
--- trunk/plugins/virus/bitdefender	(original)
+++ trunk/plugins/virus/bitdefender	Wed Jul  6 21:17:39 2005
@@ -67,7 +67,6 @@ use warnings;
 
 sub register {
     my ( $self, $qp, @args ) = @_;
-    $self->register_hook( "data_post", "bdc_scan" );
 
     while (@args) {
         $self->{"_bitd"}->{ pop @args } = pop @args;
@@ -78,7 +77,7 @@ sub register {
     $self->{"_bitd"}->{"max_size"} *= 1024;
 }
 
-sub bdc_scan {
+sub hook_data_post {
     my ( $self, $transaction ) = @_;
 
     if ( $transaction->body_size > $self->{"_bitd"}->{"max_size"} ) {

Modified: trunk/plugins/virus/check_for_hi_virus
==============================================================================
--- trunk/plugins/virus/check_for_hi_virus	(original)
+++ trunk/plugins/virus/check_for_hi_virus	Wed Jul  6 21:17:39 2005
@@ -1,11 +1,6 @@
 #!/usr/bin/perl -w
 
-sub register {
-    my $self = shift;
-    $self->register_hook('data_post', 'check_for_hi_virus');
-}
-
-sub check_for_hi_virus {
+sub hook_data_post {
     my ($self, $transaction) = @_;
 
     # make sure we read from the beginning;

Modified: trunk/plugins/virus/clamav
==============================================================================
--- trunk/plugins/virus/clamav	(original)
+++ trunk/plugins/virus/clamav	Wed Jul  6 21:17:39 2005
@@ -148,11 +148,9 @@ sub register {
         return undef;
   }
 
-  $self->register_hook("data_post", "clam_scan");
-  1;
 }
  
-sub clam_scan {
+sub hook_data_post {
   my ($self, $transaction) = @_;
 
   if ($transaction->body_size > $self->{_max_size}) {

Modified: trunk/plugins/virus/clamdscan
==============================================================================
--- trunk/plugins/virus/clamdscan	(original)
+++ trunk/plugins/virus/clamdscan	Wed Jul  6 21:17:39 2005
@@ -94,7 +94,6 @@ use Clamd;
 
 sub register {
     my ( $self, $qp, @args ) = @_;
-    $self->register_hook( "data_post", "clamdscan" );
 
     %{ $self->{"_clamd"} } = @args;
 
@@ -104,7 +103,7 @@ sub register {
     $self->{"_clamd"}->{"max_size"}     ||= 128;
 }
 
-sub clamdscan {
+sub hook_data_post {
     my ( $self, $transaction ) = @_;
     $DB::single = 1;
 

Modified: trunk/plugins/virus/hbedv
==============================================================================
--- trunk/plugins/virus/hbedv	(original)
+++ trunk/plugins/virus/hbedv	Wed Jul  6 21:17:39 2005
@@ -53,7 +53,6 @@ The B<hbedv> plugin is published under t
  
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("data_post", "hbedv_scan");
   
   if (@args % 2) {
      $self->log(LOGERROR, "FATAL ERROR: odd number of arguments");
@@ -72,7 +71,7 @@ sub register {
   }
 }
  
-sub hbedv_scan {
+sub hook_data_post {
   my ($self, $transaction) = @_;
  
   my $filename = $transaction->body_filename;

Modified: trunk/plugins/virus/kavscanner
==============================================================================
--- trunk/plugins/virus/kavscanner	(original)
+++ trunk/plugins/virus/kavscanner	Wed Jul  6 21:17:39 2005
@@ -57,7 +57,6 @@ use Mail::Address;
  
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("data_post", "kav_scan");
 
   if (@args % 2) {
     $self->log(LOGWARN, "kavscanner: Wrong number of arguments");
@@ -80,7 +79,7 @@ sub register {
   } 
 }
  
-sub kav_scan {
+sub hook_data_post {
   my ($self, $transaction) = @_;
  
   my ($temp_fh, $filename) = tempfile();

Modified: trunk/plugins/virus/klez_filter
==============================================================================
--- trunk/plugins/virus/klez_filter	(original)
+++ trunk/plugins/virus/klez_filter	Wed Jul  6 21:17:39 2005
@@ -1,9 +1,5 @@
-sub register {
-  my ($self, $qp) = @_;
-  $self->register_hook("data_post", "check_klez");
-}
 
-sub check_klez {
+sub hook_data_post {
   my ($self, $transaction) = @_;
 
   # klez files are always sorta big .. how big?  Dunno. 

Modified: trunk/plugins/virus/sophie
==============================================================================
--- trunk/plugins/virus/sophie	(original)
+++ trunk/plugins/virus/sophie	Wed Jul  6 21:17:39 2005
@@ -3,7 +3,6 @@ use IO::Socket;
 
 sub register {
     my ( $self, $qp, @args ) = @_;
-    $self->register_hook( "data_post", "sophiescan" );
 
     %{ $self->{"_sophie"} } = @args;
 
@@ -13,7 +12,7 @@ sub register {
     $self->{"_sophie"}->{"max_size"}      ||= 128;
 }
 
-sub sophiescan {
+sub hook_data_post {
     my ( $self, $transaction ) = @_;
     $DB::single = 1;
 

Modified: trunk/plugins/virus/uvscan
==============================================================================
--- trunk/plugins/virus/uvscan	(original)
+++ trunk/plugins/virus/uvscan	Wed Jul  6 21:17:39 2005
@@ -44,7 +44,6 @@ Please see the LICENSE file included wit
 
 sub register {
   my ($self, $qp, @args) = @_;
-  $self->register_hook("data_post", "uvscan");
 
   while (@args) {
   	$self->{"_uvscan"}->{pop @args}=pop @args;
@@ -52,7 +51,7 @@ sub register {
   $self->{"_uvscan"}->{"uvscan_location"}||="/usr/local/bin/uvscan";
 }
  
-sub uvscan {
+sub hook_data_post {
   my ($self, $transaction) = @_;
  
   return (DECLINED)