line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::RADSWrappers; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36911
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
47
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
1
|
|
|
1
|
|
856
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
1492
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( getHostName getCountry grabConnections |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
) ] ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT = qw( |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# This is just a convieniet wrapper around gethostbyaddr() to take away some of |
26
|
|
|
|
|
|
|
# the more obnoxious issues with that function |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub getHostName ($) { |
29
|
1
|
|
|
1
|
|
978
|
use Socket; |
|
1
|
|
|
|
|
11654
|
|
|
1
|
|
|
|
|
1056
|
|
30
|
0
|
|
|
0
|
|
|
my $ip_in = shift; |
31
|
0
|
|
|
|
|
|
my $ip = inet_aton($ip_in); |
32
|
0
|
|
|
|
|
|
my $name = gethostbyaddr($ip, AF_INET); |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if (!$name) { |
35
|
0
|
|
|
|
|
|
$name = "NXDOMAIN"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $name; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# This is just provides a bit of error checking around Geo::IPfree::LookUp |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub getCountry ($) { |
44
|
1
|
|
|
1
|
|
467
|
use Geo::IPfree; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $ip = shift; |
46
|
|
|
|
|
|
|
my ($country) = Geo::IPfree::LookUp($ip); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if (!$country) { |
49
|
|
|
|
|
|
|
$country = "Unknown"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
return $country; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub grabConnections { |
55
|
|
|
|
|
|
|
my ($pipe,$port) = @_; |
56
|
|
|
|
|
|
|
my %hosts; |
57
|
|
|
|
|
|
|
while(<$pipe>) { |
58
|
|
|
|
|
|
|
if (/:$port/) { |
59
|
|
|
|
|
|
|
my @connection = split (/\s+/, $_); |
60
|
|
|
|
|
|
|
if($connection[4] =~ /((\d+\.){3}\d+)/g) { |
61
|
|
|
|
|
|
|
$hosts{$1}++ unless $1 eq '0.0.0.0'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
close $pipe; |
66
|
|
|
|
|
|
|
return %hosts; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
__END__ |