Mail::SpamAssassin::DnsResolver - DNS resolution engine
This is a DNS resolution engine for SpamAssassin, implemented in order to reduce file descriptor usage by Net::DNS and avoid a response collision bug in that module.
load_resolver()Net::DNS::Resolver object. Returns 0 if Net::DNS cannot be used,
1 if it is available.
get_resolver()Net::DNS::Resolver object.
nameservers()connect_sock()/etc/resolv.conf or similar
platform-dependent source, as provided by Net::DNS.
get_sock()IO::Socket::INET object used to communicate with
the nameserver.
Net::DNS::Packet::new() which traps a die thrown by it.
To use this, change calls to Net::DNS::Resolver::bgsend from:
$res->bgsend($hostname, $type);
to:
$res->bgsend(Mail::SpamAssassin::DnsResolver::new_dns_packet($hostname, $type, $class));
Net::DNS::Resolver::bgsend, except that when a response
packet eventually arrives, and poll_responses is called, the callback
sub reference $cb will be called.
Note that $type and $class may be undef, in which case they
will default to A and IN, respectively.
The callback sub will be called with two arguments -- the packet that was delivered and an id string that fingerprints the query packet and the expected reply. It is expected that a closure callback be used, like so:
my $id = $self->{resolver}->bgsend($host, $type, undef, sub {
my $reply = shift;
my $reply_id = shift;
$self->got_a_reply ($reply, $reply_id);
});
The callback can ignore the reply as an invalid packet sent to the listening port if the reply id does not match the return value from bgsend.
poll_responses()bgsend response packets ready, and return
the number of such packets delivered to their callbacks.
bgabort()Net::DNS::Resolver::send().
finish_socket()finish()