lots of misc cleanups and mostly finished off

This commit is contained in:
Zane C. B-H 2019-02-25 04:16:09 -06:00
parent adcaf89e5c
commit 6e39104c57
1 changed files with 76 additions and 7 deletions

View File

@ -12,7 +12,7 @@ use Text::Table;
=head1 NAME
Parse::Netstat::Colorizer - Searches and colorizes the output from
Parse::Netstat::Colorizer - Searches and colorizes the output from Parse::Netstat
=head1 VERSION
@ -25,19 +25,37 @@ our $VERSION = '0.0.0';
=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use Parse::Netstat;
use Parse::Netstat::Colorizer;
my $pnc = Parse::Netstat::Colorizer->new();
# don't even bother parsing unix sockets... Parse::Netstat::Search, Parse::Netsat::Search::Sort;
# and this only currently handle non-unix network connections
my $res = parse_netstat(output => join("", `netstat -n`), tcp=>1, udp=>1, unix=>0, flavor=>$^O);
# search only for connections to/from specific networks
my @networks=('192.168.0.0/24', '10.10.10.0/24');
my $search=$pnc->get_search;
$search->set_cidrs( \@networks );
if ( $search->error ){
warn( 'One of the passed CIDRs is bad' );
}
# set it to host local sort
my $sorter=$pnc->get_sort;
$sorter->set_sort( 'host_l' );
my $nsc = Parse::Netstat::Colorizer->new();
...
=head1 METHODS
=head2 new
Creates a new object. This will never error.
my $pnc->new;
=cut
sub new {
@ -184,6 +202,27 @@ sub get_invert{
return $self->{invert};
}
=head2 get_port_resolve
This gets the port_resolve value, which is if it should try to resolve
port names or not.
The returned value is a boolean and defaults to 1.
my $port_resolve=$pnc->get_port_resolve;
=cut
sub get_port_resolve{
my $self=$_[0];
if( ! $self->errorblank ){
return undef;
}
return $self->{port_resolve};
}
=head1 get_search
This returns the Parse::Netstat::Search object.
@ -228,6 +267,12 @@ sub get_sort{
This sets wether or not it should invert the
returned sort or not.
# sets it to false, the default
$pnc->set_invert;
# the results will be inverted
$pnc->set_invert;
=cut
sub set_invert{
@ -240,6 +285,30 @@ sub set_invert{
$self->{invert}=$_[1];
}
=head2 set_port_resolve
This sets wether or not the ports should be resolved or not.
One value is taken and that is a perl boolean.
# sets it to true, the default
$pnc->set_port_resolve(1);
# set it false, don't resolve the ports
$pnc->set_port_resolve;
=cut
sub set_port_resolve{
my $self=$_[0];
if( ! $self->errorblank ){
return undef;
}
$self->{port_resolve}=$_[1];
}
=head
=head1 ERROR CODES / FLAGS