line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Connection::Sort::port_la; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
232208
|
use 5.006; |
|
2
|
|
|
|
|
51
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
595
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Net::Connection::Sort::port_la - Sorts the connections via the local port alphabetically. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.0.0 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This currently implements cmp sorting only. For numeric sorting using port_l. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Net::Connection::Sort::port_la; |
25
|
|
|
|
|
|
|
use Net::Connection; |
26
|
|
|
|
|
|
|
use Data::Dumper; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my @objects=( |
29
|
|
|
|
|
|
|
Net::Connection->new({ |
30
|
|
|
|
|
|
|
'foreign_host' => '3.3.3.3', |
31
|
|
|
|
|
|
|
'local_host' => '4.4.4.4', |
32
|
|
|
|
|
|
|
'local_port' => 'FTP', |
33
|
|
|
|
|
|
|
'foriegn_port' => '11132', |
34
|
|
|
|
|
|
|
'sendq' => '1', |
35
|
|
|
|
|
|
|
'recvq' => '0', |
36
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
37
|
|
|
|
|
|
|
'proto' => 'tcp4', |
38
|
|
|
|
|
|
|
'ports' => 0, |
39
|
|
|
|
|
|
|
}), |
40
|
|
|
|
|
|
|
Net::Connection->new({ |
41
|
|
|
|
|
|
|
'foreign_host' => '1.1.1.1', |
42
|
|
|
|
|
|
|
'local_host' => '2.2.2.2', |
43
|
|
|
|
|
|
|
'local_port' => 'SSH', |
44
|
|
|
|
|
|
|
'foreign_port' => '11132', |
45
|
|
|
|
|
|
|
'sendq' => '1', |
46
|
|
|
|
|
|
|
'recvq' => '0', |
47
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
48
|
|
|
|
|
|
|
'proto' => 'tcp4', |
49
|
|
|
|
|
|
|
'ports' => 0, |
50
|
|
|
|
|
|
|
}), |
51
|
|
|
|
|
|
|
Net::Connection->new({ |
52
|
|
|
|
|
|
|
'foreign_host' => '5.5.5.5', |
53
|
|
|
|
|
|
|
'local_host' => '6.6.6.6', |
54
|
|
|
|
|
|
|
'local_port' => 'HTTP', |
55
|
|
|
|
|
|
|
'foreign_port' => '11132', |
56
|
|
|
|
|
|
|
'sendq' => '1', |
57
|
|
|
|
|
|
|
'recvq' => '0', |
58
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
59
|
|
|
|
|
|
|
'proto' => 'tcp4', |
60
|
|
|
|
|
|
|
'ports' => 0, |
61
|
|
|
|
|
|
|
}), |
62
|
|
|
|
|
|
|
Net::Connection->new({ |
63
|
|
|
|
|
|
|
'foreign_host' => '3.3.3.3', |
64
|
|
|
|
|
|
|
'local_host' => '4.4.4.4', |
65
|
|
|
|
|
|
|
'local_port' => 'HTTPS', |
66
|
|
|
|
|
|
|
'foreign_port' => '11132', |
67
|
|
|
|
|
|
|
'sendq' => '1', |
68
|
|
|
|
|
|
|
'recvq' => '0', |
69
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
70
|
|
|
|
|
|
|
'proto' => 'tcp4', |
71
|
|
|
|
|
|
|
'ports' => 0, |
72
|
|
|
|
|
|
|
}), |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $sorter=$sorter=Net::Connection::Sort::port_la->new; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
@objects=$sorter->sorter( \@objects ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
print Dumper( \@objects ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 new |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This initiates the module. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
No arguments are taken and this will always succeed. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $sorter=$sorter=Net::Connection::Sort::port_la->new; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new{ |
94
|
1
|
|
|
1
|
1
|
1928
|
my %args; |
95
|
1
|
50
|
|
|
|
7
|
if(defined($_[1])){ |
96
|
0
|
|
|
|
|
0
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
0
|
|
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
3
|
my $self = { |
101
|
|
|
|
|
|
|
}; |
102
|
1
|
|
|
|
|
2
|
bless $self; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
3
|
return $self; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 sort |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This sorts the array of Net::Connection objects. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
One object is taken and that is a array of objects. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
@objects=$sorter->sorter( \@objects ); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
print Dumper( \@objects ); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub sorter{ |
120
|
1
|
|
|
1
|
0
|
367
|
my $self=$_[0]; |
121
|
1
|
|
|
|
|
3
|
my @objects; |
122
|
1
|
50
|
33
|
|
|
9
|
if ( |
123
|
|
|
|
|
|
|
defined( $_[1] ) && |
124
|
|
|
|
|
|
|
( ref($_[1]) eq 'ARRAY' ) |
125
|
|
|
|
|
|
|
){ |
126
|
1
|
|
|
|
|
3
|
@objects=@{ $_[1] }; |
|
1
|
|
|
|
|
4
|
|
127
|
|
|
|
|
|
|
}else{ |
128
|
0
|
|
|
|
|
0
|
die 'The passed item is either not a array or undefined'; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
@objects=sort { |
132
|
1
|
|
|
|
|
5
|
&helper( $a ) cmp &helper( $b ) |
|
4
|
|
|
|
|
15
|
|
133
|
|
|
|
|
|
|
} @objects; |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
18
|
return @objects; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 helper |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
A internal helper function. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub helper{ |
145
|
8
|
50
|
|
8
|
1
|
24
|
if ( !defined( $_[0]->local_port_name ) ){ |
146
|
0
|
|
|
|
|
0
|
return $_[0]->local_port; |
147
|
|
|
|
|
|
|
} |
148
|
8
|
|
|
|
|
35
|
return $_[0]->local_port_name; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 AUTHOR |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 BUGS |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
158
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
159
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SUPPORT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
perldoc Net::Connection::Sort |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
You can also look for information at: |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=over 4 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * CPAN Ratings |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * Search CPAN |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * Git Repo |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Zane C. Bowers-Hadley. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This is free software, licensed under: |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; # End of Net::Connection::Sort |