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.7 by root, Fri May 23 05:30:59 2008 UTC vs.
Revision 1.12 by root, Fri May 23 06:13:10 2008 UTC

8 8
9=head1 DESCRIPTION 9=head1 DESCRIPTION
10 10
11This module offers both a number of DNS convenience functions as well 11This module offers both a number of DNS convenience functions as well
12as a fully asynchronous and high-performance pure-perl stub resolver. 12as a fully asynchronous and high-performance pure-perl stub resolver.
13
14The stub resolver supports DNS over UDP, optional EDNS0 support for up to
154kiB datagrams and automatically falls back to virtual circuit mode for
16large responses.
13 17
14=head2 CONVENIENCE FUNCTIONS 18=head2 CONVENIENCE FUNCTIONS
15 19
16=over 4 20=over 4
17 21
161 165
162=head2 DNS EN-/DECODING FUNCTIONS 166=head2 DNS EN-/DECODING FUNCTIONS
163 167
164=over 4 168=over 4
165 169
170=item $AnyEvent::DNS::EDNS0
171
172This variable decides wether dns_pack automatically enables EDNS0
173support. By default, this is disabled (C<0>), but when set to C<1>,
174AnyEvent::DNS will use EDNS0 in all requests.
175
166=cut 176=cut
177
178our $EDNS0 = 0; # set to 1 to enable (partial) edns0
167 179
168our %opcode_id = ( 180our %opcode_id = (
169 query => 0, 181 query => 0,
170 iquery => 1, 182 iquery => 1,
171 status => 2, 183 status => 2,
309 + $rcode_id{$req->{rc}} * 0x0001, 321 + $rcode_id{$req->{rc}} * 0x0001,
310 322
311 scalar @{ $req->{qd} || [] }, 323 scalar @{ $req->{qd} || [] },
312 scalar @{ $req->{an} || [] }, 324 scalar @{ $req->{an} || [] },
313 scalar @{ $req->{ns} || [] }, 325 scalar @{ $req->{ns} || [] },
314 1 + scalar @{ $req->{ar} || [] }, # include EDNS0 option 326 $EDNS0 + scalar @{ $req->{ar} || [] }, # include EDNS0 option here
315 327
316 (join "", map _enc_qd, @{ $req->{qd} || [] }), 328 (join "", map _enc_qd, @{ $req->{qd} || [] }),
317 (join "", map _enc_rr, @{ $req->{an} || [] }), 329 (join "", map _enc_rr, @{ $req->{an} || [] }),
318 (join "", map _enc_rr, @{ $req->{ns} || [] }), 330 (join "", map _enc_rr, @{ $req->{ns} || [] }),
319 (join "", map _enc_rr, @{ $req->{ar} || [] }), 331 (join "", map _enc_rr, @{ $req->{ar} || [] }),
320 332
321 (pack "C nnNn", 0, 41, 4000, 0, 0) # EDNS0, 4k udp payload size 333 ($EDNS0 ? pack "C nnNn", 0, 41, 4096, 0, 0 : "") # EDNS0, 4kiB udp payload size
322} 334}
323 335
324our $ofs; 336our $ofs;
325our $pkt; 337our $pkt;
326 338
698} 710}
699 711
700sub _recv { 712sub _recv {
701 my ($self) = @_; 713 my ($self) = @_;
702 714
703 while (my $peer = recv $self->{fh}, my $res, 4000, 0) { 715 while (my $peer = recv $self->{fh}, my $res, 4096, 0) {
704 my ($port, $host) = Socket::unpack_sockaddr_in $peer; 716 my ($port, $host) = Socket::unpack_sockaddr_in $peer;
705 717
706 return unless $port == 53 && grep $_ eq $host, @{ $self->{server} }; 718 return unless $port == 53 && grep $_ eq $host, @{ $self->{server} };
707 719
708 $self->_feed ($res); 720 $self->_feed ($res);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines