update basic docs and now works properly

This commit is contained in:
Zane C. B-H 2019-07-28 06:38:37 -05:00
parent c0035a1149
commit 603099a8da
4 changed files with 64 additions and 12 deletions

View File

@ -7,3 +7,4 @@ t/00-load.t
t/manifest.t
t/pod-coverage.t
t/pod.t
t/lsof.t

View File

@ -1,16 +1,19 @@
Net-Connection-lsof
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.
Uses lsof to generate a array of Net::Connection objects.
A README file is required for CPAN modules since CPAN extracts the README
file from a module distribution so that people browsing the archive
can use it to get an idea of the module's uses. It is usually a good idea
to provide version information here so that people can decide whether
fixes for the module are worth downloading.
use Net::Connection::lsof;
my @objects;
eval{ @objects = &lsof_to_nc_objects; };
# this time don't resolve ports, ptrs, or usernames
my $args={
ports=>0,
ptrs=>0,
uid_resolve=>0,
};
eval{ @objects = &lsof_to_nc_objects($args); };
INSTALLATION
@ -42,6 +45,8 @@ You can also look for information at:
Search CPAN
https://metacpan.org/release/Net-Connection-lsof
Git Repo
https://gitea.eesdp.org/vvelox/Net-Connection-lsof
LICENSE AND COPYRIGHT

View File

@ -26,14 +26,50 @@ our $VERSION = '0.0.0';
use Net::Connection::lsof;
my @objects = lsof_to_nc_objects;
my @objects;
eval{ @objects = &lsof_to_nc_objects; };
# this time don't resolve ports, ptrs, or usernames
my $args={
ports=>0,
ptrs=>0,
uid_resolve=>0,
};
eval{ @objects = &lsof_to_nc_objects($args); };
=head1 SUBROUTINES
=head2 lsof_to_nc_objects
This runs 'lsof -i UDP -i TCP -n -l +c 19 -P' and parses the output
returns a array of Net::Connection objects.
returns a array of L<Net::Connection> objects. If a non-zero exit code is
returned, it will die.
There is one optional argument and that is hash reference that can take
several possible keys.
=head3 args hash
=head4 ports
Attempt to resolve the port names.
Defaults to 1.
=head4 ptrs
Attempt to resolve the PTRs.
Defaults to 1.
=head4 uid_resolve
Attempt to resolve the UID to a username.
Defaults to 1.
my @objects;
eval{ @objects = &lsof_to_nc_objects( $args ); };
=cut
@ -49,8 +85,14 @@ sub lsof_to_nc_objects{
if ( !defined( $func_args{ports} ) ){
$func_args{ports}=1;
}
if ( !defined( $func_args{uid_resolve} ) ){
$func_args{uid_resolve}=1;
}
my $output_raw=`lsof -i UDP -i TCP -n -l +c 19 -P`;
if ( $? ne 0 ){
die('"lsof -i UDP -i TCP -n -l +c 19 -P" exited with a non-zero value');
}
my @output_lines=split(/\n/, $output_raw);
my @nc_objects;
@ -172,6 +214,10 @@ L<https://cpanratings.perl.org/d/Net-Connection-lsof>
L<https://metacpan.org/release/Net-Connection-lsof>
=item * Git Repo
L<https://gitea.eesdp.org/vvelox/Net-Connection-lsof>
=back

View File

@ -12,7 +12,7 @@ BEGIN {
my $output_raw=`lsof -i UDP -i TCP -n -l +c 19 -P`;
if ( $@ ne 0 ){
if ( $? eq 0 ){
$extra_tests++;
my $worked=0;
eval{