make sure the port is always numeric... * becomes 0

This commit is contained in:
Zane C. B-H 2019-02-28 05:05:41 -06:00
parent 92291a2aa9
commit 04f732d639
1 changed files with 24 additions and 6 deletions

View File

@ -216,21 +216,21 @@ sub sort{
} @found;
}elsif( $self->{sort} eq 'port_ff' ){
@found=sort {
$a->{foreign_port} <=> $b->{foreign_port} or
$a->{local_port} <=> $b->{local_port}
&port_sort_helper( $a->{foreign_port} ) <=> &port_sort_helper( $b->{foreign_port} ) or
&port_sort_helper( $a->{local_port} ) <=> &port_sort_helper( $b->{local_port} )
} @found;
}elsif( $self->{sort} eq 'port_lf' ){
@found=sort {
$a->{local_port} <=> $b->{local_port} or
$a->{foreign_port} <=> $b->{foreign_port}
&port_sort_helper( $a->{local_port} ) <=> &port_sort_helper( $b->{local_port} ) or
&port_sort_helper( $a->{foreign_port} ) <=> &port_sort_helper( $b->{foreign_port} )
} @found;
}elsif( $self->{sort} eq 'port_f' ){
@found=sort {
$a->{foreign_port} <=> $b->{foreign_port}
&port_sort_helper( $a->{foreign_port} ) <=> &port_sort_helper( $b->{foreign_port} )
} @found;
}elsif( $self->{sort} eq 'port_l' ){
@found=sort {
$a->{local_port} <=> $b->{local_port}
&port_sort_helper( $a->{local_port} ) <=> &port_sort_helper( $b->{local_port} )
} @found;
}elsif( $self->{sort} eq 'state' ){
@found=sort {
@ -286,6 +286,24 @@ sub host_sort_helper{
return $host;
}
=head2 port_sort_helper
Internal function.
Makes sure a port number is always returned.
=cut
sub port_sort_helper{
if (
( !defined($_[0]) ) ||
( $_[0] eq '*' )
){
return 0;
}
return $_[0];
}
=head1 ERROR CODES / FLAGS
Error handling is provided by L<Error::Helper>.