Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 14624
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: berni [...] birkenwald.de
raptor [...] tvskat.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.53
Fixed in: (no value)



Subject: peerhost still not working as expected
Earlier versions has a problem with not showing correct $peerhost in .53_01 this problem is solved partialy (passing $sock directly to udp_connection() instead of $sock->peerhost, which doesn work !!) Now it almost work. What happen when i make queries from two different ip addresses is : 1. On the first query : $peerhost is empty 2. Every first request from different address returns in $peerhost the previous address Haven't debugged the code to figure out the root of the cause. Gentoo Linux vr 2.6.10-rc3 #1 Sat Jan 8 22:15:17 EET 2005 i686 Intel(R) Celeron(R) CPU 2.53GHz GenuineIntel GNU/Linux This is perl, v5.8.6 built for i686-linux Net::DNS $VERSION = '0.53_01'; that is for now
Subject: Manpage inconsistent, $peerhost
The manpage of 0.53 is inconsistent regarding the peerhost variable In the example-section there is The following example will listen on port 5353 and respond to all queries for A records with the IP address 10.1.2.3. All other queries will be answered with NXDOMAIN. Authority and additional sections are left empty. The $peerhost variable catches the IP address of the peer host, so that additional filtering on its basis may be applied. reply_handler() has four parameters, $qname, $qclass, $qtype, $peerhost In the METHODS section the fourth parameter is described as an header bit setting. The ReplyHandler subroutine is passed the query name, query class, query type and optionally an argument containing header bit settings (see below). It must return the response code and references to the answer, authority, and additional sections of the response. Common response codes are: The first description seems to be wrong, at least I can't get anything when doing "print $peerhost" in reply_handler.
This is better, and hopefully understandable: The ReplyHandler subroutine is passed the query name, query class, query type, the peerhost and a Net::DNS::Packet object containing the incomming query. The latter can be used to determine if the query had EDNS extentions or to study the exact header bits setting.
(It looks like the mail gateway is down, so I'll try to comment through Web) That is how I understood it. However, then my problem is that $peerhost isn't set appropriately. Show quoted text
>> cat test-dns.pl
#!/usr/bin/perl -w use Net::DNS::Nameserver; my $ns = Net::DNS::Nameserver->new( LocalAddr => '127.0.0.1', LocalPort => 53, ReplyHandler => \&reply_handler, ); $ns->main_loop; sub reply_handler { my ($qname, $qclass, $qtype, $peerhost, $packet) = @_; my ($rcode, @ans, @auth, @add); print "Received query $qname $qclass $qtype from $peerhost - $packet\n"; $rcode = "NXDOMAIN"; return($rcode, \@ans, \@auth, \@add, { aa => 1 }); }; Show quoted text
>> sudo perl test-dns.pl
Use of uninitialized value in concatenation (.) or string at test-dns.pl line 17. Received query www.test.de IN A from - Net::DNS::Packet=HASH(0x8489950) Anything I'm missing? The system is SuSE 9.3, Net::DNS version 0.53 compiled and installed with -MCPAN. Bernhard
[guest - Thu Sep 22 15:50:15 2005]: Show quoted text
> (It looks like the mail gateway is down, so I'll try to comment > through Web) > > > That is how I understood it. However, then my problem is that > $peerhost > isn't set appropriately.
Acknowledged and fixed. in nameserver.pm the "my($peerhost,peerport)=" line should appear after recv from the socket. sub udp_connection { my ($self, $sock) = @_; my $buf = ""; $sock->recv($buf, &Net::DNS::PACKETSZ); my ($peerhost,$peerport)=($sock->peerhost,$sock->peerport); The code is in the subversion repository. Closing the ticket. --Olaf