removed hook_connect, unnecessary.
---
 plugins/count_unrecognized_commands |   29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/plugins/count_unrecognized_commands 
b/plugins/count_unrecognized_commands
index 445dca7..1c3cbf2 100644
--- a/plugins/count_unrecognized_commands
+++ b/plugins/count_unrecognized_commands
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-count_unrecognized_commands - Count unrecognized commands and disconnect when 
we have too many
+count_unrecognized_commands - and disconnect after too many
 
 =head1 DESCRIPTION
 
@@ -31,29 +31,18 @@ sub register {
     }
 }
 
-sub hook_connect {
-  my $self = shift;
-
-  $self->connection->notes('unrec_cmd_count', 0);
-  return DECLINED;
-}
-
 sub hook_unrecognized_command {
   my ($self, $cmd) = @_[0,2];
   
-  $self->log(LOGINFO, "Unrecognized command '$cmd'");
-
-  my $badcmdcount = 
-    $self->connection->notes( 'unrec_cmd_count',
-        ($self->connection->notes('unrec_cmd_count') || 0) + 1
-    );
+    my $count = $self->connection->notes('unrec_cmd_count') || 0 + 1;
+                $self->connection->notes('unrec_cmd_count', $count );
 
-  if ($badcmdcount >= $self->{_unrec_cmd_max}) {
-    my $msg = "Closing connection, $badcmdcount unrecognized commands.";
-    $self->log(LOGINFO, "fail: $msg");
-    return (DENY_DISCONNECT, "$msg Perhaps you should read RFC 2821?");
-  }
+    if ( $count < $self->{_unrec_cmd_max} ) {
+        $self->log(LOGINFO, "'$cmd', ($count)");
+        return DECLINED;
+    };
 
-  return DECLINED;
+    $self->log(LOGINFO, "fail, '$cmd' ($count)");
+    return (DENY_DISCONNECT, "Closing connection, $count unrecognized 
commands. Perhaps you should read RFC 2821?" );
 }
 
-- 
1.7.9.6

Reply via email to