.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::LDNS 3pm" .TH Net::LDNS 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME .Vb 1 \& Net::LDNS \- DNS\-talking module based on the ldns C library .Ve .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 3 \& my $resolver = Net::LDNS\->new(\*(Aq8.8.8.8\*(Aq); \& my $packet = $resolver\->query(\*(Aqwww.iis.se\*(Aq); \& say $packet\->string; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`Net::LDNS\*(C'\fR represents a resolver, which is the part of the system responsible for sending queries and receiving answers to them. .SH "EXPORTABLE FUNCTIONS" .IX Header "EXPORTABLE FUNCTIONS" .IP \fBlib_version()\fR 4 .IX Item "lib_version()" Returns the ldns version string. Can be exported, but is not by default. .IP "to_idn($name, ...)" 4 .IX Item "to_idn($name, ...)" Takes a number of strings and returns a list of them converted to IDNA format. Assumes that the strings have been converted to Perl's internal encoding before it's called. Can be exported, but is not by default. .Sp This function requires that GNU libidn was present when Net::LDNS was compiled. If not, calling \f(CW\*(C`to_idn\*(C'\fR will result in an exception getting thrown. .IP \fBhas_idn()\fR 4 .IX Item "has_idn()" Takes no arguments. Returns true if libidn was present at compilation, false if not. .IP \fBhas_gost()\fR 4 .IX Item "has_gost()" Takes no arguments. Returns true if GOST support was present at compilation, false if not. .IP load_zonefile($filename) 4 .IX Item "load_zonefile($filename)" Load all resource records in a zone file, returning them as a list. .SH "CLASS METHOD" .IX Header "CLASS METHOD" .IP new($addr,...) 4 .IX Item "new($addr,...)" Creates a new resolver object. If given no arguments, if will pick up nameserver addresses from the system configuration (\fI/etc/resolv.conf\fR or equivalent). If given a single argument that is \f(CW\*(C`undef\*(C'\fR, it will not know of any nameservers and all attempts to send queries will throw exceptions. If given one or more arguments that are not \f(CW\*(C`undef\*(C'\fR, attempts to parse them as IPv4 and IPv6 addresses will be made, and if successful make up a list of servers to send queries to. If an argument cannot be parsed as an IP address, an exception will be thrown. .SH "INSTANCE METHODS" .IX Header "INSTANCE METHODS" .ie n .IP "query($name, $type, $class)" 4 .el .IP "query($name, \f(CW$type\fR, \f(CW$class\fR)" 4 .IX Item "query($name, $type, $class)" Send a query for the given triple. If type or class are not provided they default to A and IN, respectively. Returns a Net::LDNS::Packet or undef. .IP name2addr($name) 4 .IX Item "name2addr($name)" Asks this resolver to look up A and AAAA records for the given name, and return a list of the IP addresses (as strings). In scalar context, returns the number of addresses found. .IP addr2name($addr) 4 .IX Item "addr2name($addr)" Takes an IP address, asks the resolver to do PTR lookups and returns the names found. In scalar context, returns the number of names found. .IP recurse($flag) 4 .IX Item "recurse($flag)" Returns the setting of the recursion flag. If given an argument, it will be treated as a boolean and the flag set accordingly. .IP debug($flag) 4 .IX Item "debug($flag)" Gets and optionally sets the debug flag. .IP dnssec($flag) 4 .IX Item "dnssec($flag)" Get and optionally sets the DNSSEC flag. .IP cd($flag) 4 .IX Item "cd($flag)" Get and optionally sets the CD flag. .IP igntc($flag) 4 .IX Item "igntc($flag)" Get and optionally sets the igntc flag. .IP usevc($flag) 4 .IX Item "usevc($flag)" Get and optionally sets the usevc flag. .IP retry($count) 4 .IX Item "retry($count)" Get and optionally set the number of retries. .IP retrans($seconds) 4 .IX Item "retrans($seconds)" Get and optionally set the number of seconds between retries. .IP port($port) 4 .IX Item "port($port)" Get and optionally set the destination port for requests. .IP edns_size($size) 4 .IX Item "edns_size($size)" Get and optionally set the EDNS0 UDP maximum size. .ie n .IP "axfr( $domain, $callback, $class )" 4 .el .IP "axfr( \f(CW$domain\fR, \f(CW$callback\fR, \f(CW$class\fR )" 4 .IX Item "axfr( $domain, $callback, $class )" Perform an AXFR operation. \f(CW$callback\fR must be a code reference, which will be called once for every received resource record with the RR object as its one and only argument. After every such call, the return value of the callback will be examined, and if the value is false the AXFR process will be aborted. The return value of the \f(CWaxfr()\fR method itself will be true if the transfer completed normally, and false if it was aborted because the callback returned a false value. .Sp If anything goes wrong during the process, an exception will be thrown. .Sp As an example, saving all the RRs received from an AXFR can be done like this: .Sp .Vb 2 \& my @rrs; \& $resolver\->axfr( $domain, sub { my ($rr) = @_; push @rrs, $rr; return 1;} ); .Ve .IP axfr_start($domain,$class) 4 .IX Item "axfr_start($domain,$class)" Deprecated. Use \fBaxfr()\fR instead. .Sp Set this resolver object up for a zone transfer of the specified domain. If \f(CW$class\fR is not given, it defaults to IN. .IP \fBaxfr_next()\fR 4 .IX Item "axfr_next()" Deprecated. Use \fBaxfr()\fR instead. .Sp Get the next RR in the zone transfer. \fBaxfr_start()\fR must have been done before this is called, and after this is called \fBaxfr_complete()\fR should be used to check if there are more records to get. If there's any problem, an exception will be thrown. Basically, the sequence should be something like: .Sp .Vb 4 \& $res\->axfr_start(\*(Aqexample.org\*(Aq); \& do { \& push @rrlist, $res\->axfr_next; \& } until $res\->axfr_complete; .Ve .IP \fBaxfr_complete()\fR 4 .IX Item "axfr_complete()" Deprecated. Use \fBaxfr()\fR instead. .Sp Returns false if there is a started zone transfer with more records to get, and true if the started transfer has completed. .IP \fBaxfr_last_packet()\fR 4 .IX Item "axfr_last_packet()" Deprecated. Use \fBaxfr()\fR instead. .Sp If \fBaxfr_next()\fR threw an exception, this method returns the Net::LDNS::Packet that made it do so. The packet's RCODE is likely to say what the problem was (for example, NOTAUTH or NXDOMAIN). .IP timeout($time) 4 .IX Item "timeout($time)" Get and/or set the socket timeout for the resolver. .IP source($addr) 4 .IX Item "source($addr)" Get and/or set the IP address the resolver should try to send its queries from.