This commit is contained in:
Zane C. B-H 2019-07-24 01:20:16 -05:00
parent 5208da3c3c
commit 6eb63a7eba
2 changed files with 15 additions and 15 deletions

View File

@ -20,7 +20,7 @@ our $VERSION = '0.0.0';
=head1 SYNOPSIS
If a foriegn PTR could not be found or is not set, then the foreign host is used.
If a local PTR could not be found or is not set, then the foreign host is used.
use Net::Connection::Sort::ptr_l;
use Net::Connection;
@ -37,7 +37,7 @@ If a foriegn PTR could not be found or is not set, then the foreign host is used
'state' => 'ESTABLISHED',
'proto' => 'tcp4',
'ptrs' => 0,
'foreign_ptr' => 'c.foo',
'local_ptr' => 'c.foo',
}),
Net::Connection->new({
'foreign_host' => '1.1.1.1',
@ -49,7 +49,7 @@ If a foriegn PTR could not be found or is not set, then the foreign host is used
'state' => 'ESTABLISHED',
'proto' => 'tcp4',
'ptrs' => 0,
'foreign_ptr' => 'a.foo',
'local_ptr' => 'a.foo',
}),
Net::Connection->new({
'foreign_host' => '5.5.5.5',
@ -61,7 +61,7 @@ If a foriegn PTR could not be found or is not set, then the foreign host is used
'state' => 'ESTABLISHED',
'proto' => 'tcp4',
'ptrs' => 0,
'foreign_ptr' => 'b.foo',
'local_ptr' => 'b.foo',
}),
Net::Connection->new({
'foreign_host' => '3.3.3.3',
@ -142,17 +142,17 @@ sub sorter{
This is a internal function.
If the foreign PTR is not defined, the foreign host is returned.
If the local PTR is not defined, the local host is returned.
=cut
sub helper{
if (
( !defined($_[0]->foreign_ptr ) )
( !defined($_[0]->local_ptr ) )
){
return $_[0]->foreign_host;
return $_[0]->local_host;
}
return $_[0]->foreign_ptr;
return $_[0]->local_ptr;
}
=head1 AUTHOR

View File

@ -20,7 +20,7 @@ my @objects=(
'username' => 'toor',
'uid_resolve' => 0,
'ptrs' => 0,
'foreign_ptr' => 'a.foo',
'local_ptr' => 'a.foo',
}),
Net::Connection->new({
'foreign_host' => '1.1.1.1',
@ -36,7 +36,7 @@ my @objects=(
'username' => 'root',
'uid_resolve' => 0,
'ptrs' => 0,
'foreign_ptr' => 'c.foo',
'local_ptr' => 'c.foo',
}),
Net::Connection->new({
'foreign_host' => '5.5.5.5',
@ -52,7 +52,7 @@ my @objects=(
'username'=> 'foo',
'uid_resolve' => 0,
'ptrs' => 0,
'foreign_ptr' => 'b.foo',
'local_ptr' => 'b.foo',
}),
Net::Connection->new({
'foreign_host' => '3.3.3.3',
@ -89,13 +89,13 @@ eval{
ok( $worked eq 1, 'sort') or die ('Net::Connection::Sort::proto->sorter(@objects) resulted in... '.$@);
my $is_defined=1;
if ( !defined( $sorted[0]->foreign_ptr ) ){
if ( !defined( $sorted[0]->local_ptr ) ){
$is_defined=0;
}
ok( $is_defined eq '0', 'sort order 0') or die ('The first ptr should be undef.');
ok( $sorted[1]->foreign_ptr =~ 'a.foo', 'sort order 1') or die ('The ptr for 1 is not a.foo ');
ok( $sorted[2]->foreign_ptr =~ 'b.foo', 'sort order 2') or die ('The ptr for 2 is not b.foo');
ok( $sorted[3]->foreign_ptr =~ 'c.foo', 'sort order 2') or die ('The ptr for 3 is not c.foo');
ok( $sorted[1]->local_ptr =~ 'a.foo', 'sort order 1') or die ('The ptr for 1 is not a.foo ');
ok( $sorted[2]->local_ptr =~ 'b.foo', 'sort order 2') or die ('The ptr for 2 is not b.foo');
ok( $sorted[3]->local_ptr =~ 'c.foo', 'sort order 2') or die ('The ptr for 3 is not c.foo');
done_testing(7);