| HTTPD-ADS documentation | Contained in the HTTPD-ADS distribution. |
HTTPD::ADS::Blocker - Block a given IP address using some technique or other.
use HTTPD::ADS::Blocker
This is a wrapper. The idea is that various techniques might be available to block communication with a blacklisted IP address. Right now is just one: install a reject route. The interface, therefore, to this module is still evolving but the default will always use the reject route technique.
Dana Hudes CPAN ID: DHUDES dhudes@hudes.org http://www.hudes.org
This program is free software licensed under the...
The General Public License (GPL) Version 2, June 1991
The full text of the license can be found in the LICENSE file included with this module.
perl(1), HTTPD::ADS .
Usage : How to use this function/method
Purpose : What it does
Returns : What it returns
Argument : What it wants to know
Throws : Exceptions and other anomolies
Comments : This is a sample subroutine header.
: It is polite to include more pod and fewer comments.
See Also :
| HTTPD-ADS documentation | Contained in the HTTPD-ADS distribution. |
package HTTPD::ADS::Blocker; use strict; use Carp; use IPC::Cmd qw[can_run run]; BEGIN { use Exporter (); use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.1; @ISA = qw (Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw (); @EXPORT_OK = qw (); %EXPORT_TAGS = (); } ########################################### main pod documentation begin ## # Below is the documentation for this module.
############################################# main pod documentation end ## ################################################ subroutine header begin ##
################################################## subroutine header end ## sub new { my ($class, %parameters) = @_; my $self = bless ({}, ref ($class) || $class); &reject($parameters{ip}); return ($self); } sub reject { my $ipaddr = shift; my $route_full_path = can_run('route') or die "cannot find the route command"; my @routecmd = ($route_full_path, qw(add foo reject)); $routecmd[2]=$ipaddr; unless (run(command => \@routecmd, verbose =>0)) { my $errmesg = (scalar localtime)." failed to add reject route for $ipaddr (maybe its already listed?)\n "; carp $errmesg; } } 1; #this line is important and will help the module return a true value __END__