Browse Source

all good now!

tags/0.0.0
Zane C. B-H 9 months ago
parent
commit
2a93394a93

+ 19
- 18
Parse-Netstat-Search/Makefile.PL View File

@@ -4,21 +4,22 @@ use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
NAME => 'Parse::Netstat::Search',
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
VERSION_FROM => 'lib/Parse/Netstat/Search.pm',
ABSTRACT_FROM => 'lib/Parse/Netstat/Search.pm',
LICENSE => 'artistic_2',
PL_FILES => {},
MIN_PERL_VERSION => '5.006',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
},
BUILD_REQUIRES => {
'Test::More' => '0',
'Net::CIDR' => '0',
'Error::Helper' => '1.0.0',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Parse-Netstat-Search-*' },
);
NAME => 'Parse::Netstat::Search',
AUTHOR => q{Zane C. Bowers-Hadley <vvelox@vvelox.net>},
VERSION_FROM => 'lib/Parse/Netstat/Search.pm',
ABSTRACT_FROM => 'lib/Parse/Netstat/Search.pm',
LICENSE => 'artistic_2',
PL_FILES => {},
MIN_PERL_VERSION => '5.006',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
},
BUILD_REQUIRES => {
'Test::More' => '0',
'Net::CIDR' => '0',
'Parse::Netstat'=>'0.14',
'Error::Helper' => '1.0.0',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Parse-Netstat-Search-*' },
);

+ 29
- 1
Parse-Netstat-Search/lib/Parse/Netstat/Search.pm View File

@@ -29,13 +29,25 @@ our $VERSION = '0.0.0';

my $search = Parse::Netstat::Search->new();

$search->set_cidrs( [ '10.0.0.0/24', '192.168.0.0/16' ] );

my @found=$search->search($res);


Two big things to bet aware of is this module does not currently resulve names and this module
does not handle unix sockets. Unix sockets will just be skipped over.

=head1 methods

=head2 new

=cut
This initiates it.

No values are taken.

my $search=Parse::Netstat::Search->new;

=cut

sub new{
my $self={
@@ -63,6 +75,8 @@ Retrieves the CIDR match list.

The returned value is an array.

my @CIDRs=$search->get_cidrs;

=cut

sub get_cidrs{
@@ -102,6 +116,12 @@ Gets a list of desired protocols.

The returned value is a array.

Also if you've passed any named ones to it previously,
this will not return them, but the port number as that
is how they are stored internlly.

my @protocols=$search->get_protocols;

=cut

sub get_protocols{
@@ -120,6 +140,11 @@ Get a list of desired sets.

The returned value is a array.

The returned values are all lowercased. Any trailing
or proceeding whitespace will also have been removed.

my @states=$search->get_states;

=cut

sub get_states{
@@ -295,6 +320,9 @@ One value is taken and that is a array ref of CIDRs.

Validating in is done by Net::CIDR::cidrvalidate.

If you are using this, you will want to use -n with netstat
as this module currently does not resolve names.

# set the desired CIDRs to the contents of @CIDRs
$search->set_cidrs( \@CIDRs );
if ( $search->error ){

+ 12
- 0
Parse-Netstat-Search/t/search.t View File

@@ -70,6 +70,18 @@ my $res=[ '0', '1',
'proto' => 'tcp4',
'sendq' => '0'
},
{
'inode' => '0',
'address' => 'fffff8004ca0ca00',
'addr' => '/var/run/dovecot/stats-writer',
'conn' => 'fffff8004c9ae500',
'proto' => 'unix',
'sendq' => '0',
'type' => 'stream',
'recvq' => '0',
'refs' => '0',
'nextref' => '0'
},
],
}
];

Loading…
Cancel
Save