CGI::Application::Plugin::RemoteIP - Unified Remote IP handling
use CGI::Application::Plugin::RemoteIP; # Your application sub run_mode { my ($self) = ( @_); my $ip = $self->remote_ip(); }
This module simplifies the detection of the remote IP address of your visitors.
This module allows you to remove scattered references in your code, such as:
# Get IP my $ip = $ENV{'REMOTE_ADDR'}; # Remove faux IPv6-prefix. $ip =~ s/^::ffff://g; ..
Instead your code and use the simpler expression:
my $ip = $self->remote_ip();
The code in this module will successfully understand the X-Forwarded-For header and trust it.
X-Forwarded-For
Unless you have setup any proxy, or webserver, to scrub this header this means the value that is used is at risk of being spoofed, bogus, or otherwise malicious.
Add our three public-methods into the caller's namespace:
The remote IP of the client.
A method to return 1 if the visitor is using IPv4 and 0 otherwise.
A method to return 1 if the visitor is using IPv6 and 0 otherwise.
Return the remote IP of the visitor, whether via the X-Forwarded-For header or via the standard CGI environmental variable REMOTE_ADDR.
REMOTE_ADDR
Determine whether the remote IP address is IPv4.
Determine whether the remote IP address is IPv6.
Steve Kemp <steve@steve.org.uk>
Copyright (C) 2015 Steve Kemp <steve@steve.org.uk>.
This library is free software. You can modify and or distribute it under the same terms as Perl itself.
To install CGI::Application::Plugin::RemoteIP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Plugin::RemoteIP
CPAN shell
perl -MCPAN -e shell install CGI::Application::Plugin::RemoteIP
For more information on module installation, please visit the detailed CPAN module installation guide.