Skip Menu |

This queue is for tickets about the HTTP-Daemon CPAN distribution.

Report information
The Basics
Id: 67247
Status: resolved
Priority: 0/
Queue: HTTP-Daemon

People
Owner: Nobody in particular
Requestors: IKEGAMI [...] cpan.org
Cc:
AdminCc:

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



Subject: <<LocalAddr => 'localhost'>> doesn't work.
Hi, The documentation suggests that LocalAddr can be used to bind the server to a specific address. To limit unwarranted connections, one might do HTTP::Daemon->new( LocalAddr => 'localhost' ) However, when one do this, ->url returns http://hostname:12345/ That's a problem. A connection cannot be established to the HTTP::Daemon because it only accepts connections to localhost. I don't know if the problem is a bug in gethostbyaddr, or if the bug is the use of gethostbyaddr, but it's not producing the desired result. Show quoted text
>perl -MSocket -E"say scalar gethostbyaddr(pack('C4', 127,0,0,1),
AF_INET)" tribble I'm not sure what the solution is. Tested on both a Windows machine and a Linux machine. Thanks, Eric
Fixed with: commit 6a42402138773e341e278637da920bcc78c1d733 Author: Gisle Aas <gisle@aas.no> Date: Sat Feb 18 13:13:40 2012 +0100 Don't trust result of gethostbyaddr(INADDR_LOOPBACK) [RT#67247] diff --git a/lib/HTTP/Daemon.pm b/lib/HTTP/Daemon.pm index 6988bd4..804f15d 100644 --- a/lib/HTTP/Daemon.pm +++ b/lib/HTTP/Daemon.pm @@ -5,7 +5,7 @@ use vars qw($VERSION @ISA $PROTO $DEBUG); $VERSION = "6.00"; -use IO::Socket qw(AF_INET INADDR_ANY inet_ntoa); +use IO::Socket qw(AF_INET INADDR_ANY INADDR_LOOPBACK inet_ntoa); @ISA=qw(IO::Socket::INET); $PROTO = "HTTP/1.1"; @@ -44,6 +44,9 @@ sub url require Sys::Hostname; $url .= lc Sys::Hostname::hostname(); } + elsif ($addr eq INADDR_LOOPBACK) { + $url .= inet_ntoa($addr); + } else { $url .= gethostbyaddr($addr, AF_INET) || inet_ntoa($addr); }