lib/Net/SinFP3/Input/IpPort.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 76 CC 5 SCAR 26.1
CC
5
Cov
0%
new
30.0
give
2.0
init
2.0
CRAP 13.7
1 #
2 # $Id: IpPort.pm,v 008243d3e89a 2018/07/21 14:54:07 gomor $
3 #
4 package Net::SinFP3::Input::IpPort;
5 use strict;
6 use warnings;
7  
8 use base qw(Net::SinFP3::Input);
9 our @AS = qw(
10 mac
11 );
12 __PACKAGE__->cgBuildIndices;
13 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
14  
15 use Net::SinFP3::Next::IpPort;
16  
17 sub give {
18 return [
19 'Net::SinFP3::Next::IpPort',
20 ];
21 }
22  
23 sub new {
24 my $self = shift->SUPER::new(
25 mac => '00:00:00:00:00:00',
26 @_,
27 );
28  
29 my $global = $self->global;
30 my $log = $global->log;
31  
32 if (! defined($global->target)) {
33 $log->fatal("You must provide `target' attribute in Global object");
34 }
35  
36 if (! defined($global->port)) {
37 $log->fatal("You must provide `port' attribute in Global object");
38 }
39  
40 if (! $global->targetIp) {
41 $log->fatal("Invalid target IP provided: [".$global->targetIp."]");
42 }
43  
44 my $port = $global->port;
45 if ($port !~ /^[-,\d]+$/) {
46 $log->fatal("Invalid port provided: [$port]");
47 }
48  
49 return $self;
50 }
51  
52 sub init {
53 my $self = shift->SUPER::init(@_) or return;
54  
55 my $global = $self->global;
56 my $log = $global->log;
57  
58 my $portList = $global->portList;
59 my $ip = $global->targetIp;
60 my $hostname = $global->targetHostname;
61  
62 my $reverse = $global->targetReverse;
63 my $mac = $self->mac;
64  
65 my @nextList = ();
66 for my $port (@$portList) {
67 my $next = Net::SinFP3::Next::IpPort->new(
68 global => $self->global,
69 ip => $ip,
70 port => $port,
71 hostname => $hostname,
72 reverse => $reverse,
73 mac => $mac,
74 );
75 push @nextList, $next;
76 }
77  
78 $self->nextList(\@nextList);
79  
80 return 1;
81 }
82  
83 sub run {
84 my $self = shift->SUPER::run(@_) or return;
85  
86 my @nextList = $self->nextList;
87 my $next = shift @nextList;
88 $self->nextList(\@nextList);
89  
90 return $next;
91 }
92  
93 1;
94  
95 __END__