ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/EV-ADNS/README
Revision: 1.2
Committed: Sat Dec 1 22:36:10 2007 UTC (16 years, 7 months ago) by root
Branch: MAIN
Changes since 1.1: +108 -42 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 NAME
2 EV::ADNS -
3
4 SYNOPSIS
5 use EV;
6 use EV::ADNS;
7
8 EV::ADNS::submit "example.com", EV::ADNS::r_a, 0, sub {
9 my ($status, $expires, @a) = @_;
10 warn $a[0]; # "127.13.166.3" etc.
11 };
12
13 EV::loop;
14
15 DESCRIPTION
16 This is a simple interface to libadns (asynchronous dns) that integrates
17 well and automatically into the EV event loop. The documentation for
18 libadns is vital to understand this module, see
19 <http://www.chiark.greenend.org.uk/~ian/adns/>.
20
21 You can use it only with EV (directly or indirectly, e.g. via Glib::EV).
22 Apart from loading and using the "submit" function you need not do
23 anything (except run an EV event loop).
24
25 OVERVIEW
26 All the constants/enums from adns.h are available in the EV::ADNS
27 namespace, without the "adns_" prefix, e.g. "adns_r_a" becomes
28 "EV::ADNS::r_a", "adns__qtf_deref" becomes "EV::ADNS::_qtf_deref" and so
29 on.
30
31 FUNCTIONS
32 $query = EV::ADNS::submit "domain", $rrtype, $flags, $cb
33 Submits a new request to be handled. See the "adns_submit" C
34 function description for more details. The function optionally
35 returns a query object which can be used to cancel an in-progress
36 request. You do not need to store the query object, even if you
37 ignore it the query will proceed.
38
39 The callback will be invoked with a result status, the time the
40 resource record validity expires and zero or more resource records,
41 one scalar per result record. Example:
42
43 sub adns_cb {
44 my ($status, $expires, @rr) = @_;
45 if ($status == EV::ADNS::s_ok) {
46 use JSON::XS;
47 warn to_json \@rr;
48 }
49 }
50
51 The format of result records varies considerably, here is some
52 cursory documentation of how each record will look like, depending
53 on the query type:
54
55 EV::ADNS::rr_a
56 An IPv4 address in dotted quad (string) form.
57
58 adns_r_ns_raw, adns_r_cname, adns_r_ptr, adns_r_ptr_raw
59 The resource record as a simple string.
60
61 adns_r_txt
62 An arrayref of strings.
63
64 adns_r_ns
65 A "host address", a hostname with any number of addresses (hint
66 records).
67
68 Currently only the hostname will be stored, so this is alway an
69 arrayref with a single element of the hostname. Future versions
70 might add additional address entries.
71
72 adns_r_hinfo
73 An arrayref consisting of the two strings.
74
75 adns_r_rp, adns_r_rp_raw
76 An arrayref with two strings.
77
78 adns_r_mx
79 An arrayref consisting of the priority and a "host address" (see
80 "adns_r_ns"). Example:
81
82 [10,"mail10.example.com"]
83
84 adns_r_mx_raw:
85 An arrayref consisting of the priority and the hostname, e.g.
86 "[10, "mail.example.com"]".
87
88 adns_r_soa, adns_r_soa_raw
89 An arrayref consisting of the primary nameserver, admin name,
90 serial, refresh, retry expire and minimum times, e.g.:
91
92 ["ns.example.net","hostmaster@example.net",2000001102,86400,21600,2592000,172800]
93
94 The "raw" form doesn't mangle the e-mail address.
95
96 adns_r_srv_raw
97 An arrayref consisting of the priority, weight, port and
98 hostname, e.g.:
99
100 [10,10,5060,"sip1.example.net"]
101
102 adns_r_srv
103 The same as "adns_r_srv_raw", but the hostname is replaced by a
104 "host address" (see "adns_r_ns").
105
106 adns_r_unknown
107 A single octet string with the raw contents.
108
109 anything else
110 Currently "undef".
111
112 $query->cancel
113 Cancels a request that is in progress.
114
115 SEE ALSO
116 EV, Net::ADNS another interface to adns, maybe better, but without real
117 support to integrate it into other event loops.
118
119 AUTHOR
120 Marc Lehmann <schmorp@schmorp.de>
121 http://home.schmorp.de/
122