… | |
… | |
295 | C<$ENV{PERL_ANYEVENT_EDNS0}>, but when set to C<1>, AnyEvent::DNS will use |
295 | C<$ENV{PERL_ANYEVENT_EDNS0}>, but when set to C<1>, AnyEvent::DNS will use |
296 | EDNS0 in all requests. |
296 | EDNS0 in all requests. |
297 | |
297 | |
298 | =cut |
298 | =cut |
299 | |
299 | |
300 | our $EDNS0 = $ENV{PERL_ANYEVENT_EDNS0} * 1; # set to 1 to enable (partial) edns0 |
300 | our $EDNS0 = $ENV{PERL_ANYEVENT_EDNS0}*1; # set to 1 to enable (partial) edns0 |
301 | |
301 | |
302 | our %opcode_id = ( |
302 | our %opcode_id = ( |
303 | query => 0, |
303 | query => 0, |
304 | iquery => 1, |
304 | iquery => 1, |
305 | status => 2, |
305 | status => 2, |
… | |
… | |
655 | |
655 | |
656 | our $RESOLVER; |
656 | our $RESOLVER; |
657 | |
657 | |
658 | sub resolver() { |
658 | sub resolver() { |
659 | $RESOLVER || do { |
659 | $RESOLVER || do { |
660 | $RESOLVER = new AnyEvent::DNS; |
660 | $RESOLVER = new AnyEvent::DNS untaint => 1; |
661 | $RESOLVER->os_config; |
661 | $RESOLVER->os_config; |
662 | $RESOLVER |
662 | $RESOLVER |
663 | } |
663 | } |
664 | } |
664 | } |
665 | |
665 | |
… | |
… | |
703 | =item reuse => $seconds |
703 | =item reuse => $seconds |
704 | |
704 | |
705 | The number of seconds (default: C<300>) that a query id cannot be re-used |
705 | The number of seconds (default: C<300>) that a query id cannot be re-used |
706 | after a timeout. If there was no time-out then query ids can be reused |
706 | after a timeout. If there was no time-out then query ids can be reused |
707 | immediately. |
707 | immediately. |
|
|
708 | |
|
|
709 | =item untaint => $boolean |
|
|
710 | |
|
|
711 | When true, then the resolver will automatically untaint results, and might |
|
|
712 | also ignore certain environment variables. |
708 | |
713 | |
709 | =back |
714 | =back |
710 | |
715 | |
711 | =cut |
716 | =cut |
712 | |
717 | |
… | |
… | |
822 | $self->_compile; |
827 | $self->_compile; |
823 | } |
828 | } |
824 | |
829 | |
825 | =item $resolver->os_config |
830 | =item $resolver->os_config |
826 | |
831 | |
827 | Tries so load and parse F</etc/resolv.conf> on portable operating systems. Tries various |
832 | Tries so load and parse F</etc/resolv.conf> on portable operating |
828 | egregious hacks on windows to force the DNS servers and searchlist out of the system. |
833 | systems. Tries various egregious hacks on windows to force the DNS servers |
|
|
834 | and searchlist out of the system. |
829 | |
835 | |
830 | =cut |
836 | =cut |
831 | |
837 | |
832 | sub os_config { |
838 | sub os_config { |
833 | my ($self) = @_; |
839 | my ($self) = @_; |
… | |
… | |
939 | } |
945 | } |
940 | |
946 | |
941 | sub _feed { |
947 | sub _feed { |
942 | my ($self, $res) = @_; |
948 | my ($self, $res) = @_; |
943 | |
949 | |
|
|
950 | ($res) = $res =~ /^(.*)$/s |
|
|
951 | if AnyEvent::TAINT && $self->{untaint}; |
|
|
952 | |
944 | $res = dns_unpack $res |
953 | $res = dns_unpack $res |
945 | or return; |
954 | or return; |
946 | |
955 | |
947 | my $id = $self->{id}{$res->{id}}; |
956 | my $id = $self->{id}{$res->{id}}; |
948 | |
957 | |