ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/EV-ADNS/README
Revision: 1.4
Committed: Wed Dec 12 23:44:46 2007 UTC (16 years, 7 months ago) by root
Branch: MAIN
CVS Tags: rel-1_0, rel-2_0
Changes since 1.3: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 NAME
2 root 1.3 EV::ADNS - lightweight asynchronous dns queries using EV and libadns
3 root 1.1
4     SYNOPSIS
5 root 1.2 use EV;
6     use EV::ADNS;
7 root 1.1
8 root 1.2 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 root 1.1
15     DESCRIPTION
16 root 1.2 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 root 1.4 warn encode_json \@rr;
48 root 1.2 }
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 root 1.3 EV::ADNS::r_ns_raw, EV::ADNS::r_cname, EV::ADNS::r_ptr,
59     EV::ADNS::r_ptr_raw
60 root 1.2 The resource record as a simple string.
61    
62 root 1.3 EV::ADNS::r_txt
63 root 1.2 An arrayref of strings.
64    
65 root 1.3 EV::ADNS::r_ns
66 root 1.2 A "host address", a hostname with any number of addresses (hint
67     records).
68    
69     Currently only the hostname will be stored, so this is alway an
70     arrayref with a single element of the hostname. Future versions
71     might add additional address entries.
72    
73 root 1.3 EV::ADNS::r_hinfo
74 root 1.2 An arrayref consisting of the two strings.
75    
76 root 1.3 EV::ADNS::r_rp, EV::ADNS::r_rp_raw
77 root 1.2 An arrayref with two strings.
78    
79 root 1.3 EV::ADNS::r_mx
80 root 1.2 An arrayref consisting of the priority and a "host address" (see
81 root 1.3 "EV::ADNS::r_ns"). Example:
82 root 1.2
83 root 1.3 [10, "mail10.example.com"]
84 root 1.2
85 root 1.3 EV::ADNS::r_mx_raw
86 root 1.2 An arrayref consisting of the priority and the hostname, e.g.
87     "[10, "mail.example.com"]".
88    
89 root 1.3 EV::ADNS::r_soa, EV::ADNS::r_soa_raw
90 root 1.2 An arrayref consisting of the primary nameserver, admin name,
91     serial, refresh, retry expire and minimum times, e.g.:
92    
93 root 1.3 ["ns.example.net", "hostmaster@example.net", 2000001102, 86400, 21600, 2592000, 172800]
94 root 1.2
95     The "raw" form doesn't mangle the e-mail address.
96    
97 root 1.3 EV::ADNS::r_srv_raw
98 root 1.2 An arrayref consisting of the priority, weight, port and
99     hostname, e.g.:
100    
101 root 1.3 [10, 10, 5060, "sip1.example.net"]
102 root 1.2
103 root 1.3 EV::ADNS::r_srv
104     The same as "EV::ADNS::r_srv_raw", but the hostname is replaced
105     by a "host address" (see "EV::ADNS::r_ns").
106 root 1.2
107 root 1.3 EV::ADNS::r_unknown
108 root 1.2 A single octet string with the raw contents.
109    
110     anything else
111     Currently "undef".
112 root 1.1
113 root 1.2 $query->cancel
114     Cancels a request that is in progress.
115 root 1.1
116     SEE ALSO
117 root 1.2 EV, Net::ADNS another interface to adns, maybe better, but without real
118     support to integrate it into other event loops.
119 root 1.1
120     AUTHOR
121     Marc Lehmann <schmorp@schmorp.de>
122     http://home.schmorp.de/
123