From a9e2089ab71ab7e44698aa74f7d04343db7be578 Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Mon, 12 May 2008 14:42:41 +0000 Subject: [PATCH] async: check return values from pre-connection hook git-svn-id: https://svn.perl.org/qpsmtpd/trunk@900 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd/PollServer.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Qpsmtpd/PollServer.pm b/lib/Qpsmtpd/PollServer.pm index 58207a1..a9812a7 100644 --- a/lib/Qpsmtpd/PollServer.pm +++ b/lib/Qpsmtpd/PollServer.pm @@ -55,7 +55,21 @@ sub new { $self->{mode} = 'connect'; $self->load_plugins; $self->load_logging; - $self->run_hooks("pre-connection"); + + my ($rc, @msg) = $self->run_hooks("pre-connection"); + if ($rc == DENYSOFT || $rc == DENYSOFT_DISCONNECT) { + @msg = ("Sorry, try again later") + unless @msg; + $self->respond(451, @msg); + $self->disconnect; + } + elsif ($rc == DENY || $rc == DENY_DISCONNECT) { + @msg = ("Sorry, service not available for you") + unless @msg; + $self->respond(550, @msg); + $self->disconnect; + } + return $self; }