Follow the logic of the non-async version and other MTAs: make first
the MX lookups and, only if they return nothing, make the A lookups. git-svn-id: https://svn.perl.org/qpsmtpd/trunk@880 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
79aa27f444
commit
149c9c4790
@ -73,7 +73,8 @@ sub check_dns {
|
|||||||
$qp->input_sock->pause_read;
|
$qp->input_sock->pause_read;
|
||||||
|
|
||||||
my $a_records = [];
|
my $a_records = [];
|
||||||
my $num_queries = $has_ipv6 ? 3 : 2; # queries in progress
|
my $num_queries = 1; # queries in progress
|
||||||
|
my $mx_found = 0;
|
||||||
|
|
||||||
ParaDNS->new(
|
ParaDNS->new(
|
||||||
callback => sub {
|
callback => sub {
|
||||||
@ -81,6 +82,7 @@ sub check_dns {
|
|||||||
return if $mx =~ /^[A-Z]+$/; # error
|
return if $mx =~ /^[A-Z]+$/; # error
|
||||||
|
|
||||||
my $addr = $mx->[0];
|
my $addr = $mx->[0];
|
||||||
|
$mx_found = 1;
|
||||||
|
|
||||||
$num_queries++;
|
$num_queries++;
|
||||||
ParaDNS->new(
|
ParaDNS->new(
|
||||||
@ -100,28 +102,42 @@ sub check_dns {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
finished => sub { $num_queries--; $self->finish_up($qp, $a_records, $num_queries) },
|
finished => sub {
|
||||||
host => $host,
|
|
||||||
type => 'MX',
|
unless ($mx_found) {
|
||||||
) or return;
|
|
||||||
|
$num_queries++;
|
||||||
ParaDNS->new(
|
ParaDNS->new(
|
||||||
callback => sub { push @$a_records, $_[0] if $_[0] !~ /^[A-Z]+$/; },
|
callback => sub { push @$a_records, $_[0] if $_[0] !~ /^[A-Z]+$/; },
|
||||||
finished => sub { $num_queries--; $self->finish_up($qp, $a_records, $num_queries) },
|
finished => sub { $num_queries--; $self->finish_up($qp, $a_records, $num_queries) },
|
||||||
host => $host,
|
host => $host,
|
||||||
type => 'A',
|
type => 'A',
|
||||||
) or return;
|
);
|
||||||
|
|
||||||
|
if ($has_ipv6) {
|
||||||
|
$num_queries++;
|
||||||
ParaDNS->new(
|
ParaDNS->new(
|
||||||
callback => sub { push @$a_records, $_[0] if $_[0] !~ /^[A-Z]+$/; },
|
callback => sub { push @$a_records, $_[0] if $_[0] !~ /^[A-Z]+$/; },
|
||||||
finished => sub { $num_queries--; $self->finish_up($qp, $a_records, $num_queries) },
|
finished => sub { $num_queries--; $self->finish_up($qp, $a_records, $num_queries) },
|
||||||
host => $host,
|
host => $host,
|
||||||
type => 'AAAA',
|
type => 'AAAA',
|
||||||
) or return if $has_ipv6;
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$num_queries--;
|
||||||
|
$self->finish_up($qp, $a_records, $num_queries);
|
||||||
|
},
|
||||||
|
host => $host,
|
||||||
|
type => 'MX',
|
||||||
|
) or $qp->input_sock->continue_read, return;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub finish_up {
|
sub finish_up {
|
||||||
my ($self, $qp, $a_records, $num_queries, $source) = @_;
|
my ($self, $qp, $a_records, $num_queries) = @_;
|
||||||
|
|
||||||
return if defined $qp->transaction->notes('resolvable_fromhost');
|
return if defined $qp->transaction->notes('resolvable_fromhost');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user