line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id: SinFP3.pm 2234 2014-04-08 13:05:14Z gomor $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
package Net::SinFP3; |
5
|
1
|
|
|
1
|
|
4699
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.22'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4
|
use base qw(Class::Gomor::Array DynaLoader); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
593
|
|
11
|
|
|
|
|
|
|
our @AS = qw( |
12
|
|
|
|
|
|
|
global |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
our @AA = qw( |
15
|
|
|
|
|
|
|
db |
16
|
|
|
|
|
|
|
mode |
17
|
|
|
|
|
|
|
search |
18
|
|
|
|
|
|
|
input |
19
|
|
|
|
|
|
|
output |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
22
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
23
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray (\@AA); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
26
|
|
|
|
|
|
|
matchType => [qw( |
27
|
|
|
|
|
|
|
NS_MATCH_TYPE_S1S2S3 |
28
|
|
|
|
|
|
|
NS_MATCH_TYPE_S1S2 |
29
|
|
|
|
|
|
|
NS_MATCH_TYPE_S2 |
30
|
|
|
|
|
|
|
)], |
31
|
|
|
|
|
|
|
matchMask => [qw( |
32
|
|
|
|
|
|
|
NS_MATCH_MASK_HEURISTIC0 |
33
|
|
|
|
|
|
|
NS_MATCH_MASK_HEURISTIC1 |
34
|
|
|
|
|
|
|
NS_MATCH_MASK_HEURISTIC2 |
35
|
|
|
|
|
|
|
)], |
36
|
|
|
|
|
|
|
functions => [qw( |
37
|
|
|
|
|
|
|
sinfp3_tcp_synscan |
38
|
|
|
|
|
|
|
sinfp3_geterror |
39
|
|
|
|
|
|
|
)], |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
43
|
|
|
|
|
|
|
@{$EXPORT_TAGS{matchType}}, |
44
|
|
|
|
|
|
|
@{$EXPORT_TAGS{matchMask}}, |
45
|
|
|
|
|
|
|
@{$EXPORT_TAGS{functions}}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->bootstrap($VERSION); |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
12575
|
use constant NS_MATCH_TYPE_S1S2S3 => 'S1S2S3'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
68
|
|
51
|
1
|
|
|
1
|
|
6
|
use constant NS_MATCH_TYPE_S1S2 => 'S1S2'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
753
|
|
52
|
1
|
|
|
1
|
|
6
|
use constant NS_MATCH_TYPE_S2 => 'S2'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
8
|
use constant NS_MATCH_MASK_HEURISTIC0 => 'BH0FH0WH0OH0MH0SH0LH0'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
55
|
1
|
|
|
1
|
|
5
|
use constant NS_MATCH_MASK_HEURISTIC1 => 'BH1FH1WH1OH1MH1SH1LH1'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
110
|
|
56
|
1
|
|
|
1
|
|
6
|
use constant NS_MATCH_MASK_HEURISTIC2 => 'BH2FH2WH2OH2MH2SH2LH2'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
61
|
|
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
507
|
use Net::SinFP3::Worker qw(:consts); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
299
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub new { |
61
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
62
|
0
|
|
|
|
|
|
my %param = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Sets unbuffered STDOUT |
65
|
0
|
|
|
|
|
|
$|++; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
0
|
|
|
|
if (!exists($param{output}) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
68
|
|
|
|
|
|
|
|| !exists($param{input}) |
69
|
|
|
|
|
|
|
|| !exists($param{mode}) |
70
|
|
|
|
|
|
|
|| !exists($param{search}) |
71
|
|
|
|
|
|
|
|| !exists($param{global}) |
72
|
|
|
|
|
|
|
|| !exists($param{db})) { |
73
|
0
|
|
|
|
|
|
die("[-] ".__PACKAGE__.": You must provide all of the following ". |
74
|
|
|
|
|
|
|
"attributes: output, input, mode, search, db, global\n"); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( |
78
|
|
|
|
|
|
|
db => [], |
79
|
|
|
|
|
|
|
input => [], |
80
|
|
|
|
|
|
|
mode => [], |
81
|
|
|
|
|
|
|
search => [], |
82
|
|
|
|
|
|
|
output => [], |
83
|
|
|
|
|
|
|
@_, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $log = $self->global->log; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
{ |
89
|
1
|
|
|
1
|
|
5
|
no strict 'vars'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1020
|
|
|
0
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
for my $var ('output', 'input', 'db', 'mode', 'search') { |
91
|
0
|
|
|
|
|
|
my $idx = '$__'.$var; |
92
|
0
|
|
|
|
|
|
my $ref = ref($self->[eval($idx)]); |
93
|
0
|
0
|
|
|
|
|
if ($ref !~ /^ARRAY$/) { |
94
|
0
|
|
|
|
|
|
$log->fatal("$var attribute must be an ARRAYREF and it is [$ref]"); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return $self; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _do { |
103
|
0
|
|
|
0
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $global = $self->global; |
106
|
0
|
|
|
|
|
|
my $log = $global->log; |
107
|
0
|
|
|
|
|
|
my $input = $global->input; |
108
|
0
|
|
|
|
|
|
my $next = $global->next; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$log->info("Starting of job with Next ".$next->print); |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my @db = $self->db; |
113
|
0
|
|
|
|
|
|
my @mode = $self->mode; |
114
|
0
|
|
|
|
|
|
my @search = $self->search; |
115
|
0
|
|
|
|
|
|
my @output = $self->output; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
$input->postRun or return; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
for my $db (@db) { |
120
|
0
|
|
|
|
|
|
$log->verbose("Starting of DB [".ref($db)."]"); |
121
|
0
|
|
|
|
|
|
$global->db($db); |
122
|
0
|
0
|
|
|
|
|
$db->init or $log->fatal("Unable to init [".ref($db)."] module"); |
123
|
0
|
0
|
|
|
|
|
$db->run or next; |
124
|
0
|
|
|
|
|
|
$log->verbose("Running of DB [".ref($db)."]: Done"); |
125
|
0
|
|
|
|
|
|
for my $mode (@mode) { |
126
|
0
|
|
|
|
|
|
$global->mode($mode); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$log->verbose( |
129
|
|
|
|
|
|
|
"Running with Next: ".$next->print." with type [".ref($next)."]" |
130
|
|
|
|
|
|
|
); |
131
|
0
|
|
|
|
|
|
$log->verbose("Starting of Mode [".ref($mode)."]"); |
132
|
0
|
0
|
|
|
|
|
$mode->init or $log->fatal("Unable to init [".ref($mode)."] module"); |
133
|
0
|
0
|
|
|
|
|
$mode->run or next; |
134
|
0
|
|
|
|
|
|
$log->verbose("Running of Mode [".ref($mode)."]: Done"); |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
for my $search (@search) { |
137
|
0
|
|
|
|
|
|
$global->search($search); |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$log->verbose("Starting of Search [".ref($search)."]"); |
140
|
0
|
0
|
|
|
|
|
$search->init or $log->fatal("Unable to init [".ref($search). |
141
|
|
|
|
|
|
|
"] module"); |
142
|
0
|
0
|
|
|
|
|
my $result = $search->run or next; |
143
|
0
|
|
|
|
|
|
$global->result($result); |
144
|
0
|
|
|
|
|
|
$log->verbose("Running of Search [".ref($search)."]: Done"); |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
$mode->postSearch; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
for my $output (@output) { |
149
|
0
|
|
|
|
|
|
$global->output($output); |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
$log->verbose("Starting of Output [".ref($output)."]"); |
152
|
0
|
|
|
|
|
|
$output->firstInit; |
153
|
0
|
0
|
|
|
|
|
$output->init or $log->fatal("Unable to init [".ref($output). |
154
|
|
|
|
|
|
|
"] module"); |
155
|
0
|
0
|
|
|
|
|
$output->run or next; |
156
|
0
|
|
|
|
|
|
$output->post; |
157
|
0
|
|
|
|
|
|
$log->verbose("Running of Output [".ref($output)."]: Done"); |
158
|
|
|
|
|
|
|
} |
159
|
0
|
|
|
|
|
|
$search->post; |
160
|
|
|
|
|
|
|
} |
161
|
0
|
|
|
|
|
|
$mode->post; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
# To have persistent $dbh, we MUST post() in main process |
164
|
|
|
|
|
|
|
#$db->post; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
return 1; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub _getWorkerModel { |
171
|
0
|
|
|
0
|
|
|
my $self = shift; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
my $global = $self->global; |
174
|
0
|
|
|
|
|
|
my $log = $global->log; |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
my $model; |
177
|
0
|
0
|
|
|
|
|
if ($global->worker =~ /fork/i) { |
|
|
0
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
eval "use Net::SinFP3::Worker::Fork"; |
179
|
0
|
0
|
|
|
|
|
if ($@) { |
180
|
0
|
|
|
|
|
|
chomp($@); |
181
|
0
|
|
|
|
|
|
$log->fatal("Unable to use worker model Fork: error [$@]"); |
182
|
|
|
|
|
|
|
} |
183
|
0
|
|
|
|
|
|
$model = 'Net::SinFP3::Worker::Fork'; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
elsif ($global->worker =~ /thread/i) { |
186
|
0
|
|
|
|
|
|
eval "use Net::SinFP3::Worker::Thread"; |
187
|
0
|
0
|
|
|
|
|
if ($@) { |
188
|
0
|
|
|
|
|
|
chomp($@); |
189
|
0
|
|
|
|
|
|
$log->fatal("Unable to use worker model Thread: error [$@]"); |
190
|
|
|
|
|
|
|
} |
191
|
0
|
|
|
|
|
|
$model = 'Net::SinFP3::Worker::Thread'; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
return $model; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub run { |
198
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my $global = $self->global; |
201
|
0
|
|
|
|
|
|
my $log = $global->log; |
202
|
0
|
|
|
|
|
|
my @input = $self->input; |
203
|
0
|
|
|
|
|
|
my @output = $self->output; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Beware, recursive loop |
206
|
0
|
|
|
|
|
|
$log->global($global); |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
my $worker = $self->_getWorkerModel->new( |
209
|
|
|
|
|
|
|
global => $global, |
210
|
|
|
|
|
|
|
); |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
$log->info("Loaded Input: ".join(', ', map { ref($_) } $self->input)); |
|
0
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$log->info("Loaded DB: ".join(', ', map { ref($_) } $self->db)); |
|
0
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
$log->info("Loaded Mode: ".join(', ', map { ref($_) } $self->mode)); |
|
0
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
$log->info("Loaded Search: ".join(', ', map { ref($_) } $self->search)); |
|
0
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$log->info("Loaded Output: ".join(', ', map { ref($_) } $self->output)); |
|
0
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
for my $output (@output) { |
219
|
0
|
|
|
|
|
|
$output->preInit; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
my $job = 0; |
223
|
0
|
|
|
|
|
|
for my $input (@input) { |
224
|
0
|
|
|
|
|
|
$log->info("Starting of Input [".ref($input)."]"); |
225
|
0
|
0
|
|
|
|
|
$input->init or $log->fatal("Unable to init [".ref($input)."] module"); |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
$global->input($input); |
228
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
while (my $next = $input->run) { |
230
|
0
|
0
|
|
|
|
|
last unless defined($next); |
231
|
|
|
|
|
|
|
|
232
|
0
|
0
|
|
|
|
|
my @next = (ref($next) =~ /^ARRAY$/) ? @$next : ( $next ); |
233
|
0
|
|
|
|
|
|
for my $next (@next) { |
234
|
0
|
|
|
|
|
|
$global->job(++$job); |
235
|
0
|
|
|
|
|
|
$global->next($next); |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
$worker->init( |
238
|
|
|
|
|
|
|
callback => sub { |
239
|
0
|
|
|
0
|
|
|
$self->_do; |
240
|
|
|
|
|
|
|
}, |
241
|
0
|
0
|
|
|
|
|
) or $log->fatal("Unable to init [".ref($worker)."] module"); |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# We are just before fork()ing or thread()ing. |
244
|
|
|
|
|
|
|
# Now, all data will be copied to the new process. |
245
|
0
|
|
|
|
|
|
my $r = $worker->run; |
246
|
0
|
0
|
|
|
|
|
if ($r == NS_WORKER_SUCCESS) { |
247
|
0
|
|
|
|
|
|
$input->postFork; |
248
|
0
|
|
|
|
|
|
next; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# Father process will skip that part |
252
|
0
|
|
|
|
|
|
$log->verbose("Running of job with Next ".$next->print.": Done"); |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
$worker->post; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
} |
257
|
0
|
|
|
|
|
|
$global->job(0); |
258
|
0
|
|
|
|
|
|
$input->post; |
259
|
0
|
|
|
|
|
|
$log->verbose("Running of Input [".ref($input)."]: Done"); |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
$worker->clean; |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
for my $db ($self->db) { |
265
|
0
|
|
|
|
|
|
$db->post; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
for my $output (@output) { |
269
|
0
|
|
|
|
|
|
$output->lastPost; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
|
$log->info("Done: operation successful"); |
273
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
return 1; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
1; |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
__END__ |