UDP cleanups and bump to 0.0.2
This commit is contained in:
parent
2b60eacef3
commit
2a24162726
|
@ -1,5 +1,10 @@
|
|||
Revision history for Parse-Netstat-Search
|
||||
|
||||
0.0.2 2019-02-24/08:30
|
||||
- Previous issue turned out to be specifically. Added
|
||||
addtional handling for UDP as it is stateless. This
|
||||
removes '?' from previously. State for for UDP is ''.
|
||||
|
||||
0.0.1 2019-02-24/06:30
|
||||
- Handle where FreeBSD does not state LISTEN.
|
||||
- Add a missing error flag.
|
||||
|
|
|
@ -12,11 +12,11 @@ Parse::Netstat::Search - Searches the connection list in the results returned by
|
|||
|
||||
=head1 VERSION
|
||||
|
||||
Version 0.0.1
|
||||
Version 0.0.2
|
||||
|
||||
=cut
|
||||
|
||||
our $VERSION = '0.0.1';
|
||||
our $VERSION = '0.0.2';
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
@ -37,8 +37,6 @@ our $VERSION = '0.0.1';
|
|||
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.
|
||||
|
||||
If it comes across instance where the state is undefined, it is set to '?'.
|
||||
|
||||
=head1 methods
|
||||
|
||||
=head2 new
|
||||
|
@ -214,7 +212,9 @@ sub search{
|
|||
my $res_int=0;
|
||||
while ( defined( $res->[2]->{active_conns}->[$res_int] ) ){
|
||||
# ignore unix sockets
|
||||
if ( $res->[2]->{active_conns}->[$res_int]->{proto} ne 'unix' ){
|
||||
if ( defined( $res->[2]->{active_conns}->[$res_int]->{proto} ) &&
|
||||
($res->[2]->{active_conns}->[$res_int]->{proto} ne 'unix')
|
||||
){
|
||||
my $foreign_port=$res->[2]->{active_conns}->[$res_int]->{foreign_port};
|
||||
my $state=$res->[2]->{active_conns}->[$res_int]->{state};
|
||||
my $protocol=$res->[2]->{active_conns}->[$res_int]->{proto};
|
||||
|
@ -224,17 +224,23 @@ sub search{
|
|||
my $sendq=$res->[2]->{active_conns}->[$res_int]->{sendq};
|
||||
my $recvq=$res->[2]->{active_conns}->[$res_int]->{recvq};
|
||||
|
||||
# works around a edge case in which Parse::Netstat does not properly handle LISTEN ports
|
||||
# UDP is stateless and in some cases on listening ports for it Parse::Netstat
|
||||
# does not return any host, so use * for it.
|
||||
if (!defined( $foreign_host )){
|
||||
$foreign_host='*';
|
||||
}
|
||||
if (
|
||||
( $foreign_host eq '*' ) &&
|
||||
( $protocol =~ /^[Uu][Dd][Pp]/ ) &&
|
||||
( ! defined( $state ) )
|
||||
){
|
||||
$state='LISTEN';
|
||||
$state='';
|
||||
}
|
||||
|
||||
# sometimes no state appears to be returned for UDP
|
||||
if ( !defined( $state ) ){
|
||||
$state='?';
|
||||
if (
|
||||
( !defined( $state ) ) &&
|
||||
( $protocol =~ /^[Uu][Dd][Pp]/ )
|
||||
){
|
||||
$state='';
|
||||
}
|
||||
|
||||
# checks for making sure a check is meet... defaults to 1
|
||||
|
|
Loading…
Reference in New Issue