line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ThreatNet::Message::IPv4; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
45496
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
181
|
|
4
|
4
|
|
|
4
|
|
27
|
use base 'ThreatNet::Message'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
5644
|
|
5
|
4
|
|
|
4
|
|
24412
|
use Net::IP (); |
|
4
|
|
|
|
|
273151
|
|
|
4
|
|
|
|
|
143
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
50
|
use vars qw{$VERSION}; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
230
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
4
|
|
|
4
|
|
1123
|
$VERSION = '0.20'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
##################################################################### |
17
|
|
|
|
|
|
|
# Constructor and Accessors |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
19
|
50
|
|
19
|
1
|
4299
|
my $class = ref $_[0] ? ref shift : shift; |
21
|
19
|
|
|
|
|
35
|
my $msg = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Create the basic object from out parent class |
24
|
19
|
100
|
|
|
|
103
|
my $self = $class->SUPER::new($msg) or return undef; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Find the first non-whitespace segment |
27
|
14
|
50
|
|
|
|
103
|
$msg =~ /^(\S+)(\s+.+)?$/ or return undef; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Net::IP supports a variety of different formats. |
30
|
|
|
|
|
|
|
# We, on the other hand, don't. |
31
|
|
|
|
|
|
|
# Run a basic check to ensure the format is generally correct. |
32
|
|
|
|
|
|
|
# If we find at least one dot, then it won't be misrecognised. |
33
|
14
|
|
|
|
|
42
|
my $ip = $1; |
34
|
14
|
50
|
|
|
|
55
|
$ip =~ /\./ or return undef; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# The rest of the line (if any) is the comment |
37
|
14
|
|
|
|
|
43
|
$self->{comment} = ''; |
38
|
14
|
50
|
|
|
|
42
|
if ( defined $2 ) { |
39
|
0
|
|
|
|
|
0
|
$self->{comment} = $2; |
40
|
0
|
|
|
|
|
0
|
$self->{comment} =~ s/^\s+//; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Complete the creation of the IP and message |
44
|
14
|
100
|
|
|
|
205
|
$self->{IP} = Net::IP->new( $ip, 4 ) or return undef; |
45
|
|
|
|
|
|
|
|
46
|
13
|
|
|
|
|
8588
|
$self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
22
|
|
|
22
|
0
|
3937
|
sub IP { $_[0]->{IP} } |
50
|
|
|
|
|
|
|
|
51
|
19
|
|
|
19
|
0
|
52
|
sub ip { $_[0]->IP->ip } |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
0
|
|
sub comment { $_[0]->{comment} } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
##################################################################### |
60
|
|
|
|
|
|
|
# Param::Coerce Support |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
|
|
sub __as_Net_IP { $_[0]->IP } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |