line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Connection::Sort::pid; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
227019
|
use 5.006; |
|
2
|
|
|
|
|
19
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
40
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
571
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Net::Connection::Sort::pid - Sorts the connections via the PID. |
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
|
|
|
|
|
|
|
Please keep in mind that PID is not a requirement and if not specified is set to 0, |
23
|
|
|
|
|
|
|
meaning it will show up earlier. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Net::Connection::Sort::host_f; |
26
|
|
|
|
|
|
|
use Net::Connection; |
27
|
|
|
|
|
|
|
use Data::Dumper; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my @objects=( |
30
|
|
|
|
|
|
|
Net::Connection->new({ |
31
|
|
|
|
|
|
|
'foreign_host' => '3.3.3.3', |
32
|
|
|
|
|
|
|
'local_host' => '4.4.4.4', |
33
|
|
|
|
|
|
|
'foreign_port' => '22', |
34
|
|
|
|
|
|
|
'local_port' => '11132', |
35
|
|
|
|
|
|
|
'sendq' => '1', |
36
|
|
|
|
|
|
|
'recvq' => '0', |
37
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
38
|
|
|
|
|
|
|
'proto' => 'tcp4', |
39
|
|
|
|
|
|
|
'uid' => 22, |
40
|
|
|
|
|
|
|
'pid' => 2, |
41
|
|
|
|
|
|
|
}), |
42
|
|
|
|
|
|
|
Net::Connection->new({ |
43
|
|
|
|
|
|
|
'foreign_host' => '1.1.1.1', |
44
|
|
|
|
|
|
|
'local_host' => '2.2.2.2', |
45
|
|
|
|
|
|
|
'foreign_port' => '22', |
46
|
|
|
|
|
|
|
'local_port' => '11132', |
47
|
|
|
|
|
|
|
'sendq' => '1', |
48
|
|
|
|
|
|
|
'recvq' => '0', |
49
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
50
|
|
|
|
|
|
|
'proto' => 'tcp4', |
51
|
|
|
|
|
|
|
'uid' => 1000, |
52
|
|
|
|
|
|
|
'pid' => 0, |
53
|
|
|
|
|
|
|
}), |
54
|
|
|
|
|
|
|
Net::Connection->new({ |
55
|
|
|
|
|
|
|
'foreign_host' => '5.5.5.5', |
56
|
|
|
|
|
|
|
'local_host' => '6.6.6.6', |
57
|
|
|
|
|
|
|
'foreign_port' => '22', |
58
|
|
|
|
|
|
|
'local_port' => '11132', |
59
|
|
|
|
|
|
|
'sendq' => '1', |
60
|
|
|
|
|
|
|
'recvq' => '0', |
61
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
62
|
|
|
|
|
|
|
'proto' => 'tcp4', |
63
|
|
|
|
|
|
|
'uid' => 1, |
64
|
|
|
|
|
|
|
'pid' => 44, |
65
|
|
|
|
|
|
|
}), |
66
|
|
|
|
|
|
|
# as no PID is specified, the value of 0 will just be used instead |
67
|
|
|
|
|
|
|
Net::Connection->new({ |
68
|
|
|
|
|
|
|
'foreign_host' => '3.3.3.3', |
69
|
|
|
|
|
|
|
'local_host' => '4.4.4.4', |
70
|
|
|
|
|
|
|
'foreign_port' => '22', |
71
|
|
|
|
|
|
|
'local_port' => '11132', |
72
|
|
|
|
|
|
|
'sendq' => '1', |
73
|
|
|
|
|
|
|
'recvq' => '0', |
74
|
|
|
|
|
|
|
'state' => 'ESTABLISHED', |
75
|
|
|
|
|
|
|
'proto' => 'tcp4', |
76
|
|
|
|
|
|
|
}), |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $sorter=$sorter=Net::Connection::Sort::uid->new; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
@objects=$sorter->sorter( \@objects ); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
print Dumper( \@objects ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 new |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This initiates the module. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
No arguments are taken and this will always succeed. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $sorter=$sorter=Net::Connection::Sort::uid->new; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub new{ |
98
|
1
|
|
|
1
|
1
|
2118
|
my %args; |
99
|
1
|
50
|
|
|
|
4
|
if(defined($_[1])){ |
100
|
0
|
|
|
|
|
0
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
0
|
|
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
3
|
my $self = { |
105
|
|
|
|
|
|
|
}; |
106
|
1
|
|
|
|
|
2
|
bless $self; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
3
|
return $self; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 sort |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This sorts the array of Net::Connection objects. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
One object is taken and that is a array of objects. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
@objects=$sorter->sorter( \@objects ); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
print Dumper( \@objects ); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub sorter{ |
124
|
1
|
|
|
1
|
0
|
648
|
my $self=$_[0]; |
125
|
1
|
|
|
|
|
3
|
my @objects; |
126
|
1
|
50
|
33
|
|
|
12
|
if ( |
127
|
|
|
|
|
|
|
defined( $_[1] ) && |
128
|
|
|
|
|
|
|
( ref($_[1]) eq 'ARRAY' ) |
129
|
|
|
|
|
|
|
){ |
130
|
1
|
|
|
|
|
4
|
@objects=@{ $_[1] }; |
|
1
|
|
|
|
|
5
|
|
131
|
|
|
|
|
|
|
}else{ |
132
|
0
|
|
|
|
|
0
|
die 'The passed item is either not a array or undefined'; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# whoops... just realized I forgot to create a method for this in Net::Connection... doing it this way foreign |
136
|
|
|
|
|
|
|
# compatibility with Net::Connection 0.0.0 as of currently |
137
|
|
|
|
|
|
|
@objects=sort { |
138
|
1
|
|
|
|
|
10
|
&helper( $a->{pid} ) <=> &helper( $b->{pid} ) |
139
|
5
|
|
|
|
|
10
|
} @objects; |
140
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
6
|
return @objects; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 helper |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This is a internal function. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
If no PID is defined, returns 0. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub helper{ |
153
|
10
|
100
|
|
10
|
1
|
17
|
if ( !defined($_[0]) ){ |
154
|
3
|
|
|
|
|
9
|
return 0; |
155
|
|
|
|
|
|
|
} |
156
|
7
|
|
|
|
|
17
|
return $_[0]; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 BUGS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
166
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
167
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SUPPORT |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
perldoc Net::Connection::Sort |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
You can also look for information at: |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over 4 |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
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 |