CGI::remote_addr - Enhanced version of CGI.pm's "remote_addr()"
use CGI;
use CGI::remote_addr;
my $cgi = CGI->new();
my $addr = $cgi->remote_addr();CGI::remote_addr implements an enhanced version of the remote_addr()
method provided by CGI.pm, which attempts to return the original IP address
that the connection originated from (which is not necessarily the IP address
that we received the connection from).
Simply loading CGI::remote_addr causes it to over-ride the existing
remote_addr() method. Do note, though, that this is a global over-ride; if
you're running under mod_perl you've just over-ridden it for all of your
applications.
$ENV{REMOTE_ADDR} to find the IP address, but also look in
$ENV{HTTP_X_FORWARDED_FOR} to find the IP address. If
$ENV{HTTP_X_FORWARDED_FOR} is defined, we try that first.$ENV{REMOTE_ADDR} or $ENV{HTTP_X_FORWARDED_FOR}. I've seen lots of cases
where the values for $ENV{HTTP_X_FORWARDED_FOR} were stuffed with garbage,
and we make sure that you only get a real IP back.undef, NOT 127.0.0.1 (like CGI.pm does).remote_addr()
Returns the IP address(es) of the remote host.
Graham TerMarsch ([email protected])
Copyright (C) 2008 Graham TerMarsch. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.