1Mail::SpamAssassin::DnsURseesrolCvoenrt(r3i)buted Perl DMoaciulm:e:nStpaatmiAosnsassin::DnsResolver(3)
2
3
4
6 Mail::SpamAssassin::DnsResolver - DNS resolution engine
7
9 This is a DNS resolution engine for SpamAssassin, implemented in order
10 to reduce file descriptor usage by Net::DNS and avoid a response
11 collision bug in that module.
12
14 $res->load_resolver()
15 Load the "Net::DNS::Resolver" object. Returns 0 if Net::DNS cannot
16 be used, 1 if it is available.
17
18 $resolver = $res->get_resolver()
19 Return the "Net::DNS::Resolver" object.
20
21 $res->configured_nameservers()
22 Get a list of nameservers as configured by dns_server directives or
23 as provided by Net::DNS, typically from /etc/resolv.conf
24
25 $res->available_nameservers()
26 Get or set a list of currently available nameservers, which is
27 typically a known-to-be-good subset of configured nameservers
28
29 $res->connect_sock()
30 Re-connect to the first nameserver listed in "/etc/resolv.conf" or
31 similar platform-dependent source, as provided by "Net::DNS".
32
33 $res->get_sock()
34 Return the "IO::Socket::INET" object used to communicate with the
35 nameserver.
36
37 $packet = new_dns_packet ($domain, $type, $class)
38 A wrapper for Net::DNS::Packet::new() which traps a die thrown by
39 it.
40
41 To use this, change calls to "Net::DNS::Resolver::bgsend" from:
42
43 $res->bgsend($domain, $type);
44
45 to:
46
47 $res->bgsend(Mail::SpamAssassin::DnsResolver::new_dns_packet($domain, $type, $class));
48
49 $id = $res->bgsend($domain, $type, $class, $cb)
50 DIRECT USE DISCOURAGED, please use bgsend_and_start_lookup in
51 plugins.
52
53 Quite similar to "Net::DNS::Resolver::bgsend", except that when a
54 reply packet eventually arrives, and "poll_responses" is called,
55 the callback sub reference $cb will be called.
56
57 Note that $type and $class may be "undef", in which case they will
58 default to "A" and "IN", respectively.
59
60 The callback sub will be called with three arguments -- the packet
61 that was delivered, and an id string that fingerprints the query
62 packet and the expected reply. The third argument is a timestamp
63 (Unix time, floating point), captured at the time the packet was
64 collected. It is expected that a closure callback be used, like so:
65
66 my $id = $self->{resolver}->bgsend($domain, $type, undef, sub {
67 my ($reply, $reply_id, $timestamp) = @_;
68 $self->got_a_reply($reply, $reply_id);
69 });
70
71 The callback can ignore the reply as an invalid packet sent to the
72 listening port if the reply id does not match the return value from
73 bgsend.
74
75 $id = $res->bgread()
76 Similar to "Net::DNS::Resolver::bgread". Reads a DNS packet from a
77 supplied socket, decodes it, and returns a Net::DNS::Packet object
78 if successful. Dies on error.
79
80 $nfound = $res->poll_responses()
81 See if there are any "bgsend" reply packets ready, and return the
82 number of such packets delivered to their callbacks.
83
84 $res->bgabort()
85 Call this to release pending requests from memory, when aborting
86 backgrounded requests, or when the scan is complete.
87 "Mail::SpamAssassin::PerMsgStatus::check" calls this before
88 returning.
89
90 $packet = $res->send($name, $type, $class)
91 Emulates Net::DNS::Resolver::send().
92
93 This subroutine is a simple synchronous leftover from SpamAssassin
94 version 3.3 and does not participate in packet query caching and
95 callback grouping as implemented by
96 AsyncLoop::bgsend_and_start_lookup(). As such it should be avoided
97 for mainstream usage. Currently used through Mail::SPF::Server by
98 the SPF plugin.
99
100 $res->errorstring()
101 Little more than a stub for callers expecting this from
102 "Net::DNS::Resolver".
103
104 If called immediately after a call to $res->send this will return
105 "query timed out" if the $res->send DNS query timed out. Otherwise
106 "unknown error or no error" will be returned.
107
108 No other errors are reported.
109
110 $res->finish_socket()
111 Reset socket when done with it.
112
113 $res->finish()
114 Clean up for destruction.
115
116
117
118perl v5.36.0 2023-01-21Mail::SpamAssassin::DnsResolver(3)