blib/lib/DJabberd/Authen/UserLimit.pm

filter: Statementstmt 66.6% 22 / 33 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 4 totaltotal 60.0% 30 / 50 CC 3 SCAR 7.9
CC
3
Cov
62%
check_cleartext
6.0
finalize
2.1
log
2.0
CRAP 2.2
↑ Summary
1 package DJabberd::Authen::UserLimit;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use base 'DJabberd::Authen';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use DJabberd::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $logger = DJabberd::Log->get_logger;
6  
7 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 $VERSION = '0.30';
9  
10  
11 2 ▶use DJabberd::Util qw(as_num);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 0 ▶sub log {
Subroutine log: not called CC=1 SCAR=6.9
Pod undocumented
13 0 $logger;
14 }
15  
16 1 ▶sub set_config_userlimit {
Subroutine set_config_userlimit: called CC=1 SCAR=0.0
Pod undocumented
17 1 my ($self, $val) = @_;
18 1 $self->{limit} = as_num($val);
19 }
20  
21 1 ▶sub finalize {
Subroutine finalize: called CC=2 SCAR=7.2
Pod undocumented
22 1 my ($self) = @_;
23 1 ▶ die "Missing UserLimit directive" if not $self->{limit};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"limit"} 0 1 1
24 }
25  
26  
27 0 ▶sub check_cleartext {
Subroutine check_cleartext: not called CC=2 SCAR=17.9
Pod undocumented
28 0 my ($self, $cb, %args) = @_;
29 # args contain: username and conn
30 0 my $conn = $args{conn};
31 0 my $nb_user = keys %{$conn->vhost->{jid2sock}};
32 0 my $limit = $self->{limit};
33 0 $logger->info("Number of user : $nb_user , limit : $limit ");
34 0 ▶ if ($nb_user ge $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nb_user ge $limit) 0 0 0
35 0 $cb->reject;
36 0 return;
37 };
38 0 $cb->decline;
39 }
40  
41 2 1;
42  
43 __END__
↑ Summary