Mail::...esolver(3pm)
π¦ NAME π¦
hey bestie, welcome to Mail::SpamAssassin::DnsResolver β it's the DNS resolution engine β¨ (that's the 3pm perl manual page for it, btw, no cap)
π DESCRIPTION π
okay so listen. this is a DNS resolution engine for SpamAssassin, and the whole reason it exists is tea: it was implemented in order to reduce file descriptor usage by Net::DNS and also to avoid a response collision bug in that module. like, they built a whole engine because Net::DNS was doing too much π. iconic behavior honestly.
π METHODS π
$res->load_resolver()β loads up theNet::DNS::Resolverobject. returns0if Net::DNS cannot be used, and1if it is available. so basically a vibe check on Net::DNS πΈ$resolver = $res->get_resolver()β hands you back theNet::DNS::Resolverobject. that's it, that's the whole thing π«Ά$res->configured_nameservers()β gets you a list of nameservers as configured bydns_serverdirectives, or as provided by Net::DNS β typically straight from/etc/resolv.confπ$res->available_nameservers()β get or set a list of currently available nameservers. typically this is a known-to-be-good subset of the configured nameservers, like the ones that aren't flaking on you π$res->connect_sock()β re-connects to the first nameserver listed in/etc/resolv.confor a similar platform-dependent source, as provided byNet::DNSπ$res->get_sock()β returns theIO::Socket::INETobject that's used to talk to the nameserver π¬$packet = new_dns_packet ($domain, $type, $class)β a wrapper forNet::DNS::Packet::new()that traps adiethrown by it. very protective gf energy π‘οΈ
to use this, you change calls to Net::DNS::Resolver::bgsend from:
$res->bgsend($domain, $type);
to:
$res->bgsend(Mail::SpamAssassin::DnsResolver::new_dns_packet($domain, $type, $class));
$id = $res->bgsend($domain, $type, $class, $cb)β DIRECT USE DISCOURAGED, please usebgsend_and_start_lookupin plugins π« (bestie, they're literally asking you nicely)
it's quite similar to Net::DNS::Resolver::bgsend, except that when a reply packet eventually arrives, and poll_responses gets 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. (defaults, we love her β¨)
the callback sub will be called with three arguments β the packet that was delivered, and an id string that fingerprints the query packet and the expected reply. the third argument is a timestamp (Unix time, floating point), captured at the time the packet was collected. it is expected that a closure callback be used, like so:
my $id = $self->{resolver}->bgsend($domain, $type, undef, sub {
my ($reply, $reply_id, $timestamp) = @_;
$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 π
$id = $res->bgread()β similar toNet::DNS::Resolver::bgread. reads a DNS packet from a supplied socket, decodes it, and returns aNet::DNS::Packetobject if successful. dies on error π (dramatic but true)$nfound = $res->poll_responses()β checks whether there are anybgsendreply packets ready, and returns the number of such packets delivered to their callbacks π$res->bgabort()β call this to release pending requests from memory, when aborting backgrounded requests, or when the scan is complete.Mail::SpamAssassin::PerMsgStatus::checkcalls this before returning. it's giving cleanup crew π§Ή$packet = $res->send($name, $type, $class)β emulatesNet::DNS::Resolver::send().
warning bestie: this subroutine is a simple synchronous leftover from SpamAssassin version 3.3 and does not participate in packet query caching and callback grouping as implemented byAsyncLoop::bgsend_and_start_lookup(). as such it should be avoided for mainstream usage. π currently used throughMail::SPF::Serverby the SPF plugin. (so like, it's still employed, just not for the cool stuff)
$res->errorstring()β little more than a stub for callers expecting this fromNet::DNS::Resolver.
if called immediately after a call to $res->send this will return query timed out if the $res->send DNS query timed out. otherwise unknown error or no error will be returned. π
no other errors are reported. that's it, that's the whole error menu.
$res->finish_socket()β resets the socket when you're done with it πΏ$res->finish()β cleans up for destruction π
and that's the page, bestie π«Ά this was perl v5.40.1, dated 2026-07-23, pulled from the 3pm User Contributed Perl Documentation section. slay, go resolve some DNS ππ
π¦ where this page comes from
- ubuntu stonking: spamassassin 4.0.2+svn1935691-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms