add in the ability to inversion, PTR, and regexp PTR... invertsion related methods need completed

This commit is contained in:
Zane C. B-H 2019-02-28 10:01:17 -06:00
parent 13184cf0d5
commit fde8327c9a
2 changed files with 54 additions and 2 deletions

View File

@ -2,6 +2,8 @@ Revision history for Parse-Netstat-Search
0.2.0 ?/?
- Minor typo correction(japh).
- Add PTR search support.
- Add regexp PTR search support.
0.1.1 2019-02-26/04:00
- Apparently Net::CIDR does not like searching IPv4 and IPv6 at the

View File

@ -13,11 +13,11 @@ Parse::Netstat::Search - Searches the connection list in the results returned by
=head1 VERSION
Version 0.2.1
Version 0.2.0
=cut
our $VERSION = '0.2.1';
our $VERSION = '0.2.0';
=head1 SYNOPSIS
@ -96,7 +96,14 @@ sub new{
ports=>{},
states=>{},
ptrs=>{},
ptrs_r=>[],
resolver=>Net::DNS::Resolver->new,
ptr_invert=>0,
ptr_r_invert=>0,
cidr_invert=>0,
protocol_invert=>0,
state_invert=>0,
port_invert=>0,
};
bless $self;
@ -145,6 +152,20 @@ sub get_ports{
return keys( %{ $self->{ports} } );
}
=head2 get_ports_invert
=cut
sub get_ports_invert{
my $self=$_[0];
if( ! $self->errorblank ){
return undef;
}
return $self->{ports_invert};
}
=head2 get_protocols
Gets a list of desired protocols.
@ -461,6 +482,14 @@ sub search{
}
}
# handle inversion
$port_meet = $port_meet ^ $self->{port_invert};
$protocol_meet = $protocol_meet ^ $self->{protocol_invert};
$cidr_meet = $cidr_meet ^ $self->{cidr_invert};
$state_meet = $state_meet ^ $self->{state_invert};
$ptr_require = $ptr_require ^ $self->{ptr_invert};
$ptr_r_require = $ptr_r_require ^ $self->{ptr_r_invert};
# if these are all good, add them
if (
$port_meet && $protocol_meet && $cidr_meet && $state_meet &&
@ -613,6 +642,27 @@ sub set_ports{
return 1;
}
=head2 set_ports_invert
=cut
sub set_ports_invert{
my $self=$_[0];
my $bool=$_[1];
if( ! $self->errorblank ){
return undef;
}
if ( $bool ){
$self->{ports_invert}=1;
}else{
$self->{ports_invert}=0;
}
return 1;
}
=head2 set_protocols
Sets the list of desired protocols to match.