ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/DNS.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/DNS.pm (file contents):
Revision 1.53 by root, Fri May 30 09:40:41 2008 UTC vs.
Revision 1.54 by root, Fri May 30 10:06:14 2008 UTC

698been resolved. 698been resolved.
699 699
700=item reuse => $seconds 700=item reuse => $seconds
701 701
702The number of seconds (default: C<300>) that a query id cannot be re-used 702The number of seconds (default: C<300>) that a query id cannot be re-used
703after a timeout. If there as no time-out then query id's can be reused 703after a timeout. If there was no time-out then query ids can be reused
704immediately. 704immediately.
705 705
706=back 706=back
707 707
708=cut 708=cut
723 server => [], 723 server => [],
724 timeout => [2, 5, 5], 724 timeout => [2, 5, 5],
725 search => [], 725 search => [],
726 ndots => 1, 726 ndots => 1,
727 max_outstanding => 10, 727 max_outstanding => 10,
728 reuse => 300, # reuse id's after 5 minutes only, if possible 728 reuse => 300,
729 %arg, 729 %arg,
730 reuse_q => [], 730 reuse_q => [],
731 }, $class; 731 }, $class;
732 732
733 # search should default to gethostname's domain 733 # search should default to gethostname's domain
838 # - the registry thing needs separate code on win32 native vs. cygwin 838 # - the registry thing needs separate code on win32 native vs. cygwin
839 # - the registry layout differs between windows versions 839 # - the registry layout differs between windows versions
840 # - calling windows api functions doesn't work on cygwin 840 # - calling windows api functions doesn't work on cygwin
841 # - ipconfig uses locale-specific messages 841 # - ipconfig uses locale-specific messages
842 842
843 # we use ipconfig parsing because, despite all it's brokenness, 843 # we use ipconfig parsing because, despite all its brokenness,
844 # it seems most stable in practise. 844 # it seems most stable in practise.
845 # for good measure, we append a fallback nameserver to our list. 845 # for good measure, we append a fallback nameserver to our list.
846 846
847 if (open my $fh, "ipconfig /all |") { 847 if (open my $fh, "ipconfig /all |") {
848 # parsing strategy: we go through the output and look for 848 # parsing strategy: we go through the output and look for
857 } elsif (/^\S/ || /^\s[^:]{16,}: /) { 857 } elsif (/^\S/ || /^\s[^:]{16,}: /) {
858 $dns = 0; 858 $dns = 0;
859 } 859 }
860 if ($dns && /^\s*(\S+)\s*$/) { 860 if ($dns && /^\s*(\S+)\s*$/) {
861 my $s = $1; 861 my $s = $1;
862 $s =~ s/%\d+(?!\S)//; # get rid of scope id 862 $s =~ s/%\d+(?!\S)//; # get rid of ipv6 scope id
863 if (my $ipn = AnyEvent::Socket::parse_address ($s)) { 863 if (my $ipn = AnyEvent::Socket::parse_address ($s)) {
864 push @{ $self->{server} }, $ipn; 864 push @{ $self->{server} }, $ipn;
865 } else { 865 } else {
866 push @{ $self->{search} }, $s; 866 push @{ $self->{search} }, $s;
867 } 867 }
884} 884}
885 885
886=item $resolver->timeout ($timeout, ...) 886=item $resolver->timeout ($timeout, ...)
887 887
888Sets the timeout values. See the C<timeout> constructor argument (and note 888Sets the timeout values. See the C<timeout> constructor argument (and note
889that this method uses the values itselt, not an array-reference). 889that this method uses the values itself, not an array-reference).
890 890
891=cut 891=cut
892 892
893sub timeout { 893sub timeout {
894 my ($self, @timeout) = @_; 894 my ($self, @timeout) = @_;
1094 } 1094 }
1095} 1095}
1096 1096
1097=item $resolver->request ($req, $cb->($res)) 1097=item $resolver->request ($req, $cb->($res))
1098 1098
1099This is the main low-level workhorse for sending DNS requests.
1100
1099Sends a single request (a hash-ref formated as specified for 1101This function sends a single request (a hash-ref formated as specified
1100C<dns_pack>) to the configured nameservers including 1102for C<dns_pack>) to the configured nameservers in turn until it gets a
1103response. It handles timeouts, retries and automatically falls back to
1104virtual circuit mode (TCP) when it receives a truncated reply.
1105
1101retries. Calls the callback with the decoded response packet if a reply 1106Calls the callback with the decoded response packet if a reply was
1102was received, or no arguments on timeout. 1107received, or no arguments in case none of the servers answered.
1103 1108
1104=cut 1109=cut
1105 1110
1106sub request($$) { 1111sub request($$) {
1107 my ($self, $req, $cb) = @_; 1112 my ($self, $req, $cb) = @_;
1112 1117
1113=item $resolver->resolve ($qname, $qtype, %options, $cb->($rcode, @rr)) 1118=item $resolver->resolve ($qname, $qtype, %options, $cb->($rcode, @rr))
1114 1119
1115Queries the DNS for the given domain name C<$qname> of type C<$qtype>. 1120Queries the DNS for the given domain name C<$qname> of type C<$qtype>.
1116 1121
1117A C<$qtype> is either a numerical query type (e.g. C<1> for A recods) or 1122A C<$qtype> is either a numerical query type (e.g. C<1> for A records) or
1118a lowercase name (you have to look at the source to see which aliases are 1123a lowercase name (you have to look at the source to see which aliases are
1119supported, but all types from RFC 1035, C<aaaa>, C<srv>, C<spf> and a few 1124supported, but all types from RFC 1035, C<aaaa>, C<srv>, C<spf> and a few
1120more are known to this module). A qtype of "*" is supported and means 1125more are known to this module). A C<$qtype> of "*" is supported and means
1121"any" record type. 1126"any" record type.
1122 1127
1123The callback will be invoked with a list of matching result records or 1128The callback will be invoked with a list of matching result records or
1124none on any error or if the name could not be found. 1129none on any error or if the name could not be found.
1125 1130

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines