diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2007-12-02 18:24:21 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2007-12-02 18:24:21 +0000 |
commit | dd0899f955fb647a08885d28d21c7747a2ec135a (patch) | |
tree | 5a53d1df277d4b81fe6223448e10d54fec1c341d /sitesummary-collector.cgi | |
parent | 537c5264fbdaaf552050374524146656807ecf59 (diff) | |
download | sitesummary-dd0899f955fb647a08885d28d21c7747a2ec135a.tar.gz sitesummary-dd0899f955fb647a08885d28d21c7747a2ec135a.tar.bz2 sitesummary-dd0899f955fb647a08885d28d21c7747a2ec135a.tar.xz |
More fixes for get_peerinfo().
Diffstat (limited to 'sitesummary-collector.cgi')
-rw-r--r-- | sitesummary-collector.cgi | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sitesummary-collector.cgi b/sitesummary-collector.cgi index 38238ea..1ba4607 100644 --- a/sitesummary-collector.cgi +++ b/sitesummary-collector.cgi @@ -142,12 +142,13 @@ sub process_entry { sub get_peerinfo { my $sockethandle = shift; - my ($peeripaddr, $peername) = ("", ""); + my ($peeripstr, $peername) = ("", ""); if ($ENV{'REMOTE_ADDR'}) { # CGI variable - $peeripaddr = $ENV{'REMOTE_ADDR'}; - $peeripaddr =~ m/(\d+).(\d+).(\d+).(\d+)/; # Untaint - $peeripaddr = inet_aton("$1.$2.$3.$4"); + $peeripstr = $ENV{'REMOTE_ADDR'}; + $peeripstr =~ m/(\d+).(\d+).(\d+).(\d+)/; # Untaint + $peeripstr = "$1.$2.$3.$4"; + $peeripaddr = inet_aton($peeripstr); $peername = gethostbyaddr($peeripaddr, AF_INET); } elsif (my $sockaddr = getpeername($sockethandle)) { my $peerport; @@ -155,12 +156,12 @@ sub get_peerinfo { $peername = gethostbyaddr($peeripaddr, AF_INET); } else { # Running on the command line, use test host - $peeripaddr = "127.0.0.1"; + $peeripstr = "127.0.0.1"; $peername = "localhost"; } if ("" eq $peername) { - syslog('warning', "%s", "client without DNS entry connected from \[$peeripaddr\]"); - $peername = "$peeripaddr"; + syslog('warning', "%s", "client without DNS entry connected from \[$peeripstr\]"); + $peername = "$peeripstr"; } - return ($peeripaddr, $peername); + return ($peeripstr, $peername); } |