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.92 by root, Sun Jun 7 16:48:38 2009 UTC vs.
Revision 1.98 by root, Fri Jul 3 21:44:14 2009 UTC

32use strict; 32use strict;
33 33
34use Socket qw(AF_INET SOCK_DGRAM SOCK_STREAM); 34use Socket qw(AF_INET SOCK_DGRAM SOCK_STREAM);
35 35
36use AnyEvent (); 36use AnyEvent ();
37use AnyEvent::Handle ();
38use AnyEvent::Util qw(AF_INET6); 37use AnyEvent::Util qw(AF_INET6);
39 38
40our $VERSION = 4.411; 39our $VERSION = 4.452;
41 40
42our @DNS_FALLBACK = (v208.67.220.220, v208.67.222.222); 41our @DNS_FALLBACK = (v208.67.220.220, v208.67.222.222);
43 42
44=item AnyEvent::DNS::a $domain, $cb->(@addrs) 43=item AnyEvent::DNS::a $domain, $cb->(@addrs)
45 44
295C<$ENV{PERL_ANYEVENT_EDNS0}>, but when set to C<1>, AnyEvent::DNS will use 294C<$ENV{PERL_ANYEVENT_EDNS0}>, but when set to C<1>, AnyEvent::DNS will use
296EDNS0 in all requests. 295EDNS0 in all requests.
297 296
298=cut 297=cut
299 298
300our $EDNS0 = $ENV{PERL_ANYEVENT_EDNS0} * 1; # set to 1 to enable (partial) edns0 299our $EDNS0 = $ENV{PERL_ANYEVENT_EDNS0}*1; # set to 1 to enable (partial) edns0
301 300
302our %opcode_id = ( 301our %opcode_id = (
303 query => 0, 302 query => 0,
304 iquery => 1, 303 iquery => 1,
305 status => 2, 304 status => 2,
655 654
656our $RESOLVER; 655our $RESOLVER;
657 656
658sub resolver() { 657sub resolver() {
659 $RESOLVER || do { 658 $RESOLVER || do {
660 $RESOLVER = new AnyEvent::DNS; 659 $RESOLVER = new AnyEvent::DNS untaint => 1;
661 $RESOLVER->os_config; 660 $RESOLVER->os_config;
662 $RESOLVER 661 $RESOLVER
663 } 662 }
664} 663}
665 664
703=item reuse => $seconds 702=item reuse => $seconds
704 703
705The number of seconds (default: C<300>) that a query id cannot be re-used 704The number of seconds (default: C<300>) that a query id cannot be re-used
706after a timeout. If there was no time-out then query ids can be reused 705after a timeout. If there was no time-out then query ids can be reused
707immediately. 706immediately.
707
708=item untaint => $boolean
709
710When true, then the resolver will automatically untaint results, and might
711also ignore certain environment variables.
708 712
709=back 713=back
710 714
711=cut 715=cut
712 716
822 $self->_compile; 826 $self->_compile;
823} 827}
824 828
825=item $resolver->os_config 829=item $resolver->os_config
826 830
827Tries so load and parse F</etc/resolv.conf> on portable operating systems. Tries various 831Tries so load and parse F</etc/resolv.conf> on portable operating
828egregious hacks on windows to force the DNS servers and searchlist out of the system. 832systems. Tries various egregious hacks on windows to force the DNS servers
833and searchlist out of the system.
829 834
830=cut 835=cut
831 836
832sub os_config { 837sub os_config {
833 my ($self) = @_; 838 my ($self) = @_;
939} 944}
940 945
941sub _feed { 946sub _feed {
942 my ($self, $res) = @_; 947 my ($self, $res) = @_;
943 948
949 ($res) = $res =~ /^(.*)$/s
950 if AnyEvent::TAINT && $self->{untaint};
951
944 $res = dns_unpack $res 952 $res = dns_unpack $res
945 or return; 953 or return;
946 954
947 my $id = $self->{id}{$res->{id}}; 955 my $id = $self->{id}{$res->{id}};
948 956
1011 AnyEvent::Socket::tcp_connect (AnyEvent::Socket::format_address ($server), DOMAIN_PORT, sub { 1019 AnyEvent::Socket::tcp_connect (AnyEvent::Socket::format_address ($server), DOMAIN_PORT, sub {
1012 return unless $do_retry; # some other request could have invalidated us already 1020 return unless $do_retry; # some other request could have invalidated us already
1013 1021
1014 my ($fh) = @_ 1022 my ($fh) = @_
1015 or return &$do_retry; 1023 or return &$do_retry;
1024
1025 require AnyEvent::Handle;
1016 1026
1017 my $handle; $handle = new AnyEvent::Handle 1027 my $handle; $handle = new AnyEvent::Handle
1018 fh => $fh, 1028 fh => $fh,
1019 timeout => $timeout, 1029 timeout => $timeout,
1020 on_error => sub { 1030 on_error => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines