line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DJabberd::Plugin::Ping; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23549
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
1
|
|
|
1
|
|
6
|
use base 'DJabberd::Plugin'; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
613
|
|
6
|
|
|
|
|
|
|
our $logger = DJabberd::Log->get_logger(); |
7
|
1
|
|
|
1
|
|
454
|
use DJabberd; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
DJabberd::Plugin::Ping - Add support for "XEP 0199, Xmpp Ping" to DJabberd. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.46 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
use vars qw($VERSION); |
19
|
|
|
|
|
|
|
$VERSION = '0.46'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
... |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
... |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 register($self, $vhost) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Register the vhost with the module. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub register { |
39
|
|
|
|
|
|
|
my ($self, $vhost) = @_; |
40
|
|
|
|
|
|
|
my $private_cb = sub { |
41
|
|
|
|
|
|
|
my ($vh, $cb, $iq) = @_; |
42
|
|
|
|
|
|
|
unless ($iq->isa('DJabberd::IQ')) { |
43
|
|
|
|
|
|
|
$cb->decline; |
44
|
|
|
|
|
|
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
unless ( ! $iq->to || $iq->to eq $vhost->{server_name}) { |
47
|
|
|
|
|
|
|
$cb->decline; |
48
|
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if ($iq->signature eq 'get-{urn:xmpp:ping}ping') { |
52
|
|
|
|
|
|
|
$self->_get_ping($vh, $iq); |
53
|
|
|
|
|
|
|
$cb->stop_chain; |
54
|
|
|
|
|
|
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
$cb->decline; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
$vhost->register_hook('switch_incoming_client',$private_cb); |
59
|
|
|
|
|
|
|
$vhost->register_hook('switch_incoming_server',$private_cb); |
60
|
|
|
|
|
|
|
# for version 0.3 of the spec |
61
|
|
|
|
|
|
|
# http://mail.jabber.org/pipermail/standards/2006-November/013207.html |
62
|
|
|
|
|
|
|
$vhost->add_feature('urn:xmpp:ping'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _get_ping { |
67
|
|
|
|
|
|
|
my ($self, $vhost, $iq) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$logger->info('Get ping from : ' . $iq->from_jid); |
70
|
|
|
|
|
|
|
$iq->send_result(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Michael Scherer, C<< >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 BUGS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
80
|
|
|
|
|
|
|
C, or through the web interface at |
81
|
|
|
|
|
|
|
L. |
82
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
83
|
|
|
|
|
|
|
your bug as I make changes. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Copyright 2007 Michael Scherer, all rights reserved. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
92
|
|
|
|
|
|
|
under the same terms as Perl itself. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |