Net::DN...ammable(3)
πΈ NAME πΈ
okay bestie, you're looking at Net::DN...ammable(3) from the User Contributed Perl Documentation, and the actual module is Net::DNS::Resolver::Programmable β a programmable DNS resolver class for offline emulation of DNS. slay, no real DNS querying required π
β¨ SYNOPSIS β¨
use Net::DNS::Resolver::Programmable;
use Net::DNS::RR;
my $resolver = Net::DNS::Resolver::Programmable->new(
records => {
'example.com' => [
Net::DNS::RR->new('example.com. NS ns.example.org.'),
Net::DNS::RR->new('example.com. A 192.168.0.1')
],
'ns.example.org' => [
Net::DNS::RR->new('ns.example.org. A 192.168.1.1')
]
},
resolver_code => sub {
my ($domain, $rr_type, $class) = @_;
...
return ($result, $aa, @rrs);
}
);
π¦ DESCRIPTION π¦
Net::DNS::Resolver::Programmable is a Net::DNS::Resolver descendant class that lets you emulate a virtual DNS instead of querying the real DNS. You can supply a set of static DNS records, or specify arbitrary code as a way to retrieve DNS records β or even generate them on the fly. iconic behavior, honestly β¨
π§ Constructor π§
The following constructor is provided:
new(%options)β returnsNet::DNS::Resolver::Programmable; creates a new programmed DNS resolver object.
%options is a list of key/value pairs representing any of the following options:
π records π
A reference to a hash of arrays containing a static set of Net::DNS::RR objects. The hash entries must be indexed by fully qualified domain names (lower-case, without any trailing dots), and the entries themselves must be arrays of the RR objects pertaining to these domain names. For example:
records => {
'example.com' => [
Net::DNS::RR->new('example.com. NS ns.example.org.'),
Net::DNS::RR->new('example.com. A 192.168.0.1')
],
'www.example.com' => [
Net::DNS::RR->new('www.example.com. A 192.168.0.2')
],
'ns.example.org' => [
Net::DNS::RR->new('ns.example.org. A 192.168.1.1')
]
}
If this option is specified, the resolver retrieves requested RRs from this data structure. periodt π
π resolver_code π
A code reference used as a call-back for dynamically retrieving requested RRs.
The code must take the following query parameters as arguments: the domain, RR type, and class.
It must return a list composed of: the response's RCODE (by name, as returned by Net::DNS::Header->rcode), the "aa" (authoritative answer) flag (boolean, use undef if you don't care), and the Net::DNS::RR answer objects. If an error string is returned instead of a valid RCODE, a Net::DNS::Packet object is not constructed but an error condition for the resolver is signaled instead.
For example:
resolver_code => sub {
my ($domain, $rr_type, $class) = @_;
...
return ($result, $aa, @rrs);
}
If both this and the records option are specified, then statically programmed records are used in addition to any that are returned by the configured resolver code. iykyk π«Ά
πΈ defnames, dnsrch, domain, searchlist, debug πΈ
These Net::DNS::Resolver options are also meaningful with Net::DNS::Resolver::Programmable β see Net::DNS::Resolver for their descriptions:
defnamesdnsrchdomainsearchlistdebug
π» Instance methods π»
The following instance methods of Net::DNS::Resolver are also supported by Net::DNS::Resolver::Programmable:
searchβ returnsNet::DNS::Packetqueryβ returnsNet::DNS::Packetsendβ returnsNet::DNS::Packet
These perform an offline DNS query, using the statically programmed DNS RRs and/or the configured dynamic resolver code. See the new constructor's records and resolver_code options. See the descriptions of search, query, and send for details about the calling syntax of these methods.
printstringβ returns stringsearchlistβ returns list of stringdefnamesβ returns booleandnsrchβ returns booleandebugβ returns booleanerrorstringβ returns stringanswerfromβ returns stringanswersizeβ returns integer
See "METHODS" in Net::DNS::Resolver. π
π¨ Currently the following methods ofNet::DNS::Resolverare not supported:axfr,axfr_start,axfr_next,nameservers,port,srcport,srcaddr,bgsend,bgread,bgisready,tsig,retrans,retry,recurse,usevc,tcp_timeout,udp_timeout,persistent_tcp,persistent_udp,igntc,dnssec,cdflag,udppacketsize. The effects of using these onNet::DNS::Resolver::Programmableobjects are undefined. do not play with those, bestie π
π¦ SEE ALSO π¦
Net::DNS::Resolver
For availability, support, and license information, see the README file included with Net::DNS::Resolver::Programmable. π
π AUTHORS π
David Precious (BIGPRESH) "<davidp@preshweb.co.uk>"took on maintainership in July 2017- Original author
Julian Mehnle "<julian@mehnle.net>"
π«Ά ACKNOWLEDGEMENTS π«Ά
Dick Franks (rwfranks)
(This section was added by BIGPRESH in July 2017, so currently omits acknowledgements for those who contributed things in the past; I may retrospectively add them in future.) πΈ
okay that's the whole page, bestie! source/version/date tea: this manual is from perl v5.42.0, dated 2017-07-25, under the manual name Net::DN...ammable(3). mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-DNS-Resolver-Programmable 0.009-bp160.1.11 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms