parent
df0f144d32
commit
7c73b80649
|
@ -205,17 +205,17 @@ sub sort{
|
|||
if ( $self->{sort} ne 'none' ){
|
||||
if( $self->{sort} eq 'host_ff' ){
|
||||
@found=sort {
|
||||
&host_sort_helper( $b->{foreign_host} ) <=> &host_sort_helper( $b->{foreign_host} ) or
|
||||
&host_sort_helper( $a->{foreign_host} ) <=> &host_sort_helper( $b->{foreign_host} ) or
|
||||
&host_sort_helper( $a->{local_host} ) <=> &host_sort_helper( $b->{local_host} )
|
||||
} @found;
|
||||
}elsif( $self->{sort} eq 'host_lf' ){
|
||||
@found=sort {
|
||||
&host_sort_helper( $a->{local_host} ) <=> &host_sort_helper( $b->{local_host} ) or
|
||||
&host_sort_helper( $b->{foreign_host} ) <=> &host_sort_helper( $b->{foreign_host} )
|
||||
&host_sort_helper( $a->{foreign_host} ) <=> &host_sort_helper( $b->{foreign_host} )
|
||||
} @found;
|
||||
}elsif( $self->{sort} eq 'host_f' ){
|
||||
@found=sort {
|
||||
&host_sort_helper( $b->{foreign_host} ) <=> &host_sort_helper( $b->{foreign_host} )
|
||||
&host_sort_helper( $a->{foreign_host} ) <=> &host_sort_helper( $b->{foreign_host} )
|
||||
} @found;
|
||||
}elsif( $self->{sort} eq 'host_l' ){
|
||||
@found=sort {
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
use strict;
|
||||
|
||||
use Test::More;
|
||||
use Data::Dumper;
|
||||
use Parse::Netstat::Search;
|
||||
|
||||
BEGIN {
|
||||
use_ok('Parse::Netstat::Search::Sort');
|
||||
}
|
||||
|
||||
my @found=(
|
||||
{
|
||||
'foreign_host'=>'1.1.1.1',
|
||||
'local_host'=>'10.0.0.2',
|
||||
'foreign_port'=>'22222',
|
||||
'local_port'=>'22',
|
||||
'sendq'=>'0',
|
||||
'recvq'=>'0',
|
||||
'state' => 'ESTABLISHED',
|
||||
'proto' => 'tcp4',
|
||||
},
|
||||
{
|
||||
'foreign_host'=>'1.1.1.2',
|
||||
'local_host'=>'10.0.0.2',
|
||||
'foreign_port'=>'22',
|
||||
'local_port'=>'2222',
|
||||
'sendq'=>'0',
|
||||
'recvq'=>'0',
|
||||
'state' => 'TIME_WAIT',
|
||||
'proto' => 'tcp4',
|
||||
},
|
||||
{
|
||||
'foreign_host'=>'1.1.1.1',
|
||||
'local_host'=>'192.168.0.1',
|
||||
'foreign_port'=>'22',
|
||||
'local_port'=>'2222',
|
||||
'sendq'=>'0',
|
||||
'recvq'=>'0',
|
||||
'state' => 'ESTABLISHED',
|
||||
'proto' => 'tcp4',
|
||||
},
|
||||
{
|
||||
'foreign_host'=>'1.1.1.1',,
|
||||
'local_host'=>'10.0.0.2',
|
||||
'foreign_port'=>'22',
|
||||
'local_port'=>'2222',
|
||||
'sendq'=>'0',
|
||||
'recvq'=>'0',
|
||||
'state' => 'ESTABLISHED',
|
||||
'proto' => 'tcp4',
|
||||
},
|
||||
);
|
Loading…
Reference in New Issue