.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mail::SpamAssassin::DnsResolver 3" .TH Mail::SpamAssassin::DnsResolver 3 2024-09-01 "perl v5.40.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Mail::SpamAssassin::DnsResolver \- DNS resolution engine .SH DESCRIPTION .IX Header "DESCRIPTION" 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. .SH METHODS .IX Header "METHODS" .ie n .IP $res\->\fBload_resolver()\fR 4 .el .IP \f(CW$res\fR\->\fBload_resolver()\fR 4 .IX Item "$res->load_resolver()" Load the \f(CW\*(C`Net::DNS::Resolver\*(C'\fR object. Returns 0 if Net::DNS cannot be used, 1 if it is available. .ie n .IP "$resolver = $res\->\fBget_resolver()\fR" 4 .el .IP "\f(CW$resolver\fR = \f(CW$res\fR\->\fBget_resolver()\fR" 4 .IX Item "$resolver = $res->get_resolver()" Return the \f(CW\*(C`Net::DNS::Resolver\*(C'\fR object. .ie n .IP $res\->\fBconfigured_nameservers()\fR 4 .el .IP \f(CW$res\fR\->\fBconfigured_nameservers()\fR 4 .IX Item "$res->configured_nameservers()" Get a list of nameservers as configured by dns_server directives or as provided by Net::DNS, typically from /etc/resolv.conf .ie n .IP $res\->\fBavailable_nameservers()\fR 4 .el .IP \f(CW$res\fR\->\fBavailable_nameservers()\fR 4 .IX Item "$res->available_nameservers()" Get or set a list of currently available nameservers, which is typically a known-to-be-good subset of configured nameservers .ie n .IP $res\->\fBconnect_sock()\fR 4 .el .IP \f(CW$res\fR\->\fBconnect_sock()\fR 4 .IX Item "$res->connect_sock()" Re-connect to the first nameserver listed in \f(CW\*(C`/etc/resolv.conf\*(C'\fR or similar platform-dependent source, as provided by \f(CW\*(C`Net::DNS\*(C'\fR. .ie n .IP $res\->\fBget_sock()\fR 4 .el .IP \f(CW$res\fR\->\fBget_sock()\fR 4 .IX Item "$res->get_sock()" Return the \f(CW\*(C`IO::Socket::INET\*(C'\fR object used to communicate with the nameserver. .ie n .IP "$packet = new_dns_packet ($domain, $type, $class)" 4 .el .IP "\f(CW$packet\fR = new_dns_packet ($domain, \f(CW$type\fR, \f(CW$class\fR)" 4 .IX Item "$packet = new_dns_packet ($domain, $type, $class)" A wrapper for \f(CWNet::DNS::Packet::new()\fR which traps a die thrown by it. .Sp To use this, change calls to \f(CW\*(C`Net::DNS::Resolver::bgsend\*(C'\fR from: .Sp .Vb 1 \& $res\->bgsend($domain, $type); .Ve .Sp to: .Sp .Vb 1 \& $res\->bgsend(Mail::SpamAssassin::DnsResolver::new_dns_packet($domain, $type, $class)); .Ve .ie n .IP "$id = $res\->bgsend($domain, $type, $class, $cb)" 4 .el .IP "\f(CW$id\fR = \f(CW$res\fR\->bgsend($domain, \f(CW$type\fR, \f(CW$class\fR, \f(CW$cb\fR)" 4 .IX Item "$id = $res->bgsend($domain, $type, $class, $cb)" DIRECT USE DISCOURAGED, please use bgsend_and_start_lookup in plugins. .Sp Quite similar to \f(CW\*(C`Net::DNS::Resolver::bgsend\*(C'\fR, except that when a reply packet eventually arrives, and \f(CW\*(C`poll_responses\*(C'\fR is called, the callback sub reference \f(CW$cb\fR will be called. .Sp Note that \f(CW$type\fR and \f(CW$class\fR may be \f(CW\*(C`undef\*(C'\fR, in which case they will default to \f(CW\*(C`A\*(C'\fR and \f(CW\*(C`IN\*(C'\fR, respectively. .Sp 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: .Sp .Vb 4 \& my $id = $self\->{resolver}\->bgsend($domain, $type, undef, sub { \& my ($reply, $reply_id, $timestamp) = @_; \& $self\->got_a_reply($reply, $reply_id); \& }); .Ve .Sp 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. .ie n .IP "$id = $res\->\fBbgread()\fR" 4 .el .IP "\f(CW$id\fR = \f(CW$res\fR\->\fBbgread()\fR" 4 .IX Item "$id = $res->bgread()" Similar to \f(CW\*(C`Net::DNS::Resolver::bgread\*(C'\fR. Reads a DNS packet from a supplied socket, decodes it, and returns a Net::DNS::Packet object if successful. Dies on error. .ie n .IP "$nfound = $res\->\fBpoll_responses()\fR" 4 .el .IP "\f(CW$nfound\fR = \f(CW$res\fR\->\fBpoll_responses()\fR" 4 .IX Item "$nfound = $res->poll_responses()" See if there are any \f(CW\*(C`bgsend\*(C'\fR reply packets ready, and return the number of such packets delivered to their callbacks. .ie n .IP $res\->\fBbgabort()\fR 4 .el .IP \f(CW$res\fR\->\fBbgabort()\fR 4 .IX Item "$res->bgabort()" Call this to release pending requests from memory, when aborting backgrounded requests, or when the scan is complete. \&\f(CW\*(C`Mail::SpamAssassin::PerMsgStatus::check\*(C'\fR calls this before returning. .ie n .IP "$packet = $res\->send($name, $type, $class)" 4 .el .IP "\f(CW$packet\fR = \f(CW$res\fR\->send($name, \f(CW$type\fR, \f(CW$class\fR)" 4 .IX Item "$packet = $res->send($name, $type, $class)" Emulates \f(CWNet::DNS::Resolver::send()\fR. .Sp 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 by \fBAsyncLoop::bgsend_and_start_lookup()\fR. As such it should be avoided for mainstream usage. Currently used through Mail::SPF::Server by the SPF plugin. .ie n .IP $res\->\fBerrorstring()\fR 4 .el .IP \f(CW$res\fR\->\fBerrorstring()\fR 4 .IX Item "$res->errorstring()" Little more than a stub for callers expecting this from \f(CW\*(C`Net::DNS::Resolver\*(C'\fR. .Sp If called immediately after a call to \f(CW$res\fR\->send this will return \&\f(CW\*(C`query timed out\*(C'\fR if the \f(CW$res\fR\->send DNS query timed out. Otherwise \&\f(CW\*(C`unknown error or no error\*(C'\fR will be returned. .Sp No other errors are reported. .ie n .IP $res\->\fBfinish_socket()\fR 4 .el .IP \f(CW$res\fR\->\fBfinish_socket()\fR 4 .IX Item "$res->finish_socket()" Reset socket when done with it. .ie n .IP $res\->\fBfinish()\fR 4 .el .IP \f(CW$res\fR\->\fBfinish()\fR 4 .IX Item "$res->finish()" Clean up for destruction.