2002-07-03 15:10:44 +02:00
|
|
|
package Qpsmtpd::Constants;
|
|
|
|
use strict;
|
2002-07-08 04:30:11 +02:00
|
|
|
require Exporter;
|
|
|
|
|
2004-03-05 13:46:24 +01:00
|
|
|
# log levels
|
2005-03-29 22:15:53 +02:00
|
|
|
my %log_levels = (
|
2013-04-21 06:08:43 +02:00
|
|
|
LOGDEBUG => 7,
|
|
|
|
LOGINFO => 6,
|
|
|
|
LOGNOTICE => 5,
|
|
|
|
LOGWARN => 4,
|
|
|
|
LOGERROR => 3,
|
|
|
|
LOGCRIT => 2,
|
|
|
|
LOGALERT => 1,
|
|
|
|
LOGEMERG => 0,
|
|
|
|
LOGRADAR => 0,
|
|
|
|
);
|
2005-03-29 22:15:53 +02:00
|
|
|
|
|
|
|
# return codes
|
|
|
|
my %return_codes = (
|
2013-04-21 06:08:43 +02:00
|
|
|
OK => 900,
|
|
|
|
DENY => 901, # 550
|
|
|
|
DENYSOFT => 902, # 450
|
|
|
|
DENYHARD => 903, # 550 + disconnect (deprecated in 0.29)
|
|
|
|
DENY_DISCONNECT => 903, # 550 + disconnect
|
|
|
|
DENYSOFT_DISCONNECT => 904, # 450 + disconnect
|
|
|
|
DECLINED => 909,
|
|
|
|
DONE => 910,
|
|
|
|
);
|
2005-03-29 22:15:53 +02:00
|
|
|
|
|
|
|
use vars qw(@ISA @EXPORT);
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
@EXPORT = (keys(%return_codes), keys(%log_levels), "return_code", "log_level");
|
|
|
|
|
2013-04-21 06:08:43 +02:00
|
|
|
foreach (keys %return_codes) {
|
|
|
|
eval "use constant $_ => " . $return_codes{$_};
|
2005-03-29 22:15:53 +02:00
|
|
|
}
|
|
|
|
|
2013-04-21 06:08:43 +02:00
|
|
|
foreach (keys %log_levels) {
|
|
|
|
eval "use constant $_ => " . $log_levels{$_};
|
2005-03-29 22:15:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub return_code {
|
|
|
|
my $test = shift;
|
2013-04-21 06:08:43 +02:00
|
|
|
if ($test =~ /^\d+$/) { # need to return the textural form
|
|
|
|
foreach (keys %return_codes) {
|
|
|
|
return $_ if $return_codes{$_} =~ /$test/;
|
|
|
|
}
|
2005-03-29 22:15:53 +02:00
|
|
|
}
|
2013-04-21 06:08:43 +02:00
|
|
|
else { # just return the numeric value
|
|
|
|
return $return_codes{$test};
|
2005-03-29 22:15:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub log_level {
|
|
|
|
my $test = shift;
|
2013-04-21 06:08:43 +02:00
|
|
|
if ($test =~ /^\d+$/) { # need to return the textural form
|
|
|
|
foreach (keys %log_levels) {
|
|
|
|
return $_ if $log_levels{$_} =~ /$test/;
|
|
|
|
}
|
2005-03-29 22:15:53 +02:00
|
|
|
}
|
2013-04-21 06:08:43 +02:00
|
|
|
else { # just return the numeric value
|
|
|
|
return $log_levels{$test};
|
2005-03-29 22:15:53 +02:00
|
|
|
}
|
|
|
|
}
|
2002-07-03 15:10:44 +02:00
|
|
|
|
|
|
|
1;
|
2002-07-04 03:45:19 +02:00
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2003-06-24 09:42:38 +02:00
|
|
|
Qpsmtpd::Constants - Constants for plugins to use
|
2002-07-04 03:45:19 +02:00
|
|
|
|
2003-06-24 09:42:38 +02:00
|
|
|
=head1 CONSTANTS
|
2002-07-04 03:45:19 +02:00
|
|
|
|
2003-06-24 18:04:55 +02:00
|
|
|
See L<README.plugins> for hook specific information on applicable
|
|
|
|
constants.
|
|
|
|
|
2003-06-24 09:42:38 +02:00
|
|
|
Constants available:
|
2002-07-04 03:45:19 +02:00
|
|
|
|
2003-06-24 09:42:38 +02:00
|
|
|
=over 4
|
|
|
|
|
|
|
|
=item C<OK>
|
|
|
|
|
|
|
|
Return this only from the queue phase to indicate the mail was queued
|
|
|
|
successfully.
|
|
|
|
|
|
|
|
=item C<DENY>
|
|
|
|
|
|
|
|
Returning this from a hook causes a 5xx error (hard failure) to be
|
|
|
|
returned to the connecting client.
|
|
|
|
|
|
|
|
=item C<DENYSOFT>
|
|
|
|
|
|
|
|
Returning this from a hook causes a 4xx error (temporary failure - try
|
|
|
|
again later) to be returned to the connecting client.
|
|
|
|
|
|
|
|
=item C<DECLINED>
|
|
|
|
|
|
|
|
Returning this from a hook implies success, but tells qpsmtpd to go
|
|
|
|
on to the next plugin.
|
|
|
|
|
|
|
|
=item C<DONE>
|
|
|
|
|
|
|
|
Returning this from a hook implies success, but tells qpsmtpd to
|
|
|
|
skip any remaining plugins for this phase.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=cut
|