… | |
… | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use EV; |
7 | use EV; |
8 | use EV::ADNS; |
8 | use EV::ADNS; |
9 | |
9 | |
10 | EV::ADNS::submit "example.com", EV::ADNS::r_addr, 0, sub { |
10 | EV::ADNS::submit "example.com", EV::ADNS::r_addr, EV::ADNS::qf_cname_loose, sub { |
11 | my ($status, $expires, @a) = @_; |
11 | my ($status, $expires, @a) = @_; |
12 | warn $a[0]; # "127.13.166.3" etc. |
12 | warn $a[0]; # "127.13.166.3" etc. |
13 | }; |
13 | }; |
14 | |
14 | |
15 | EV::loop; |
15 | EV::run; |
16 | |
16 | |
17 | =head1 DESCRIPTION |
17 | =head1 DESCRIPTION |
18 | |
18 | |
19 | This is a simple interface to libadns (asynchronous dns) that |
19 | This is a simple interface to libadns (asynchronous dns) that |
20 | integrates well and automatically into the EV event loop. The |
20 | integrates well and automatically into the EV event loop. The |
… | |
… | |
26 | not do anything (except run an EV event loop). |
26 | not do anything (except run an EV event loop). |
27 | |
27 | |
28 | =head1 OVERVIEW |
28 | =head1 OVERVIEW |
29 | |
29 | |
30 | All the constants/enums from F<adns.h> are available in the EV::ADNS |
30 | All the constants/enums from F<adns.h> are available in the EV::ADNS |
31 | namespace, without the C<adns_> prefix, e.g. C<adns_r_a> becomes |
31 | namespace, without the C<adns_> prefix, i.e. C<adns_r_a> becomes |
32 | C<EV::ADNS::r_a>, C<adns__qtf_deref> becomes C<EV::ADNS::_qtf_deref> and |
32 | C<EV::ADNS::r_a> and so on. |
33 | so on. |
|
|
34 | |
33 | |
35 | =head1 FUNCTIONS |
34 | =head1 FUNCTIONS |
36 | |
35 | |
37 | =over 4 |
36 | =over 4 |
38 | |
37 | |
39 | =item $query = EV::ADNS::submit "domain", $rrtype, $flags, $cb |
38 | =item $query = EV::ADNS::submit "domain", $rrtype, $flags, $cb |
40 | |
39 | |
41 | Submits a new request to be handled. See the C<adns_submit> C function |
40 | Submits a new request to be handled. See the C<adns_submit> C function |
42 | description for more details. The function optionally returns a query |
41 | description for more details. The function optionally returns a query |
43 | object which can be used to cancel an in-progress request. You do not need |
42 | object which can be used to cancel an in-progress request. You do not need |
44 | to store the query object, even if you ignore it the query will proceed. |
43 | to store the query object, even if you ignore it, the query will proceed. |
45 | |
44 | |
46 | The callback will be invoked with a result status, the time the resource |
45 | The callback will be invoked with a result status, the time the resource |
47 | record validity expires and zero or more resource records, one scalar per |
46 | record validity expires and zero or more resource records, one scalar per |
48 | result record. Example: |
47 | result record. Example: |
49 | |
48 | |
… | |
… | |
75 | |
74 | |
76 | =item EV::ADNS::r_ns |
75 | =item EV::ADNS::r_ns |
77 | |
76 | |
78 | A "host address", a hostname with any number of addresses (hint records). |
77 | A "host address", a hostname with any number of addresses (hint records). |
79 | |
78 | |
80 | Currently only the hostname will be stored, so this is alway an arrayref |
79 | The record will be an arrayref with domainname, adns status and any number |
81 | with a single element of the hostname. Future versions might add |
80 | of associated addresses: C<< ["domain", adns_status, addr...] >>. |
82 | additional address entries. |
|
|
83 | |
81 | |
84 | =item EV::ADNS::r_hinfo |
82 | =item EV::ADNS::r_hinfo |
85 | |
83 | |
86 | An arrayref consisting of the two strings. |
84 | An arrayref consisting of the two strings. |
87 | |
85 | |
… | |
… | |
92 | =item EV::ADNS::r_mx |
90 | =item EV::ADNS::r_mx |
93 | |
91 | |
94 | An arrayref consisting of the priority and a "host address" (see |
92 | An arrayref consisting of the priority and a "host address" (see |
95 | C<EV::ADNS::r_ns>). Example: |
93 | C<EV::ADNS::r_ns>). Example: |
96 | |
94 | |
97 | [10, "mail10.example.com"] |
95 | [10, [["alt3.aspmx.l.google.com", 0, "64.233.189.27", "2404:6800:4008:c07::1a"]]] |
98 | |
96 | |
99 | =item EV::ADNS::r_mx_raw |
97 | =item EV::ADNS::r_mx_raw |
100 | |
98 | |
101 | An arrayref consisting of the priority and the hostname, e.g. C<[10, |
99 | An arrayref consisting of the priority and the hostname, e.g. C<[10, |
102 | "mail.example.com"]>. |
100 | "mail.example.com"]>. |
… | |
… | |
133 | |
131 | |
134 | =item $query->cancel |
132 | =item $query->cancel |
135 | |
133 | |
136 | Cancels a request that is in progress. |
134 | Cancels a request that is in progress. |
137 | |
135 | |
|
|
136 | =item EV::ADNS::reinit undef, $resolvdata_or_undef |
|
|
137 | |
|
|
138 | Cancels all outstanding queries, frees all adns state and reinitialises |
|
|
139 | it. It is highly recommended to only call this when there are no |
|
|
140 | outstanding requests. |
|
|
141 | |
|
|
142 | The first argument must currently be specified as C<undef>. |
|
|
143 | |
|
|
144 | The second argument can be missing or C<undef>; in which case the normal |
|
|
145 | initialisation is done (such as reading the F<resolv.conf>), or it might |
|
|
146 | be a stirng, in which case no config files or environment variables will |
|
|
147 | be read and the given string will be interpreted as the F<resolv.conf> |
|
|
148 | contents. |
|
|
149 | |
138 | =back |
150 | =back |
139 | |
151 | |
140 | =cut |
152 | =cut |
141 | |
153 | |
142 | package EV::ADNS; |
154 | package EV::ADNS; |
143 | |
155 | |
144 | use Carp (); |
156 | use Carp (); |
145 | use EV (); |
157 | use EV (); |
146 | |
158 | |
147 | BEGIN { |
159 | BEGIN { |
148 | $VERSION = 2.3; |
160 | $VERSION = '3.0'; |
149 | |
161 | |
150 | require XSLoader; |
162 | require XSLoader; |
151 | XSLoader::load (EV::ADNS, $VERSION); |
163 | XSLoader::load (EV::ADNS, $VERSION); |
152 | } |
164 | } |
153 | |
165 | |