| 1 | package NET::IPFilter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # use 5.008008; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Compress::Zlib; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Fcntl ':flock'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # use Math::BigInt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # This allows declaration use NET::IPFilter ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # will save memory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | beautifyRawIPfromIPFilter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | readIPFilterFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | httpGetStore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | _ip2long | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | _long2ip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | isValid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | gunzip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | _init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | beautifyRawIPfromIPFilter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | readIPFilterFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | httpGetStore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | _ip2long | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | _long2ip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | isValid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | gunzip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | _init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | our $VERSION = '1.2'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ###### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $MaxFileSizeOfWebDocument = (50 * 1024 * 1024); # 5mb | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | my $MaxRedirectRequests = 15; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $AuthorEmail = 'yourname@cpan.org'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | my $Timeout = 25; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my $CrawlDelay = int(rand(3)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my $Referer = "http://www.google.com/"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | my $DEBUG = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # IPFilter.dat: http://www.bluetack.co.uk/forums/index.php | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ###### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub new(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my %args = ref($_[0])?%{$_[0]}:@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $self = \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->_init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | }; # sub new(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub isValid(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isValid: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $IPtoCheck = $self->_ip2long(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $RangesArrayRef = $self->{'_IPRANGES_ARRAY_REF'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $howmany = scalar( @{$RangesArrayRef} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # $IPtoCheck = Math::BigInt->new($IPtoCheck); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | for ( my $count=0; $count<=$howmany; $count++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($RangFrom, $RangTo) = split("-", $RangesArrayRef->[$count]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( $IPtoCheck >= $RangFrom && $IPtoCheck <= $RangTo ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$IPtoCheck >= $RangFrom and $IPtoCheck <= $RangTo
MC/DC0%0/2
$IPtoCheck >= $RangFrom and $IPtoCheck <= $RangTo
$IPtoCheck >= $RangFrom
$IPtoCheck <= $RangTo
Truth table0%0/3
A and B
A= $IPtoCheck >= $RangFromB= $IPtoCheck <= $RangTo
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | }; # for ( my $count=0; $count<=$howmany; $count++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return 1; # if ip not found in ipfilter.dat its valid | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | }; # sub isValid(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub readIPFilterFile(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readIPFilterFile: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $IPFilterDatFile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my @IP_Ranges = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | open(RH,"<$IPFilterDatFile") or croak("$self -> _readIPFilterFile( $IPFilterDatFile ) Reading Failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | while (defined( my $entry = <RH>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | chomp($entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | next if ( $entry =~ /^#/g || $entry =~ /#/g ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$entry =~ /^#/g or $entry =~ /#/g
MC/DC0%0/2
$entry =~ /^#/g or $entry =~ /#/g
$entry =~ /^#/g
$entry =~ /#/g
Truth table0%0/3
A or B
A= $entry =~ /^#/gB= $entry =~ /#/g
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my ($IPRange, undef, $DESC) = split(",", $entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | next if ( $DESC =~ /\[BG\]FreeSP/ig ); # ignore not used ips | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my ($IP_Start,$IP_End) = split("-", $IPRange ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $IP_Start =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $IP_Start =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $IP_End =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $IP_End =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # beautifyRawIPfromIPFilter is not needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # my $IPStart = $self->beautifyRawIPfromIPFilter( $IP_Start ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # my $IPEnd = $self->beautifyRawIPfromIPFilter( $IP_End ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $IPStart = $self->_ip2long( $IP_Start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $IPEnd = $self->_ip2long( $IP_End ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # $IPStart = Math::BigInt->new($IPStart); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # $IPEnd = Math::BigInt->new($IPEnd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # print "$IP_Start und $IP_End\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | push(@IP_Ranges, "$IPStart-$IPEnd"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | }; # while (defined( my $entry = <RH>)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | close RH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->{'_IPRANGES_ARRAY_REF'} = \@IP_Ranges; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | }; # sub _readIPFilterFile(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub beautifyRawIPfromIPFilter(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
beautifyRawIPfromIPFilter: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $RawIP = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my ($a,$b,$c,$d) = split(/\./, $RawIP ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my @tmp = ($a, $b, $c, $d); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my %IP = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $tmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | for (my $i=0; $i<=$#tmp; $i++ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($one, $two, $thr) = split("", $tmp[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ( $one == 0 && $two == 0 && $thr == 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/6
$one == 0 and $two == 0 and $thr == 0
$one == 0 and $two == 0
MC/DC0%0/3
$one == 0 and $two == 0 and $thr == 0
$one == 0
$two == 0
$thr == 0
Truth table0%0/4
A and B and C
A= $one == 0B= $two == 0C= $thr == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # 000->0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $IP{$i} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ▶ | } elsif ( $one == 0 && $two == 0 && $thr != 0 ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$one == 0 and $two == 0 and $thr != 0
$one == 0 and $two == 0
MC/DC0%0/3
$one == 0 and $two == 0 and $thr != 0
$one == 0
$two == 0
$thr != 0
Truth table0%0/4
A and B and C
A= $one == 0B= $two == 0C= $thr != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # 001->1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $IP{$i} = $thr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ▶ | } elsif ( $one == 0 && $two != 0 && $thr != 0){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$one == 0 and $two != 0 and $thr != 0
$one == 0 and $two != 0
MC/DC0%0/3
$one == 0 and $two != 0 and $thr != 0
$one == 0
$two != 0
$thr != 0
Truth table0%0/4
A and B and C
A= $one == 0B= $two != 0C= $thr != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # 0XY->XY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $IP{$i} = $two.$thr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ▶ | } elsif ( $one != 0 && $two != 0 && $thr != 0 ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$one != 0 and $two != 0 and $thr != 0
$one != 0 and $two != 0
MC/DC0%0/3
$one != 0 and $two != 0 and $thr != 0
$one != 0
$two != 0
$thr != 0
Truth table0%0/4
A and B and C
A= $one != 0B= $two != 0C= $thr != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # XYZ->XYZ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $IP{$i} = $tmp[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # rest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $IP{$i} = $tmp[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | }; # if ( $one == 0 && $two == 0 && $thr == 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | }; # for (my $i=1; $i<=$#tmp; $i++ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return $IP{0} . "." . $IP{1} . "." . $IP{2} . "." . $IP{3}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | }; # sub _BeautifyRawIPfromIPFilter(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub _ip2long(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ip2long: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $ip = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my @numbers = split(/\./,$ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return ($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | }; # sub ip2long() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub _long2ip(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_long2ip: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | use Socket qw ( inet_ntoa ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $long = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return inet_ntoa(pack("N*", $long)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | }; # sub long2ip(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub httpGetStore(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
httpGetStore: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $url = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $storePath = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $UA = LWP::UserAgent->new( keep_alive => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $UA->agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # $UA->agent("wget"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $UA->timeout( $Timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $UA->max_size( $MaxFileSizeOfWebDocument ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $UA->from( $AuthorEmail ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $UA->max_redirect( $MaxRedirectRequests ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $UA->parse_head( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $UA->protocols_allowed( [ 'http', 'https', 'ftp', 'ed2k'] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $UA->protocols_forbidden( [ 'file', 'mailto'] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $UA->requests_redirectable( [ 'HEAD', 'GET', 'POST'] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # $ua->credentials( $netloc, $realm, $uname, $pass ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/'); # f�r protokollschema http und ftp benutze proxy ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # $ua->env_proxy -> wais_proxy=http://proxy.my.place/ -> export gopher_proxy wais_proxy no_proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | sleep $CrawlDelay; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $req = HTTP::Request->new( GET => $url ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $req->referer($Referer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $res = $UA->request($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ( $res->is_success ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # open(WH,">$storePath") or die "$self -> _httpGetStore() - I/O Error!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # flock(WH,LOCK_EX); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # print WH $res->content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # flock(WH,LOCK_UN); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # close WH; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->saveFile( $storePath, $res->content , ">"); # '>' - perl file handle openening type | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | croak("$self -> _httpGetStore() -http-Get Request Failed: $res->status_line\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | }; # if ($res->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | }; # sub _httpGetStore(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub gunzip(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gunzip: not called CC=7 SCAR=36.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $ZippedFile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $UnzippedFile = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | no strict 'subs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $gzerrno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | my $buffer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $gz = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $success = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (! open FH, ">$UnzippedFile") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # print "Unable to write to '$outfile'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | binmode FH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | flock(FH,LOCK_EX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ($gz = gzopen($ZippedFile, "rb")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | while ($gz->gzread($buffer) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | print FH $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | }; # while ($gz->gzread($buffer) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ($gzerrno != Z_STREAM_END) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # print "ZLib Error: reading $outfile - $gzerrno: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $success = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | }; # if ($gzerrno != Z_STREAM_END) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $gz->gzclose; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $success = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # print "ZLib Error: opening $infile - $gzerrno: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | }; # if ($gz = gzopen($infile, "rb")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | close FH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | flock(FH,LOCK_UN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | }; # if (! open FH, ">$UnzippedFile") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ( $success == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | system("/bin/mv $ZippedFile $UnzippedFile"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | system("/bin/gunzip $UnzippedFile") && system("/usr/bin/gunzip $UnzippedFile"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | }; # if ( $success == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | }; # sub _gunzip(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub saveFile(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveFile: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $File = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $refContent = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | my $oberator = shift || ">"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || '>'
MC/DC0%0/1
shift() || '>'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | open(FILE, $oberator . $File) or croak "$self->_saveFile(): Open Error: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | binmode(FILE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | flock(FILE,LOCK_EX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if ( ref($refContent) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | for ( my $i=0; $i<=$#{$refContent}; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | print FILE $refContent->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | }; # for ( my $i=0; ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } elsif ( ref($refContent) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $keys = keys( %{$refContent} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | for ( my $i=0; $i<=$keys; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | print FILE $refContent->{$i}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | }; # for ( my $i=0; ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } elsif ( ref($refContent) eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | print FILE ${$refContent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } elsif ( ref($refContent) eq '' ) { # normaler scalar senden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | print FILE $refContent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # code oder glob ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | croak "CODE or GLOB Ref - not supported\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | flock(FILE,LOCK_UN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | close FILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | }; # if ( ref($refContent) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | flock(FILE,LOCK_UN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | close FILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return $File; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | }; # sub _saveFile(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _init(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $ipfilter_file = $self->{'ipfilter'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $tmp_dir = $self->{'tmpdir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $force_init = $self->{'force_init'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | mkdir $tmp_dir || system("/bin/mkdir $tmp_dir"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$tmp_dir || system("/bin/mkdir $tmp_dir")
MC/DC0%0/2
$tmp_dir || system("/bin/mkdir $tmp_dir")
$tmp_dir
system("/bin/mkdir $tmp_dir")
Truth table0%0/3
A || B
A= $tmp_dirB= system("/bin/mkdir $tmp_dir")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $IPFilerFile = "$tmp_dir/ipfilter.dat"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $IPFilerFileGZ = "$tmp_dir/ipfilter.dat.gz"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Delete Files if force init == 1 resulting in recreation of ipfilter files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if ( $force_init == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | unlink $IPFilerFile || system("/bin/rm -f $IPFilerFile"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$IPFilerFile || system("/bin/rm -f $IPFilerFile")
MC/DC0%0/2
$IPFilerFile || system("/bin/rm -f $IPFilerFile")
$IPFilerFile
system("/bin/rm -f $IPFilerFile")
Truth table0%0/3
A || B
A= $IPFilerFileB= system("/bin/rm -f $IPFilerFile")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | unlink $IPFilerFileGZ || system("/bin/rm -f $IPFilerFileGZ"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$IPFilerFileGZ || system("/bin/rm -f $IPFilerFileGZ")
MC/DC0%0/2
$IPFilerFileGZ || system("/bin/rm -f $IPFilerFileGZ")
$IPFilerFileGZ
system("/bin/rm -f $IPFilerFileGZ")
Truth table0%0/3
A || B
A= $IPFilerFileGZB= system("/bin/rm -f $IPFilerFileGZ")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | }; # if ( $force_init == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # File doesnt exsits so we need to download it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if ( ( !-e $ipfilter_file && !-f $ipfilter_file ) || ( !-e $IPFilerFile && !-f $IPFilerFile ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
-e $ipfilter_file || -f $ipfilter_file and -e $IPFilerFile || -f $IPFilerFile
-e $ipfilter_file or -f $ipfilter_file
-e $IPFilerFile or -f $IPFilerFile
MC/DC0%0/4
-e $ipfilter_file || -f $ipfilter_file and -e $IPFilerFile || -f $IPFilerFile
-e $ipfilter_file
-f $ipfilter_file
-e $IPFilerFile
-f $IPFilerFile
Truth table0%0/7
A or B and C or D
A= -e $ipfilter_fileB= -f $ipfilter_fileC= -e $IPFilerFileD= -f $IPFilerFile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | if ( $ipfilter_file =~ /^http:\/\//i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my @tmp = split('/', $ipfilter_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $FileName = $tmp[$#tmp]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my ( $OnlyFileName , $OnlyFileTyp ) = split(/(\.([^.]+?)$)/i, $FileName ); # working correctly for "TEST.JPEG.bmp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # todo: later bzip2|rar support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ( $OnlyFileTyp eq 'gz' || $OnlyFileTyp =~ /gz/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$OnlyFileTyp eq "gz" or $OnlyFileTyp =~ /gz/i
MC/DC0%0/2
$OnlyFileTyp eq "gz" or $OnlyFileTyp =~ /gz/i
$OnlyFileTyp eq "gz"
$OnlyFileTyp =~ /gz/i
Truth table0%0/3
A or B
A= $OnlyFileTyp eq "gz"B= $OnlyFileTyp =~ /gz/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | print "Downloading gzip file $ipfilter_file \n " if $DEBUG == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Download and Save file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $self->httpGetStore($ipfilter_file, $IPFilerFileGZ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | print "Unzipping gzip file $ipfilter_file \n " if $DEBUG == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # gunzip file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $self->gunzip($IPFilerFileGZ, $IPFilerFile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # read file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $self->readIPFilterFile( $IPFilerFile ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } else { # asume txt file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | print "Downloading txt file $ipfilter_file \n " if $DEBUG == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # Download and Save file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->httpGetStore($ipfilter_file, $IPFilerFile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $self->readIPFilterFile( $IPFilerFile ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | }; # if ( $OnlyFileTyp eq 'gz' || $OnlyFileTyp =~ /gz/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | }; # if ( $ipfilter_file =~ /^http:\/\//i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | }; # if ( ! -e $IPFilerFile && ! -f $IPFilerFile ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $self->readIPFilterFile( $ipfilter_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | }; # sub _init(){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||