Avoid passing Qpsmtpd object refs around
Use an instantiator in Qpsmtpd.pm for creating Qpsmtpd::Address objects instead
This commit is contained in:
parent
1253e73a4d
commit
e9c56dc268
@ -648,6 +648,13 @@ sub auth_mechanism {
|
|||||||
return (defined $self->{_auth_mechanism} ? $self->{_auth_mechanism} : "");
|
return (defined $self->{_auth_mechanism} ? $self->{_auth_mechanism} : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub address {
|
||||||
|
my $self = shift;
|
||||||
|
my $addr = Qpsmtpd::Address->new(@_);
|
||||||
|
$addr->{qp} = $self;
|
||||||
|
return $addr;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -345,9 +345,14 @@ hook_user_config
|
|||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
sub qp {
|
||||||
|
my ($self) = @_;
|
||||||
|
return $self->{qp};
|
||||||
|
}
|
||||||
|
|
||||||
sub config {
|
sub config {
|
||||||
my ($self,$key) = @_;
|
my ($self,$key) = @_;
|
||||||
my $qp = $self->notes('qp_obj') or return;
|
my $qp = $self->qp or return;
|
||||||
return $qp->config($key,$self);
|
return $qp->config($key,$self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ use Qpsmtpd::Transaction;
|
|||||||
use Qpsmtpd::Plugin;
|
use Qpsmtpd::Plugin;
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
use Qpsmtpd::Auth;
|
use Qpsmtpd::Auth;
|
||||||
use Qpsmtpd::Address ();
|
|
||||||
use Qpsmtpd::Command;
|
use Qpsmtpd::Command;
|
||||||
|
|
||||||
my %auth_mechanisms = ();
|
my %auth_mechanisms = ();
|
||||||
@ -389,14 +388,13 @@ sub mail_pre_respond {
|
|||||||
unless $from =~ /^<.*>$/;
|
unless $from =~ /^<.*>$/;
|
||||||
|
|
||||||
if ($from eq "<>" or $from =~ m/\[undefined\]/ or $from eq "<#@[]>") {
|
if ($from eq "<>" or $from =~ m/\[undefined\]/ or $from eq "<#@[]>") {
|
||||||
$from = Qpsmtpd::Address->new("<>");
|
$from = $self->address("<>");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$from = (Qpsmtpd::Address->parse($from))[0];
|
$from = $self->address($from);
|
||||||
}
|
}
|
||||||
return $self->respond(501, "could not parse your mail from command")
|
return $self->respond(501, "could not parse your mail from command")
|
||||||
unless $from;
|
unless $from;
|
||||||
$from->notes('qp_obj',$self);
|
|
||||||
|
|
||||||
$self->run_hooks("mail", $from, %$param);
|
$self->run_hooks("mail", $from, %$param);
|
||||||
}
|
}
|
||||||
@ -481,12 +479,11 @@ sub rcpt_pre_respond {
|
|||||||
return $self->respond(501, "could not parse recipient")
|
return $self->respond(501, "could not parse recipient")
|
||||||
unless $rcpt =~ /^<.*>$/;
|
unless $rcpt =~ /^<.*>$/;
|
||||||
|
|
||||||
$rcpt = (Qpsmtpd::Address->parse($rcpt))[0];
|
$rcpt = $self->address($rcpt);
|
||||||
|
|
||||||
return $self->respond(501, "could not parse recipient")
|
return $self->respond(501, "could not parse recipient")
|
||||||
if (!$rcpt or ($rcpt->format eq '<>'));
|
if (!$rcpt or ($rcpt->format eq '<>'));
|
||||||
|
|
||||||
$rcpt->notes('qp_obj',$self);
|
|
||||||
$self->run_hooks("rcpt", $rcpt, %$param);
|
$self->run_hooks("rcpt", $rcpt, %$param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user