1Net::DNS::Resolver::ProUgsrearmmCaobnlter(i3b)uted PerlNDeotc:u:mDeNnSt:a:tRieosnolver::Programmable(3)
2
3
4

NAME

6       Net::DNS::Resolver::Programmable - programmable DNS resolver class for
7       offline emulation of DNS
8

VERSION

10       0.003
11

SYNOPSIS

13           use Net::DNS::Resolver::Programmable;
14           use Net::DNS::RR;
15
16           my $resolver = Net::DNS::Resolver::Programmable->new(
17               records         => {
18                   'example.com'     => [
19                       Net::DNS::RR->new('example.com.     NS  ns.example.org.'),
20                       Net::DNS::RR->new('example.com.     A   192.168.0.1')
21                   ],
22                   'ns.example.org'  => [
23                       Net::DNS::RR->new('ns.example.org.  A   192.168.1.1')
24                   ]
25               },
26
27               resolver_code   => sub {
28                   my ($domain, $rr_type, $class) = @_;
29                   ...
30                   return ($result, $aa, @rrs);
31               }
32           );
33

DESCRIPTION

35       Net::DNS::Resolver::Programmable is a Net::DNS::Resolver descendant
36       class that allows a virtual DNS to be emulated instead of querying the
37       real DNS.  A set of static DNS records may be supplied, or arbitrary
38       code may be specified as a means for retrieving DNS records, or even
39       generating them on the fly.
40
41   Constructor
42       The following constructor is provided:
43
44       new(%options): returns Net::DNS::Resolver::Programmable
45           Creates a new programmed DNS resolver object.
46
47           %options is a list of key/value pairs representing any of the
48           following options:
49
50           records
51               A reference to a hash of arrays containing a static set of
52               Net::DNS::RR objects.  The hash entries must be indexed by
53               fully qualified domain names (lower-case, without any trailing
54               dots), and the entries themselves must be arrays of the RR
55               objects pertaining to these domain names.  For example:
56
57                   records => {
58                       'example.com'     => [
59                           Net::DNS::RR->new('example.com.     NS  ns.example.org.'),
60                           Net::DNS::RR->new('example.com.     A   192.168.0.1')
61                       ],
62                       'www.example.com' => [
63                           Net::DNS::RR->new('www.example.com. A   192.168.0.2')
64                       ],
65                       'ns.example.org'  => [
66                           Net::DNS::RR->new('ns.example.org.  A   192.168.1.1')
67                       ]
68                   }
69
70               If this option is specified, the resolver retrieves requested
71               RRs from this data structure.
72
73           resolver_code
74               A code reference used as a call-back for dynamically retrieving
75               requested RRs.
76
77               The code must take the following query parameters as arguments:
78               the domain, RR type, and class.
79
80               It must return a list composed of: the response's RCODE (by
81               name, as returned by Net::DNS::Header->rcode), the "aa"
82               (authoritative answer) flag (boolean, use undef if you don't
83               care), and the Net::DNS::RR answer objects.  If an error string
84               is returned instead of a valid RCODE, a Net::DNS::Packet object
85               is not constructed but an error condition for the resolver is
86               signaled instead.
87
88               For example:
89
90                   resolver_code => sub {
91                       my ($domain, $rr_type, $class) = @_;
92                       ...
93                       return ($result, $aa, @rrs);
94                   }
95
96               If both this and the "records" option are specified, then
97               statically programmed records are used in addition to any that
98               are returned by the configured resolver code.
99
100           defnames
101           dnsrch
102           domain
103           searchlist
104           debug
105               These Net::DNS::Resolver options are also meaningful with
106               Net::DNS::Resolver::Programmable.  See Net::DNS::Resolver for
107               their descriptions.
108
109   Instance methods
110       The following instance methods of Net::DNS::Resolver are also supported
111       by Net::DNS::Resolver::Programmable:
112
113       search: returns Net::DNS::Packet
114       query: returns Net::DNS::Packet
115       send: returns Net::DNS::Packet
116           Performs an offline DNS query, using the statically programmed DNS
117           RRs and/or the configured dynamic resolver code.  See the "new"
118           constructor's "records" and "resolver_code" options.  See the
119           descriptions of search, query, and send for details about the
120           calling syntax of these methods.
121
122       print
123       string: returns string
124       searchlist: returns list of string
125       defnames: returns boolean
126       dnsrch: returns boolean
127       debug: returns boolean
128       errorstring: returns string
129       answerfrom: returns string
130       answersize: returns integer
131           See "METHODS" in Net::DNS::Resolver.
132
133       Currently the following methods of Net::DNS::Resolver are not
134       supported: axfr, axfr_start, axfr_next, nameservers, port, srcport,
135       srcaddr, bgsend, bgread, bgisready, tsig, retrans, retry, recurse,
136       usevc, tcp_timeout, udp_timeout, persistent_tcp, persistent_udp, igntc,
137       dnssec, cdflag, udppacketsize.  The effects of using these on
138       Net::DNS::Resolver::Programmable objects are undefined.
139

SEE ALSO

141       Net::DNS::Resolver
142
143       For availability, support, and license information, see the README file
144       included with Net::DNS::Resolver::Programmable.
145

AUTHORS

147       Julian Mehnle <julian@mehnle.net>
148
149
150
151perl v5.16.3                      2014-06-09Net::DNS::Resolver::Programmable(3)
Impressum