fix a few issues where it does not like how IPv6 stuff is sometimes reported by netstat
This commit is contained in:
parent
b3bbb47024
commit
bcf609fba4
|
@ -219,11 +219,24 @@ sub search{
|
|||
my $state=$res->[2]->{active_conns}->[$res_int]->{state};
|
||||
my $protocol=$res->[2]->{active_conns}->[$res_int]->{proto};
|
||||
my $local_port=$res->[2]->{active_conns}->[$res_int]->{local_port};
|
||||
my $local_host=$res->[2]->{active_conns}->[$res_int]->{local_host};
|
||||
my $foreign_host=$res->[2]->{active_conns}->[$res_int]->{foreign_host};
|
||||
#my $local_host=$res->[2]->{active_conns}->[$res_int]->{local_host};
|
||||
#my $foreign_host=$res->[2]->{active_conns}->[$res_int]->{foreign_host};
|
||||
my $sendq=$res->[2]->{active_conns}->[$res_int]->{sendq};
|
||||
my $recvq=$res->[2]->{active_conns}->[$res_int]->{recvq};
|
||||
|
||||
#handle IPv6 % stuff if needed
|
||||
my ( $local_host, $local_pp ) = split( /\%/, $res->[2]->{active_conns}->[$res_int]->{local_host} );
|
||||
my ( $foreign_host, $foreign_pp ) = split( /\%/, $res->[2]->{active_conns}->[$res_int]->{foreign_host} );
|
||||
|
||||
# Handle when parse netstat chokes on lines like...
|
||||
# udp6 0 0 fe80::4ecc:6aff:.123 *.*
|
||||
if ( $local_host =~ /[0123456789AaBbCcDdEeFf]\:$/ ){
|
||||
$local_host =~ s/\:$//;
|
||||
}
|
||||
if ( $foreign_host =~ /[0123456789AaBbCcDdEeFf]\:$/ ){
|
||||
$foreign_host =~ s/\:$//;
|
||||
}
|
||||
|
||||
# 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 )){
|
||||
|
@ -322,6 +335,8 @@ sub search{
|
|||
'recvq'=>$recvq,
|
||||
'proto'=>$protocol,
|
||||
'state'=>$state,
|
||||
'local_pp'=>$local_pp,
|
||||
'foreign_pp'=>$foreign_pp,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue