line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Slackeria::Plugin::OpenPorts; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
903401
|
use strict; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
179
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
121
|
|
5
|
1
|
|
|
1
|
|
155
|
use 5.010; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
53
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2181
|
use parent 'App::Slackeria::Plugin'; |
|
1
|
|
|
|
|
625
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
3069
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
115563
|
|
|
1
|
|
|
|
|
16
|
|
10
|
1
|
|
|
1
|
|
514
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my ( $obj, %conf ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $ref = {}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$ref->{default} = \%conf; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ref->{ua} = LWP::UserAgent->new( timeout => 10 ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return bless( $ref, $obj ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check { |
27
|
|
|
|
|
|
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $name = $self->{conf}->{name}; |
30
|
|
|
|
|
|
|
my $reply = $self->{ua} |
31
|
|
|
|
|
|
|
->get("http://openports.se/search.php?stype=folder&so=${name}"); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ( not $reply->is_success() ) { |
34
|
|
|
|
|
|
|
die( $reply->status_line() ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $html = $reply->decoded_content(); |
38
|
|
|
|
|
|
|
my $tree = XML::LibXML->load_html( string => $html ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $xp_main = XML::LibXML::XPathExpression->new('//div[@id="main"]/b'); |
41
|
|
|
|
|
|
|
my $xp_url = XML::LibXML::XPathExpression->new('following::a[1]'); |
42
|
|
|
|
|
|
|
my $xp_ver = XML::LibXML::XPathExpression->new('following::em/b[1]'); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
for my $node ( @{ $tree->findnodes($xp_main) } ) { |
45
|
|
|
|
|
|
|
if ( $node->textContent() eq '*** Exact match ***' ) { |
46
|
|
|
|
|
|
|
my $category = $node->findnodes($xp_url)->[0]->textContent(); |
47
|
|
|
|
|
|
|
my $version = $node->findnodes($xp_ver)->[0]->textContent(); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$version =~ s{ ^ version \s }{}x; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return { data => $version, }; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
die("not found\n"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |