| 1 | package Net::Firewall::BlockerHelper::backends::shell; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base 'Error::Helper'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Regexp::IPv4 qw($IPv4_re); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Regexp::IPv6 qw($IPv6_re); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | Net::Firewall::BlockerHelper::backends::shell - A shell backend for Net::Firewall::BlockHelper. | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | Version 0.0.1 | ||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our $VERSION = '0.0.1'; | |||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | use Net::Firewall::BlockerHelper; | ||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | my $fw_helper; | ||||||||||||||||||||||||||||||||||||||
| 27 | eval { | ||||||||||||||||||||||||||||||||||||||
| 28 | $fw_helper = Net::Firewall::BlockerHelper->new( | ||||||||||||||||||||||||||||||||||||||
| 29 | backend=>'shell', | ||||||||||||||||||||||||||||||||||||||
| 30 | name=>'derp', | ||||||||||||||||||||||||||||||||||||||
| 31 | options=>{ | ||||||||||||||||||||||||||||||||||||||
| 32 | init=>'mkdir /tmp/fw_helper_example/', | ||||||||||||||||||||||||||||||||||||||
| 33 | teardown=>'rm -rf /tmp/fw_helper_example/', | ||||||||||||||||||||||||||||||||||||||
| 34 | unban=>'rm -rf /tmp/fw_helper_example/%%%BAN%%%', | ||||||||||||||||||||||||||||||||||||||
| 35 | ban=>'touch /tmp/fw_helper_example/%%%BAN%%%', | ||||||||||||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||||||||||||
| 39 | if ($@) { | ||||||||||||||||||||||||||||||||||||||
| 40 | print 'Error: ' | ||||||||||||||||||||||||||||||||||||||
| 41 | . $Error::Helper::error | ||||||||||||||||||||||||||||||||||||||
| 42 | . "\nError String: " | ||||||||||||||||||||||||||||||||||||||
| 43 | . $Error::Helper::errorString | ||||||||||||||||||||||||||||||||||||||
| 44 | . "\nError Flag: " | ||||||||||||||||||||||||||||||||||||||
| 45 | . $Error::Helper::errorFlag . "\n"; | ||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | $fw_helper->init; | ||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | $fw_helper->ban(ban => '5.6.7.8'); | ||||||||||||||||||||||||||||||||||||||
| 51 | $fw_helper->ban(ban => '1.2.3.4'); | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | $fw_helper->unban(ban => '5.6.7.8'); | ||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | $fw_helper->teardown; | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | =head2 new | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | Initiates the the object. Unlike other backends, this only takes uses | ||||||||||||||||||||||||||||||||||||||
| 62 | the options hash. | ||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | - options :: A hash of options to pass to the backend. | ||||||||||||||||||||||||||||||||||||||
| 65 | Default :: {} | ||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||
| 67 | - name :: Not used but is required by Net::Firewall::BlockerHelper. | ||||||||||||||||||||||||||||||||||||||
| 68 | Default :: undef | ||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||
| 70 | The values used for options is as below. All must be defined and can't be ''. | ||||||||||||||||||||||||||||||||||||||
| 71 | '2>&1' is appended to the end of the commands. | ||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | - init :: The command to run to init the blocking. | ||||||||||||||||||||||||||||||||||||||
| 74 | Default :: undef | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | - teardown :: The command to run to teardown the blocking. | ||||||||||||||||||||||||||||||||||||||
| 77 | Default :: undef | ||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||
| 79 | - ban :: The command to run to ban a IP. %%%BAN%%% is replaced with the IP. | ||||||||||||||||||||||||||||||||||||||
| 80 | Default :: undef | ||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | - unban :: The command to run to un ban a IP. %%%BAN%%% is replaced with the IP. | ||||||||||||||||||||||||||||||||||||||
| 83 | Default :: undef | ||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||
| 85 | All errors are considered fatal, meaning if new fails it will die. | ||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | my $fw_helper; | ||||||||||||||||||||||||||||||||||||||
| 88 | eval { | ||||||||||||||||||||||||||||||||||||||
| 89 | $fw_helper = Net::Firewall::BlockerHelper->new( | ||||||||||||||||||||||||||||||||||||||
| 90 | backend=>'shell', | ||||||||||||||||||||||||||||||||||||||
| 91 | name=>'derp', | ||||||||||||||||||||||||||||||||||||||
| 92 | options=>{ | ||||||||||||||||||||||||||||||||||||||
| 93 | init=>'mkdir /tmp/fw_helper_example/', | ||||||||||||||||||||||||||||||||||||||
| 94 | teardown=>'rm -rf /tmp/fw_helper_example/', | ||||||||||||||||||||||||||||||||||||||
| 95 | unban=>'rm -rf /tmp/fw_helper_example/%%%BAN%%%', | ||||||||||||||||||||||||||||||||||||||
| 96 | ban=>'touch /tmp/fw_helper_example/%%%BAN%%%', | ||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||||||||||||
| 100 | if ($@) { | ||||||||||||||||||||||||||||||||||||||
| 101 | print 'Error: ' | ||||||||||||||||||||||||||||||||||||||
| 102 | . $Error::Helper::error | ||||||||||||||||||||||||||||||||||||||
| 103 | . "\nError String: " | ||||||||||||||||||||||||||||||||||||||
| 104 | . $Error::Helper::errorString | ||||||||||||||||||||||||||||||||||||||
| 105 | . "\nError Flag: " | ||||||||||||||||||||||||||||||||||||||
| 106 | . $Error::Helper::errorFlag . "\n"; | ||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | sub new { | ||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | my ( $blank, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=14 SCAR=43.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | 1 | my $self = { | |||||||||||||||||||||||||||||||||||||
| 115 | perror => undef, | ||||||||||||||||||||||||||||||||||||||
| 116 | error => undef, | ||||||||||||||||||||||||||||||||||||||
| 117 | errorLine => undef, | ||||||||||||||||||||||||||||||||||||||
| 118 | errorFilename => undef, | ||||||||||||||||||||||||||||||||||||||
| 119 | errorString => "", | ||||||||||||||||||||||||||||||||||||||
| 120 | errorExtra => { | ||||||||||||||||||||||||||||||||||||||
| 121 | all_errors_fatal => 1, | ||||||||||||||||||||||||||||||||||||||
| 122 | flags => { | ||||||||||||||||||||||||||||||||||||||
| 123 | 1 => 'notInited', | ||||||||||||||||||||||||||||||||||||||
| 124 | 2 => 'initInvalid', | ||||||||||||||||||||||||||||||||||||||
| 125 | 3 => 'optionsUndef', | ||||||||||||||||||||||||||||||||||||||
| 126 | 4 => 'teardownInvalid', | ||||||||||||||||||||||||||||||||||||||
| 127 | 5 => 'banInvalid', | ||||||||||||||||||||||||||||||||||||||
| 128 | 6 => 'unbanInvalid', | ||||||||||||||||||||||||||||||||||||||
| 129 | 8 => 'optionsNotHash', | ||||||||||||||||||||||||||||||||||||||
| 130 | 9 => 'noBanItem', | ||||||||||||||||||||||||||||||||||||||
| 131 | 10 => 'banItemNotIP', | ||||||||||||||||||||||||||||||||||||||
| 132 | 12 => 'backendInitError', | ||||||||||||||||||||||||||||||||||||||
| 133 | 13 => 'banFailed', | ||||||||||||||||||||||||||||||||||||||
| 134 | 14 => 'unbanFailed', | ||||||||||||||||||||||||||||||||||||||
| 135 | 15 => 'listFailed', | ||||||||||||||||||||||||||||||||||||||
| 136 | 16 => 'reInitFailed', | ||||||||||||||||||||||||||||||||||||||
| 137 | 17 => 'teardownFailed', | ||||||||||||||||||||||||||||||||||||||
| 138 | 18 => 'alreadyInited', | ||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||
| 140 | fatal_flags => {}, | ||||||||||||||||||||||||||||||||||||||
| 141 | perror_not_fatal => 0, | ||||||||||||||||||||||||||||||||||||||
| 142 | }, | ||||||||||||||||||||||||||||||||||||||
| 143 | backend => undef, | ||||||||||||||||||||||||||||||||||||||
| 144 | options => {}, | ||||||||||||||||||||||||||||||||||||||
| 145 | ports => [], | ||||||||||||||||||||||||||||||||||||||
| 146 | protocols => [], | ||||||||||||||||||||||||||||||||||||||
| 147 | testing => undef, | ||||||||||||||||||||||||||||||||||||||
| 148 | test_data => undef, | ||||||||||||||||||||||||||||||||||||||
| 149 | prefix => 'kur', | ||||||||||||||||||||||||||||||||||||||
| 150 | postfix => undef, | ||||||||||||||||||||||||||||||||||||||
| 151 | frontend_obj => undef, | ||||||||||||||||||||||||||||||||||||||
| 152 | inited => 0, | ||||||||||||||||||||||||||||||||||||||
| 153 | banned => {}, | ||||||||||||||||||||||||||||||||||||||
| 154 | }; | ||||||||||||||||||||||||||||||||||||||
| 155 | 1 | bless $self; | |||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | # used internally for testing | ||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | if ( defined( $opts{testing} ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $self->{testing} = $opts{testing}; | |||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | if ( defined( $opts{frontend_obj} ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 162 | 1 | $self->{frontend_obj} = $opts{frontend_obj}; | |||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | if ( defined( $opts{options} ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | if ( ref( $opts{options} ) ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->{error} = 8; | |||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->{errorString} = 'ref for options is "' . ref( $opts{options} ) . '" and not HASH'; | |||||||||||||||||||||||||||||||||||||
| 170 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||
| 172 | 1 | $self->{options} = $opts{options}; | |||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ▶ | if ( !defined( $opts{options}{init} ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->{error} = 2; | |||||||||||||||||||||||||||||||||||||
| 177 | 0 | $self->{errorString} = 'init is not defined'; | |||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 179 | } elsif ( $opts{options}{init} eq '' ) { | ||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->{error} = 3; | |||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{errorString} = 'init is not blank'; | |||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 184 | } elsif ( !defined( $opts{options}{teardown} ) ) { | ||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->{error} = 4; | |||||||||||||||||||||||||||||||||||||
| 187 | 0 | $self->{errorString} = 'teardown is not defined'; | |||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 189 | } elsif ( $opts{options}{teardown} eq '' ) { | ||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 191 | 0 | $self->{error} = 4; | |||||||||||||||||||||||||||||||||||||
| 192 | 0 | $self->{errorString} = 'teardown is not blank'; | |||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 194 | } elsif ( !defined( $opts{options}{ban} ) ) { | ||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->{error} = 5; | |||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->{errorString} = 'ban is not defined'; | |||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 199 | } elsif ( $opts{options}{ban} eq '' ) { | ||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->{error} = 5; | |||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->{errorString} = 'ban is not blank'; | |||||||||||||||||||||||||||||||||||||
| 203 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 204 | } elsif ( !defined( $opts{options}{unban} ) ) { | ||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->{error} = 6; | |||||||||||||||||||||||||||||||||||||
| 207 | 0 | $self->{errorString} = 'unban is not defined'; | |||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 209 | } elsif ( $opts{options}{unban} eq '' ) { | ||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 211 | 0 | $self->{error} = 5; | |||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->{errorString} = 'unban is not blank'; | |||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||
| 215 | } else { | ||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if ( ref( $opts{options} ) ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->{perror} = 1; | |||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->{error} = 3; | |||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->{errorString} = 'options is undef and not a hash'; | |||||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||
| 224 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||
| 225 | } ## end sub new | ||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||
| 227 | =head2 init | ||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||
| 229 | Initiates the backend. | ||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||
| 231 | No arguments are taken. | ||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||
| 233 | =cut | ||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||
| 235 | sub init { | ||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | my ( $self, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | 2 | $self->errorblank; | |||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | if ( $self->{inited} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->{error} = 18; | |||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->{errorString} = 'backend has already been inited'; | |||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||
| 246 | 2 | my $command = $self->{options}{init}; | |||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | 2 | ▶ | if ( $self->{testing} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 249 | 2 | $self->{frontend_obj}->{test_data} = $command; | |||||||||||||||||||||||||||||||||||||
| 250 | } else { | ||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $output = `$command 2>&1`; | |||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ( $? ne '0' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->{error} = 12; | |||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->{errorString} = 'Init failed... command "' . $command . '" resulted in... ' . $output; | |||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||
| 259 | 2 | $self->{inited} = 1; | |||||||||||||||||||||||||||||||||||||
| 260 | } ## end sub init | ||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||
| 262 | =head2 ban | ||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||
| 264 | Bans the IP. | ||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||
| 266 | $fw_helper->ban(ban => $ip); | ||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | =cut | ||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||
| 270 | sub ban { | ||||||||||||||||||||||||||||||||||||||
| 271 | 2 | ▶ | my ( $self, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ban: called CC=8 SCAR=32.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||
| 273 | 2 | $self->errorblank; | |||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | if ( !$self->{inited} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $self->{error} = 1; | |||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->{errorString} = 'backend has not been inited'; | |||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 279 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | if ( !defined( $opts{ban} ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->{error} = 9; | |||||||||||||||||||||||||||||||||||||
| 284 | 0 | $self->{errorString} = 'Nothing specified for the value ban'; | |||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 286 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 287 | } elsif ( ref( $opts{ban} ) ne '' ) { | ||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $self->{error} = 10; | |||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->{errorString} = 'Bad ref type for ban... ref is "' . ref( $opts{ban} ) . '"'; | |||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 291 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 292 | ▶ | } elsif ( $opts{ban} !~ /$IPv4_re/ | |||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/ || $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
MC/DC0%0/2
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/ || $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
Truth table33%1/3
A || B
A= $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/B= $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
| |||||||||||||||||||||||||||||||||||||||
| 293 | && $opts{ban} !~ /$IPv6_re/ ) | ||||||||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->{error} = 10; | |||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->{errorString} = 'ban item,"' . $opts{ban} . '", does not appear to be a IPv4 or IPv6 IP'; | |||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 298 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||
| 301 | 2 | my $command = $self->{options}{ban}; | |||||||||||||||||||||||||||||||||||||
| 302 | 2 | $command =~ s/\%\%\%BAN\%\%\%/$opts{ban}/g; | |||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | if ( $self->{testing} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 305 | 2 | $self->{frontend_obj}->{test_data} = $command; | |||||||||||||||||||||||||||||||||||||
| 306 | } else { | ||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $output = `$command 2>&1`; | |||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if ( $? ne '0' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $self->{error} = 13; | |||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->{errorString} = 'Ban failed... command "' . $command . '" resulted in... ' . $output; | |||||||||||||||||||||||||||||||||||||
| 311 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||
| 315 | 2 | $self->{banned}{ $opts{ban} } = 1; | |||||||||||||||||||||||||||||||||||||
| 316 | } ## end sub ban | ||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||
| 318 | =head2 unban | ||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | Unbans the an IP. | ||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||
| 322 | $fw_helper->ban(ban => $ip); | ||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||
| 324 | =cut | ||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||
| 326 | sub unban { | ||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | my ( $self, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
unban: called CC=8 SCAR=32.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||
| 329 | 1 | $self->errorblank; | |||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | 1 | ▶ | if ( !$self->{inited} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $self->{error} = 1; | |||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->{errorString} = 'backend has not been inited'; | |||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 335 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||
| 338 | 1 | ▶ | if ( !defined( $opts{ban} ) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $self->{error} = 9; | |||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->{errorString} = 'Nothing specified for the value ban'; | |||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 342 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 343 | } elsif ( ref( $opts{ban} ) ne '' ) { | ||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->{error} = 10; | |||||||||||||||||||||||||||||||||||||
| 345 | 0 | $self->{errorString} = 'Bad ref type for ban... ref is "' . ref( $opts{ban} ) . '"'; | |||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 347 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 348 | ▶ | } elsif ( $opts{ban} !~ /$IPv4_re/ | |||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/ || $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
MC/DC0%0/2
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/ || $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/
$opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
Truth table33%1/3
A || B
A= $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv4_re/B= $opts{'ban'} =~ /$Net::Firewall::BlockerHelper::backends::shell::IPv6_re/
| |||||||||||||||||||||||||||||||||||||||
| 349 | && $opts{ban} !~ /$IPv6_re/ ) | ||||||||||||||||||||||||||||||||||||||
| 350 | { | ||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->{error} = 10; | |||||||||||||||||||||||||||||||||||||
| 352 | 0 | $self->{errorString} = 'ban item,"' . $opts{ban} . '", does not appear to be a IPv4 or IPv6 IP'; | |||||||||||||||||||||||||||||||||||||
| 353 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 354 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||
| 357 | 1 | my $command = $self->{options}{unban}; | |||||||||||||||||||||||||||||||||||||
| 358 | 1 | $command =~ s/\%\%\%BAN\%\%\%/$opts{ban}/g; | |||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||
| 360 | 1 | ▶ | if ( $self->{testing} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 361 | 1 | $self->{frontend_obj}->{test_data} = $command; | |||||||||||||||||||||||||||||||||||||
| 362 | } else { | ||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $output = `$command 2>&1`; | |||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ( $? ne '0' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $self->{error} = 14; | |||||||||||||||||||||||||||||||||||||
| 366 | 0 | $self->{errorString} = 'Unban failed... command "' . $command . '" resulted in... ' . $output; | |||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||
| 371 | 1 | delete( $self->{banned}{ $opts{ban} } ); | |||||||||||||||||||||||||||||||||||||
| 372 | } ## end sub unban | ||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||
| 374 | =head2 list | ||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||
| 376 | List banned IPs. | ||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||
| 378 | my @banned = $fw_helper->list; | ||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||
| 380 | =cut | ||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||
| 382 | sub list { | ||||||||||||||||||||||||||||||||||||||
| 383 | 2 | ▶ | my ( $self, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||
| 385 | 2 | $self->errorblank; | |||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||
| 387 | 2 | $self->{frontend_obj}->{test_data} = 'list'; | |||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||
| 389 | 2 | return keys( %{ $self->{banned} } ); | |||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||
| 392 | =head2 re_init | ||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||
| 394 | Tells the backend to re-init it's self. | ||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||
| 398 | sub re_init { | ||||||||||||||||||||||||||||||||||||||
| 399 | 1 | ▶ | my ( $self, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
re_init: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||
| 401 | 1 | $self->errorblank; | |||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||
| 403 | 1 | $self->teardown; | |||||||||||||||||||||||||||||||||||||
| 404 | 1 | $self->init; | |||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||
| 406 | 1 | my @to_re_ban = keys( %{ $self->{banned} } ); | |||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||
| 408 | 1 | foreach my $item (@to_re_ban) { | |||||||||||||||||||||||||||||||||||||
| 409 | 1 | my $command = $self->{options}{ban}; | |||||||||||||||||||||||||||||||||||||
| 410 | 1 | $command =~ s/\%\%\%BAN\%\%\%/$item/g; | |||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||
| 412 | 1 | ▶ | if ( !$self->{testing} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $output = `$command 2>&1`; | |||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | if ( $? ne '0' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->{error} = 13; | |||||||||||||||||||||||||||||||||||||
| 416 | 0 | $self->{errorString} = 'Ban failed... command "' . $command . '" resulted in... ' . $output; | |||||||||||||||||||||||||||||||||||||
| 417 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||
| 420 | } ## end foreach my $items (@to_re_ban) | ||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||
| 422 | 1 | ▶ | if ( $self->{testing} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 423 | 1 | $self->{frontend_obj}->{test_data} = 're-inited'; | |||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||
| 426 | 1 | $self->{inited} = 1; | |||||||||||||||||||||||||||||||||||||
| 427 | } ## end sub re_init | ||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||
| 429 | =head2 teardown | ||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||
| 431 | Tears down the setup for the backend. | ||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||
| 433 | =cut | ||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||
| 435 | sub teardown { | ||||||||||||||||||||||||||||||||||||||
| 436 | 2 | ▶ | my ( $self, %opts ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
teardown: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||
| 438 | 2 | $self->{inited} = 0; | |||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||
| 440 | 2 | $self->errorblank; | |||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||
| 442 | 2 | my $command = $self->{options}{teardown}; | |||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||
| 444 | 2 | ▶ | if ( $self->{testing} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 445 | 2 | $self->{frontend_obj}->{test_data} = $command; | |||||||||||||||||||||||||||||||||||||
| 446 | } else { | ||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $output = `$command 2>&1`; | |||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | if ( $? ne '0' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $self->{error} = 17; | |||||||||||||||||||||||||||||||||||||
| 450 | 0 | $self->{errorString} = 'Teardown failed... command "' . $command . '" resulted in... ' . $output; | |||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||
| 455 | 2 | $self->{inited} = 0; | |||||||||||||||||||||||||||||||||||||
| 456 | } ## end sub teardown | ||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||
| 458 | =head1 ERROR CODES / FLAGS | ||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||
| 460 | =head2 1, notInited | ||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||
| 462 | Backend has not been initted yet. | ||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||
| 464 | =head2 2, initInvalid | ||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||
| 466 | 'init' for options hash is invalid. Either undef or blank. | ||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||
| 468 | =head 3, optionsUndef | ||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||
| 470 | Options is not a hash. | ||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||
| 472 | =head2 4, teardownInvalid | ||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||
| 474 | 'teardown' for options hash is invalid. Either undef or blank. | ||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||
| 476 | =head2 5, banInvalid | ||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||
| 478 | 'ban' for options hash is invalid. Either undef or blank. | ||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||
| 480 | =head2 6, unbanInvalid | ||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||
| 482 | 'unban' for options hash is invalid. Either undef or blank. | ||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||
| 484 | =head2 8, optionsNotHash | ||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||
| 486 | The item passed to new for options is not a hash. | ||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||
| 488 | =head2 9, noBanItem | ||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||
| 490 | No IP specified to ban. | ||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||
| 492 | =head2 10, banItemNotIP | ||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||
| 494 | The item to ban is not an IP. Either wrong ref type or regexp | ||||||||||||||||||||||||||||||||||||||
| 495 | test using L<Regexp::IPv4> and L<Regexp::IPv6> failed. | ||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||
| 497 | =head2 11, invalidBackend | ||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||
| 499 | The specified backend failed to pass a basic sanity check of making sure it | ||||||||||||||||||||||||||||||||||||||
| 500 | matches the regexp /^[a-zA-Z0-9\_]+$/. | ||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||
| 502 | =head2 12, backendInitError | ||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||
| 504 | Failed to init the backend. | ||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||
| 506 | =head2 13, banFailed | ||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||
| 508 | Failed to ban the item. | ||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||
| 510 | =head2 14, unbanFailed | ||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||
| 512 | Failed to unban the item. | ||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||
| 514 | =head2 15, listFailed | ||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||
| 516 | Failed get a list of bans. | ||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||
| 518 | =head2 16, reInitFailed | ||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||
| 520 | Failed to re_init the backend. | ||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||
| 522 | =head2 17, teardownFailed | ||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||
| 524 | Failed to teardown the backend. | ||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||
| 526 | =head2 18, alreadyInited | ||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||
| 528 | Backend has already been initiated. | ||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||
| 530 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||
| 532 | Zane C. Bowers-Hadley, C<< <vvelox at vvelox.ent> >> | ||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||
| 534 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||
| 536 | Please report any bugs or feature requests to C<bug-net-firewall-blockerhelper at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||||||
| 537 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Firewall-BlockerHelper>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||||||||
| 538 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||
| 543 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||
| 545 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||
| 547 | perldoc Net::Firewall::BlockerHelper | ||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||
| 550 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||
| 552 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||
| 554 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||
| 556 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Firewall-BlockerHelper> | ||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||
| 558 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||
| 560 | L<https://metacpan.org/release/Net-Firewall-BlockerHelper> | ||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||
| 562 | =back | ||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||
| 565 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||
| 568 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||
| 570 | This software is Copyright (c) 2023 by Zane C. Bowers-Hadley. | ||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||
| 572 | This is free software, licensed under: | ||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||
| 574 | The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||
| 577 | =cut | ||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||
| 579 | 2 | 1; # End of Net::Firewall::BlockerHelper | |||||||||||||||||||||||||||||||||||||