Subject: | Re: PoCo::Client::Keepalive and dotted quads |
Date: | Tue, 29 Jul 2008 08:36:23 +0100 |
To: | poe [...] perl.org |
From: | Kidney Bingos <chris [...] bingosnet.co.uk> |
On Mon, Jul 28, 2008 at 05:13:17PM -0700, J.G.Konrad wrote:
Show quoted text
> 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.
That regex does look decidedly unrobust. I'd suggest that as PoCo-
Client-Keepalive
requires PoCo-Client-DNS and that in turn requires Net::DNS, which in
turn requires
Net::IP that we use Net::IP's ip_is_ipv4() function which should be
more accurate.
Cheers,
--
Chris Williams
aka BinGOs
PGP ID 0x4658671F
http://www.gumbynet.org.uk
==========================