aboutsummaryrefslogtreecommitdiffstats
path: root/sitesummary-collector.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'sitesummary-collector.cgi')
-rw-r--r--sitesummary-collector.cgi11
1 files changed, 5 insertions, 6 deletions
diff --git a/sitesummary-collector.cgi b/sitesummary-collector.cgi
index 68ab091..199f4cc 100644
--- a/sitesummary-collector.cgi
+++ b/sitesummary-collector.cgi
@@ -144,16 +144,15 @@ sub get_peerinfo {
my $sockethandle = shift;
my ($peeripaddr, $peername) = ("", "");
- my $sockaddr = getpeername($sockethandle);
- if ($sockaddr) {
- my $peerport;
- ($peerport, $peeripaddr) = sockaddr_in($sockaddr);
- $peername = gethostbyaddr($peeripaddr, AF_INET);
- } elsif ($ENV{'REMOTE_ADDR'}) { # CGI variable
+ if ($ENV{'REMOTE_ADDR'}) { # CGI variable
$peeripaddr = $ENV{'REMOTE_ADDR'};
$peeripaddr =~ m/(\d+).(\d+).(\d+).(\d+)/; # Untaint
$peeripaddr = "$1.$2.$3.$4";
$peername = gethostbyaddr($peeripaddr, AF_INET);
+ } elsif (my $sockaddr = getpeername($sockethandle)) {
+ my $peerport;
+ ($peerport, $peeripaddr) = sockaddr_in($sockaddr);
+ $peername = gethostbyaddr($peeripaddr, AF_INET);
} else {
# Running on the command line, use test host
$peeripaddr = "127.0.0.1";