Skip Menu |

This queue is for tickets about the POE-Component-Client-Keepalive CPAN distribution.

Report information
The Basics
Id: 38219
Status: resolved
Priority: 0/
Queue: POE-Component-Client-Keepalive

People
Owner: Nobody in particular
Requestors: perl [...] 0ne.us
Cc:
AdminCc:

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



CC: bug-POE-Component-Client-Keepalive [...] rt.cpan.org
Subject: Re: PoCo::Client::Keepalive and dotted quads
Date: Tue, 05 Aug 2008 19:06:55 -0400
To: poe [...] perl.org
From: Apocalypse <perl [...] 0ne.us>
Hello, I typed up a lengthy email that explained this EXACT problem I encountered yesterday. Saw this email today, ha! Just wanted to throw in my 1c... Hello, I've wracked my head trying to solve this problem that spontaneously appeared on one of my servers. I must have screwed up something badly, because I updated some CPAN modules and all of a sudden my app server didn't function with this module. The exact error I got was: CON: request 1 encountered resolve error ??: Host has no address. After digging through my modules and trying to figure out why all of a sudden we were trying to DNS resolve "192.168.3.101", I arrived on this line in Client::Keepalive. It immediately made me suspicious! Line 842 in Client-Keepalive.pm v0.20 Show quoted text
> sub _ka_resolve_request { > my ($self, $kernel, $heap, $request) = @_[OBJECT, KERNEL, HEAP, ARG0]; > > my $host = $request->[RQ_ADDRESS]; > > # Skip DNS resolution if it's already a dotted quad. > # TODO - Not all dotted quads are good. > if ($host !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { > DEBUG_DNS and warn "DNS: $host is a dotted quad; skipping lookup"; > $kernel->call("$self", ka_add_to_queue => $request); > return; > }
Notice the erroneous !~ condition here. If we replace that with the proper =~ comparison, everything works well. This is an obvious logic flaw, yes? Please advise on what I should do, because this kind of monkeypatching is bad for me :( What makes me sick is thinking that it always was like that and some other condition masked this bug... I'm still trying to figure out what exactly I changed that could have "unmasked" this. I'm using: perl v5.8.8 built for x86_64-linux POE v1.003 PoCo-Client-Keepalive v0.20 PoCo-Client-HTTP v0.85 ~Apocalypse http://search.cpan.org/~APOCAL/ J.G.Konrad wrote: Show quoted text
> I have a need to override DNS lookup and to for a request to go to a > specific IP address. I decided to try and create a HTTP::Request object > with a dotted quad and to manually specify the host in headers. > example: > > --snip-- > > my $request = > HTTP::Request->new(GET => 'http://10.1.0.1' ); > $request->header('host' => 'vhost.behindfirewall.com'); > > $kernel->post( 'ua', 'request', 'response', $request ); > > --snip-- > > > This did not work. I kept getting DNS resolve errors > > <html> > <HEAD><TITLE>Error: Internal Server Error</TITLE></HEAD> > <BODY> > <H1>Error: Internal Server Error</H1> > Cannot connect to 10.1.0.1:80 (resolve error ??: Host has no address.) > </BODY> > </HTML> > > > After some fun playing with the perl debugger I got down to a section of the > PoCo::Client::Keepalive code that I think is not correct with how it handles > dotted quads. In _ka_resolve_request() there is this code > > > # Skip DNS resolution if it's already a dotted quad. > # TODO - Not all dotted quads are good. > if ($host !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { > DEBUG_DNS and warn "DNS: $host is a dotted quad; skipping lookup"; > $kernel->call("$self", ka_add_to_queue => $request); > return; > } > > The comments say that if it is a dotted quad then skip resolution but that > is not happening. I think the conditional needs to be inverted. Change the > '!~' into a '=~'. > > After I made the change in my copy of PoCo::Client::Keepalive the dotted > quad worked as expected. >
Recommended change made, and 0.21 uploaded to PAUSE. Thank you. :)
Thank J.G.Konrad too ;) Again, thanks for the speedy fix - I think it's a RT record for a bug to be filed and a new distro on CPAN in 20min or less? =] -- ~Apocalypse