| 1 | package Ereshkigal::App::Command::cidr_unban; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Ereshkigal::App -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Ereshkigal::App::Command::cidr_unban - Unban a CIDR range. | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 0.0.1 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 1 | our $VERSION = '0.0.1'; | |||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | |||||||||||
| 22 | # check every kur for the CIDR and unban it where present | ||||||||||
| 23 | ereshkigal cidr-unban 1.2.3.0/24 | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | Every kur is asked whether it is holding the range and it is released from | ||||||||||
| 28 | each one that is. Host bits are masked off first, the same as when banning, | ||||||||||
| 29 | so naming any address inside a banned network finds it. | ||||||||||
| 30 | |||||||||||
| 31 | The range is released as a range. A range ban is one firewall entry | ||||||||||
| 32 | covering the whole prefix rather than one ban per address inside it, so | ||||||||||
| 33 | unbanning a single IP within a banned range will not punch a hole in | ||||||||||
| 34 | it... that address stays blocked as long as the range is. | ||||||||||
| 35 | |||||||||||
| 36 | There is no --all form... C<ereshkigal unban --all> already flushes CIDR bans | ||||||||||
| 37 | alongside single IP bans. | ||||||||||
| 38 | |||||||||||
| 39 | =head1 METHODS | ||||||||||
| 40 | |||||||||||
| 41 | The App::Cmd hooks this subcommand supplies... command_names, abstract, | ||||||||||
| 42 | description, usage_desc, opt_spec, validate_args, and execute. | ||||||||||
| 43 | |||||||||||
| 44 | =cut | ||||||||||
| 45 | |||||||||||
| 46 | # accept both the dashed and underscored spellings | ||||||||||
| 47 | 113 | ▶ | sub command_names { return ( 'cidr-unban', 'cidr_unban' ); } | ||||||||
|
Subroutine
command_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | sub abstract { return 'unban a CIDR range' } | ||||||||
|
Subroutine
abstract: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | |||||||||||
| 51 | 4 | ▶ | sub description { | ||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 4 | return <<'DESCRIPTION'; | |||||||||
| 53 | Release a CIDR range from the underworld. | ||||||||||
| 54 | |||||||||||
| 55 | Every kur is asked whether it is holding the range and it is released from | ||||||||||
| 56 | each one that is. Host bits are masked off first, the same as when banning, | ||||||||||
| 57 | so naming any address inside a banned network finds it. | ||||||||||
| 58 | |||||||||||
| 59 | This releases the range as a range. A range ban is a single firewall entry | ||||||||||
| 60 | covering the whole prefix, not one ban per address in it, so unbanning an | ||||||||||
| 61 | individual IP inside a banned range will not punch a hole in it... that | ||||||||||
| 62 | address stays blocked as long as the range is. | ||||||||||
| 63 | |||||||||||
| 64 | To empty everything, ranges and single IPs alike, use "unban --all". | ||||||||||
| 65 | |||||||||||
| 66 | ereshkigal cidr-unban 1.2.3.0/24 | ||||||||||
| 67 | ereshkigal cidr-unban 1.2.3.4/24 # same range, host bits masked off | ||||||||||
| 68 | DESCRIPTION | ||||||||||
| 69 | } ## end sub description | ||||||||||
| 70 | |||||||||||
| 71 | 8 | ▶ | sub usage_desc { return '%c cidr-unban %o <CIDR>'; } | ||||||||
|
Subroutine
usage_desc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 72 | |||||||||||
| 73 | 8 | ▶ | sub opt_spec { | ||||||||
|
Subroutine
opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 74 | 8 | return (); | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 4 | ▶ | sub validate_args { | ||||||||
|
Subroutine
validate_args: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | 4 | my ( $self, $opt, $args ) = @_; | |||||||||
| 79 | |||||||||||
| 80 | 4 | ▶ | if ( @{$args} != 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 2 | $self->usage_error('a single CIDR must be specified'); | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 2 | return; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | 2 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 88 | 2 | my ( $self, $opt, $args ) = @_; | |||||||||
| 89 | |||||||||||
| 90 | 2 | $self->run_command( 'cidr_unban', { 'cidr' => $args->[0] } ); | |||||||||
| 91 | |||||||||||
| 92 | 1 | return; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 1 | 1; | |||||||||