blib/lib/POE/Component/Server/IRC.pm

filter: Statementstmt 71.1% 5505 / 7743 Branchbran 54.3% 2007 / 3692 Conditioncond 42.3% 1038 / 2449 MC/DCmcdc 11.9% 168 / 1408 Subroutinesub 84.0% 248 / 295 Podpod 68.6% 46 / 67 totaltotal 57.5% 9012 / 15654 CC 3030 SCAR 59.0
CC
3030
Cov
62%
_daemon_do_stats
4563.8
_daemon_peer_tmode
3422.0
_daemon_cmd_mode
1473.3
CRAP 366.5
↑ Summary blib/lib/POE/Component/Server/IRC/Plugin/Auth.pm »
1 package POE::Component::Server::IRC;
2 180 $POE::Component::Server::IRC::VERSION = '1.66';
3 180 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 180 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 180 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 180 ▶use IRC::Utils qw(uc_irc parse_mode_line unparse_mode_line normalize_mask
Subroutine BEGIN: called CC=1 SCAR=0.0
7 matches_mask matches_mask_array gen_mode_change is_valid_nick_name
8 180 is_valid_chan_name has_color has_formatting parse_user);
9 180 ▶use List::Util qw(sum);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 180 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 180 ▶use POE::Component::Server::IRC::Common qw(chkpasswd);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 180 ▶use POE::Component::Server::IRC::Plugin qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 180 ▶use POSIX 'strftime';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 180 ▶use Net::CIDR ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 180 ▶use base qw(POE::Component::Server::IRC::Backend);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 180 my $sid_re = qr/^[0-9][A-Z0-9][A-Z0-9]$/;
18 180 my $id_re = qr/^[A-Z][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]$/;
19 180 my $uid_re = qr/^[0-9][A-Z0-9][A-Z0-9][A-Z][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]$/;
20 180 my $host_re = qr/^[^.:][A-Za-z0-9.:-]+$/;
21 180 my $user_re = qr/^[^\x2D][\x24\x2D-\x39\x41-\x7E]+$/;
22  
23 180 ▶sub spawn {
Subroutine spawn: called CC=4 SCAR=13.9
Pod documented
24 180 my ($package, %args) = @_;
25 180 $args{lc $_} = delete $args{$_} for keys %args;
26 180 my $config = delete $args{config};
27 180 my $debug = delete $args{debug};
28 my $self = $package->create(
29 ($debug ? (raw_events => 1) : ()),
30 %args,
31 states => [
32 [qw(add_spoofed_nick del_spoofed_nick _state_drkx_line_alarm _daemon_do_safelist)],
33 {
34 180 ▶ map { +"daemon_cmd_$_" => '_spoofed_command' }
Branch: 1 branch
BranchTrueFalseTotal
$debug ? : 0 180 180
35 qw(join part mode kick topic nick privmsg notice xline unxline resv unresv
36 rkline unrkline kline unkline sjoin locops wallops globops dline undline)
37 },
38 ],
39 );
40  
41 180 ▶ $self->configure($config ? $config : ());
Branch: 1 branch
BranchTrueFalseTotal
$config ? : 179 1 180
42 180 $self->{debug} = $debug;
43 180 $self->_state_create();
44 180 return $self;
45 }
46  
47 519 ▶sub IRCD_connection {
Subroutine IRCD_connection: called CC=3 SCAR=11.0
Pod undocumented
48 519 my ($self, $ircd) = splice @_, 0, 2;
49 519 pop @_;
50 my ($conn_id, $peeraddr, $peerport, $sockaddr, $sockport, $needs_auth, $secured, $filter)
51 519 = map { ${ $_ } } @_;
52  
53 519 ▶ if ($self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_exists($conn_id)) 0 519 519
54 0 delete $self->{state}{conns}{$conn_id};
55 }
56  
57 519 $self->{state}{conns}{$conn_id}{registered} = 0;
58 519 $self->{state}{conns}{$conn_id}{type} = 'u';
59 519 $self->{state}{conns}{$conn_id}{seen} = time();
60 519 $self->{state}{conns}{$conn_id}{conn_time} = time();
61 519 $self->{state}{conns}{$conn_id}{secured} = $secured;
62 519 $self->{state}{conns}{$conn_id}{stats} = $filter;
63 $self->{state}{conns}{$conn_id}{socket}
64 519 = [$peeraddr, $peerport, $sockaddr, $sockport];
65  
66 519 $self->_state_conn_stats();
67  
68 519 ▶ if (!$needs_auth) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($needs_auth) 518 1 519
69 $self->{state}{conns}{$conn_id}{auth} = {
70 518 hostname => '',
71 ident => '',
72 };
73 518 $self->_client_register($conn_id);
74 }
75  
76 519 return PCSI_EAT_CLIENT;
77 }
78  
79 3 ▶sub IRCD_connected {
Subroutine IRCD_connected: called CC=2 SCAR=7.0
Pod undocumented
80 3 my ($self, $ircd) = splice @_, 0, 2;
81 3 pop @_;
82 my ($conn_id, $peeraddr, $peerport, $sockaddr, $sockport, $name, $filter)
83 3 = map { ${ $_ } } @_;
84  
85 3 ▶ if ($self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_exists($conn_id)) 0 3 3
86 0 delete $self->{state}{conns}{$conn_id};
87 }
88  
89 3 $self->{state}{conns}{$conn_id}{peer} = $name;
90 3 $self->{state}{conns}{$conn_id}{registered} = 0;
91 3 $self->{state}{conns}{$conn_id}{cntr} = 1;
92 3 $self->{state}{conns}{$conn_id}{type} = 'u';
93 3 $self->{state}{conns}{$conn_id}{seen} = time();
94 3 $self->{state}{conns}{$conn_id}{conn_time} = time();
95 3 $self->{state}{conns}{$conn_id}{stats} = $filter;
96 $self->{state}{conns}{$conn_id}{socket}
97 3 = [$peeraddr, $peerport, $sockaddr, $sockport];
98  
99 3 $self->_state_conn_stats();
100 3 $self->_state_send_credentials($conn_id, $name);
101 3 return PCSI_EAT_CLIENT;
102 }
103  
104 0 ▶sub IRCD_connection_flood {
Subroutine IRCD_connection_flood: not called CC=1 SCAR=6.9
Pod undocumented
105 0 my ($self, $ircd) = splice @_, 0, 2;
106 0 pop @_;
107 0 my ($conn_id) = map { ${ $_ } } @_;
108 0 $self->_terminate_conn_error($conn_id, 'Excess Flood');
109 0 return PCSI_EAT_CLIENT;
110 }
111  
112 0 ▶sub IRCD_connection_idle {
Subroutine IRCD_connection_idle: not called CC=4 SCAR=30.0
Pod undocumented
113 0 my ($self, $ircd) = splice @_, 0, 2;
114 0 pop @_;
115 0 my ($conn_id, $interval) = map { ${ $_ } } @_;
116 0 ▶ return PCSI_EAT_NONE if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 0 0
117  
118 0 my $conn = $self->{state}{conns}{$conn_id};
119 0 ▶ if ($conn->{type} eq 'u') {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"type"} eq "u") 0 0 0
120 0 $self->_terminate_conn_error($conn_id, 'Connection Timeout');
121 0 return PCSI_EAT_CLIENT;
122 }
123  
124 0 ▶ if ($conn->{pinged}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"pinged"}) 0 0 0
125 0 my $msg = 'Ping timeout: '.(time - $conn->{seen}).' seconds';
126 0 $self->_terminate_conn_error($conn_id, $msg);
127 0 return PCSI_EAT_CLIENT;
128 }
129  
130 0 $conn->{pinged} = 1;
131 0 $self->send_output(
132 {
133 command => 'PING',
134 params => [$self->server_name()],
135 },
136 $conn_id,
137 );
138 0 return PCSI_EAT_CLIENT;
139 }
140  
141 1 ▶sub IRCD_auth_done {
Subroutine IRCD_auth_done: called CC=2 SCAR=6.9
Pod undocumented
142 1 my ($self, $ircd) = splice @_, 0, 2;
143 1 pop @_;
144 1 my ($conn_id, $ref) = map { ${ $_ } } @_;
145 1 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 1 1
146  
147 1 $self->{state}{conns}{$conn_id}{auth} = $ref;
148 1 $self->_client_register($conn_id);
149 1 return PCSI_EAT_CLIENT;
150 }
151  
152 482 ▶sub IRCD_disconnected {
Subroutine IRCD_disconnected: called CC=4 SCAR=13.9
Pod undocumented
153 482 my ($self, $ircd) = splice @_, 0, 2;
154 482 pop @_;
155 482 my ($conn_id, $errstr) = map { ${ $_ } } @_;
156 482 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 482 482
157  
158 482 ▶ if ($self->_connection_is_peer($conn_id)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_connection_is_peer($conn_id)) { } 225 257 482
elsif ($self->_connection_is_client($conn_id)) { } 214 43 257
159 225 my $peer = $self->{state}{conns}{$conn_id}{sid};
160 $self->send_output(
161 225 @{ $self->_daemon_peer_squit($conn_id, $peer, $errstr) }
162 );
163 }
164 elsif ($self->_connection_is_client($conn_id)) {
165 $self->send_output(
166 214 @{ $self->_daemon_cmd_quit(
167 $self->_client_nickname($conn_id,$errstr ),
168 $errstr,
169 )}
170 );
171 }
172  
173 482 delete $self->{state}{conns}{$conn_id};
174 482 return PCSI_EAT_CLIENT;
175 }
176  
177 2 ▶sub IRCD_compressed_conn {
Subroutine IRCD_compressed_conn: called CC=1 SCAR=0.0
Pod undocumented
178 2 my ($self, $ircd) = splice @_, 0, 2;
179 2 pop @_;
180 2 my ($conn_id) = map { ${ $_ } } @_;
181 2 $self->_state_send_burst($conn_id);
182 2 return PCSI_EAT_CLIENT;
183 }
184  
185 0 ▶sub IRCD_raw_input {
Subroutine IRCD_raw_input: not called CC=2 SCAR=17.9
Pod undocumented
186 0 my ($self, $ircd) = splice @_, 0, 2;
187 0 ▶ return PCSI_EAT_CLIENT if !$self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"debug"} 0 0 0
188 0 my $conn_id = ${ $_[0] };
189 0 my $input = ${ $_[1] };
190 0 warn "<<< $conn_id: $input\n";
191 0 return PCSI_EAT_CLIENT;
192 }
193  
194 0 ▶sub IRCD_raw_output {
Subroutine IRCD_raw_output: not called CC=2 SCAR=17.9
Pod undocumented
195 0 my ($self, $ircd) = splice @_, 0, 2;
196 0 ▶ return PCSI_EAT_CLIENT if !$self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"debug"} 0 0 0
197 0 my $conn_id = ${ $_[0] };
198 0 my $output = ${ $_[1] };
199 0 warn ">>> $conn_id: $output\n";
200 0 return PCSI_EAT_CLIENT;
201 }
202  
203 13317 ▶sub _default {
Subroutine _default: called CC=7 SCAR=19.5
204 13317 my ($self, $ircd, $event) = splice @_, 0, 3;
205 13317 ▶ return PCSI_EAT_NONE if $event !~ /^IRCD_cmd_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $event =~ /^IRCD_cmd_/ 9191 4126 13317
206 4126 pop @_;
207 4126 my ($conn_id, $input) = map { $$_ } @_;
208  
209 4126 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4126 4126
210 4126 ▶ return PCSI_EAT_CLIENT if $self->_connection_terminated($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_terminated($conn_id) 21 4105 4126
211 4105 $self->{state}{conns}{$conn_id}{seen} = time;
212  
213 4105 ▶ if (!$self->_connection_registered($conn_id)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $self->_connection_registered($conn_id)) { } 1421 2684 4105
elsif ($self->_connection_is_peer($conn_id)) { } 1893 791 2684
elsif ($self->_connection_is_client($conn_id)) { } 791 0 791
214 1421 $self->_cmd_from_unknown($conn_id, $input);
215 }
216 elsif ($self->_connection_is_peer($conn_id)) {
217 1893 $self->_cmd_from_peer($conn_id, $input);
218 }
219 elsif ($self->_connection_is_client($conn_id)) {
220 791 delete $input->{prefix};
221 791 $self->_cmd_from_client($conn_id, $input);
222 }
223  
224 4105 return PCSI_EAT_CLIENT;
225 }
226  
227 242 ▶sub _auth_finished {
Subroutine _auth_finished: called CC=3 SCAR=11.4
228 242 my $self = shift;
229 242 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2420
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
230 242 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 242 242
231 242 return $self->{state}{conns}{$conn_id}{auth};
232 }
233  
234 22860 ▶sub _connection_exists {
Subroutine _connection_exists: called CC=3 SCAR=11.0
235 22860 my $self = shift;
236 22860 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
228600
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
237 22860 ▶ return if !defined $self->{state}{conns}{$conn_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"conns"}{$conn_id} 523 22337 22860
238 22337 return 1;
239 }
240  
241 4636 ▶sub _connection_terminated {
Subroutine _connection_terminated: called CC=4 SCAR=14.2
242 4636 my $self = shift;
243 4636 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
46360
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
244 4636 ▶ return if !defined $self->{state}{conns}{$conn_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"conns"}{$conn_id} 0 4636 4636
245 4636 ▶ return 1 if defined $self->{state}{conns}{$conn_id}{terminated};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"conns"}{$conn_id}{"terminated"} 21 4615 4636
246 }
247  
248 1053 ▶sub _client_register {
Subroutine _client_register: called CC=25 SCAR=33.8
249 1053 my $self = shift;
250 1053 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
251 1053 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 1053 1053
252 1053 ▶ return if !$self->{state}{conns}{$conn_id}{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"nick"} 558 495 1053
253 495 ▶ return if !$self->{state}{conns}{$conn_id}{user};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"user"} 243 252 495
254 252 ▶ return if $self->{state}{conns}{$conn_id}{capneg};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"capneg"} 10 242 252
255 242 my $server = $self->server_name();
256  
257 242 my $auth = $self->_auth_finished($conn_id);
258 242 ▶ return if !$auth;
Branch: 1 branch
BranchTrueFalseTotal
unless $auth 0 242 242
259 # pass required for link
260 242 ▶ if (!$self->_state_auth_client_conn($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_state_auth_client_conn($conn_id)) 5 237 242
261 5 my $crec = $self->{state}{conns}{$conn_id};
262 $self->_send_to_realops(
263 sprintf(
264 'Unauthorized client connection from %s!%s@%s on [%s/%u].',
265 $crec->{nick}, $crec->{user}, $crec->{socket}[0],
266 5 $crec->{socket}[2], $crec->{socket}[3],
267 ),
268 'Notice', 'u',
269 );
270 5 $self->_terminate_conn_error(
271 $conn_id,
272 'You are not authorized to use this server',
273 );
274 5 return;
275 }
276 237 ▶ if ($self->{auth}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"auth"}) 1 236 237
277 1 ▶ if ( $self->{state}{conns}{$conn_id}{need_ident} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"conns"}{$conn_id}{"need_ident"} and not $self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"}) 1 0 1
Condition33%1/3
$self->{"state"}{"conns"}{$conn_id}{"need_ident"} and not $self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"}
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"state"}{"conns"}{$conn_id}{"need_ident"} and not $self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"}
$self->{"state"}{"conns"}{$conn_id}{"need_ident"} not $self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"}
Truth table33%1/3
A and not(B)
A= $self->{"state"}{"conns"}{$conn_id}{"need_ident"}B= not $self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"}
ABresult
0X0
100
111
278 !$self->{state}{conns}{$conn_id}{auth}{ident} ) {
279 1 $self->_send_output_to_client(
280 $conn_id,
281 {
282 prefix => $server,
283 command => 'NOTICE',
284 params => [
285 '*',
286 '*** Notice -- You need to install identd to use this server',
287 ],
288 },
289 );
290 1 $self->_terminate_conn_error(
291 $conn_id,
292 'Install identd',
293 );
294 1 return;
295 }
296 }
297 236 ▶ if (my $reason = $self->_state_user_matches_xline($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $self->_state_user_matches_xline($conn_id)) 5 231 236
298 5 my $crec = $self->{state}{conns}{$conn_id};
299 $self->_send_to_realops(
300 sprintf(
301 'X-line Rejecting [%s] [%s], user %s!%s@%s [%s]',
302 $crec->{ircname}, $reason,
303 $crec->{nick}, $crec->{user},
304 ( $crec->{auth}{hostname} || $crec->{socket}[0] ),
305 5 ▶ $crec->{socket}[0],
Condition33%1/3
$crec->{'auth'}{'hostname'} || $crec->{'socket'}[0]
l!l&&r!l&&!r
050
MC/DC0%0/2
$crec->{'auth'}{'hostname'} || $crec->{'socket'}[0]
$crec->{'auth'}{'hostname'} $crec->{'socket'}[0]
Truth table33%1/3
A || B
A= $crec->{'auth'}{'hostname'}B= $crec->{'socket'}[0]
ABresult
1X1
011
000
306 ),
307 'Notice',
308 'j',
309 );
310 5 $self->_send_output_to_client( $conn_id, '465' );
311 5 $self->_terminate_conn_error($conn_id, "X-Lined: [$reason]");
312 5 return;
313 }
314 231 ▶ if (my $reason = $self->_state_user_matches_kline($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $self->_state_user_matches_kline($conn_id)) 5 226 231
315 5 $self->_send_output_to_client( $conn_id, '465' );
316 5 $self->_terminate_conn_error($conn_id, "K-Lined: [$reason]");
317 5 return;
318 }
319 226 ▶ if (my $reason = $self->_state_user_matches_rkline($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $self->_state_user_matches_rkline($conn_id)) 2 224 226
320 2 $self->_send_output_to_client( $conn_id, '465' );
321 2 $self->_terminate_conn_error($conn_id, "K-Lined: [$reason]");
322 2 return;
323 }
324  
325 224 ▶ if ( !$self->{state}{conns}{$conn_id}{auth}{ident} &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"} or $self->{"state"}{"conns"}{$conn_id}{"user"} =~ /$user_re/) 0 224 224
Condition66%2/3
$self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"} or $self->{"state"}{"conns"}{$conn_id}{"user"} =~ /$user_re/
l!l&&r!l&&!r
12230
MC/DC0%0/2
$self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"} or $self->{"state"}{"conns"}{$conn_id}{"user"} =~ /$user_re/
$self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"} $self->{"state"}{"conns"}{$conn_id}{"user"} =~ /$user_re/
Truth table66%2/3
A or B
A= $self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"}B= $self->{"state"}{"conns"}{$conn_id}{"user"} =~ /$user_re/
ABresult
1X1
011
000
326 $self->{state}{conns}{$conn_id}{user} !~ $user_re ) {
327 0 my $crec = $self->{state}{conns}{$conn_id};
328 $self->_send_to_realops(
329 sprintf(
330 'Invalid username: %s (%s@%s)',
331 $crec->{nick}, $crec->{user},
332 0 ▶ ( $crec->{auth}{hostname} || $crec->{socket}[0] ),
Condition0%0/3
$crec->{'auth'}{'hostname'} || $crec->{'socket'}[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$crec->{'auth'}{'hostname'} || $crec->{'socket'}[0]
$crec->{'auth'}{'hostname'} $crec->{'socket'}[0]
Truth table0%0/3
A || B
A= $crec->{'auth'}{'hostname'}B= $crec->{'socket'}[0]
ABresult
1X1
011
000
333 ),
334 'Notice',
335 'j',
336 );
337 $self->_terminate_conn_error(
338 $conn_id,
339 sprintf(
340 'Invalid username [%s]', $crec->{user},
341 0 ),
342 );
343 0 return;
344 }
345  
346 224 my $clients = keys %{ $self->{state}{sids}{$self->server_sid()}{uids} };
347 224 ▶ if ( $self->{config}{MAXCLIENTS} < $clients + 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"config"}{"MAXCLIENTS"} < $clients + 1) 0 224 224
348 0 my $crec = $self->{state}{conns}{$conn_id};
349 0 ▶ if (!$crec->{exceed_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($crec->{"exceed_limit"}) 0 0 0
350 0 $self->_terminate_conn_error($conn_id,
351 'Sorry, server is full - try later');
352 0 return;
353 }
354 }
355  
356 # Add new nick
357 224 my $uid = $self->_state_register_client($conn_id);
358 224 my $umode = $self->{state}{conns}{$conn_id}{umode};
359 224 my $nick = $self->_client_nickname($conn_id);
360 224 my $port = $self->{state}{conns}{$conn_id}{socket}[3];
361 224 my $version = $self->server_version();
362 224 my $network = $self->server_config('NETWORK');
363 224 my $server_is = "$server\[$server/$port]";
364  
365 224 ▶ if (my $sslinfo = $self->connection_secured($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sslinfo = $self->connection_secured($conn_id)) 5 219 224
366 5 $self->_send_output_to_client(
367 $conn_id,
368 {
369 prefix => $server,
370 command => 'NOTICE',
371 params => [
372 $nick,
373 "*** Connected securely via $sslinfo",
374 ],
375 },
376 );
377 }
378  
379 224 $self->_state_auth_flags_notices($conn_id);
380  
381 224 $self->_send_output_to_client(
382 $conn_id,
383 {
384 prefix => $server,
385 command => '001',
386 params => [
387 $nick,
388 "Welcome to the $network Internet Relay Chat network $nick"
389 ],
390 }
391 );
392 224 $self->_send_output_to_client(
393 $conn_id,
394 {
395 prefix => $server,
396 command => '002',
397 params => [
398 $nick,
399 "Your host is $server_is, running version $version",
400 ],
401 },
402 );
403 224 $self->_send_output_to_client(
404 $conn_id,
405 {
406 prefix => $server,
407 command => '003',
408 params => [$nick, $self->server_created()],
409 },
410 );
411 224 $self->_send_output_to_client(
412 $conn_id,
413 {
414 prefix => $server,
415 command => '004',
416 colonify => 0,
417 params => [
418 $nick,
419 $server,
420 $version,
421 'DFGHRSWXabcdefgijklnopqrsuwy',
422 'biklmnopstveIh',
423 'bkloveIh',
424 ],
425 }
426 );
427  
428 224 for my $output (@{ $self->_daemon_do_isupport($uid) }) {
429 448 $output->{prefix} = $server;
430 448 $output->{params}[0] = $nick;
431 448 $self->_send_output_to_client($conn_id, $output);
432 }
433  
434 224 $self->{state}{conns}{$conn_id}{registered} = 1;
435 224 $self->{state}{conns}{$conn_id}{type} = 'c';
436  
437 224 $self->send_output( $_, $conn_id ) for
438 1333 map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
439 224 @{ $self->_daemon_do_lusers($uid) };
440  
441  
442 224 $self->send_output( $_, $conn_id ) for
443 224 map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
444 224 @{ $self->_daemon_do_motd($uid) };
445  
446 224 ▶ if ( $umode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umode) 5 219 224
447 $self->send_output(
448 {
449 5 prefix => $self->{state}{uids}{$uid}{full}->(),
450 command => 'MODE',
451 params => [ $nick, "+$umode" ],
452 },
453 $conn_id,
454 );
455 }
456  
457 $self->send_event(
458 224 'cmd_mode',
459 $conn_id,
460 {
461 command => 'MODE',
462 params => [$nick, "+i"],
463 },
464 );
465  
466 224 return 1;
467 }
468  
469 4246 ▶sub _connection_registered {
Subroutine _connection_registered: called CC=3 SCAR=11.4
470 4246 my $self = shift;
471 4246 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
42460
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
472 4246 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4246 4246
473 4246 return $self->{state}{conns}{$conn_id}{registered};
474 }
475  
476 6548 ▶sub _connection_is_peer {
Subroutine _connection_is_peer: called CC=5 SCAR=16.2
477 6548 my $self = shift;
478 6548 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
65480
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
479  
480 6548 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 6548 6548
481 6548 ▶ return if !$self->{state}{conns}{$conn_id}{registered};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"registered"} 1517 5031 6548
482 5031 ▶ return 1 if $self->{state}{conns}{$conn_id}{type} eq 'p';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} eq "p" 3068 1963 5031
483 1963 return;
484 }
485  
486 1083 ▶sub _connection_is_client {
Subroutine _connection_is_client: called CC=5 SCAR=16.2
487 1083 my $self = shift;
488 1083 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10830
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
489  
490 1083 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 1083 1083
491 1083 ▶ return if !$self->{state}{conns}{$conn_id}{registered};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"registered"} 43 1040 1083
492 1040 ▶ return 1 if $self->{state}{conns}{$conn_id}{type} eq 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} eq "c" 1034 6 1040
493 6 return;
494 }
495  
496 1421 ▶sub _cmd_from_unknown {
Subroutine _cmd_from_unknown: called CC=49 SCAR=45.5
497 1421 my ($self, $wheel_id, $input) = @_;
498  
499 1421 my $cmd = uc $input->{command};
500 1421 ▶ my $params = $input->{params} || [ ];
Condition100%2/2
$input->{'params'} || []
l!l
14201
MC/DC100%1/1
$input->{'params'} || []
$input->{'params'}
Truth table100%2/2
A
A= $input->{'params'}
Aresult
11
00
501 1421 my $pcount = @$params;
502 1421 my $invalid = 0;
503  
504 SWITCH: {
505 1421 ▶ if ($cmd eq 'ERROR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "ERROR") 0 1421 1421
506 0 my $peer = $self->{state}{conns}{$wheel_id}{peer};
507 0 ▶ if (defined $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $peer) 0 0 0
508 0 $self->send_event_next(
509 'daemon_error',
510 $wheel_id,
511 $peer,
512 $params->[0],
513 );
514 }
515 }
516 1421 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 7 1414 1421
517 7 $self->_terminate_conn_error($wheel_id, 'Client Quit');
518 7 last SWITCH;
519 }
520  
521 1414 ▶ if ($cmd eq 'CAP' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAP") 141 1273 1414
522 141 $self->_daemon_cmd_cap($wheel_id, @$params);
523 141 last SWITCH;
524 }
525  
526 # PASS or NICK cmd but no parameters.
527 1273 ▶ if ($cmd =~ /^(PASS|NICK|SERVER)$/ && !$pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount) 0 1273 1273
Condition66%2/3
$cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount
!ll&&!rl&&r
5057680
MC/DC0%0/2
$cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount
$cmd =~ /^(PASS|NICK|SERVER)$/ not $pcount
Truth table66%2/3
A and not(B)
A= $cmd =~ /^(PASS|NICK|SERVER)$/B= not $pcount
ABresult
0X0
100
111
528 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
529 0 last SWITCH;
530 }
531  
532 # PASS or NICK cmd with one parameter, connection from client
533 1273 ▶ if ($cmd eq 'PASS' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "PASS" and $pcount) 262 1011 1273
Condition66%2/3
$cmd eq "PASS" and $pcount
!ll&&!rl&&r
10110262
MC/DC50%1/2
$cmd eq "PASS" and $pcount
$cmd eq "PASS" $pcount
Truth table66%2/3
A and B
A= $cmd eq "PASS"B= $pcount
ABresult
0X0
100
111
534 262 $self->{state}{conns}{$wheel_id}{lc $cmd} = $params->[0];
535  
536 262 ▶ if ($params->[1] && $params->[1] =~ /TS$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->[1] and $params->[1] =~ /TS$/) 260 2 262
Condition66%2/3
$params->[1] and $params->[1] =~ /TS$/
!ll&&!rl&&r
20260
MC/DC50%1/2
$params->[1] and $params->[1] =~ /TS$/
$params->[1] $params->[1] =~ /TS$/
Truth table66%2/3
A and B
A= $params->[1]B= $params->[1] =~ /TS$/
ABresult
0X0
100
111
537 260 $self->{state}{conns}{$wheel_id}{ts_server} = 1;
538 260 $self->antiflood($wheel_id, 0);
539  
540 # TS6 server
541 # PASS password TS 6 6FU
542 260 ▶ if ($params->[2] && $params->[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->[2] and $params->[3]) { } 259 1 260
Condition66%2/3
$params->[2] and $params->[3]
!ll&&!rl&&r
10259
MC/DC50%1/2
$params->[2] and $params->[3]
$params->[2] $params->[3]
Truth table66%2/3
A and B
A= $params->[2]B= $params->[3]
ABresult
0X0
100
111
543 259 $self->{state}{conns}{$wheel_id}{ts_data} = [ @{$params}[2,3] ];
544 259 my $ts = $params->[2];
545 259 my $sid = $params->[3];
546 259 my $errstr;
547 259 ▶ if ($sid !~ $sid_re || $ts ne '6') {
Branch: 2 branches
BranchTrueFalseTotal
if (not $sid =~ /$sid_re/ or $ts ne '6') { } 1 258 259
elsif ($self->state_sid_exists($sid)) { } 1 257 258
Condition66%2/3
not $sid =~ /$sid_re/ or $ts ne 6
l!l&&r!l&&!r
10258
MC/DC50%1/2
not $sid =~ /$sid_re/ or $ts ne 6
not $sid =~ /$sid_re/ $ts ne 6
Truth table66%2/3
not(A) or B
A= not $sid =~ /$sid_re/B= $ts ne 6
ABresult
1X1
011
000
548 1 my $crec = $self->{state}{conns}{$wheel_id};
549 $self->_send_to_realops(
550 sprintf(
551 'Link [unknown@%s] introduced server with bogus server ID %s',
552 1 $crec->{socket}[0], $sid,
553 ), qw[Notice s],
554 );
555 1 $errstr = 'Bogus server ID introduced';
556 }
557 elsif ($self->state_sid_exists( $sid )) {
558 1 my $crec = $self->{state}{conns}{$wheel_id};
559 $self->_send_to_realops(
560 sprintf(
561 'Attempt to re-introduce server %s SID %s from [unknown@%s]',
562 1 $self->_state_sid_name($sid), $sid, $crec->{socket}[0],
563 ), qw[Notice s],
564 );
565 1 $errstr = 'Server ID already exists';
566 }
567 259 ▶ if ($errstr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errstr) 2 257 259
568 2 $self->_terminate_conn_error($wheel_id, $errstr);
569 2 last SWITCH;
570 }
571 }
572 else {
573 1 $self->_terminate_conn_error($wheel_id, 'Incompatible TS version' );
574 1 last SWITCH;
575 }
576 }
577 259 last SWITCH;
578 }
579  
580 # SERVER stuff.
581 1011 ▶ if ($cmd eq 'CAPAB' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAPAB" and $pcount) 257 754 1011
Condition66%2/3
$cmd eq "CAPAB" and $pcount
!ll&&!rl&&r
7540257
MC/DC50%1/2
$cmd eq "CAPAB" and $pcount
$cmd eq "CAPAB" $pcount
Truth table66%2/3
A and B
A= $cmd eq "CAPAB"B= $pcount
ABresult
0X0
100
111
582 $self->{state}{conns}{$wheel_id}{capab}
583 257 = [split /\s+/, $params->[0]];
584 257 last SWITCH;
585 }
586 754 ▶ if ($cmd eq 'SERVER' && $pcount < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SERVER" and $pcount < 2) 0 754 754
Condition66%2/3
$cmd eq "SERVER" and $pcount < 2
!ll&&!rl&&r
4972570
MC/DC0%0/2
$cmd eq "SERVER" and $pcount < 2
$cmd eq "SERVER" $pcount < 2
Truth table66%2/3
A and B
A= $cmd eq "SERVER"B= $pcount < 2
ABresult
0X0
100
111
587 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
588 0 last SWITCH;
589 }
590 754 ▶ if ($cmd eq 'SERVER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SERVER") 257 497 754
591 257 my $conn = $self->{state}{conns}{$wheel_id};
592 257 $conn->{name} = $params->[0];
593 257 ▶ $conn->{hops} = $params->[1] || 1;
Condition50%1/2
$params->[1] || 1
l!l
2570
MC/DC0%0/1
$params->[1] || 1
$params->[1]
Truth table50%1/2
A
A= $params->[1]
Aresult
11
00
594 257 ▶ $conn->{desc} = $params->[2] || '(unknown location)';
Condition50%1/2
$params->[2] || '(unknown location)'
l!l
2570
MC/DC0%0/1
$params->[2] || '(unknown location)'
$params->[2]
Truth table50%1/2
A
A= $params->[2]
Aresult
11
00
595  
596 257 ▶ if ( $conn->{desc} && $conn->{desc} =~ m!^\(H\) ! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"desc"} and $conn->{"desc"} =~ /^\(H\) /) 0 257 257
Condition33%1/3
$conn->{"desc"} and $conn->{"desc"} =~ /^\(H\) /
!ll&&!rl&&r
02570
MC/DC0%0/2
$conn->{"desc"} and $conn->{"desc"} =~ /^\(H\) /
$conn->{"desc"} $conn->{"desc"} =~ /^\(H\) /
Truth table33%1/3
A and B
A= $conn->{"desc"}B= $conn->{"desc"} =~ /^\(H\) /
ABresult
0X0
100
111
597 0 $conn->{hidden} = 1;
598 0 $conn->{desc} =~ s!^\(H\) !!;
599 }
600  
601 257 ▶ if (!$conn->{ts_server}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn->{"ts_server"}) 0 257 257
602 0 $self->_terminate_conn_error($wheel_id, 'Non-TS server.');
603 0 last SWITCH;
604 }
605 my $result = $self->_state_auth_peer_conn($wheel_id,
606 257 $conn->{name}, $conn->{pass});
607 257 ▶ if (!$result || $result <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result or $result <= 0) 2 255 257
Condition66%2/3
not $result or $result <= 0
l!l&&r!l&&!r
02255
MC/DC50%1/2
not $result or $result <= 0
not $result $result <= 0
Truth table66%2/3
not(A) or B
A= not $resultB= $result <= 0
ABresult
1X1
011
000
608 2 my $errstr; my $snotice;
609 2 ▶ if (!defined $result || $result == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $result or $result == 0) { } 0 2 2
elsif ($result == -1) { } 1 1 2
elsif ($result == -2) { } 1 0 1
Condition33%1/3
not defined $result or $result == 0
l!l&&r!l&&!r
002
MC/DC0%0/2
not defined $result or $result == 0
not defined $result $result == 0
Truth table33%1/3
not(A) or B
A= not defined $resultB= $result == 0
ABresult
1X1
011
000
610 0 $snotice = 'No entry for';
611 0 $errstr = 'No connect {} block.';
612 }
613 elsif ($result == -1) {
614 1 $snotice = 'Bad password';
615 1 $errstr = 'Invalid password.';
616 }
617 elsif ($result == -2) {
618 1 $snotice = 'Invalid certificate fingerprint';
619 1 $errstr = 'Invalid certificate fingerprint.';
620 }
621 else {
622 0 $snotice = 'Invalid host';
623 0 $errstr = 'Invalid host.';
624 }
625 $self->_send_to_realops(
626 sprintf(
627 'Unauthorized server connection attempt from [unknown@%s]: %s for server %s',
628 $conn->{socket}[0], $snotice, $conn->{name},
629 2 ),
630 'Notice', 's',
631 );
632 2 $self->_terminate_conn_error(
633 $wheel_id,
634 $errstr,
635 );
636 2 last SWITCH;
637 }
638 255 ▶ if ($self->state_peer_exists($conn->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($conn->{"name"})) 0 255 255
639 $self->_send_to_realops(
640 sprintf(
641 'Attempt to re-introduce server %s from [unknown@%s]',
642 0 $conn->{name}, $conn->{socket}[0],
643 ), qw[Notice s],
644 );
645 0 $self->_terminate_conn_error($wheel_id, 'Server exists.');
646 0 last SWITCH;
647 }
648 255 $self->_state_register_peer($wheel_id);
649  
650 255 ▶ if ($conn->{zip} && grep { $_ eq 'ZIP' } @{ $conn->{capab} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{'zip'} and grep {$_ eq 'ZIP';} @{$$conn{'capab'};}) { } 2 253 255
Condition100%3/3
$conn->{"zip"} and grep {$_ eq "ZIP";} @{$$conn{"capab"};}
!ll&&!rl&&r
42492
MC/DC100%2/2
$conn->{"zip"} and grep {$_ eq "ZIP";} @{$$conn{"capab"};}
$conn->{"zip"} grep {$_ eq "ZIP";} @{$$conn{"capab"};}
Truth table100%3/3
A and B
A= $conn->{"zip"}B= grep {$_ eq "ZIP";} @{$$conn{"capab"};}
ABresult
0X0
100
111
651 2 $self->compressed_link($wheel_id, 1, $conn->{cntr});
652 }
653 else {
654 253 $self->_state_send_burst($wheel_id);
655 }
656  
657 $self->send_event(
658 "daemon_capab",
659 $conn->{name},
660 255 @{ $conn->{capab} },
661 );
662 255 last SWITCH;
663 }
664  
665 497 ▶ if ($cmd eq 'NICK' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "NICK" and $pcount) 249 248 497
Condition66%2/3
$cmd eq "NICK" and $pcount
!ll&&!rl&&r
2480249
MC/DC50%1/2
$cmd eq "NICK" and $pcount
$cmd eq "NICK" $pcount
Truth table66%2/3
A and B
A= $cmd eq "NICK"B= $pcount
ABresult
0X0
100
111
666 249 my $nicklen = $self->server_config('NICKLEN');
667 249 ▶ if (length($params->[0]) > $nicklen) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $params->[0] > $nicklen) 0 249 249
668 0 $params->[0] = substr($params->[0], 0, $nicklen);
669 }
670  
671 249 ▶ if (!is_valid_nick_name($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_nick_name($params->[0])) 0 249 249
672 0 $self->_send_output_to_client(
673 $wheel_id,
674 '432',
675 $params->[0],
676 );
677 0 last SWITCH;
678 }
679  
680 249 ▶ if ($self->state_nick_exists($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($params->[0])) 1 248 249
681 1 $self->_send_output_to_client(
682 $wheel_id,
683 '433',
684 $params->[0],
685 );
686 1 last SWITCH;
687 }
688  
689 248 ▶ if ( my $reason = $self->_state_is_resv( $params->[0], $wheel_id ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $self->_state_is_resv($params->[0], $wheel_id)) 5 243 248
690 5 $self->_send_output_to_client(
691 $wheel_id, {
692 prefix => $self->server_name(),
693 command => '432',
694 params => [
695 '*',
696 $params->[0],
697 $reason,
698 ],
699 }
700 );
701 5 last SWITCH;
702 }
703  
704 243 $self->{state}{conns}{$wheel_id}{lc $cmd} = $params->[0];
705 243 $self->{state}{pending}{uc_irc($params->[0])} = $wheel_id;
706 243 $self->_client_register($wheel_id);
707 243 last SWITCH;
708 }
709 248 ▶ if ($cmd eq 'USER' && $pcount < 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "USER" and $pcount < 4) 0 248 248
Condition33%1/3
$cmd eq "USER" and $pcount < 4
!ll&&!rl&&r
02480
MC/DC0%0/2
$cmd eq "USER" and $pcount < 4
$cmd eq "USER" $pcount < 4
Truth table33%1/3
A and B
A= $cmd eq "USER"B= $pcount < 4
ABresult
0X0
100
111
710 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
711 0 last SWITCH;
712 }
713 248 ▶ if ($cmd eq 'USER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "USER") 248 0 248
714 248 $self->{state}{conns}{$wheel_id}{user} = $params->[0];
715 248 ▶ $self->{state}{conns}{$wheel_id}{ircname} = $params->[3] || '';
Condition50%1/2
$params->[3] || ''
l!l
2480
MC/DC0%0/1
$params->[3] || ''
$params->[3]
Truth table50%1/2
A
A= $params->[3]
Aresult
11
00
716 248 $self->_client_register($wheel_id);
717 248 last SWITCH;
718 }
719  
720 0 ▶ last SWITCH if $self->{state}{conns}{$wheel_id}{cntr};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$wheel_id}{"cntr"} 0 0 0
721 0 $invalid = 1;
722 0 $self->_send_output_to_client($wheel_id, '451');
723 }
724  
725 1421 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 1421 1421
726 1421 $self->_state_cmd_stat($cmd, $input->{raw_line});
727 1421 return 1;
728 }
729  
730 1893 ▶sub _cmd_from_peer {
Subroutine _cmd_from_peer: called CC=28 SCAR=34.5
731 1893 my ($self, $conn_id, $input) = @_;
732  
733 1893 my $cmd = uc $input->{command};
734 1893 my $params = $input->{params};
735 1893 my $prefix = $input->{prefix};
736 1893 my $sid = $self->server_sid();
737 1893 my $invalid = 0;
738  
739 SWITCH: {
740 1893 my $method = '_daemon_peer_' . lc $cmd;
741 1893 ▶ if ($cmd eq 'SQUIT' && !$prefix ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SQUIT" and not $prefix) 1 1892 1893
Condition66%2/3
$cmd eq "SQUIT" and not $prefix
!ll&&!rl&&r
189201
MC/DC50%1/2
$cmd eq "SQUIT" and not $prefix
$cmd eq "SQUIT" not $prefix
Truth table66%2/3
A and not(B)
A= $cmd eq "SQUIT"B= not $prefix
ABresult
0X0
100
111
742 1 $self->_daemon_peer_squit($conn_id, @$params);
743 #$self->_send_output_to_client(
744 # $conn_id,
745 # $prefix,
746 # (ref $_ eq 'ARRAY' ? @{ $_ } : $_)
747 #) for $self->_daemon_cmd_squit($prefix, @$params);
748 1 last SWITCH;
749 }
750  
751 1892 ▶ if ($cmd =~ /\d{3}/ && $params->[0] !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\d{3}/ and not $params->[0] =~ /^$sid/) 0 1892 1892
Condition66%2/3
$cmd =~ /\d{3}/ and not $params->[0] =~ /^$sid/
!ll&&!rl&&r
1881110
MC/DC0%0/2
$cmd =~ /\d{3}/ and not $params->[0] =~ /^$sid/
$cmd =~ /\d{3}/ not $params->[0] =~ /^$sid/
Truth table66%2/3
A and not(B)
A= $cmd =~ /\d{3}/B= not $params->[0] =~ /^$sid/
ABresult
0X0
100
111
752 0 $self->send_output(
753 $input,
754 $self->_state_uid_route($params->[0]),
755 );
756 0 last SWITCH;
757 }
758 1892 ▶ if ($cmd =~ /\d{3}/ && $params->[0] =~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\d{3}/ and $params->[0] =~ /^$sid/) 11 1881 1892
Condition66%2/3
$cmd =~ /\d{3}/ and $params->[0] =~ /^$sid/
!ll&&!rl&&r
1881011
MC/DC50%1/2
$cmd =~ /\d{3}/ and $params->[0] =~ /^$sid/
$cmd =~ /\d{3}/ $params->[0] =~ /^$sid/
Truth table66%2/3
A and B
A= $cmd =~ /\d{3}/B= $params->[0] =~ /^$sid/
ABresult
0X0
100
111
759 11 $input->{prefix} = $self->_state_sid_name($prefix);
760 11 my $uid = $params->[0];
761 11 $input->{params}[0] = $self->state_user_nick($uid);
762 11 $self->send_output(
763 $input,
764 $self->_state_uid_route($uid),
765 );
766 11 last SWITCH;
767 }
768 1881 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 4 1877 1881
769 $self->send_output(
770 4 @{ $self->_daemon_peer_quit(
771 $prefix, @$params, $conn_id
772 )}
773 );
774 4 last SWITCH;
775 }
776  
777 1877 ▶ if ($cmd =~ /^(PRIVMSG|NOTICE)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PRIVMSG|NOTICE)$/) 7 1870 1877
778 $self->_send_output_to_client(
779 $conn_id,
780 $prefix,
781 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_)
782 7 ▶ ) for $self->_daemon_peer_message(
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
783 $conn_id,
784 $prefix,
785 $cmd,
786 @$params
787 );
788 7 last SWITCH;
789 }
790  
791 1870 ▶ if ($cmd =~ /^(VERSION|TIME|LINKS|ADMIN|INFO|MOTD|STATS)$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(VERSION|TIME|LINKS|ADMIN|INFO|MOTD|STATS)$/i) 6 1864 1870
792 6 my $client_method = '_daemon_peer_miscell';
793 6 ▶ $client_method = '_daemon_peer_links' if $cmd eq 'LINKS';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "LINKS" 1 5 6
794 $self->_send_output_to_client(
795 $conn_id,
796 $prefix,
797 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_ )
798 6 ▶ ) for $self->$client_method($cmd, $prefix, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 34 34
799 6 last SWITCH;
800 }
801  
802 1864 ▶ if ($cmd =~ /^(PING|PONG)$/i && $self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PING|PONG)$/i and $self->can($method)) 253 1611 1864
Condition66%2/3
$cmd =~ /^(PING|PONG)$/i and $self->can($method)
!ll&&!rl&&r
16110253
MC/DC50%1/2
$cmd =~ /^(PING|PONG)$/i and $self->can($method)
$cmd =~ /^(PING|PONG)$/i $self->can($method)
Truth table66%2/3
A and B
A= $cmd =~ /^(PING|PONG)$/iB= $self->can($method)
ABresult
0X0
100
111
803 253 $self->$method($conn_id, $prefix, @{ $params });
804 253 last SWITCH;
805 }
806  
807 1611 ▶ if ($cmd =~ /^SVINFO$/i && $self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^SVINFO$/i and $self->can($method)) 255 1356 1611
Condition66%2/3
$cmd =~ /^SVINFO$/i and $self->can($method)
!ll&&!rl&&r
13560255
MC/DC50%1/2
$cmd =~ /^SVINFO$/i and $self->can($method)
$cmd =~ /^SVINFO$/i $self->can($method)
Truth table66%2/3
A and B
A= $cmd =~ /^SVINFO$/iB= $self->can($method)
ABresult
0X0
100
111
808 255 $self->$method($conn_id, @$params);
809 255 my $conn = $self->{state}{conns}{$conn_id};
810 $self->send_event(
811 "daemon_svinfo",
812 $conn->{name},
813 255 @$params,
814 );
815 255 last SWITCH;
816 }
817  
818 1356 ▶ if ( $cmd =~ m!^E?TRACE$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^E?TRACE$/i) 4 1352 1356
819 4 $self->send_output( $_, $conn_id ) for
820 $self->_daemon_peer_tracing($cmd, $conn_id, $prefix, @$params);
821 4 last SWITCH;
822 }
823  
824 # Chanmode and umode have distinct commands now
825 # No need for check, MODE is always umode
826 1352 ▶ if ($cmd eq 'MODE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "MODE") 0 1352 1352
827 0 $method = '_daemon_peer_umode';
828 }
829  
830 1352 ▶ if ($cmd =~ m!^(UN)?([DKX]LINE|RESV)$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(UN)?([DKX]LINE|RESV)$/i) 12 1340 1352
831 12 $self->send_output( $_, $conn_id ) for
832 $self->$method($conn_id, $prefix, @$params);
833 12 last SWITCH;
834 }
835  
836 1340 ▶ if ($cmd =~ m!^WHO(IS|WAS)$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^WHO(IS|WAS)$/i) 4 1336 1340
837 4 $self->send_output( $_, $conn_id ) for
838 $self->$method($conn_id, $prefix, @$params);
839 4 last SWITCH;
840 }
841  
842 1336 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 1336 0 1336
843 1336 $self->$method($conn_id, $prefix, @$params);
844 1336 last SWITCH;
845 }
846 0 $invalid = 1;
847 }
848  
849 1893 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 1893 1893
850 1893 $self->_state_cmd_stat($cmd, $input->{raw_line}, 1);
851 1893 return 1;
852 }
853  
854 791 ▶sub _cmd_from_client {
Subroutine _cmd_from_client: called CC=40 SCAR=38.1
855 791 my ($self, $wheel_id, $input) = @_;
856  
857 791 my $cmd = uc $input->{command};
858 791 ▶ my $params = $input->{params} || [ ];
Condition100%2/2
$input->{'params'} || []
l!l
73556
MC/DC100%1/1
$input->{'params'} || []
$input->{'params'}
Truth table100%2/2
A
A= $input->{'params'}
Aresult
11
00
859 791 my $pcount = @$params;
860 791 my $server = $self->server_name();
861 791 my $nick = $self->_client_nickname($wheel_id);
862 791 my $uid = $self->_client_uid($wheel_id);
863 791 my $invalid = 0;
864 791 my $pseudo = 0;
865  
866 SWITCH: {
867 791 my $method = '_daemon_cmd_' . lc $cmd;
868 791 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 197 594 791
869 197 my $qmsg = $params->[0];
870 197 delete $self->{state}{localops}{ $wheel_id };
871 197 ▶ if ( $qmsg and my $msgtime = $self->{config}{anti_spam_exit_message_time} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($qmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}) 7 190 197
Condition100%3/3
$qmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
!ll&&!rl&&r
261647
MC/DC100%2/2
$qmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
$qmsg my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
Truth table100%3/3
A and B
A= $qmsgB= my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
ABresult
0X0
100
111
872 $qmsg = '' if
873 7 ▶ time - $self->{state}{conns}{$wheel_id}->{conn_time} < $msgtime;
Branch: 1 branch
BranchTrueFalseTotal
if time - $self->{"state"}{"conns"}{$wheel_id}{"conn_time"} < $msgtime 7 0 7
874 }
875 $self->_terminate_conn_error(
876 197 ▶ $wheel_id,
Branch: 1 branch
BranchTrueFalseTotal
$qmsg ? : 164 33 197
877 ($qmsg ? qq{Quit: "$qmsg"} : 'Client Quit'),
878 );
879 197 last SWITCH;
880 }
881  
882 594 ▶ if ($cmd =~ /^(USERHOST|MODE)$/ && !$pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(USERHOST|MODE)$/ and not $pcount) 0 594 594
Condition66%2/3
$cmd =~ /^(USERHOST|MODE)$/ and not $pcount
!ll&&!rl&&r
3122820
MC/DC0%0/2
$cmd =~ /^(USERHOST|MODE)$/ and not $pcount
$cmd =~ /^(USERHOST|MODE)$/ not $pcount
Truth table66%2/3
A and not(B)
A= $cmd =~ /^(USERHOST|MODE)$/B= not $pcount
ABresult
0X0
100
111
883 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
884 0 last SWITCH;
885 }
886 594 ▶ if ($cmd =~ /^(USERHOST)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(USERHOST)$/) 1 593 594
887 $self->_send_output_to_client($wheel_id, $_)
888 1 ▶ for $self->$method(
Branch: 1 branch
BranchTrueFalseTotal
$pcount <= 5 ? : 1 0 1
889 $nick,
890 ($pcount <= 5
891 ? @$params
892 0 : @{ $params }[0..5]
893 )
894 );
895 1 last SWITCH;
896 }
897  
898 593 ▶ if ($cmd =~ /^(PRIVMSG|NOTICE)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PRIVMSG|NOTICE)$/) 30 563 593
899 30 $self->{state}{conns}{$wheel_id}{idle_time} = time;
900 $self->_send_output_to_client(
901 $wheel_id,
902 7 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
903 30 ▶ ) for $self->_daemon_cmd_message($nick, $cmd, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 7 2 9
904 30 last SWITCH;
905 }
906  
907 563 ▶ if ($cmd eq 'MODE' && $self->state_nick_exists($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "MODE" and $self->state_nick_exists($params->[0])) 228 335 563
Condition100%3/3
$cmd eq "MODE" and $self->state_nick_exists($params->[0])
!ll&&!rl&&r
28253228
MC/DC100%2/2
$cmd eq "MODE" and $self->state_nick_exists($params->[0])
$cmd eq "MODE" $self->state_nick_exists($params->[0])
Truth table100%3/3
A and B
A= $cmd eq "MODE"B= $self->state_nick_exists($params->[0])
ABresult
0X0
100
111
908 228 ▶ if (uc_irc($nick) ne uc_irc($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc_irc($nick) ne uc_irc($params->[0])) 0 228 228
909 0 $self->_send_output_to_client($wheel_id => '502');
910 0 last SWITCH;
911 }
912  
913 1 $self->_send_output_to_client($wheel_id, (ref $_ eq 'ARRAY' ? @{ $_ } : $_) )
914 228 ▶ for $self->_daemon_cmd_umode($nick, @{ $params }[1..$#{ $params }]);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 227 228
915 228 last SWITCH;
916 }
917  
918 335 ▶ if ($cmd eq 'CAP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAP") 0 335 335
919 0 $self->_daemon_cmd_cap($wheel_id, @$params);
920 0 last SWITCH;
921 }
922  
923 335 ▶ if ( $cmd =~ m!^(ADMIN|INFO|VERSION|TIME|MOTD)$! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(ADMIN|INFO|VERSION|TIME|MOTD)$/) 6 329 335
924 $self->_send_output_to_client(
925 $wheel_id,
926 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
927 6 ▶ ) for $self->_daemon_client_miscell($cmd, $nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 30 30
928 6 last SWITCH;
929 }
930  
931 329 ▶ if ( $cmd =~ m!^E?TRACE$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^E?TRACE$/i) 6 323 329
932 $self->_send_output_to_client(
933 $wheel_id,
934 1 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
935 6 ▶ ) for $self->_daemon_client_tracing($cmd, $nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 17 18
936 6 last SWITCH;
937 }
938  
939 323 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 319 4 323
940 $self->_send_output_to_client(
941 $wheel_id,
942 33 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
943 319 ▶ ) for $self->$method($nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 33 314 347
944 319 last SWITCH;
945 }
946  
947 4 ▶ if (defined $self->{config}{pseudo}{$cmd}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"config"}{"pseudo"}{$cmd}) 3 1 4
948 3 $pseudo = 1;
949 3 my $pseudo = $self->{config}{pseudo}{$cmd};
950 3 ▶ if (!$params->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params->[0]) 1 2 3
951 1 $self->_send_output_to_client($wheel_id, '412');
952 1 last SWITCH;
953 }
954 2 my $targ = $self->state_user_nick($pseudo->{nick});
955 2 my $serv = $self->_state_peer_name($pseudo->{host});
956 2 ▶ if ( !$targ || !$serv ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ and $serv) 1 1 2
Condition66%2/3
$targ and $serv
!ll&&!rl&&r
101
MC/DC50%1/2
$targ and $serv
$targ $serv
Truth table66%2/3
A and B
A= $targB= $serv
ABresult
0X0
100
111
957 1 $self->_send_output_to_client($wheel_id, '440', $pseudo->{name});
958 1 last SWITCH;
959 }
960 1 my $msg;
961 1 ▶ if ($pseudo->{prepend}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudo->{'prepend'}) { } 1 0 1
962 1 ▶ my $join = ($pseudo->{prepend} =~ m! $! ? '' : ' ');
Branch: 1 branch
BranchTrueFalseTotal
$pseudo->{'prepend'} =~ / $/ ? : 0 1 1
963 1 $msg = join $join, $pseudo->{prepend}, $params->[0];
964 }
965 else {
966 0 $msg = $params->[0];
967 }
968 $self->_send_output_to_client(
969 $wheel_id,
970 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
971 1 ▶ ) for $self->_daemon_cmd_message($nick, 'PRIVMSG', $pseudo->{nick}, $msg);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
972 1 last SWITCH;
973 }
974  
975 1 $invalid = 1;
976 1 $self->_send_output_to_client($wheel_id, '421', $cmd);
977 }
978  
979 791 ▶ return 1 if $invalid || $pseudo;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid or $pseudo 4 787 791
Condition100%3/3
$invalid or $pseudo
l!l&&r!l&&!r
13787
MC/DC100%2/2
$invalid or $pseudo
$invalid $pseudo
Truth table100%3/3
A or B
A= $invalidB= $pseudo
ABresult
1X1
011
000
980 787 $self->_state_cmd_stat($cmd, $input->{raw_line});
981 787 return 1;
982 }
983  
984 5 ▶sub _daemon_cmd_help {
Subroutine _daemon_cmd_help: called CC=11 SCAR=24.1
985 5 my $self = shift;
986 5 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
987 5 my $server = $self->server_name();
988 5 my $ref = [ ];
989 5 my $args = [@_];
990 5 my $count = @$args;
991  
992 SWITCH: {
993 5 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 2 3 5
994 2 my $lastuse = $self->{state}{lastuse}{help};
995 2 my $pacewait = $self->{config}{pace_wait};
996 2 ▶ if ( $lastuse && $pacewait && ( $lastuse + $pacewait ) > time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastuse and $pacewait and $lastuse + $pacewait > time) 1 1 2
Condition66%4/6
$lastuse and $pacewait and $lastuse + $pacewait > time
!ll&&!rl&&r
101
$lastuse and $pacewait
!ll&&!rl&&r
101
MC/DC33%1/3
$lastuse and $pacewait and $lastuse + $pacewait > time
$lastuse $pacewait $lastuse + $pacewait > time
Truth table50%2/4
A and B and C
A= $lastuseB= $pacewaitC= $lastuse + $pacewait > time
ABCresult
0XX0
10X0
1100
1111
997 1 push @$ref, ['263', 'HELP'];
998 1 last SWITCH;
999 }
1000 1 $self->{state}{lastuse}{help} = time();
1001 }
1002 4 ▶ my $item = shift @$args || 'index';
Condition100%2/2
shift @$args || 'index'
l!l
22
MC/DC100%1/1
shift @$args || 'index'
shift @$args
Truth table100%2/2
A
A= shift @$args
Aresult
11
00
1003 4 ▶ if (!$self->{_help}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_help"}) 2 2 4
1004 2 require POE::Component::Server::IRC::Help;
1005 2 $self->{_help} = POE::Component::Server::IRC::Help->new();
1006 }
1007 4 $item = lc $item;
1008 4 my @lines = $self->{_help}->topic($item);
1009 4 ▶ if (!scalar @lines) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @lines) 1 3 4
1010 1 push @$ref, [ '524', $item ];
1011 1 last SWITCH;
1012 }
1013 3 my $reply = '704';
1014 3 foreach my $line (@lines) {
1015 43 push @$ref, {
1016 prefix => $server,
1017 command => $reply,
1018 params => [
1019 $nick,
1020 $item,
1021 $line,
1022 ],
1023 };
1024 43 $reply = '705';
1025 }
1026 3 push @$ref, {
1027 prefix => $server,
1028 command => '706',
1029 params => [
1030 $nick,
1031 $item,
1032 'End of /HELP.',
1033 ],
1034 };
1035 }
1036  
1037 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
1038 0 return $ref;
1039 }
1040  
1041 4 ▶sub _daemon_cmd_watch {
Subroutine _daemon_cmd_watch: called CC=31 SCAR=51.9
1042 4 my $self = shift;
1043 4 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1044 4 my $server = $self->server_name();
1045 4 my $ref = [ ];
1046 4 my $args = [@_];
1047 4 my $count = @$args;
1048  
1049 SWITCH: {
1050 4 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 4 4
1051 0 $args->[0] = 'l';
1052 }
1053 4 my $uid = $self->state_user_uid($nick);
1054 4 ▶ my $watches = $self->{state}{uids}{$uid}{watches} || { };
Condition100%2/2
$self->{'state'}{'uids'}{$uid}{'watches'} || {}
l!l
22
MC/DC100%1/1
$self->{'state'}{'uids'}{$uid}{'watches'} || {}
$self->{'state'}{'uids'}{$uid}{'watches'}
Truth table100%2/2
A
A= $self->{'state'}{'uids'}{$uid}{'watches'}
Aresult
11
00
1055 4 my $list = 0;
1056 4 ITEM: foreach my $item ( split m!,!, $args->[0] ) {
1057 6 ▶ if ( $item =~ m!^\+! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^\+/) 4 2 6
1058 4 $item =~ s!^\+!!;
1059 4 ▶ if ( keys %$watches >= $self->{config}{max_watch} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$watches >= $self->{"config"}{"max_watch"}) 0 4 4
1060 0 push @$ref, ['512', $self->{config}{max_watch}];
1061 0 next ITEM;
1062 }
1063 4 ▶ next ITEM if !$item || !is_valid_nick_name($item);
Branch: 1 branch
BranchTrueFalseTotal
unless $item and is_valid_nick_name($item) 0 4 4
Condition33%1/3
$item and is_valid_nick_name($item)
!ll&&!rl&&r
004
MC/DC0%0/2
$item and is_valid_nick_name($item)
$item is_valid_nick_name($item)
Truth table33%1/3
A and B
A= $itemB= is_valid_nick_name($item)
ABresult
0X0
100
111
1064 # Add_to_watch_list
1065 4 $watches->{uc_irc $item} = $item;
1066 4 $self->{state}{watches}{uc_irc $item}{uids}{$uid} = 1;
1067 # Show_watch possible refactor here
1068 4 ▶ if ( my $tuid = $self->state_user_uid($item) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tuid = $self->state_user_uid($item)) { } 0 4 4
1069 0 my $rec = $self->{state}{uids}{$tuid};
1070 push @$ref, {
1071 prefix => $server,
1072 command => '604',
1073 params => [
1074 $nick,
1075 $rec->{nick},
1076 $rec->{auth}{ident},
1077 $rec->{auth}{hostname},
1078 $rec->{ts},
1079 0 'is online',
1080 ],
1081 };
1082 }
1083 else {
1084 4 ▶ my $laston = $self->{state}{watches}{uc_irc $item}{laston} || 0;
Condition50%1/2
$self->{'state'}{'watches'}{uc_irc($item)}{'laston'} || 0
l!l
04
MC/DC0%0/1
$self->{'state'}{'watches'}{uc_irc($item)}{'laston'} || 0
$self->{'state'}{'watches'}{uc_irc($item)}{'laston'}
Truth table50%1/2
A
A= $self->{'state'}{'watches'}{uc_irc($item)}{'laston'}
Aresult
11
00
1085 4 push @$ref, {
1086 prefix => $server,
1087 command => '605',
1088 params => [
1089 $nick, $item, '*', '*', $laston, 'is offline'
1090 ],
1091 };
1092 }
1093 4 next ITEM;
1094 }
1095 2 ▶ if ( $item =~ m!^\-! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^\-/) 0 2 2
1096 0 $item =~ s!^\-!!;
1097 0 ▶ next ITEM if !$item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
1098 0 $item = uc_irc $item;
1099 0 my $pitem = delete $watches->{$item};
1100 0 delete $self->{state}{watches}{$item}{uids}{$uid};
1101 0 ▶ if ( my $tuid = $self->state_user_uid($item) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tuid = $self->state_user_uid($item)) { } 0 0 0
1102 0 my $rec = $self->{state}{uids}{$tuid};
1103 push @$ref, {
1104 prefix => $server,
1105 command => '602',
1106 params => [
1107 $nick,
1108 $rec->{nick},
1109 $rec->{auth}{ident},
1110 $rec->{auth}{hostname},
1111 $rec->{ts},
1112 0 'stopped watching',
1113 ],
1114 };
1115 }
1116 else {
1117 0 ▶ my $laston = $self->{state}{watches}{$item}{laston} || 0;
Condition0%0/2
$self->{'state'}{'watches'}{$item}{'laston'} || 0
l!l
00
MC/DC0%0/1
$self->{'state'}{'watches'}{$item}{'laston'} || 0
$self->{'state'}{'watches'}{$item}{'laston'}
Truth table0%0/2
A
A= $self->{'state'}{'watches'}{$item}{'laston'}
Aresult
11
00
1118 0 push @$ref, {
1119 prefix => $server,
1120 command => '602',
1121 params => [
1122 $nick, $pitem, '*', '*', $laston, 'stopped watching'
1123 ],
1124 };
1125 }
1126 delete $self->{state}{watches}{$item}
1127 0 ▶ if !keys %{ $self->{state}{watches}{$item}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"watches"}{$item}{"uids"};} 0 0 0
1128 0 next ITEM;
1129 }
1130 2 ▶ if ( $item =~ m!^C!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^C/i) 0 2 2
1131 0 foreach my $watched ( keys %$watches ) {
1132 0 delete $self->{state}{watches}{$watched}{uids}{$uid};
1133 delete $self->{state}{watches}{$watched}
1134 0 ▶ if !keys %{ $self->{state}{watches}{$watched}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"watches"}{$watched}{"uids"};} 0 0 0
1135 }
1136 0 $watches = { };
1137 0 next ITEM;
1138 }
1139 2 ▶ if ( $item =~ m!^S!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^S/i) 2 0 2
1140 2 ▶ next ITEM if $list & 0x1;
Branch: 1 branch
BranchTrueFalseTotal
if $list & 1 0 2 2
1141 2 $item = substr $item, 0, 1;
1142 2 $list |= 0x1;
1143 2 my @watching = sort keys %$watches;
1144 2 my $wcount = 0;
1145 2 my $mcount = @watching;
1146 2 ▶ if ( defined $self->{state}{watches}{uc_irc $nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{uc_irc($nick)}) 0 2 2
1147 0 $wcount = keys %{ $self->{state}{watches}{uc_irc $nick}{uids} };
1148 }
1149 2 push @$ref, {
1150 prefix => $server,
1151 command => '603',
1152 params => [
1153 $nick,
1154 "You have $mcount and are on $wcount WATCH entries",
1155 ],
1156 };
1157 2 my $len = length($server) + length($nick) + 8;
1158 2 my $buf = '';
1159 2 WATCHED: foreach my $watched ( @watching ) {
1160 4 $watched = $watches->{$watched};
1161 4 ▶ if (length(join ' ', $buf, $watched)+$len+1 > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buf, $watched) + $len + 1 > 510) 0 4 4
1162 0 push @$ref, {
1163 prefix => $server,
1164 command => '606',
1165 params => [ $nick, $buf ],
1166 };
1167 0 $buf = $watched;
1168 0 next WATCHED;
1169 }
1170 4 $buf = join ' ', $buf, $watched;
1171 4 $buf =~ s!^\s+!!;
1172 }
1173 2 ▶ if ($buf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf) 2 0 2
1174 2 push @$ref, {
1175 prefix => $server,
1176 command => '606',
1177 params => [ $nick, $buf ],
1178 };
1179 }
1180 2 push @$ref, {
1181 prefix => $server,
1182 command => '607',
1183 params => [
1184 $nick,
1185 "End of WATCH $item",
1186 ],
1187 };
1188 2 next ITEM;
1189 }
1190 0 ▶ if ( $item =~ m!^L!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^L/i) 0 0 0
1191 0 ▶ next ITEM if $list & 0x2;
Branch: 1 branch
BranchTrueFalseTotal
if $list & 2 0 0 0
1192 0 $item = substr $item, 0, 1;
1193 0 $list |= 0x2;
1194 0 foreach my $watched ( keys %$watches ) {
1195 0 ▶ if ( my $tuid = $self->state_user_uid($watched) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $tuid = $self->state_user_uid($watched)) { } 0 0 0
elsif ($item eq 'L') { } 0 0 0
1196 0 my $rec = $self->{state}{uids}{$tuid};
1197 push @$ref, {
1198 prefix => $server,
1199 command => '604',
1200 params => [
1201 $nick,
1202 $rec->{nick},
1203 $rec->{auth}{ident},
1204 $rec->{auth}{hostname},
1205 $rec->{ts},
1206 0 'is online',
1207 ],
1208 };
1209 }
1210 elsif ( $item eq 'L' ) {
1211 push @$ref, {
1212 prefix => $server,
1213 command => '605',
1214 params => [
1215 0 $nick, $watches->{$watched}, '*', '*', 0, 'is offline'
1216 ],
1217 };
1218 }
1219 }
1220 0 push @$ref, {
1221 prefix => $server,
1222 command => '607',
1223 params => [
1224 $nick,
1225 "End of WATCH $item",
1226 ],
1227 };
1228 0 next ITEM;
1229 }
1230 }
1231 4 $self->{state}{uids}{$uid}{watches} = $watches;
1232 }
1233  
1234 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4 0 4
1235 0 return $ref;
1236 }
1237  
1238 141 ▶sub _daemon_cmd_cap {
Subroutine _daemon_cmd_cap: called CC=17 SCAR=32.0
1239 141 my $self = shift;
1240 141 ▶ my $wheel_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
1410
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1241 141 my $subcmd = shift;
1242 141 my $args = [@_];
1243 141 my $server = $self->server_name();
1244  
1245 141 my $registered = $self->_connection_registered($wheel_id);
1246  
1247 SWITCH: {
1248 141 ▶ if (!$subcmd) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subcmd) 0 141 141
1249 0 $self->_send_output_to_client($wheel_id, '461', 'CAP');
1250 0 last SWITCH;
1251 }
1252 141 $subcmd = uc $subcmd;
1253 141 ▶ if( $subcmd !~ m!^(LS|LIST|REQ|ACK|NAK|CLEAR|END)$! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subcmd =~ /^(LS|LIST|REQ|ACK|NAK|CLEAR|END)$/) 0 141 141
1254 0 $self->_send_output_to_client($wheel_id, '410', $subcmd);
1255 0 last SWITCH;
1256 }
1257 141 ▶ if ( $subcmd eq 'END' && $registered ) { #NOOP
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "END" and $registered) 0 141 141
Condition66%2/3
$subcmd eq "END" and $registered
!ll&&!rl&&r
98430
MC/DC0%0/2
$subcmd eq "END" and $registered
$subcmd eq "END" $registered
Truth table66%2/3
A and B
A= $subcmd eq "END"B= $registered
ABresult
0X0
100
111
1258 0 last SWITCH;
1259 }
1260 141 ▶ if ( $subcmd eq 'END' && !$registered ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "END" and not $registered) 43 98 141
Condition66%2/3
$subcmd eq "END" and not $registered
!ll&&!rl&&r
98043
MC/DC50%1/2
$subcmd eq "END" and not $registered
$subcmd eq "END" not $registered
Truth table66%2/3
A and not(B)
A= $subcmd eq "END"B= not $registered
ABresult
0X0
100
111
1261 43 my $capneg = delete $self->{state}{conns}{$wheel_id}{capneg};
1262 43 ▶ $self->_client_register($wheel_id) if $capneg;
Branch: 1 branch
BranchTrueFalseTotal
if $capneg 43 0 43
1263 43 last SWITCH;
1264 }
1265 98 ▶ $self->{state}{conns}{$wheel_id}{capneg} = 1 if !$registered && $subcmd =~ m!^(LS|REQ)$!;
Branch: 1 branch
BranchTrueFalseTotal
if not $registered and $subcmd =~ /^(LS|REQ)$/ 98 0 98
Condition33%1/3
not $registered and $subcmd =~ /^(LS|REQ)$/
!ll&&!rl&&r
0098
MC/DC0%0/2
not $registered and $subcmd =~ /^(LS|REQ)$/
not $registered $subcmd =~ /^(LS|REQ)$/
Truth table33%1/3
not(A) and B
A= not $registeredB= $subcmd =~ /^(LS|REQ)$/
ABresult
0X0
100
111
1266 98 ▶ if ( $subcmd eq 'LS' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "LS") 32 66 98
1267 32 my $output = {
1268 prefix => $server,
1269 command => 'CAP',
1270 params => [ $self->_client_nickname($wheel_id), $subcmd, ],
1271 };
1272 32 push @{ $output->{params} }, join ' ', sort keys %{ $self->{state}{caps} };
1273 32 $self->_send_output_to_client($wheel_id, $output);
1274 32 last SWITCH;
1275 }
1276 66 ▶ if ( $subcmd eq 'LIST' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "LIST") 0 66 66
1277 0 my $output = {
1278 prefix => $server,
1279 command => 'CAP',
1280 params => [ $self->_client_nickname($wheel_id), $subcmd, ],
1281 };
1282 0 push @{ $output->{params} }, join ' ', sort keys %{ $self->{state}{conns}{$wheel_id}{caps} };
1283 0 $self->_send_output_to_client($wheel_id, $output);
1284 0 last SWITCH;
1285 }
1286 66 ▶ if ( $subcmd eq 'REQ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "REQ") 66 0 66
1287 66 foreach my $cap ( split ' ', $args->[0] ) {
1288 73 my $ocap = $cap;
1289 73 my $neg = $cap =~ s!^\-!!;
1290 73 $cap = lc $cap;
1291 73 ▶ if ( !$self->{state}{caps}{$cap} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"state"}{"caps"}{$cap}) 23 50 73
1292 23 my $output = {
1293 prefix => $server,
1294 command => 'CAP',
1295 params => [ $self->_client_nickname($wheel_id), 'NAK', $args->[0] ],
1296 };
1297 23 $self->_send_output_to_client($wheel_id, $output);
1298 23 last SWITCH;
1299 }
1300 50 ▶ if ( $neg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($neg) { } 0 50 50
1301 0 delete $self->{state}{conns}{$wheel_id}{caps}{$cap};
1302 }
1303 else {
1304 50 $self->{state}{conns}{$wheel_id}{caps}{$cap} = 1;
1305 }
1306 }
1307 43 my $output = {
1308 prefix => $server,
1309 command => 'CAP',
1310 params => [ $self->_client_nickname($wheel_id), 'ACK', $args->[0] ],
1311 };
1312 43 $self->_send_output_to_client($wheel_id, $output);
1313 43 last SWITCH;
1314 }
1315 }
1316  
1317 141 return 1;
1318 }
1319  
1320 31 ▶sub _daemon_cmd_message {
Subroutine _daemon_cmd_message: called CC=79 SCAR=69.9
1321 31 my $self = shift;
1322 31 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
310
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1323 31 ▶ my $type = shift || return;
Condition50%1/2
shift() || (return)
l!l
310
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1324 31 my $ref = [ ];
1325 31 my $args = [@_];
1326 31 my $count = @$args;
1327  
1328 SWITCH: {
1329 31 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 31 31
1330 0 push @$ref, ['461', $type];
1331 0 last SWITCH;
1332 }
1333 31 ▶ if ($count < 2 || !$args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < 2 or not $args->[1]) 0 31 31
Condition33%1/3
$count < 2 or not $args->[1]
l!l&&r!l&&!r
0031
MC/DC0%0/2
$count < 2 or not $args->[1]
$count < 2 not $args->[1]
Truth table33%1/3
A or not(B)
A= $count < 2B= not $args->[1]
ABresult
1X1
011
000
1334 0 push @$ref, ['412'];
1335 0 last SWITCH;
1336 }
1337  
1338 31 my $targets = 0;
1339 31 my $max_targets = $self->server_config('MAXTARGETS');
1340 31 my $uid = $self->state_user_uid($nick);
1341 31 my $sid = $self->server_sid();
1342 31 my $full = $self->state_user_full($nick);
1343 31 my $targs = $self->_state_parse_msg_targets($args->[0]);
1344  
1345 31 LOOP: for my $target (keys %$targs) {
1346 31 my $targ_type = shift @{ $targs->{$target} };
1347  
1348 31 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)) 0 31 31
Condition33%1/3
$targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
3100
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)
$targ_type =~ /(server|host)mask/ not $self->state_user_is_operator($nick)
Truth table33%1/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $self->state_user_is_operator($nick)
ABresult
0X0
100
111
1349 && !$self->state_user_is_operator($nick)) {
1350 0 push @$ref, ['481'];
1351 0 next LOOP;
1352 }
1353  
1354 31 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./) 0 31 31
Condition33%1/3
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
!ll&&!rl&&r
3100
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
$targ_type =~ /(server|host)mask/ not $targs->{$target}[0] =~ /\./
Truth table33%1/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $targs->{$target}[0] =~ /\./
ABresult
0X0
100
111
1355 && $targs->{$target}[0] !~ /\./) {
1356 0 push @$ref, ['413', $target];
1357 0 next LOOP;
1358 }
1359  
1360 31 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/) 0 31 31
Condition33%1/3
$targ_type =~ /(server|host)mask/ and $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
!ll&&!rl&&r
3100
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
$targ_type =~ /(server|host)mask/ $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
Truth table33%1/3
A and B
A= $targ_type =~ /(server|host)mask/B= $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
ABresult
0X0
100
111
1361 && $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/) {
1362 0 push @$ref, ['414', $target];
1363 0 next LOOP;
1364 }
1365  
1366 31 ▶ if ($targ_type eq 'channel_ext'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])) 0 31 31
Condition33%1/3
$targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])
!ll&&!rl&&r
3100
MC/DC0%0/2
$targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])
$targ_type eq "channel_ext" not $self->state_chan_exists($targs->{$target}[1])
Truth table33%1/3
A and not(B)
A= $targ_type eq "channel_ext"B= not $self->state_chan_exists($targs->{$target}[1])
ABresult
0X0
100
111
1367 && !$self->state_chan_exists($targs->{$target}[1])) {
1368 0 push @$ref, ['401', $targs->{$target}[1]];
1369 0 next LOOP;
1370 }
1371  
1372 31 ▶ if ($targ_type eq 'channel'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel" and not $self->state_chan_exists($target)) 0 31 31
Condition66%2/3
$targ_type eq "channel" and not $self->state_chan_exists($target)
!ll&&!rl&&r
14170
MC/DC0%0/2
$targ_type eq "channel" and not $self->state_chan_exists($target)
$targ_type eq "channel" not $self->state_chan_exists($target)
Truth table66%2/3
A and not(B)
A= $targ_type eq "channel"B= not $self->state_chan_exists($target)
ABresult
0X0
100
111
1373 && !$self->state_chan_exists($target)) {
1374 0 push @$ref, ['401', $target];
1375 0 next LOOP;
1376 }
1377  
1378 31 ▶ if ($targ_type eq 'nick'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick" and not $self->state_nick_exists($target)) 0 31 31
Condition66%2/3
$targ_type eq "nick" and not $self->state_nick_exists($target)
!ll&&!rl&&r
17140
MC/DC0%0/2
$targ_type eq "nick" and not $self->state_nick_exists($target)
$targ_type eq "nick" not $self->state_nick_exists($target)
Truth table66%2/3
A and not(B)
A= $targ_type eq "nick"B= not $self->state_nick_exists($target)
ABresult
0X0
100
111
1379 && !$self->state_nick_exists($target)) {
1380 0 push @$ref, ['401', $target];
1381 0 next LOOP;
1382 }
1383  
1384 31 ▶ if ($targ_type eq 'nick_ext'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])) 0 31 31
Condition33%1/3
$targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])
!ll&&!rl&&r
3100
MC/DC0%0/2
$targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])
$targ_type eq "nick_ext" not $self->state_peer_exists($targs->{$target}[1])
Truth table33%1/3
A and not(B)
A= $targ_type eq "nick_ext"B= not $self->state_peer_exists($targs->{$target}[1])
ABresult
0X0
100
111
1385 && !$self->state_peer_exists($targs->{$target}[1])) {
1386 0 push @$ref, ['402', $targs->{$target}[1]];
1387 0 next LOOP;
1388 }
1389  
1390 31 $targets++;
1391 31 ▶ if ($targets > $max_targets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targets > $max_targets) 0 31 31
1392 0 push @$ref, ['407', $target];
1393 0 last SWITCH;
1394 }
1395  
1396 # $$whatever
1397 31 ▶ if ($targ_type eq 'servermask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "servermask") 0 31 31
1398 0 my $us = 0;
1399 0 my %targets;
1400 0 my $ucserver = uc $self->server_name();
1401  
1402 0 for my $peer (keys %{ $self->{state}{peers} }) {
1403 0 ▶ if (matches_mask( $targs->{$target}[0], $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targs->{$target}[0], $peer)) 0 0 0
1404 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
1405 0 $us = 1;
1406 }
1407 else {
1408 0 $targets{ $self->_state_peer_route($peer) }++;
1409 }
1410 }
1411 }
1412  
1413 $self->send_output(
1414 {
1415 0 prefix => $uid,
1416 command => $type,
1417 params => [$target, $args->[1]],
1418 },
1419 keys %targets,
1420 );
1421  
1422 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
1423 my $local
1424 0 = $self->{state}{peers}{uc $self->server_name()}{users};
1425 0 my @local;
1426 0 my $spoofed = 0;
1427  
1428 0 for my $luser (values %$local) {
1429 0 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 0 0
1430 0 $spoofed = 1;
1431 }
1432 else {
1433 0 push @local, $luser->{route_id};
1434 }
1435 }
1436  
1437 $self->send_output(
1438 {
1439 0 prefix => $full,
1440 command => $type,
1441 params => [$target, $args->[1]],
1442 },
1443 @local,
1444 );
1445  
1446 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
1447 "daemon_" . lc $type,
1448 $full,
1449 $target,
1450 $args->[1],
1451 ) if $spoofed;
1452 }
1453 0 next LOOP;
1454 }
1455  
1456 # $#whatever
1457 31 ▶ if ($targ_type eq 'hostmask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "hostmask") 0 31 31
1458 0 my $spoofed = 0;
1459 0 my %targets; my @local;
1460  
1461 0 HOST: for my $luser (values %{ $self->{state}{users} }) {
1462 0 ▶ if (!matches_mask($targs->{$target}[0],
Branch: 1 branch
BranchTrueFalseTotal
unless (matches_mask($targs->{$target}[0], $luser->{"auth"}{"hostname"})) 0 0 0
1463 $luser->{auth}{hostname})) {;
1464 0 next HOST;
1465 }
1466  
1467 0 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 2 branches
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 0 0
elsif ($luser->{'type'} eq 'r') { } 0 0 0
1468 0 $spoofed = 1;
1469 }
1470 elsif ($luser->{type} eq 'r') {
1471 0 $targets{ $luser->{route_id} }++;
1472 }
1473 else {
1474 0 push @local, $luser->{route_id};
1475 }
1476 }
1477  
1478 $self->send_output(
1479 {
1480 0 prefix => $uid,
1481 command => $type,
1482 params => [$target, $args->[1]],
1483 },
1484 keys %targets,
1485 );
1486  
1487 0 $self->send_output(
1488 {
1489 prefix => $full,
1490 command => $type,
1491 params => [$target, $args->[1]],
1492 },
1493 @local,
1494 );
1495  
1496 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
1497 "daemon_" . lc $type,
1498 $full,
1499 $target,
1500 $args->[1],
1501 ) if $spoofed;
1502  
1503 0 next LOOP;
1504 }
1505  
1506 31 ▶ if ($targ_type eq 'nick_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext") 0 31 31
1507 $targs->{$target}[1] = $self->_state_peer_name(
1508 0 $targs->{$target}[1]);
1509  
1510 0 ▶ if ($targs->{$target}[2]
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[2] and not $self->state_user_is_operator($nick)) 0 0 0
Condition0%0/3
$targs->{$target}[2] and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
000
MC/DC0%0/2
$targs->{$target}[2] and not $self->state_user_is_operator($nick)
$targs->{$target}[2] not $self->state_user_is_operator($nick)
Truth table0%0/3
A and not(B)
A= $targs->{$target}[2]B= not $self->state_user_is_operator($nick)
ABresult
0X0
100
111
1511 && !$self->state_user_is_operator($nick)) {
1512 0 push @$ref, ['481'];
1513 0 next LOOP;
1514 }
1515  
1516 0 ▶ if ($targs->{$target}[1] ne $self->server_name()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[1] ne $self->server_name) 0 0 0
1517 $self->send_output(
1518 {
1519 prefix => $uid,
1520 command => $type,
1521 params => [$target, $args->[1]],
1522 },
1523 0 $self->_state_peer_route($targs->{$target}[1]),
1524 );
1525 0 next LOOP;
1526 }
1527  
1528 0 ▶ if (uc $targs->{$target}[0] eq 'OPERS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $targs->{$target}[0] eq "OPERS") 0 0 0
1529 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1530 0 push @$ref, ['481'];
1531 0 next LOOP;
1532 }
1533  
1534 $self->send_output(
1535 {
1536 prefix => $full,
1537 command => $type,
1538 params => [$target, $args->[1]],
1539 },
1540 0 keys %{ $self->{state}{localops} },
1541 );
1542 0 next LOOP;
1543 }
1544  
1545 my @local = $self->_state_find_user_host(
1546 $targs->{$target}[0],
1547 0 $targs->{$target}[2],
1548 );
1549  
1550 0 ▶ if (@local == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local == 1) { } 0 0 0
1551 0 my $ref = shift @local;
1552 0 ▶ if ($ref->[0] eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->[0] eq 'spoofed') { } 0 0 0
1553 0 $self->send_event(
1554 "daemon_" . lc $type,
1555 $full,
1556 $ref->[1],
1557 $args->[1],
1558 );
1559 }
1560 else {
1561 0 $self->send_output(
1562 {
1563 prefix => $full,
1564 command => $type,
1565 params => [$target, $args->[1]],
1566 },
1567 $ref->[0],
1568 );
1569 }
1570 }
1571 else {
1572 0 push @$ref, ['407', $target];
1573 0 next LOOP;
1574 }
1575 }
1576  
1577 31 my ($channel, $status_msg);
1578 31 ▶ if ($targ_type eq 'channel') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel") 17 14 31
1579 17 $channel = $self->_state_chan_name($target);
1580 }
1581 31 ▶ if ($targ_type eq 'channel_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext") 0 31 31
1582 0 $channel = $self->_state_chan_name($targs->{target}[1]);
1583 0 $status_msg = $targs->{target}[0];
1584 }
1585 31 ▶ if ($channel && $status_msg
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)) 0 31 31
Condition50%3/6
$channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
3100
$channel and $status_msg
!ll&&!rl&&r
14170
MC/DC0%0/3
$channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)
$channel $status_msg not $self->state_user_chan_mode($nick, $channel)
Truth table50%2/4
A and B and not(C)
A= $channelB= $status_msgC= not $self->state_user_chan_mode($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
1586 && !$self->state_user_chan_mode($nick, $channel)) {
1587 0 push @$ref, ['482', $target];
1588 0 next LOOP;
1589 }
1590 31 ▶ if ($channel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($channel) 17 14 31
1591 17 my $res = $self->state_can_send_to_channel($nick,$channel,$args->[1],$type);
1592 17 ▶ if ( !$res ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $res) { } 0 17 17
elsif (ref $res eq 'ARRAY') { } 7 10 17
1593 0 next LOOP;
1594 }
1595 elsif ( ref $res eq 'ARRAY' ) {
1596 7 push @$ref, $res;
1597 7 next LOOP;
1598 }
1599 10 ▶ if ( $res != 2 && $self->state_flood_attack_channel($nick,$channel,$type) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res != 2 and $self->state_flood_attack_channel($nick, $channel, $type)) 1 9 10
Condition100%3/3
$res != 2 and $self->state_flood_attack_channel($nick, $channel, $type)
!ll&&!rl&&r
271
MC/DC100%2/2
$res != 2 and $self->state_flood_attack_channel($nick, $channel, $type)
$res != 2 $self->state_flood_attack_channel($nick, $channel, $type)
Truth table100%3/3
A and B
A= $res != 2B= $self->state_flood_attack_channel($nick, $channel, $type)
ABresult
0X0
100
111
1600 1 next LOOP;
1601 }
1602 9 my $common = { };
1603 9 ▶ my $msg = {
Branch: 1 branch
BranchTrueFalseTotal
$status_msg ? : 0 9 9
1604 command => $type,
1605 params => [
1606 ($status_msg ? $target : $channel), $args->[1]
1607 ],
1608 };
1609 9 for my $member ($self->state_chan_list($channel, $status_msg)) {
1610 27 ▶ next if $self->_state_user_is_deaf($member);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_is_deaf($member) 0 27 27
1611 27 $common->{ $self->_state_user_route($member) }++;
1612 }
1613 9 delete $common->{ $self->_state_user_route($nick) };
1614 9 for my $route_id (keys %$common) {
1615 18 $msg->{prefix} = $uid;
1616 18 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 17 1 18
1617 17 $msg->{prefix} = $full;
1618 }
1619 18 ▶ if ($route_id ne 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id ne 'spoofed') { } 18 0 18
1620 18 $self->send_output($msg, $route_id);
1621 }
1622 else {
1623 0 ▶ my $tmsg = $type eq 'PRIVMSG' ? 'public' : 'notice';
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'PRIVMSG' ? : 0 0 0
1624 0 $self->send_event(
1625 "daemon_$tmsg",
1626 $full,
1627 $channel,
1628 $args->[1],
1629 );
1630 }
1631 }
1632 9 next LOOP;
1633 }
1634  
1635 14 my $server = $self->server_name();
1636 14 ▶ if ($self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($target)) 14 0 14
1637 14 $target = $self->state_user_nick($target);
1638  
1639 # Flood check
1640 14 ▶ next LOOP if $self->state_flood_attack_client($nick,$target,$type);
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_flood_attack_client($nick, $target, $type) 1 13 14
1641  
1642 13 ▶ if (my $away = $self->_state_user_away_msg($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $away = $self->_state_user_away_msg($target)) 0 13 13
1643 0 push @$ref, {
1644 prefix => $server,
1645 command => '301',
1646 params => [$nick, $target, $away],
1647 };
1648 }
1649  
1650 13 my $targ_umode = $self->state_user_umode($target);
1651  
1652 # Target user has CALLERID on
1653 13 ▶ if ($targ_umode && $targ_umode =~ /[Gg]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_umode and $targ_umode =~ /[Gg]/) 1 12 13
Condition66%2/3
$targ_umode and $targ_umode =~ /[Gg]/
!ll&&!rl&&r
0121
MC/DC50%1/2
$targ_umode and $targ_umode =~ /[Gg]/
$targ_umode $targ_umode =~ /[Gg]/
Truth table66%2/3
A and B
A= $targ_umodeB= $targ_umode =~ /[Gg]/
ABresult
0X0
100
111
1654 1 my $targ_rec = $self->{state}{users}{uc_irc($target)};
1655 1 my $targ_uid = $targ_rec->{uid};
1656 1 my $local = $targ_uid =~ m!^sid!;
1657 1 ▶ if (($targ_umode =~ /G/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)} or $targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}) 1 0 1
Condition25%3/12
$targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)} or $targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}
l!l&&r!l&&!r
010
$targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)}
!ll&&!rl&&r
100
$self->state_users_share_chan($target, $nick) && $targ_rec->{'accepts'}{uc_irc($nick)}
!ll&&!rl&&r
000
$targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}
!ll&&!rl&&r
001
MC/DC0%0/5
$targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)} or $targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}
$targ_umode =~ /G/ $self->state_users_share_chan($target, $nick) $targ_rec->{'accepts'}{uc_irc($nick)} $targ_umode =~ /g/ not $targ_rec->{"accepts"}{uc_irc($nick)}
Truth table12%1/8
A and not(B && C) or D and not(E)
A= $targ_umode =~ /G/B= $self->state_users_share_chan($target, $nick)C= $targ_rec->{'accepts'}{uc_irc($nick)}D= $targ_umode =~ /g/E= not $targ_rec->{"accepts"}{uc_irc($nick)}
ABCDEresult
10XXX1
110XX1
0XX111
111111
0XX0X0
0XX100
1110X0
111100
1658 && (!$self->state_users_share_chan($target, $nick)
1659 || !$targ_rec->{accepts}{uc_irc($nick)}))
1660 || ($targ_umode =~ /g/
1661 && !$targ_rec->{accepts}{uc_irc($nick)})) {
1662  
1663 1 push @$ref, {
1664 prefix => $server,
1665 command => '716',
1666 params => [
1667 $nick,
1668 $target,
1669 'is in +g mode (server side ignore)',
1670 ],
1671 };
1672  
1673 1 ▶ if (!$targ_rec->{last_caller}
Branch: 1 branch
BranchTrueFalseTotal
if (not $targ_rec->{"last_caller"} or time - $targ_rec->{"last_caller"} >= 60) 1 0 1
Condition33%1/3
not $targ_rec->{"last_caller"} or time - $targ_rec->{"last_caller"} >= 60
l!l&&r!l&&!r
100
MC/DC0%0/2
not $targ_rec->{"last_caller"} or time - $targ_rec->{"last_caller"} >= 60
not $targ_rec->{"last_caller"} time - $targ_rec->{"last_caller"} >= 60
Truth table33%1/3
not(A) or B
A= not $targ_rec->{"last_caller"}B= time - $targ_rec->{"last_caller"} >= 60
ABresult
1X1
011
000
1674 || time() - $targ_rec->{last_caller} >= 60) {
1675  
1676 1 my ($n, $uh) = split /!/,
1677 $self->state_user_full($nick);
1678 $self->send_output(
1679 {
1680 prefix => ( $local ? $server : $sid ),
1681 command => '718',
1682 params => [
1683 ( $local ? $target : $targ_uid ),
1684 "$n\[$uh\]",
1685 'is messaging you, and you are umode +g.',
1686 ]
1687 },
1688 $targ_rec->{route_id},
1689 1 ▶ ) if $targ_rec->{route_id} ne 'spoofed';
Branch: 3 branches
BranchTrueFalseTotal
if $targ_rec->{"route_id"} ne "spoofed" 0 1 1
$local ? : 0 0 0
$local ? : 0 0 0
1690 1 push @$ref, {
1691 prefix => $server,
1692 command => '717',
1693 params => [
1694 $nick,
1695 $target,
1696 'has been informed that you messaged them.',
1697 ],
1698 };
1699 }
1700 1 $targ_rec->{last_caller} = time();
1701 1 next LOOP;
1702 }
1703 }
1704  
1705 12 my $targ_uid = $self->state_user_uid($target);
1706 12 my $msg = {
1707 prefix => $uid,
1708 command => $type,
1709 params => [$targ_uid, $args->[1]],
1710 };
1711 12 my $route_id = $self->_state_user_route($target);
1712  
1713 12 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 2 10 12
1714 2 $msg->{prefix} = $full;
1715 2 $self->send_event(
1716 "daemon_" . lc $type,
1717 $full,
1718 $target,
1719 $args->[1],
1720 );
1721 }
1722 else {
1723 10 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 5 5 10
1724 5 $msg->{prefix} = $full;
1725 5 $msg->{params}[0] = $target;
1726 }
1727 10 $self->send_output($msg, $route_id);
1728 }
1729 12 next LOOP;
1730 }
1731 }
1732 }
1733  
1734 31 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 31 0 31
1735 0 return $ref;
1736 }
1737  
1738 0 ▶sub _daemon_cmd_accept {
Subroutine _daemon_cmd_accept: not called CC=21 SCAR=61.4
1739 0 my $self = shift;
1740 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1741 0 my $server = $self->server_name();
1742 0 my $ref = [ ];
1743 0 my $args = [ @_ ];
1744 0 my $count = @$args;
1745  
1746 SWITCH: {
1747 0 ▶ if (!$count || !$args->[0] || $args->[0] eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count && $args->[0] or $args->[0] eq "*") 0 0 0
Condition0%0/6
not $count && $args->[0] or $args->[0] eq "*"
l!l&&r!l&&!r
000
$count && $args->[0]
!ll&&!rl&&r
000
MC/DC0%0/3
not $count && $args->[0] or $args->[0] eq "*"
$count $args->[0] $args->[0] eq "*"
Truth table0%0/4
not(A && B) or C
A= $countB= $args->[0]C= $args->[0] eq "*"
ABCresult
0XX1
10X1
1111
1100
1748 0 my $record = $self->{state}{users}{uc_irc($nick)};
1749 0 my @list;
1750 0 for my $accept (keys %{ $record->{accepts} }) {
1751 0 ▶ if (!$self->state_nick_exists($accept)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($accept)) 0 0 0
1752 0 delete $record->{accepts}{$accept};
1753 0 next;
1754 }
1755 0 push @list, $self->state_user_nick($accept);
1756 }
1757 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if @list 0 0 0
1758 prefix => $server,
1759 command => '281',
1760 params => [$nick, join( ' ', @list)],
1761 } if @list;
1762  
1763 0 push @$ref, {
1764 prefix => $server,
1765 command => '282',
1766 params => [$nick, 'End of /ACCEPT list'],
1767 };
1768 0 last SWITCH;
1769 }
1770 }
1771  
1772 0 my $record = $self->{state}{users}{uc_irc($nick)};
1773  
1774 0 for (keys %{ $record->{accepts} }) {
1775 0 ▶ delete $record->{accepts}{$_} if !$self->state_nick_exists($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($_) 0 0 0
1776 }
1777  
1778 0 OUTER: for my $target (split /,/, $args->[0]) {
1779 0 ▶ if (my ($foo) = $target =~ /^\-(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($foo) = $target =~ /^\-(.+)$/) 0 0 0
1780 0 my $dfoo = delete $record->{accepts}{uc_irc($foo)};
1781 0 ▶ if (!$dfoo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dfoo) 0 0 0
1782 0 push @$ref, {
1783 prefix => $server,
1784 command => '458',
1785 params => [$nick, $foo, "doesn\'t exist"],
1786 };
1787 }
1788 0 delete $self->{state}{accepts}{uc_irc($foo)}{uc_irc($nick)};
1789 0 ▶ if (!keys %{ $self->{state}{accepts}{uc_irc($foo)} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$self->{"state"}{"accepts"}{uc_irc($foo)};}) 0 0 0
1790 0 delete $self->{state}{accepts}{uc_irc($foo)};
1791 }
1792 0 next OUTER;
1793 }
1794  
1795 0 ▶ if (!$self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($target)) 0 0 0
1796 0 push @$ref, ['401', $target];
1797 0 next OUTER;
1798 }
1799 # 457 ERR_ACCEPTEXIST
1800 0 ▶ if ($record->{accepts}{uc_irc($target)}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"accepts"}{uc_irc($target)}) 0 0 0
1801 0 push @$ref, {
1802 prefix => $server,
1803 command => '457',
1804 params => [
1805 $nick,
1806 $self->state_user_nick($target),
1807 'already exists',
1808 ],
1809 };
1810 0 next OUTER;
1811 }
1812  
1813 0 ▶ if ($record->{umode} && $record->{umode} =~ /G/
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} and $record->{"umode"} =~ /G/ and $self->_state_users_share_chan($nick, $target)) 0 0 0
Condition0%0/6
$record->{"umode"} and $record->{"umode"} =~ /G/ and $self->_state_users_share_chan($nick, $target)
!ll&&!rl&&r
000
$record->{"umode"} and $record->{"umode"} =~ /G/
!ll&&!rl&&r
000
MC/DC0%0/3
$record->{"umode"} and $record->{"umode"} =~ /G/ and $self->_state_users_share_chan($nick, $target)
$record->{"umode"} $record->{"umode"} =~ /G/ $self->_state_users_share_chan($nick, $target)
Truth table0%0/4
A and B and C
A= $record->{"umode"}B= $record->{"umode"} =~ /G/C= $self->_state_users_share_chan($nick, $target)
ABCresult
0XX0
10X0
1100
1111
1814 && $self->_state_users_share_chan($nick, $target) ) {
1815 0 push @$ref, {
1816 prefix => $server,
1817 command => '457',
1818 params => [
1819 $nick,
1820 $self->state_user_nick($target),
1821 'already exists',
1822 ],
1823 };
1824 0 next OUTER;
1825 }
1826  
1827 $self->{state}{accepts}{uc_irc($target)}{uc_irc($nick)}
1828 0 = $record->{accepts}{uc_irc($target)} = time;
1829 0 my @list = map { $self->state_user_nick($_) } keys %{ $record->{accepts} };
1830  
1831 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if @list 0 0 0
1832 prefix => $server,
1833 command => '281',
1834 params => [
1835 $nick,
1836 join(' ', @list),
1837 ],
1838 } if @list;
1839  
1840 0 push @$ref, {
1841 prefix => $server,
1842 command => '282',
1843 params => [$nick, 'End of /ACCEPT list'],
1844 };
1845 }
1846  
1847 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1848 0 return $ref;
1849 }
1850  
1851 223 ▶sub _daemon_cmd_quit {
Subroutine _daemon_cmd_quit: called CC=19 SCAR=29.5
1852 223 my $self = shift;
1853 223 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
2230
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1854 223 my $qmsg = shift;
1855 223 my $ref = [ ];
1856 223 my $name = uc $self->server_name();
1857 223 my $sid = $self->server_sid();
1858  
1859 223 $nick = uc_irc($nick);
1860 223 my $record = delete $self->{state}{peers}{$name}{users}{$nick};
1861 223 ▶ $qmsg = 'Client Quit' if !$qmsg;
Branch: 1 branch
BranchTrueFalseTotal
unless $qmsg 0 223 223
1862 223 my $full = $record->{full}->();
1863 223 delete $self->{state}{peers}{$name}{uids}{ $record->{uid} };
1864 223 my $uid = $record->{uid};
1865 $self->send_output(
1866 {
1867 prefix => $uid,
1868 command => 'QUIT',
1869 params => [$qmsg],
1870 },
1871 $self->_state_connected_peers(),
1872 223 ▶ ) if !$record->{killed};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"killed"} 220 3 223
1873  
1874 223 push @$ref, {
1875 prefix => $full,
1876 command => 'QUIT',
1877 params => [$qmsg],
1878 };
1879 223 $self->send_event("daemon_quit", $full, $qmsg);
1880  
1881 # Remove from peoples accept lists
1882 223 for my $user (keys %{ $record->{accepts} }) {
1883 0 delete $self->{state}{users}{$user}{accepts}{uc_irc($nick)};
1884 }
1885  
1886 223 ▶ if ( defined $self->{state}{watches}{$nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$nick}) 1 222 223
1887 1 my $laston = time();
1888 1 $self->{state}{watches}{$nick}{laston} = $laston;
1889 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$nick}{uids} } ) {
1890 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
1891 1 my $wrec = $self->{state}{uids}{$wuid};
1892 $self->send_output(
1893 {
1894 prefix => $record->{server},
1895 command => '601',
1896 params => [
1897 $wrec->{nick},
1898 $record->{nick},
1899 $record->{auth}{ident},
1900 $record->{auth}{hostname},
1901 $laston,
1902 'logged offline',
1903 ],
1904 },
1905 $wrec->{route_id},
1906 1 );
1907 }
1908 }
1909 # clear WATCH list
1910 223 foreach my $watched ( keys %{ $record->{watches} } ) {
1911 4 delete $self->{state}{watches}{$watched}{uids}{$uid};
1912 delete $self->{state}{watches}{$watched}
1913 4 ▶ if !keys %{ $self->{state}{watches}{$watched}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"watches"}{$watched}{"uids"};} 4 0 4
1914 }
1915  
1916 # Okay, all 'local' users who share a common channel with user.
1917 223 my $common = { };
1918 223 for my $uchan (keys %{ $record->{chans} }) {
1919 90 delete $self->{state}{chans}{$uchan}{users}{$uid};
1920 90 for my $user ( keys %{ $self->{state}{chans}{$uchan}{users} } ) {
1921 80 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 25 55 80
1922 55 $common->{$user} = $self->_state_uid_route($user);
1923 }
1924  
1925 90 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 38 52 90
1926 38 delete $self->{state}{chans}{$uchan};
1927 }
1928 }
1929  
1930 223 push @$ref, $common->{$_} for keys %$common;
1931 223 ▶ $self->{state}{stats}{ops_online}-- if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 26 197 223
1932 223 ▶ $self->{state}{stats}{invisible}-- if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 218 5 223
1933 223 ▶ delete $self->{state}{users}{$nick} if !$record->{nick_collision};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"nick_collision"} 217 6 223
1934 223 delete $self->{state}{uids}{ $record->{uid} };
1935 223 delete $self->{state}{localops}{$record->{route_id}};
1936 223 unshift @{ $self->{state}{whowas}{$nick} }, {
1937 logoff => time(),
1938 account => $record->{account},
1939 nick => $record->{nick},
1940 user => $record->{auth}{ident},
1941 host => $record->{auth}{hostname},
1942 real => $record->{auth}{realhost},
1943 sock => $record->{socket}[0],
1944 ircname => $record->{ircname},
1945 223 server => $name,
1946 };
1947 223 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 223 223
1948 223 return $ref;
1949 }
1950  
1951 3 ▶sub _daemon_cmd_ping {
Subroutine _daemon_cmd_ping: called CC=8 SCAR=21.6
1952 3 my $self = shift;
1953 3 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1954 3 my $server = $self->server_name();
1955 3 my $sid = $self->server_sid();
1956 3 my $args = [ @_ ];
1957 3 my $count = @$args;
1958 3 my $ref = [ ];
1959  
1960 SWITCH: {
1961 3 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 1 2 3
1962 1 push @$ref, [ '409' ];
1963 1 last SWITCH;
1964 }
1965  
1966 2 ▶ if ($count >= 2 && !$self->state_peer_exists($args->[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and not $self->state_peer_exists($args->[1])) 1 1 2
Condition66%2/3
$count >= 2 and not $self->state_peer_exists($args->[1])
!ll&&!rl&&r
011
MC/DC50%1/2
$count >= 2 and not $self->state_peer_exists($args->[1])
$count >= 2 not $self->state_peer_exists($args->[1])
Truth table66%2/3
A and not(B)
A= $count >= 2B= not $self->state_peer_exists($args->[1])
ABresult
0X0
100
111
1967 1 push @$ref, ['402', $args->[1]];
1968 1 last SWITCH;
1969 }
1970 1 ▶ if ($count >= 2 && (uc $args->[1] ne uc $server)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and uc $args->[1] ne uc $server) 1 0 1
Condition33%1/3
$count >= 2 and uc $args->[1] ne uc $server
!ll&&!rl&&r
001
MC/DC0%0/2
$count >= 2 and uc $args->[1] ne uc $server
$count >= 2 uc $args->[1] ne uc $server
Truth table33%1/3
A and B
A= $count >= 2B= uc $args->[1] ne uc $server
ABresult
0X0
100
111
1971 1 my $target = $self->_state_peer_sid($args->[1]);
1972 1 $self->send_output(
1973 {
1974 prefix => $self->state_user_uid($nick),
1975 command => 'PING',
1976 params => [$nick, $target],
1977 },
1978 $self->_state_sid_route($target),
1979 );
1980 1 last SWITCH;
1981 }
1982 0 push @$ref, {
1983 prefix => $sid,
1984 command => 'PONG',
1985 params => [$server, $args->[0]],
1986 };
1987 }
1988 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
1989 0 return $ref;
1990 }
1991  
1992 0 ▶sub _daemon_cmd_pong {
Subroutine _daemon_cmd_pong: not called CC=8 SCAR=42.8
1993 0 my $self = shift;
1994 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1995 0 my $server = uc $self->server_name();
1996 0 my $args = [ @_ ];
1997 0 my $count = @$args;
1998 0 my $ref = [ ];
1999  
2000 SWITCH: {
2001 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2002 0 push @$ref, ['409'];
2003 0 last SWITCH;
2004 }
2005 0 ▶ if ($count >= 2 && !$self->state_peer_exists($args->[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and not $self->state_peer_exists($args->[1])) 0 0 0
Condition0%0/3
$count >= 2 and not $self->state_peer_exists($args->[1])
!ll&&!rl&&r
000
MC/DC0%0/2
$count >= 2 and not $self->state_peer_exists($args->[1])
$count >= 2 not $self->state_peer_exists($args->[1])
Truth table0%0/3
A and not(B)
A= $count >= 2B= not $self->state_peer_exists($args->[1])
ABresult
0X0
100
111
2006 0 push @$ref, ['402', $args->[1]];
2007 0 last SWITCH;
2008 }
2009 0 ▶ if ($count >= 2 && uc $args->[1] ne uc $server) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and uc $args->[1] ne uc $server) 0 0 0
Condition0%0/3
$count >= 2 and uc $args->[1] ne uc $server
!ll&&!rl&&r
000
MC/DC0%0/2
$count >= 2 and uc $args->[1] ne uc $server
$count >= 2 uc $args->[1] ne uc $server
Truth table0%0/3
A and B
A= $count >= 2B= uc $args->[1] ne uc $server
ABresult
0X0
100
111
2010 0 my $target = $self->_state_peer_sid($args->[1]);
2011 0 $self->send_output(
2012 {
2013 prefix => $self->state_user_uid($nick),
2014 command => 'PONG',
2015 params => [$nick, $target],
2016 },
2017 $self->_state_sid_route($target),
2018 );
2019 0 last SWITCH;
2020 }
2021 0 delete $self->{state}{users}{uc_irc($nick)}{pinged};
2022 }
2023  
2024 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2025 0 return $ref;
2026 }
2027  
2028 0 ▶sub _daemon_cmd_pass {
Subroutine _daemon_cmd_pass: not called CC=3 SCAR=24.8
2029 0 my $self = shift;
2030 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2031 0 my $server = uc $self->server_name();
2032 0 my $ref = [['462']];
2033 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2034 0 return $ref;
2035 }
2036  
2037 0 ▶sub _daemon_cmd_user {
Subroutine _daemon_cmd_user: not called CC=3 SCAR=24.8
2038 0 my $self = shift;
2039 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2040 0 my $server = uc $self->server_name();
2041 0 my $ref = [['462']];
2042 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2043 0 return $ref;
2044 }
2045  
2046 25 ▶sub _daemon_cmd_oper {
Subroutine _daemon_cmd_oper: called CC=14 SCAR=27.6
2047 25 my $self = shift;
2048 25 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2049 25 my $server = $self->server_name();
2050 25 my $sid = $self->server_sid();
2051 25 my $ref = [ ];
2052 25 my $args = [@_];
2053 25 my $count = @$args;
2054  
2055 SWITCH: {
2056 25 ▶ last SWITCH if $self->state_user_is_operator($nick);
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_user_is_operator($nick) 0 25 25
2057 25 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 25 25
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
0025
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
2058 0 push @$ref, ['461', 'OPER'];
2059 0 last SWITCH;
2060 }
2061  
2062 25 my $record = $self->{state}{users}{uc_irc($nick)};
2063 25 my $result = $self->_state_o_line($nick, @$args);
2064 25 ▶ if (!$result || $result <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result or $result <= 0) 3 22 25
Condition100%3/3
not $result or $result <= 0
l!l&&r!l&&!r
1222
MC/DC100%2/2
not $result or $result <= 0
not $result $result <= 0
Truth table100%3/3
not(A) or B
A= not $resultB= $result <= 0
ABresult
1X1
011
000
2065 3 my $omsg; my $errcode = '491';
2066 3 ▶ if (!defined $result) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $result) { } 1 2 3
elsif ($result == -1) { } 0 2 2
elsif ($result == -2) { } 1 1 2
elsif ($result == -3) { } 1 0 1
2067 1 $omsg = 'no operator {} block';
2068 }
2069 elsif ($result == -1) {
2070 0 $omsg = 'password mismatch';
2071 0 $errcode = '464';
2072 }
2073 elsif ($result == -2) {
2074 1 $omsg = 'requires SSL/TLS';
2075 }
2076 elsif ($result == -3) {
2077 1 $omsg = 'client certificate fingerprint mismatch';
2078 }
2079 else {
2080 0 $omsg = 'host mismatch';
2081 }
2082 $self->_send_to_realops(
2083 sprintf(
2084 'Failed OPER attempt as %s by %s (%s) - %s',
2085 3 $args->[0], $nick, (split /!/, $record->{full}->())[1], $omsg),
2086 'Notice',
2087 's',
2088 );
2089 3 push @$ref, [$errcode];
2090 3 last SWITCH;
2091 }
2092 22 my $opuser = $args->[0];
2093 22 $self->{stats}{ops}++;
2094 22 $record->{umode} .= 'o';
2095 22 $record->{opuser} = $opuser;
2096 22 $self->{state}{stats}{ops_online}++;
2097 22 push @$ref, {
2098 prefix => $server,
2099 command => '381',
2100 params => [$nick, 'You are now an IRC operator'],
2101 };
2102  
2103 22 my @peers = $self->_state_connected_peers();
2104  
2105 22 ▶ if (my $whois = $self->{config}{ops}{$opuser}{whois}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $whois = $self->{"config"}{"ops"}{$opuser}{"whois"}) 0 22 22
2106 0 $record->{svstags}{313} = {
2107 numeric => '313',
2108 umodes => '+',
2109 tagline => $whois,
2110 };
2111 $self->send_output(
2112 {
2113 prefix => $sid,
2114 command => 'SVSTAG',
2115 params => [
2116 $record->{uid},
2117 $record->{ts},
2118 0 '313', '+', $whois,
2119 ],
2120 },
2121 @peers,
2122 );
2123 }
2124  
2125 22 ▶ my $umode = $self->{config}{ops}{$opuser}{umode} || $self->{config}{oper_umode};
Condition66%2/3
$self->{'config'}{'ops'}{$opuser}{'umode'} || $self->{'config'}{'oper_umode'}
l!l&&r!l&&!r
2020
MC/DC0%0/2
$self->{'config'}{'ops'}{$opuser}{'umode'} || $self->{'config'}{'oper_umode'}
$self->{'config'}{'ops'}{$opuser}{'umode'} $self->{'config'}{'oper_umode'}
Truth table66%2/3
A || B
A= $self->{'config'}{'ops'}{$opuser}{'umode'}B= $self->{'config'}{'oper_umode'}
ABresult
1X1
011
000
2126 22 $record->{umode} .= $umode;
2127 22 $umode .= 'o';
2128 22 $umode = join '', sort split //, $umode;
2129  
2130 22 my $uid = $record->{uid};
2131 22 my $full = $record->{full}->();
2132  
2133 22 my $notice = sprintf("%s{%s} is now an operator",$full,$opuser);
2134  
2135 22 $self->send_output(
2136 {
2137 prefix => $sid,
2138 command => 'GLOBOPS',
2139 params => [ $notice ],
2140 },
2141 @peers,
2142 );
2143  
2144 22 $self->_send_to_realops( $notice );
2145  
2146 22 my $reply = {
2147 prefix => $uid,
2148 command => 'MODE',
2149 params => [$uid, "+$umode"],
2150 };
2151  
2152 22 $self->send_output(
2153 $reply,
2154 @peers,
2155 );
2156 22 $self->send_event(
2157 "daemon_umode",
2158 $full,
2159 "+$umode",
2160 );
2161  
2162  
2163 22 my $route_id = $record->{route_id};
2164 22 $self->{state}{localops}{$route_id} = time;
2165 22 $self->antiflood($route_id, 0);
2166 22 $reply->{prefix} = $full;
2167 22 $reply->{params}[0] = $record->{nick};
2168 22 push @$ref, $reply;
2169 }
2170  
2171 25 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 25 0 25
2172 0 return $ref;
2173 }
2174  
2175 1 ▶sub _daemon_cmd_die {
Subroutine _daemon_cmd_die: called CC=4 SCAR=15.2
2176 1 my $self = shift;
2177 1 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2178 1 my $server = $self->server_name();
2179 1 my $ref = [ ];
2180  
2181 SWITCH: {
2182 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2183 0 push @$ref, ['481'];
2184 0 last SWITCH;
2185 }
2186 1 $self->send_event("daemon_die", $nick);
2187 1 $self->shutdown();
2188 }
2189 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2190 0 return $ref;
2191 }
2192  
2193 1 ▶sub _daemon_cmd_close {
Subroutine _daemon_cmd_close: called CC=9 SCAR=23.9
2194 1 my $self = shift;
2195 1 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2196 1 my $server = $self->server_name();
2197 1 my $ref = [ ];
2198  
2199 SWITCH: {
2200 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2201 0 push @$ref, ['723','close'];
2202 0 last SWITCH;
2203 }
2204 1 $self->send_event("daemon_close", $nick);
2205 1 my $count = 0;
2206 1 foreach my $conn_id ( keys %{ $self->{state}{conns} } ) {
2207 6 ▶ next if $self->{state}{conns}{$conn_id}{type} ne 'u';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} ne "u" 5 1 6
2208 1 my $crec = $self->{state}{conns}{$conn_id};
2209 push @$ref, {
2210 prefix => $server,
2211 command => '362',
2212 params => [
2213 $nick,
2214 sprintf(
2215 '%s[%s@%s]',
2216 ( $crec->{name} || $crec->{nick} || '' ),
2217 ( $crec->{user} || 'unknown' ),
2218 1 ▶ $crec->{socket}[0],
Condition42%3/7
$crec->{'name'} || $crec->{'nick'} || ''
l!l
01
$crec->{"name"} or $crec->{"nick"}
l!l&&r!l&&!r
001
$crec->{'user'} || 'unknown'
l!l
01
MC/DC0%0/2
$crec->{'name'} || $crec->{'nick'} || ''
$crec->{"name"} $crec->{"nick"}
MC/DC0%0/1
$crec->{'user'} || 'unknown'
$crec->{'user'}
Truth table33%1/3
A or B
A= $crec->{"name"}B= $crec->{"nick"}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $crec->{'user'}
Aresult
11
00
2219 ),
2220 'Closed: status = unknown',
2221 ],
2222 };
2223 1 $count++;
2224 1 $self->_terminate_conn_error($conn_id,'Oper Closing');
2225 }
2226 1 push @$ref, {
2227 prefix => $server,
2228 command => '363',
2229 params => [
2230 $nick,
2231 $count,
2232 'Connections closed',
2233 ],
2234 };
2235 }
2236 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2237 0 return $ref;
2238 }
2239  
2240 5 ▶sub _daemon_cmd_set {
Subroutine _daemon_cmd_set: called CC=9 SCAR=33.3
2241 5 my $self = shift;
2242 5 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2243 5 my $server = $self->server_name();
2244 5 my $ref = [ ];
2245 5 my $args = [@_];
2246 5 my $count = @$args;
2247  
2248 my %vars = (
2249 0 ▶ FLOODCOUNT => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2250 0 my $val = shift;
2251 0 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 0 0 0
Condition0%0/3
$val and $val >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$val and $val >= 0
$val $val >= 0
Truth table0%0/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2252 0 $self->{config}{floodcount} = $val;
2253 0 $self->_send_to_realops(
2254 sprintf(
2255 '%s has changed FLOODCOUNT to %s',
2256 $self->state_user_full($nick,1), $val,
2257 ), qw[Notice s],
2258 );
2259 }
2260 else {
2261 push @$ref, {
2262 prefix => $server,
2263 command => 'NOTICE',
2264 params => [
2265 $nick,
2266 sprintf(
2267 'FLOODCOUNT is currently %s',
2268 $self->{config}{floodcount},
2269 0 ),
2270 ],
2271 };
2272 }
2273 },
2274 0 ▶ FLOODTIME => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2275 0 my $val = shift;
2276 0 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 0 0 0
Condition0%0/3
$val and $val >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$val and $val >= 0
$val $val >= 0
Truth table0%0/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2277 0 $self->{config}{floodtime} = $val;
2278 0 $self->_send_to_realops(
2279 sprintf(
2280 '%s has changed FLOODTIME to %s',
2281 $self->state_user_full($nick,1), $val,
2282 ), qw[Notice s],
2283 );
2284 }
2285 else {
2286 push @$ref, {
2287 prefix => $server,
2288 command => 'NOTICE',
2289 params => [
2290 $nick,
2291 sprintf(
2292 'FLOODTIME is currently %s',
2293 $self->{config}{floodtime},
2294 0 ),
2295 ],
2296 };
2297 }
2298 },
2299 0 ▶ IDENTTIMEOUT => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2300 0 my $val = shift;
2301 0 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 0 0 0
Condition0%0/3
$val and $val >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$val and $val >= 0
$val $val >= 0
Truth table0%0/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2302 0 $self->{config}{ident_timeout} = $val;
2303 0 $self->_send_to_realops(
2304 sprintf(
2305 '%s has changed IDENTTIMEOUT to %s',
2306 $self->state_user_full($nick,1), $val,
2307 ), qw[Notice s],
2308 );
2309 }
2310 else {
2311 push @$ref, {
2312 prefix => $server,
2313 command => 'NOTICE',
2314 params => [
2315 $nick,
2316 sprintf(
2317 'IDENTTIMEOUT is currently %s',
2318 0 ▶ ( $self->{config}{ident_timeout} || 10 ),
Condition0%0/2
$self->{'config'}{'ident_timeout'} || 10
l!l
00
MC/DC0%0/1
$self->{'config'}{'ident_timeout'} || 10
$self->{'config'}{'ident_timeout'}
Truth table0%0/2
A
A= $self->{'config'}{'ident_timeout'}
Aresult
11
00
2319 ),
2320 ],
2321 };
2322 }
2323 },
2324 2 ▶ MAX => sub {
Subroutine __ANON__: called CC=5 SCAR=18.0
2325 2 my $val = shift;
2326 2 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 1 1 2
Condition66%2/3
$val and $val >= 0
!ll&&!rl&&r
101
MC/DC50%1/2
$val and $val >= 0
$val $val >= 0
Truth table66%2/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2327 1 ▶ if ( $val > 7000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val > 7000) 0 1 1
2328 push @$ref, {
2329 prefix => $server,
2330 command => 'NOTICE',
2331 params => [
2332 $nick,
2333 sprintf(
2334 'You cannot set MAXCLIENTS to > 7000, restoring to %u',
2335 $self->{config}{MAXCLIENTS},
2336 0 ),
2337 ],
2338 };
2339 0 return;
2340 }
2341 1 ▶ if ( $val < 32 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val < 32) 1 0 1
2342 push @$ref, {
2343 prefix => $server,
2344 command => 'NOTICE',
2345 params => [
2346 $nick,
2347 sprintf(
2348 'You cannot set MAXCLIENTS to < 32, restoring to %u',
2349 $self->{config}{MAXCLIENTS},
2350 1 ),
2351 ],
2352 };
2353 1 return;
2354 }
2355 0 $self->{config}{MAXCLIENTS} = $val;
2356 0 $self->_send_to_realops(
2357 sprintf(
2358 '%s has changed MAXCLIENTS to %s',
2359 $self->state_user_full($nick,1), $val,
2360 ), qw[Notice s],
2361 );
2362 }
2363 else {
2364 push @$ref, {
2365 prefix => $server,
2366 command => 'NOTICE',
2367 params => [
2368 $nick,
2369 sprintf(
2370 'MAXCLIENTS is currently %s',
2371 $self->{config}{MAXCLIENTS},
2372 1 ),
2373 ],
2374 };
2375 }
2376 },
2377 0 ▶ SPAMNUM => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2378 0 my $val = shift;
2379 0 ▶ if ( defined $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and $val >= 0) { } 0 0 0
Condition0%0/3
defined $val and $val >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and $val >= 0
defined $val $val >= 0
Truth table0%0/3
A and B
A= defined $valB= $val >= 0
ABresult
0X0
100
111
2380 0 $self->{config}{MAX_JOIN_LEAVE_COUNT} = $val;
2381 0 ▶ if ( $val == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val == 0) { } 0 0 0
2382 0 $self->_send_to_realops(
2383 sprintf(
2384 '%s has disabled ANTI_SPAMBOT',
2385 $self->state_user_full($nick,1),
2386 ), qw[Notice s],
2387 );
2388 }
2389 else {
2390 0 $self->_send_to_realops(
2391 sprintf(
2392 '%s has changed SPAMNUM to %s',
2393 $self->state_user_full($nick,1), $val,
2394 ), qw[Notice s],
2395 );
2396 }
2397 }
2398 else {
2399 push @$ref, {
2400 prefix => $server,
2401 command => 'NOTICE',
2402 params => [
2403 $nick,
2404 sprintf(
2405 'SPAMNUM is currently %s',
2406 $self->{config}{MAX_JOIN_LEAVE_COUNT},
2407 0 ),
2408 ],
2409 };
2410 }
2411 },
2412 0 ▶ SPAMTIME => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2413 0 my $val = shift;
2414 0 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 0 0 0
Condition0%0/3
$val and $val >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$val and $val >= 0
$val $val >= 0
Truth table0%0/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2415 0 $self->{config}{MIN_JOIN_LEAVE_TIME} = $val;
2416 0 $self->_send_to_realops(
2417 sprintf(
2418 '%s has changed SPAMTIME to %s',
2419 $self->state_user_full($nick,1), $val,
2420 ), qw[Notice s],
2421 );
2422 }
2423 else {
2424 push @$ref, {
2425 prefix => $server,
2426 command => 'NOTICE',
2427 params => [
2428 $nick,
2429 sprintf(
2430 'SPAMTIME is currently %s',
2431 $self->{config}{MIN_JOIN_LEAVE_TIME},
2432 0 ),
2433 ],
2434 };
2435 }
2436 },
2437 2 ▶ JFLOODTIME => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
2438 2 my $val = shift;
2439 2 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 1 1 2
Condition66%2/3
$val and $val >= 0
!ll&&!rl&&r
101
MC/DC50%1/2
$val and $val >= 0
$val $val >= 0
Truth table66%2/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2440 1 $self->{config}{joinfloodtime} = $val;
2441 1 $self->_send_to_realops(
2442 sprintf(
2443 '%s has changed JFLOODTIME to %s',
2444 $self->state_user_full($nick,1), $val,
2445 ), qw[Notice s],
2446 );
2447 }
2448 else {
2449 push @$ref, {
2450 prefix => $server,
2451 command => 'NOTICE',
2452 params => [
2453 $nick,
2454 sprintf(
2455 'JFLOODTIME is currently %s',
2456 $self->{config}{joinfloodtime},
2457 1 ),
2458 ],
2459 };
2460 }
2461 },
2462 0 ▶ JFLOODCOUNT => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
2463 0 my $val = shift;
2464 0 ▶ if ( $val && $val >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val and $val >= 0) { } 0 0 0
Condition0%0/3
$val and $val >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$val and $val >= 0
$val $val >= 0
Truth table0%0/3
A and B
A= $valB= $val >= 0
ABresult
0X0
100
111
2465 0 $self->{config}{joinfloodcount} = $val;
2466 0 $self->_send_to_realops(
2467 sprintf(
2468 '%s has changed JFLOODCOUNT to %s',
2469 $self->state_user_full($nick,1), $val,
2470 ), qw[Notice s],
2471 );
2472 }
2473 else {
2474 push @$ref, {
2475 prefix => $server,
2476 command => 'NOTICE',
2477 params => [
2478 $nick,
2479 sprintf(
2480 'JFLOODCOUNT is currently %s',
2481 $self->{config}{joinfloodcount},
2482 0 ),
2483 ],
2484 };
2485 }
2486 },
2487 5 );
2488  
2489 SWITCH: {
2490 5 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 5 5
2491 0 push @$ref, ['481'];
2492 0 last SWITCH;
2493 }
2494 5 ▶ if ($count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 0) 4 1 5
2495 4 ▶ if ( defined $vars{ uc $args->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vars{uc $args->[0]}) 4 0 4
2496 4 $vars{ uc $args->[0] }->( $args->[1] );
2497 4 last SWITCH;
2498 }
2499 0 push @$ref, {
2500 prefix => $server,
2501 command => 'NOTICE',
2502 params => [
2503 $nick,
2504 'Variable not found.',
2505 ],
2506 };
2507 0 last SWITCH;
2508 }
2509 1 push @$ref, {
2510 prefix => $server,
2511 command => 'NOTICE',
2512 params => [
2513 $nick,
2514 'Available QUOTE SET commands:',
2515 ],
2516 };
2517 1 my @names;
2518 1 foreach my $var ( sort keys %vars ) {
2519 8 push @names, $var;
2520 8 ▶ if ( scalar @names == 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @names == 4) 2 6 8
2521 2 push @$ref, {
2522 prefix => $server,
2523 command => 'NOTICE',
2524 params => [
2525 $nick,
2526 join(' ',@names),
2527 ],
2528 };
2529 2 @names = ();
2530 }
2531 }
2532 1 ▶ if (@names) {
Branch: 1 branch
BranchTrueFalseTotal
if (@names) 0 1 1
2533 0 push @$ref, {
2534 prefix => $server,
2535 command => 'NOTICE',
2536 params => [
2537 $nick,
2538 join(' ',@names),
2539 ],
2540 };
2541 }
2542 }
2543 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
2544 0 return $ref;
2545 }
2546  
2547 1 ▶sub _daemon_cmd_rehash {
Subroutine _daemon_cmd_rehash: called CC=4 SCAR=15.2
2548 1 my $self = shift;
2549 1 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2550 1 my $server = $self->server_name();
2551 1 my $ref = [ ];
2552  
2553 SWITCH: {
2554 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2555 0 push @$ref, ['481'];
2556 0 last SWITCH;
2557 }
2558 1 $self->send_event("daemon_rehash", $nick);
2559 1 push @$ref, {
2560 prefix => $server,
2561 command => '383',
2562 params => [$nick, 'ircd.conf', 'Rehashing'],
2563 };
2564 }
2565 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2566 0 return $ref;
2567 }
2568  
2569 0 ▶sub _daemon_cmd_locops {
Subroutine _daemon_cmd_locops: not called CC=5 SCAR=34.0
2570 0 my $self = shift;
2571 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2572 0 my $server = $self->server_name();
2573 0 my $ref = [ ];
2574 0 my $args = [@_];
2575 0 my $count = @$args;
2576  
2577 SWITCH: {
2578 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2579 0 push @$ref, ['723', 'locops'];
2580 0 last SWITCH;
2581 }
2582 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2583 0 push @$ref, ['461', 'LOCOPS'];
2584 0 last SWITCH;
2585 }
2586 0 my $full = $self->state_user_full($nick,1);
2587 0 $self->_send_to_realops( "from $nick: " . $args->[0], 'locops', 'l' );
2588 0 $self->send_event("daemon_locops", $full, $args->[0]);
2589 }
2590  
2591 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2592 0 return $ref;
2593 }
2594  
2595 0 ▶sub _daemon_cmd_wallops {
Subroutine _daemon_cmd_wallops: not called CC=5 SCAR=34.0
2596 0 my $self = shift;
2597 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2598 0 my $server = $self->server_name();
2599 0 my $ref = [ ];
2600 0 my $args = [@_];
2601 0 my $count = @$args;
2602  
2603 SWITCH: {
2604 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2605 0 push @$ref, ['723', 'wallops'];
2606 0 last SWITCH;
2607 }
2608 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2609 0 push @$ref, ['461', 'WALLOPS'];
2610 0 last SWITCH;
2611 }
2612  
2613 0 my $full = $self->state_user_full($nick);
2614 0 my $uid = $self->state_user_uid($nick);
2615  
2616 0 $self->send_output(
2617 {
2618 prefix => $uid,
2619 command => 'WALLOPS',
2620 params => [$args->[0]],
2621 },
2622 $self->_state_connected_peers(),
2623 );
2624  
2625 $self->send_output(
2626 {
2627 prefix => $full,
2628 command => 'WALLOPS',
2629 params => [$args->[0]],
2630 },
2631 0 keys %{ $self->{state}{wallops} },
2632 );
2633  
2634 0 $self->send_event("daemon_wallops", $full, $args->[0]);
2635 }
2636  
2637 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2638 0 return $ref;
2639 }
2640  
2641 0 ▶sub _daemon_cmd_globops {
Subroutine _daemon_cmd_globops: not called CC=5 SCAR=34.0
2642 0 my $self = shift;
2643 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2644 0 my $server = $self->server_name();
2645 0 my $sid = $self->server_sid();
2646 0 my $ref = [ ];
2647 0 my $args = [@_];
2648 0 my $count = @$args;
2649  
2650 SWITCH: {
2651 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2652 0 push @$ref, ['723', 'globops'];
2653 0 last SWITCH;
2654 }
2655 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2656 0 push @$ref, ['461', 'GLOBOPS'];
2657 0 last SWITCH;
2658 }
2659  
2660 $self->send_output(
2661 {
2662 0 prefix => $self->state_user_uid($nick),
2663 command => 'GLOBOPS',
2664 params => [ $args->[0] ],
2665 },
2666 $self->_state_connected_peers(),
2667 );
2668  
2669 0 my $msg = "from $nick: " . $args->[0];
2670  
2671 0 $self->_send_to_realops(
2672 $msg,
2673 'Globops',
2674 's',
2675 );
2676  
2677 0 $self->send_event("daemon_globops", $nick, $args->[0]);
2678 }
2679 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2680 0 return $ref;
2681 }
2682  
2683 0 ▶sub _daemon_cmd_connect {
Subroutine _daemon_cmd_connect: not called CC=13 SCAR=52.0
2684 0 my $self = shift;
2685 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2686 0 my $server = $self->server_name();
2687 0 my $ref = [ ];
2688 0 my $args = [@_];
2689 0 my $count = @$args;
2690  
2691 SWITCH: {
2692 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2693 0 push @$ref, ['481'];
2694 0 last SWITCH;
2695 }
2696 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2697 0 push @$ref, ['461', 'CONNECT'];
2698 0 last SWITCH;
2699 }
2700 0 ▶ if ($count >= 3 && !$self->state_peer_exists($args->[2])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 3 and not $self->state_peer_exists($args->[2])) 0 0 0
Condition0%0/3
$count >= 3 and not $self->state_peer_exists($args->[2])
!ll&&!rl&&r
000
MC/DC0%0/2
$count >= 3 and not $self->state_peer_exists($args->[2])
$count >= 3 not $self->state_peer_exists($args->[2])
Truth table0%0/3
A and not(B)
A= $count >= 3B= not $self->state_peer_exists($args->[2])
ABresult
0X0
100
111
2701 0 push @$ref, ['402', $args->[2]];
2702 0 last SWITCH;
2703 }
2704 0 ▶ if ($count >= 3 && uc $server ne uc $args->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 3 and uc $server ne uc $args->[2]) 0 0 0
Condition0%0/3
$count >= 3 and uc $server ne uc $args->[2]
!ll&&!rl&&r
000
MC/DC0%0/2
$count >= 3 and uc $server ne uc $args->[2]
$count >= 3 uc $server ne uc $args->[2]
Truth table0%0/3
A and B
A= $count >= 3B= uc $server ne uc $args->[2]
ABresult
0X0
100
111
2705 0 $args->[2] = $self->_state_peer_name($args->[2]);
2706 0 $self->send_output(
2707 {
2708 prefix => $nick,
2709 command => 'CONNECT',
2710 params => $args,
2711 },
2712 $self->_state_peer_route($args->[2]),
2713 );
2714 0 last SWITCH;
2715 }
2716 0 ▶ if (!$self->{config}{peers}{uc $args->[0]}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"config"}{"peers"}{uc $args->[0]} or $self->{"config"}{"peers"}{uc $args->[0]}{"type"} ne "r") 0 0 0
Condition0%0/3
not $self->{"config"}{"peers"}{uc $args->[0]} or $self->{"config"}{"peers"}{uc $args->[0]}{"type"} ne "r"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->{"config"}{"peers"}{uc $args->[0]} or $self->{"config"}{"peers"}{uc $args->[0]}{"type"} ne "r"
not $self->{"config"}{"peers"}{uc $args->[0]} $self->{"config"}{"peers"}{uc $args->[0]}{"type"} ne "r"
Truth table0%0/3
not(A) or B
A= not $self->{"config"}{"peers"}{uc $args->[0]}B= $self->{"config"}{"peers"}{uc $args->[0]}{"type"} ne "r"
ABresult
1X1
011
000
2717 || $self->{config}{peers}{uc $args->[0]}{type} ne 'r') {
2718 0 push @$ref, {
2719 command => 'NOTICE',
2720 params => [
2721 $nick,
2722 "Connect: Host $args->[0] is not listed in ircd.conf",
2723 ],
2724 };
2725 0 last SWITCH;
2726 }
2727 0 ▶ if (my $peer_name = $self->_state_peer_name($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $peer_name = $self->_state_peer_name($args->[0])) 0 0 0
2728 0 push @$ref, {
2729 command => 'NOTICE',
2730 params => [
2731 $nick,
2732 "Connect: Server $args->[0] already exists from $peer_name.",
2733 ],
2734 };
2735 0 last SWITCH;
2736 }
2737  
2738 0 my $connector = $self->{config}{peers}{uc $args->[0]};
2739 0 my $name = $connector->{name};
2740 0 ▶ my $rport = $args->[1] || $connector->{rport};
Condition0%0/3
$args->[1] || $connector->{'rport'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[1] || $connector->{'rport'}
$args->[1] $connector->{'rport'}
Truth table0%0/3
A || B
A= $args->[1]B= $connector->{'rport'}
ABresult
1X1
011
000
2741 0 my $raddr = $connector->{raddress};
2742 0 $self->add_connector(
2743 remoteaddress => $raddr,
2744 remoteport => $rport,
2745 name => $name,
2746 );
2747 }
2748  
2749 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2750 0 return $ref;
2751 }
2752  
2753 0 ▶sub _daemon_cmd_squit {
Subroutine _daemon_cmd_squit: not called CC=9 SCAR=45.0
2754 0 my $self = shift;
2755 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2756 0 my $server = $self->server_name();
2757 0 my $ref = [ ];
2758 0 my $args = [@_];
2759 0 my $count = @$args;
2760  
2761 SWITCH: {
2762 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2763 0 push @$ref, ['481'];
2764 0 last SWITCH;
2765 }
2766 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2767 0 push @$ref, ['461', 'SQUIT'];
2768 0 last SWITCH;
2769 }
2770 0 ▶ if (!$self->state_peer_exists($args->[0])
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->state_peer_exists($args->[0]) or uc $server eq uc $args->[0]) 0 0 0
Condition0%0/3
not $self->state_peer_exists($args->[0]) or uc $server eq uc $args->[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->state_peer_exists($args->[0]) or uc $server eq uc $args->[0]
not $self->state_peer_exists($args->[0]) uc $server eq uc $args->[0]
Truth table0%0/3
not(A) or B
A= not $self->state_peer_exists($args->[0])B= uc $server eq uc $args->[0]
ABresult
1X1
011
000
2771 || uc $server eq uc $args->[0]) {
2772 0 push @$ref, ['402', $args->[0]];
2773 0 last SWITCH;
2774 }
2775  
2776 0 my $peer = uc $args->[0];
2777 0 ▶ my $reason = $args->[1] || 'No Reason';
Condition0%0/2
$args->[1] || 'No Reason'
l!l
00
MC/DC0%0/1
$args->[1] || 'No Reason'
$args->[1]
Truth table0%0/2
A
A= $args->[1]
Aresult
11
00
2778 0 $args->[0] = $self->_state_peer_name($peer);
2779 0 $args->[1] = $reason;
2780  
2781 0 my $conn_id = $self->_state_peer_route($peer);
2782  
2783 0 ▶ if ( !grep { $_ eq $peer }
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $peer;} keys %{$self->{"state"}{"peers"}{uc $server}{"peers"};}) 0 0 0
2784 0 keys %{ $self->{state}{peers}{uc $server}{peers} }) {
2785 0 $self->send_output(
2786 {
2787 prefix => $self->state_user_uid($nick),
2788 command => 'SQUIT',
2789 params => [ $self->_state_peer_sid($peer), $reason ],
2790 },
2791 $conn_id,
2792 );
2793 0 last SWITCH;
2794 }
2795  
2796 0 $self->disconnect($conn_id, $reason);
2797 0 $self->send_output(
2798 {
2799 command => 'ERROR',
2800 params => [
2801 join ' ', 'Closing Link:',
2802 $self->_client_ip($conn_id), $args->[0], "($nick)"
2803 ],
2804 },
2805 $conn_id,
2806 );
2807 }
2808  
2809 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2810 0 return $ref;
2811 }
2812  
2813 2 ▶sub _daemon_cmd_rkline {
Subroutine _daemon_cmd_rkline: called CC=15 SCAR=30.6
2814 2 my $self = shift;
2815 2 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2816 2 my $server = $self->server_name();
2817 2 my $ref = [ ];
2818 2 my $args = [@_];
2819 2 my $count = @$args;
2820  
2821 SWITCH: {
2822 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
2823 0 push @$ref, ['481'];
2824 0 last SWITCH;
2825 }
2826 2 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 2 2
Condition33%1/3
not $count or $count < 1
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table33%1/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
2827 0 push @$ref, ['461', 'RKLINE'];
2828 0 last SWITCH;
2829 }
2830 2 my $duration = 0;
2831 2 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 1 1 2
2832 1 $duration = shift @$args;
2833 1 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 1 1
2834 }
2835 2 my $mask = shift @$args;
2836 2 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 2 2
2837 0 push @$ref, ['461', 'RKLINE'];
2838 0 last SWITCH;
2839 }
2840 2 my ($user, $host) = split /\@/, $mask;
2841 2 ▶ if (!$user || !$host) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($user and $host) 0 2 2
Condition33%1/3
$user and $host
!ll&&!rl&&r
002
MC/DC0%0/2
$user and $host
$user $host
Truth table33%1/3
A and B
A= $userB= $host
ABresult
0X0
100
111
2842 0 last SWITCH;
2843 }
2844 2 my $full = $self->state_user_full($nick);
2845 2 my $reason;
2846  
2847 {
2848 2 ▶ if (!$reason) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 2 0 2
2849 2 ▶ $reason = pop @$args || '<No reason supplied>';
Condition50%1/2
pop @$args || '<No reason supplied>'
l!l
20
MC/DC0%0/1
pop @$args || '<No reason supplied>'
pop @$args
Truth table50%1/2
A
A= pop @$args
Aresult
11
00
2850 }
2851 $self->send_event(
2852 2 "daemon_rkline",
2853 $full,
2854 $server,
2855 $duration,
2856 $user,
2857 $host,
2858 $reason,
2859 );
2860  
2861 2 ▶ last SWITCH if !$self->_state_add_drkx_line( 'rkline', $full, time(),
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("rkline", $full, time, $server, $duration * 60, $user, $host, $reason) 0 2 2
2862 $server, $duration * 60,
2863 $user, $host, $reason );
2864  
2865 2 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 1 1 2
2866  
2867 2 my $reply_notice = "Added ${temp}RK-Line [$user\@host]";
2868 2 my $locop_notice = "$full added ${temp}RK-Line for [$user\@$host] [$reason]";
2869  
2870 2 push @$ref, {
2871 prefix => $server,
2872 command => 'NOTICE',
2873 params => [ $nick, $reply_notice ],
2874 };
2875  
2876 2 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
2877  
2878 2 $self->_state_do_local_users_match_rkline($user, $host, $reason);
2879 }
2880 }
2881  
2882 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
2883 2 return $ref;
2884 }
2885  
2886 1 ▶sub _daemon_cmd_unrkline {
Subroutine _daemon_cmd_unrkline: called CC=9 SCAR=26.2
2887 1 my $self = shift;
2888 1 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2889 1 my $server = $self->server_name();
2890 1 my $ref = [ ];
2891 1 my $args = [@_];
2892 1 my $count = @$args;
2893  
2894 SWITCH: {
2895 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2896 0 push @$ref, ['481'];
2897 0 last SWITCH;
2898 }
2899 1 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 1 1
Condition33%1/3
not $count or $count < 1
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table33%1/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
2900 0 push @$ref, ['461', 'UNRKLINE'];
2901 0 last SWITCH;
2902 }
2903 1 my ($user, $host) = split /\@/, $args->[0];
2904 1 ▶ if (!$user || !$host) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($user and $host) 0 1 1
Condition33%1/3
$user and $host
!ll&&!rl&&r
001
MC/DC0%0/2
$user and $host
$user $host
Truth table33%1/3
A and B
A= $userB= $host
ABresult
0X0
100
111
2905 0 last SWITCH;
2906 }
2907  
2908 1 my $result = $self->_state_del_drkx_line( 'rkline', $user, $host );
2909  
2910 1 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 1 1
2911 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No RK-Line for [$user\@$host] found" ] };
2912 0 last SWITCH;
2913 }
2914  
2915 1 my $full = $self->state_user_full($nick);
2916  
2917 1 $self->send_event(
2918 "daemon_unrkline", $full, $server, $user, $host,
2919 );
2920  
2921 1 push @$ref, {
2922 prefix => $server,
2923 command => 'NOTICE',
2924 params => [ $nick, "RK-Line for [$user\@$host] is removed" ],
2925 };
2926  
2927 1 $self->_send_to_realops( "$full has removed the RK-Line for: [$user\@$host]", 'Notice', 's' );
2928 }
2929  
2930 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
2931 1 return $ref;
2932 }
2933  
2934 4 ▶sub _daemon_cmd_kline {
Subroutine _daemon_cmd_kline: called CC=26 SCAR=37.0
2935 4 my $self = shift;
2936 4 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2937 4 my $server = $self->server_name();
2938 4 my $ref = [ ];
2939 4 my $args = [@_];
2940 4 my $count = @$args;
2941 # KLINE [time] <nick|user@host> [ ON <server> ] :[reason]
2942  
2943 SWITCH: {
2944 4 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 4 4
2945 0 push @$ref, ['481'];
2946 0 last SWITCH;
2947 }
2948 4 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 4 4
Condition33%1/3
not $count or $count < 1
l!l&&r!l&&!r
004
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table33%1/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
2949 0 push @$ref, ['461', 'KLINE'];
2950 0 last SWITCH;
2951 }
2952 4 my $duration = 0;
2953 4 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 2 4
2954 2 $duration = shift @$args;
2955 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
2956 }
2957 4 my $mask = shift @$args;
2958 4 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 4 4
2959 0 push @$ref, ['461', 'KLINE'];
2960 0 last SWITCH;
2961 }
2962 4 my ($user, $host);
2963 4 ▶ if ($mask !~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $mask =~ /\@/) { } 0 4 4
2964 0 ▶ if (my $rogue = $self->_state_user_full($mask)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rogue = $self->_state_user_full($mask)) { } 0 0 0
2965 0 ($user, $host) = (split /[!\@]/, $rogue )[1..2];
2966 }
2967 else {
2968 0 push @$ref, ['401', $mask];
2969 0 last SWITCH;
2970 }
2971 }
2972 else {
2973 4 ($user, $host) = split /\@/, $mask;
2974 }
2975  
2976 4 my $full = $self->state_user_full($nick);
2977 4 my $us = 0;
2978 4 my $ucserver = uc $server;
2979 4 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 4 4
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
310
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
031
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
2980 && scalar @$args < 2) {
2981 0 push @$ref, ['461', 'KLINE'];
2982 0 last SWITCH;
2983 }
2984 4 my ($target, $reason);
2985 4 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 3 4
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
031
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
2986 1 my $on = shift @$args;
2987 1 $target = shift @$args;
2988 1 ▶ $reason = shift @$args || 'No Reason';
Condition50%1/2
shift @$args || 'No Reason'
l!l
10
MC/DC0%0/1
shift @$args || 'No Reason'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
2989 1 my %targets;
2990  
2991 1 for my $peer (keys %{ $self->{state}{peers} }) {
2992 4 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 4 0 4
2993 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
2994 1 $us = 1;
2995 }
2996 else {
2997 3 $targets{ $self->_state_peer_route($peer) }++;
2998 }
2999 }
3000 }
3001  
3002 $self->send_output(
3003 {
3004 prefix => $self->state_user_uid($nick),
3005 command => 'KLINE',
3006 params => [
3007 $target,
3008 $duration * 60,
3009 $user,
3010 $host,
3011 $reason,
3012 ],
3013 },
3014 1 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
3015 );
3016 }
3017 else {
3018 3 $us = 1;
3019 }
3020  
3021 4 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 4 0 4
3022 4 ▶ $target = $server if !$target;
Branch: 1 branch
BranchTrueFalseTotal
unless $target 3 1 4
3023 4 ▶ if (!$reason) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 3 1 4
3024 3 ▶ $reason = pop @$args || 'No Reason';
Condition50%1/2
pop @$args || 'No Reason'
l!l
30
MC/DC0%0/1
pop @$args || 'No Reason'
pop @$args
Truth table50%1/2
A
A= pop @$args
Aresult
11
00
3025 }
3026  
3027 4 ▶ last SWITCH if !$self->_state_add_drkx_line( 'kline', $full, time(), $server,
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("kline", $full, time, $server, $duration * 60, $user, $host, $reason) 0 4 4
3028 $duration * 60, $user, $host, $reason );
3029 4 $self->send_event(
3030 "daemon_kline",
3031 $full,
3032 $target,
3033 $duration,
3034 $user,
3035 $host,
3036 $reason,
3037 );
3038  
3039 4 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 2 4
3040  
3041 4 my $reply_notice = "Added ${temp}K-Line [$user\@host]";
3042 4 my $locop_notice = "$full added ${temp}K-Line for [$user\@$host] [$reason]";
3043  
3044 4 push @$ref, {
3045 prefix => $server,
3046 command => 'NOTICE',
3047 params => [ $nick, $reply_notice ],
3048 };
3049  
3050 4 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3051  
3052 4 $self->_state_do_local_users_match_kline($user, $host, $reason);
3053 }
3054 }
3055  
3056 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
3057 4 return $ref;
3058 }
3059  
3060 2 ▶sub _daemon_cmd_unkline {
Subroutine _daemon_cmd_unkline: called CC=20 SCAR=42.7
3061 2 my $self = shift;
3062 2 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3063 2 my $server = $self->server_name();
3064 2 my $ref = [ ];
3065 2 my $args = [@_];
3066 2 my $count = @$args;
3067 # UNKLINE <user@host> [ ON <target_mask> ]
3068  
3069 SWITCH: {
3070 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
3071 0 push @$ref, ['481'];
3072 0 last SWITCH;
3073 }
3074 2 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 2 2
Condition33%1/3
not $count or $count < 1
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table33%1/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
3075 0 push @$ref, ['461', 'UNKLINE'];
3076 0 last SWITCH;
3077 }
3078 2 my ($user, $host);
3079 2 ▶ if ($args->[0] !~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $args->[0] =~ /\@/) { } 0 2 2
3080 0 ▶ if (my $rogue = $self->state_user_full($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rogue = $self->state_user_full($args->[0])) { } 0 0 0
3081 0 ($user, $host) = (split /[!\@]/, $rogue)[1..2]
3082 }
3083 else {
3084 0 push @$ref, ['401', $args->[0]];
3085 0 last SWITCH;
3086 }
3087 }
3088 else {
3089 2 ($user, $host) = split /\@/, $args->[0];
3090 }
3091  
3092 2 my $full = $self->state_user_full($nick);
3093 2 my $us = 0;
3094 2 my $ucserver = uc $server;
3095 2 ▶ if ($count > 1 && uc $args->[2] eq 'ON' && $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1 and uc $args->[2] eq "ON" and $count < 3) 0 2 2
Condition50%3/6
$count > 1 and uc $args->[2] eq "ON" and $count < 3
!ll&&!rl&&r
200
$count > 1 and uc $args->[2] eq "ON"
!ll&&!rl&&r
110
MC/DC0%0/3
$count > 1 and uc $args->[2] eq "ON" and $count < 3
$count > 1 uc $args->[2] eq "ON" $count < 3
Truth table50%2/4
A and B and C
A= $count > 1B= uc $args->[2] eq "ON"C= $count < 3
ABCresult
0XX0
10X0
1100
1111
3096 0 push @$ref, ['461', 'UNKLINE'];
3097 0 last SWITCH;
3098 }
3099 2 ▶ if ($count > 1 && $args->[2] && uc $args->[2] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1 and $args->[2] and uc $args->[2] eq 'ON') { } 0 2 2
Condition66%4/6
$count > 1 and $args->[2] and uc $args->[2] eq "ON"
!ll&&!rl&&r
110
$count > 1 and $args->[2]
!ll&&!rl&&r
101
MC/DC0%0/3
$count > 1 and $args->[2] and uc $args->[2] eq "ON"
$count > 1 $args->[2] uc $args->[2] eq "ON"
Truth table50%2/4
A and B and C
A= $count > 1B= $args->[2]C= uc $args->[2] eq "ON"
ABCresult
0XX0
10X0
1100
1111
3100 0 my $target = $args->[3];
3101 0 my %targets;
3102 0 for my $peer (keys %{ $self->{state}{peers} }) {
3103 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
3104 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
3105 0 $us = 1;
3106 }
3107 else {
3108 0 $targets{ $self->_state_peer_route( $peer ) }++;
3109 }
3110 }
3111 }
3112  
3113 $self->send_output(
3114 {
3115 prefix => $self->state_user_uid($nick),
3116 command => 'UNKLINE',
3117 params => [$target, $user, $host],
3118 colonify => 0,
3119 },
3120 0 grep { $self->_state_peer_capab($_, 'UNKLN') } keys %targets,
3121 );
3122 }
3123 else {
3124 2 $us = 1;
3125 }
3126  
3127 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
3128  
3129 2 ▶ my $target = $args->[3] || $server;
Condition33%1/3
$args->[3] || $server
l!l&&r!l&&!r
020
MC/DC0%0/2
$args->[3] || $server
$args->[3] $server
Truth table33%1/3
A || B
A= $args->[3]B= $server
ABresult
1X1
011
000
3130  
3131 2 my $result = $self->_state_del_drkx_line( 'kline', $user, $host );
3132  
3133 2 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 2 2
3134 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No K-Line for [$user\@$host] found" ] };
3135 0 last SWITCH;
3136 }
3137  
3138 $self->send_event(
3139 2 "daemon_unkline", $full, $target, $user, $host,
3140 );
3141  
3142 2 push @$ref, {
3143 prefix => $server,
3144 command => 'NOTICE',
3145 params => [ $nick, "K-Line for [$user\@$host] is removed" ],
3146 };
3147  
3148 2 $self->_send_to_realops( "$full has removed the K-Line for: [$user\@$host]", 'Notice', 's' );
3149 }
3150  
3151 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
3152 2 return $ref;
3153 }
3154  
3155 6 ▶sub _daemon_cmd_resv {
Subroutine _daemon_cmd_resv: called CC=24 SCAR=35.4
3156 6 my $self = shift;
3157 6 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3158 6 my $server = $self->server_name();
3159 6 my $sid = $self->server_sid();
3160 6 my $ref = [ ];
3161 6 my $args = [ @_ ];
3162 6 my $count = @$args;
3163  
3164 SWITCH: {
3165 6 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 6 6
3166 0 push @$ref, ['481'];
3167 0 last SWITCH;
3168 }
3169 6 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 6 6
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
006
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
3170 0 push @$ref, ['461', 'RESV'];
3171 0 last SWITCH;
3172 }
3173 6 my $duration = 0;
3174 6 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 4 6
3175 2 $duration = shift @$args;
3176 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
3177 }
3178 6 my $mask = shift @$args;
3179 6 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 6 6
3180 0 push @$ref, ['461', 'RESV'];
3181 0 last SWITCH;
3182 }
3183 6 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 6 6
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
510
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
051
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
3184 && scalar @$args < 2) {
3185 0 push @$ref, ['461', 'RESV'];
3186 0 last SWITCH;
3187 }
3188 6 my ($peermask,$reason);
3189 6 my $us = 0;
3190 6 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 5 6
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
051
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
3191 1 my $on = shift @$args;
3192 1 $peermask = shift @$args;
3193 1 ▶ $reason = shift @$args || '<No reason supplied>';
Condition50%1/2
shift @$args || '<No reason supplied>'
l!l
10
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
3194 1 my %targpeers; my $ucserver = uc $server;
3195 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3196 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3197 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3198 1 $us = 1;
3199 }
3200 else {
3201 3 $targpeers{ $self->_state_peer_route($peer) }++;
3202 }
3203 }
3204 }
3205 $self->send_output(
3206 {
3207 prefix => $self->state_user_uid($nick),
3208 command => 'RESV',
3209 params => [
3210 $peermask,
3211 ( $duration * 60 ),
3212 $mask,
3213 $reason,
3214 ],
3215 },
3216 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3217 );
3218 }
3219 else {
3220 5 $us = 1;
3221 }
3222  
3223 6 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 6 6
3224  
3225 6 ▶ if ( $self->_state_have_resv($mask) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_have_resv($mask)) 0 6 6
3226 0 push @$ref, {
3227 prefix => $server,
3228 command => 'NOTICE',
3229 params => [ $nick, "A RESV has already been placed on: $mask" ],
3230 };
3231 0 last SWITCH;
3232 }
3233  
3234 6 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 5 1 6
3235 5 ▶ $reason = shift @$args || '<No reason supplied>';
Condition50%1/2
shift @$args || '<No reason supplied>'
l!l
50
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
3236 }
3237  
3238 6 my $full = $self->state_user_full($nick);
3239  
3240 6 ▶ last SWITCH if !$self->_state_add_drkx_line( 'resv', $full, time(), $server,
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("resv", $full, time, $server, $duration * 60, $mask, $reason) 0 6 6
3241 $duration * 60, $mask, $reason );
3242 6 $self->send_event(
3243 "daemon_resv",
3244 $full,
3245 $mask,
3246 $duration,
3247 $reason,
3248 );
3249  
3250 6 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 4 6
3251  
3252 6 my $reply_notice = "Added ${temp}RESV [$mask]";
3253 6 my $locop_notice = "$full added ${temp}RESV for [$mask] [$reason]";
3254  
3255 6 push @$ref, {
3256 prefix => $server,
3257 command => 'NOTICE',
3258 params => [ $nick, $reply_notice ],
3259 };
3260  
3261 6 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3262  
3263 }
3264  
3265 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
3266 6 return $ref;
3267 }
3268  
3269 4 ▶sub _daemon_cmd_unresv {
Subroutine _daemon_cmd_unresv: called CC=15 SCAR=29.4
3270 4 my $self = shift;
3271 4 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3272 4 my $server = $self->server_name();
3273 4 my $sid = $self->server_sid();
3274 4 my $ref = [ ];
3275 4 my $args = [ @_ ];
3276 4 my $count = @$args;
3277  
3278 SWITCH: {
3279 4 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 4 4
3280 0 push @$ref, ['481'];
3281 0 last SWITCH;
3282 }
3283 4 ▶ if (!$count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 4 4
3284 0 push @$ref, ['461', 'UNRESV'];
3285 0 last SWITCH;
3286 }
3287 4 my $unmask = shift @$args;
3288 4 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 4 4
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
310
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
301
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
3289 && scalar @$args < 2) {
3290 0 push @$ref, ['461', 'UNRESV'];
3291 0 last SWITCH;
3292 }
3293 4 my $us = 0;
3294 4 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 3 4
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
301
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
3295 1 my $on = shift @$args;
3296 1 my $peermask = shift @$args;
3297 1 my %targpeers; my $ucserver = uc $server;
3298 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3299 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3300 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3301 1 $us = 1;
3302 }
3303 else {
3304 3 $targpeers{ $self->_state_peer_route($peer) }++;
3305 }
3306 }
3307 }
3308 $self->send_output(
3309 {
3310 prefix => $self->state_user_uid($nick),
3311 command => 'UNRESV',
3312 params => [
3313 $peermask,
3314 $unmask,
3315 ],
3316 colonify => 0,
3317 },
3318 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3319 );
3320 }
3321 else {
3322 3 $us = 1;
3323 }
3324  
3325 4 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 4 4
3326  
3327 4 my $result = $self->_state_del_drkx_line( 'resv', $unmask );
3328  
3329 4 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 4 4
3330 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No RESV for [$unmask] found" ] };
3331 0 last SWITCH;
3332 }
3333  
3334 4 my $full = $self->state_user_full($nick);
3335 4 $self->send_event(
3336 "daemon_unresv",
3337 $full,
3338 $unmask,
3339 );
3340  
3341 4 push @$ref, {
3342 prefix => $server,
3343 command => 'NOTICE',
3344 params => [ $nick, "RESV for [$unmask] is removed" ],
3345 };
3346  
3347 4 $self->_send_to_realops( "$full has removed the RESV for: [$unmask]", 'Notice', 's' );
3348 }
3349  
3350 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
3351 4 return $ref;
3352 }
3353  
3354 3 ▶sub _daemon_cmd_xline {
Subroutine _daemon_cmd_xline: called CC=23 SCAR=34.3
3355 3 my $self = shift;
3356 3 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3357 3 my $server = $self->server_name();
3358 3 my $sid = $self->server_sid();
3359 3 my $ref = [ ];
3360 3 my $args = [ @_ ];
3361 3 my $count = @$args;
3362  
3363 SWITCH: {
3364 3 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 3 3
3365 0 push @$ref, ['481'];
3366 0 last SWITCH;
3367 }
3368 3 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 3 3
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
003
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
3369 0 push @$ref, ['461', 'XLINE'];
3370 0 last SWITCH;
3371 }
3372 3 my $duration = 0;
3373 3 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 1 3
3374 2 $duration = shift @$args;
3375 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
3376 }
3377 3 my $mask = shift @$args;
3378 3 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 3 3
3379 0 push @$ref, ['461', 'XLINE'];
3380 0 last SWITCH;
3381 }
3382 3 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 3 3
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
210
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
021
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
3383 && scalar @$args < 2) {
3384 0 push @$ref, ['461', 'XLINE'];
3385 0 last SWITCH;
3386 }
3387 3 my ($peermask,$reason);
3388 3 my $us = 0;
3389 3 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 2 3
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
021
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
3390 1 my $on = shift @$args;
3391 1 $peermask = shift @$args;
3392 1 ▶ $reason = shift @$args || '<No reason supplied>';
Condition50%1/2
shift @$args || '<No reason supplied>'
l!l
10
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
3393 1 my %targpeers; my $ucserver = uc $server;
3394 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3395 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3396 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3397 1 $us = 1;
3398 }
3399 else {
3400 3 $targpeers{ $self->_state_peer_route($peer) }++;
3401 }
3402 }
3403 }
3404 $self->send_output(
3405 {
3406 prefix => $self->state_user_uid($nick),
3407 command => 'XLINE',
3408 params => [
3409 $peermask,
3410 ( $duration * 60 ),
3411 $mask,
3412 $reason,
3413 ],
3414 },
3415 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3416 );
3417 }
3418 else {
3419 2 $us = 1;
3420 }
3421  
3422 3 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 3 3
3423  
3424 3 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 2 1 3
3425 2 ▶ $reason = shift @$args || '<No reason supplied>';
Condition50%1/2
shift @$args || '<No reason supplied>'
l!l
20
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
3426 }
3427  
3428 3 my $full = $self->state_user_full($nick);
3429  
3430 3 ▶ last SWITCH if !$self->_state_add_drkx_line( 'xline', $full, time(), $server,
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("xline", $full, time, $server, $duration * 60, $mask, $reason) 0 3 3
3431 $duration * 60, $mask, $reason );
3432 3 $self->send_event(
3433 "daemon_xline",
3434 $full,
3435 $mask,
3436 $duration,
3437 $reason,
3438 );
3439  
3440 3 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 1 3
3441  
3442 3 my $reply_notice = "Added ${temp}X-Line [$mask]";
3443 3 my $locop_notice = "$full added ${temp}X-Line for [$mask] [$reason]";
3444  
3445 3 push @$ref, {
3446 prefix => $server,
3447 command => 'NOTICE',
3448 params => [ $nick, $reply_notice ],
3449 };
3450  
3451 3 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3452  
3453 3 $self->_state_do_local_users_match_xline($mask,$reason);
3454 }
3455  
3456 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
3457 3 return $ref;
3458 }
3459  
3460 2 ▶sub _daemon_cmd_unxline {
Subroutine _daemon_cmd_unxline: called CC=15 SCAR=29.4
3461 2 my $self = shift;
3462 2 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3463 2 my $server = $self->server_name();
3464 2 my $sid = $self->server_sid();
3465 2 my $ref = [ ];
3466 2 my $args = [ @_ ];
3467 2 my $count = @$args;
3468  
3469 SWITCH: {
3470 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
3471 0 push @$ref, ['481'];
3472 0 last SWITCH;
3473 }
3474 2 ▶ if (!$count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
3475 0 push @$ref, ['461', 'UNXLINE'];
3476 0 last SWITCH;
3477 }
3478 2 my $unmask = shift @$args;
3479 2 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 2 2
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
110
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
101
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
3480 && scalar @$args < 2) {
3481 0 push @$ref, ['461', 'UNXLINE'];
3482 0 last SWITCH;
3483 }
3484 2 my $us = 0;
3485 2 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 1 2
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
101
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
3486 1 my $on = shift @$args;
3487 1 my $peermask = shift @$args;
3488 1 my %targpeers; my $ucserver = uc $server;
3489 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3490 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3491 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3492 1 $us = 1;
3493 }
3494 else {
3495 3 $targpeers{ $self->_state_peer_route($peer) }++;
3496 }
3497 }
3498 }
3499 $self->send_output(
3500 {
3501 prefix => $self->state_user_uid($nick),
3502 command => 'UNXLINE',
3503 params => [
3504 $peermask,
3505 $unmask,
3506 ],
3507 colonify => 0,
3508 },
3509 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3510 );
3511 }
3512 else {
3513 1 $us = 1;
3514 }
3515  
3516 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
3517  
3518 2 my $result = $self->_state_del_drkx_line( 'xline', $unmask );
3519  
3520 2 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 2 2
3521 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No X-Line for [$unmask] found" ] };
3522 0 last SWITCH;
3523 }
3524  
3525 2 my $full = $self->state_user_full($nick);
3526 2 $self->send_event(
3527 "daemon_unxline",
3528 $full,
3529 $unmask,
3530 );
3531  
3532 2 push @$ref, {
3533 prefix => $server,
3534 command => 'NOTICE',
3535 params => [ $nick, "X-Line for [$unmask] is removed" ],
3536 };
3537  
3538 2 $self->_send_to_realops( "$full has removed the X-Line for: [$unmask]", 'Notice', 's' );
3539 }
3540  
3541 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
3542 2 return $ref;
3543 }
3544  
3545 3 ▶sub _daemon_cmd_dline {
Subroutine _daemon_cmd_dline: called CC=32 SCAR=44.7
3546 3 my $self = shift;
3547 3 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3548 3 my $server = $self->server_name();
3549 3 my $sid = $self->server_sid();
3550 3 my $ref = [ ];
3551 3 my $args = [ @_ ];
3552 3 my $count = @$args;
3553  
3554 SWITCH: {
3555 3 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 3 3
3556 0 push @$ref, ['481'];
3557 0 last SWITCH;
3558 }
3559 3 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 3 3
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
003
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
3560 0 push @$ref, ['461', 'DLINE'];
3561 0 last SWITCH;
3562 }
3563 3 my $duration = 0;
3564 3 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 1 3
3565 2 $duration = shift @$args;
3566 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
3567 }
3568 3 my $mask = shift @$args;
3569 3 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 3 3
3570 0 push @$ref, ['461', 'KLINE'];
3571 0 last SWITCH;
3572 }
3573 3 my $netmask;
3574 3 ▶ if ( $mask !~ m![:.]! && $self->state_nick_exists($mask) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $mask =~ /[:.]/ and $self->state_nick_exists($mask)) { } 0 3 3
elsif (not $mask =~ /[:.]/ || $self->state_nick_exists($mask)) { } 0 3 3
Condition33%1/3
not $mask =~ /[:.]/ and $self->state_nick_exists($mask)
!ll&&!rl&&r
300
MC/DC0%0/2
not $mask =~ /[:.]/ and $self->state_nick_exists($mask)
not $mask =~ /[:.]/ $self->state_nick_exists($mask)
Truth table33%1/3
not(A) and B
A= not $mask =~ /[:.]/B= $self->state_nick_exists($mask)
ABresult
0X0
100
111
3575 0 my $uid = $self->state_user_uid($mask);
3576 0 ▶ if ( $uid !~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($uid =~ /^$sid/) 0 0 0
3577 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, 'Cannot DLINE nick on another server' ] };
3578 0 last SWITCH;
3579 }
3580 0 ▶ if ( $self->{state}{uids}{$uid}{umode} =~ m!o! || $self->{state}{uids}{$uid}{route_id} eq 'spoofed' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/ or $self->{"state"}{"uids"}{$uid}{"route_id"} eq "spoofed") 0 0 0
Condition0%0/3
$self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/ or $self->{"state"}{"uids"}{$uid}{"route_id"} eq "spoofed"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/ or $self->{"state"}{"uids"}{$uid}{"route_id"} eq "spoofed"
$self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/ $self->{"state"}{"uids"}{$uid}{"route_id"} eq "spoofed"
Truth table0%0/3
A or B
A= $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/B= $self->{"state"}{"uids"}{$uid}{"route_id"} eq "spoofed"
ABresult
1X1
011
000
3581 0 my $tnick = $self->{state}{uids}{$uid}{nick};
3582 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "$tnick is E-lined" ] };
3583 0 last SWITCH;
3584 }
3585 0 my $addr = $self->{state}{uids}{$uid}{socket}[0];
3586 0 $netmask = Net::CIDR::cidrvalidate($addr);
3587 }
3588 ▶ elsif ( $mask !~ m![:.]! && !$self->state_nick_exists($mask) ) {
Condition33%1/3
$mask =~ /[:.]/ || $self->state_nick_exists($mask)
l!l&&r!l&&!r
300
MC/DC0%0/2
$mask =~ /[:.]/ || $self->state_nick_exists($mask)
$mask =~ /[:.]/ $self->state_nick_exists($mask)
Truth table33%1/3
A || B
A= $mask =~ /[:.]/B= $self->state_nick_exists($mask)
ABresult
1X1
011
000
3589 0 push @$ref, ['401', $mask];
3590 0 last SWITCH;
3591 }
3592 3 ▶ if ( !$netmask ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($netmask) 3 0 3
3593 3 $netmask = Net::CIDR::cidrvalidate($mask);
3594 3 ▶ if ( !$netmask ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($netmask) 0 3 3
3595 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, 'Unable to parse provided IP mask' ] };
3596 0 last SWITCH;
3597 }
3598 }
3599 3 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 3 3
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
210
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
021
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
3600 && scalar @$args < 2) {
3601 0 push @$ref, ['461', 'DLINE'];
3602 0 last SWITCH;
3603 }
3604 3 my ($peermask,$reason,$on);
3605 3 my $us = 0;
3606 3 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 2 3
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
021
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
3607 1 $on = shift @$args;
3608 1 $peermask = shift @$args;
3609 1 ▶ $reason = shift @$args || '<No reason supplied>';
Condition50%1/2
shift @$args || '<No reason supplied>'
l!l
10
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
3610 1 my %targpeers; my $ucserver = uc $server;
3611 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3612 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3613 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3614 1 $us = 1;
3615 }
3616 else {
3617 3 $targpeers{ $self->_state_peer_route($peer) }++;
3618 }
3619 }
3620 }
3621 $self->send_output(
3622 {
3623 prefix => $self->state_user_uid($nick),
3624 command => 'DLINE',
3625 params => [
3626 $peermask,
3627 ( $duration * 60 ),
3628 $netmask,
3629 $reason,
3630 ],
3631 },
3632 1 grep { $self->_state_peer_capab($_, 'DLN') } keys %targpeers,
3633 );
3634 }
3635 else {
3636 2 $us = 1;
3637 }
3638  
3639 3 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 3 3
3640  
3641 3 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 2 1 3
3642 2 ▶ $reason = shift @$args || '<No reason supplied>';
Condition50%1/2
shift @$args || '<No reason supplied>'
l!l
20
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table50%1/2
A
A= shift @$args
Aresult
11
00
3643 }
3644  
3645 3 my $full = $self->state_user_full($nick);
3646  
3647 3 ▶ last SWITCH if !$self->_state_add_drkx_line( 'dline',
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("dline", $full, time, $server, $duration * 60, $netmask, $reason) 0 3 3
3648 $full, time, $server, $duration * 60,
3649 $netmask, $reason );
3650  
3651 3 $self->send_event(
3652 "daemon_dline",
3653 $full,
3654 $netmask,
3655 $duration,
3656 $reason,
3657 );
3658  
3659 3 $self->add_denial( $netmask, 'You have been D-lined.' );
3660  
3661 3 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 1 3
3662  
3663 3 my $reply_notice = "Added ${temp}D-Line [$netmask]";
3664 3 my $locop_notice = "$full added ${temp}D-Line for [$netmask] [$reason]";
3665  
3666 3 push @$ref, {
3667 prefix => $server,
3668 command => 'NOTICE',
3669 params => [ $nick, $reply_notice ],
3670 };
3671  
3672 3 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3673  
3674 3 $self->_state_do_local_users_match_dline($netmask,$reason);
3675 }
3676  
3677 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
3678 3 return $ref;
3679 }
3680  
3681 2 ▶sub _daemon_cmd_undline {
Subroutine _daemon_cmd_undline: called CC=15 SCAR=29.3
3682 2 my $self = shift;
3683 2 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3684 2 my $server = $self->server_name();
3685 2 my $sid = $self->server_sid();
3686 2 my $ref = [ ];
3687 2 my $args = [ @_ ];
3688 2 my $count = @$args;
3689  
3690 SWITCH: {
3691 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
3692 0 push @$ref, ['481'];
3693 0 last SWITCH;
3694 }
3695 2 ▶ if (!$count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
3696 0 push @$ref, ['461', 'UNDLINE'];
3697 0 last SWITCH;
3698 }
3699 2 my $unmask = shift @$args;
3700 2 ▶ if ($args->[0] && uc $args->[0] eq 'ON'
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2) 0 2 2
Condition66%4/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
110
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
101
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
$args->[0] uc $args->[0] eq "ON" scalar @$args < 2
Truth table50%2/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
3701 && scalar @$args < 2) {
3702 0 push @$ref, ['461', 'UNDLINE'];
3703 0 last SWITCH;
3704 }
3705 2 my $us = 0;
3706 2 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 1 1 2
Condition66%2/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
101
MC/DC50%1/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table66%2/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
3707 1 my $on = shift @$args;
3708 1 my $peermask = shift @$args;
3709 1 my %targpeers; my $ucserver = uc $server;
3710 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3711 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3712 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3713 1 $us = 1;
3714 }
3715 else {
3716 3 $targpeers{ $self->_state_peer_route($peer) }++;
3717 }
3718 }
3719 }
3720 $self->send_output(
3721 {
3722 prefix => $self->state_user_uid($nick),
3723 command => 'UNDLINE',
3724 params => [
3725 $peermask,
3726 $unmask,
3727 ],
3728 colonify => 0,
3729 },
3730 1 grep { $self->_state_peer_capab($_, 'UNDLN') } keys %targpeers,
3731 );
3732 }
3733 else {
3734 1 $us = 1;
3735 }
3736  
3737 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
3738  
3739 2 my $result = $self->_state_del_drkx_line( 'dline', $unmask );
3740  
3741 2 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 2 2
3742 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No D-Line for [$unmask] found" ] };
3743 0 last SWITCH;
3744 }
3745  
3746 2 my $full = $self->state_user_full($nick);
3747 2 $self->send_event(
3748 "daemon_undline",
3749 $full,
3750 $unmask,
3751 );
3752  
3753 2 $self->del_denial( $unmask );
3754  
3755 2 push @$ref, {
3756 prefix => $server,
3757 command => 'NOTICE',
3758 params => [ $nick, "D-Line for [$unmask] is removed" ],
3759 };
3760  
3761 2 $self->_send_to_realops(
3762 "$full has removed the D-Line for: [$unmask]",
3763 'Notice',
3764 's',
3765 );
3766 }
3767  
3768 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
3769 2 return $ref;
3770 }
3771  
3772 0 ▶sub _daemon_cmd_kill {
Subroutine _daemon_cmd_kill: not called CC=11 SCAR=48.8
3773 0 my $self = shift;
3774 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
3775 my $server = ( $self->{config}{'hidden_servers'} ?
3776 0 ▶ $self->{config}{'hidden_servers'} : $self->server_name() );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'config'}{'hidden_servers'} ? : 0 0 0
3777 0 my $ref = [ ];
3778 0 my $args = [@_];
3779 0 my $count = @$args;
3780  
3781 SWITCH: {
3782 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
3783 0 push @$ref, ['481'];
3784 0 last SWITCH;
3785 }
3786 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
3787 0 push @$ref, ['461', 'KILL'];
3788 0 last SWITCH;
3789 }
3790 0 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 0 0 0
3791 0 push @$ref, ['483'];
3792 0 last SWITCH;
3793 }
3794 0 ▶ if (!$self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($args->[0])) 0 0 0
3795 0 push @$ref, ['401', $args->[0]];
3796 0 last SWITCH;
3797 }
3798 0 my $target = $self->state_user_nick($args->[0]);
3799 0 my $targuid = $self->state_user_uid($target);
3800 0 my $uid = $self->state_user_uid($nick);
3801 0 ▶ my $comment = $args->[1] || '<No reason given>';
Condition0%0/2
$args->[1] || '<No reason given>'
l!l
00
MC/DC0%0/1
$args->[1] || '<No reason given>'
$args->[1]
Truth table0%0/2
A
A= $args->[1]
Aresult
11
00
3802 0 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 0 0 0
3803 0 my $route_id = $self->_state_user_route($target);
3804 0 $self->send_output(
3805 {
3806 prefix => $uid,
3807 command => 'KILL',
3808 params => [
3809 $targuid,
3810 join('!', $server, $nick )." ($comment)",
3811 ]
3812 },
3813 $self->_state_connected_peers(),
3814 );
3815  
3816 0 $self->send_output(
3817 {
3818 prefix => $self->state_user_full($nick),
3819 command => 'KILL',
3820 params => [$target, $comment],
3821 },
3822 $route_id,
3823 );
3824 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
3825 0 $self->call('del_spoofed_nick', $target, "Killed ($comment)");
3826 }
3827 else {
3828 0 $self->{state}{conns}{$route_id}{killed} = 1;
3829 0 $self->_terminate_conn_error($route_id, "Killed ($comment)");
3830 }
3831 }
3832 else {
3833 0 $self->{state}{uids}{$targuid}{killed} = 1;
3834 0 $self->send_output(
3835 {
3836 prefix => $uid,
3837 command => 'KILL',
3838 params => [
3839 $targuid,
3840 join('!', $server, $nick )." ($comment)",
3841 ],
3842 },
3843 $self->_state_connected_peers(),
3844 );
3845 $self->send_output(
3846 0 @{ $self->_daemon_peer_quit(
3847 $targuid,
3848 "Killed ($nick ($comment))"
3849 )}
3850 );
3851 }
3852 }
3853  
3854 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3855 0 return $ref;
3856 }
3857  
3858 4 ▶sub _daemon_peer_tracing {
Subroutine _daemon_peer_tracing: called CC=15 SCAR=34.8
3859 4 my $self = shift;
3860 4 my $cmd = shift;
3861 4 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3862 4 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3863 4 my $server = $self->server_name();
3864 4 my $sid = $self->server_sid();
3865 4 my $args = [@_];
3866 4 my $count = @$args;
3867 4 my $ref = [ ];
3868 4 $cmd = uc $cmd;
3869  
3870 SWITCH: {
3871 4 ▶ if ($count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1) 0 4 4
3872 0 ▶ my $targ = ( $self->state_user_uid($args->[1]) || $self->_state_peer_sid($args->[1] ) );
Condition0%0/3
$self->state_user_uid($args->[1]) || $self->_state_peer_sid($args->[1])
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->state_user_uid($args->[1]) || $self->_state_peer_sid($args->[1])
$self->state_user_uid($args->[1]) $self->_state_peer_sid($args->[1])
Truth table0%0/3
A || B
A= $self->state_user_uid($args->[1])B= $self->_state_peer_sid($args->[1])
ABresult
1X1
011
000
3873 0 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 0 0
3874 0 push @$ref, {
3875 prefix => $sid,
3876 command => '402',
3877 params => [
3878 $uid,
3879 $args->[1],
3880 ],
3881 };
3882 0 last SWITCH;
3883 }
3884 0 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 0 0 0
3885 0 my $psid = substr $targ, 0, 3;
3886 0 $self->send_output(
3887 {
3888 prefix => $uid,
3889 command => $cmd,
3890 params => [
3891 $args->[0],
3892 $targ,
3893 ],
3894 },
3895 $self->_state_sid_route($psid),
3896 );
3897 0 last SWITCH;
3898 }
3899 }
3900 4 ▶ if ($args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0]) 4 0 4
3901 4 ▶ my $targ = ( $self->state_user_uid($args->[0]) || $self->_state_peer_sid($args->[0] ) );
Condition33%1/3
$self->state_user_uid($args->[0]) || $self->_state_peer_sid($args->[0])
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->state_user_uid($args->[0]) || $self->_state_peer_sid($args->[0])
$self->state_user_uid($args->[0]) $self->_state_peer_sid($args->[0])
Truth table33%1/3
A || B
A= $self->state_user_uid($args->[0])B= $self->_state_peer_sid($args->[0])
ABresult
1X1
011
000
3902 4 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 4 4
3903 0 push @$ref, {
3904 prefix => $sid,
3905 command => '402',
3906 params => [
3907 $uid,
3908 $args->[0],
3909 ],
3910 };
3911 0 last SWITCH;
3912 }
3913 4 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 2 2 4
3914 2 my $name;
3915 my $route_id;
3916 2 ▶ if ( length $targ == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $targ == 3) { } 2 0 2
3917 2 $name = $self->{state}{sids}{$targ}{name};
3918 2 $route_id = $self->{state}{sids}{$targ}{route_id};
3919 }
3920 else {
3921 0 $name = $self->{state}{uids}{$targ}{nick};
3922 0 $route_id = $self->{state}{uids}{$targ}{route_id};
3923 }
3924 push @$ref, {
3925 prefix => $sid,
3926 command => '200',
3927 params => [
3928 $uid,
3929 'Link',
3930 $self->server_version(),
3931 $name,
3932 $self->{state}{conns}{$route_id}{name},
3933 2 ],
3934 };
3935 2 $self->send_output(
3936 {
3937 prefix => $uid,
3938 command => $cmd,
3939 params => [
3940 $targ,
3941 ],
3942 },
3943 $route_id,
3944 );
3945 2 last SWITCH;
3946 }
3947 }
3948 2 ▶ my $method = ( $cmd eq 'ETRACE' ? '_daemon_do_etrace' : '_daemon_do_trace' );
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq 'ETRACE' ? : 1 1 2
3949 2 push @$ref, $_ for @{ $self->$method($uid, @$args) };
3950 }
3951 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4 0 4
3952 0 return $ref;
3953 }
3954  
3955 3 ▶sub _state_find_peer {
Subroutine _state_find_peer: called CC=21 SCAR=36.0
3956 3 my $self = shift;
3957 3 ▶ my $targ = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3958 3 my $connid = shift;
3959 3 my $server = $self->server_name();
3960 3 my $sid = $self->server_sid();
3961 3 my $ume = uc $server;
3962 3 my $result;
3963  
3964 3 ▶ if ($self->state_nick_exists($targ)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($targ)) 0 3 3
3965 0 $result = $self->state_user_uid($targ);
3966 }
3967 3 ▶ if (!$result && $self->state_peer_exists($targ)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result and $self->state_peer_exists($targ)) 0 3 3
Condition33%1/3
not $result and $self->state_peer_exists($targ)
!ll&&!rl&&r
030
MC/DC0%0/2
not $result and $self->state_peer_exists($targ)
not $result $self->state_peer_exists($targ)
Truth table33%1/3
not(A) and B
A= not $resultB= $self->state_peer_exists($targ)
ABresult
0X0
100
111
3968 0 $result = $self->_state_peer_sid($targ);
3969 }
3970 3 ▶ if (!$result && $targ =~ m![\x2A\x3F]!) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result and $targ =~ /[\x2A\x3F]/) 3 0 3
Condition33%1/3
not $result and $targ =~ /[\x2A\x3F]/
!ll&&!rl&&r
003
MC/DC0%0/2
not $result and $targ =~ /[\x2A\x3F]/
not $result $targ =~ /[\x2A\x3F]/
Truth table33%1/3
not(A) and B
A= not $resultB= $targ =~ /[\x2A\x3F]/
ABresult
0X0
100
111
3971 3 PEERS: foreach my $peer ( sort keys %{ $self->{state}{peers} } ) {
3972 9 ▶ if ( matches_mask($targ,$peer,'ascii') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targ, $peer, "ascii")) 1 8 9
3973 1 ▶ return $sid if $ume eq $peer;
Branch: 1 branch
BranchTrueFalseTotal
if $ume eq $peer 0 1 1
3974 1 my $peerrec = $self->{state}{peers}{$peer};
3975 next PEERS if $connid && $connid eq $peerrec->{route_id}
3976 1 ▶ && $peerrec->{type} eq 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $connid and $connid eq $peerrec->{"route_id"} and $peerrec->{"type"} eq "r" 0 1 1
Condition33%2/6
$connid and $connid eq $peerrec->{"route_id"} and $peerrec->{"type"} eq "r"
!ll&&!rl&&r
100
$connid and $connid eq $peerrec->{"route_id"}
!ll&&!rl&&r
100
MC/DC0%0/3
$connid and $connid eq $peerrec->{"route_id"} and $peerrec->{"type"} eq "r"
$connid $connid eq $peerrec->{"route_id"} $peerrec->{"type"} eq "r"
Truth table25%1/4
A and B and C
A= $connidB= $connid eq $peerrec->{"route_id"}C= $peerrec->{"type"} eq "r"
ABCresult
0XX0
10X0
1100
1111
3977 1 $result = $peerrec->{sid};
3978 1 last PEERS;
3979 }
3980 }
3981 3 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 2 1 3
3982 2 USERS: foreach my $user ( sort keys %{ $self->{state}{users} } ) {
3983 10 ▶ if ( matches_mask($targ,$user) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targ, $user)) 2 8 10
3984 2 my $rec = $self->{state}{users}{$user};
3985 2 ▶ return $sid if $rec->{uid} =~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"uid"} =~ /^$sid/ 0 2 2
3986 next USERS if $connid && $connid eq $rec->{route_id}
3987 2 ▶ && $self->{state}{sids}{ $rec->{sid} }{type} eq 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $connid and $connid eq $rec->{"route_id"} and $self->{"state"}{"sids"}{$rec->{"sid"}}{"type"} eq "r" 0 2 2
Condition33%2/6
$connid and $connid eq $rec->{"route_id"} and $self->{"state"}{"sids"}{$rec->{"sid"}}{"type"} eq "r"
!ll&&!rl&&r
200
$connid and $connid eq $rec->{"route_id"}
!ll&&!rl&&r
200
MC/DC0%0/3
$connid and $connid eq $rec->{"route_id"} and $self->{"state"}{"sids"}{$rec->{"sid"}}{"type"} eq "r"
$connid $connid eq $rec->{"route_id"} $self->{"state"}{"sids"}{$rec->{"sid"}}{"type"} eq "r"
Truth table25%1/4
A and B and C
A= $connidB= $connid eq $rec->{"route_id"}C= $self->{"state"}{"sids"}{$rec->{"sid"}}{"type"} eq "r"
ABCresult
0XX0
10X0
1100
1111
3988 2 $result = $rec->{uid};
3989 last USERS
3990 2 }
3991 }
3992 }
3993 }
3994 3 ▶ return $result if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 3 0 3
3995 0 return;
3996 }
3997  
3998 6 ▶sub _daemon_client_tracing {
Subroutine _daemon_client_tracing: called CC=14 SCAR=30.0
3999 6 my $self = shift;
4000 6 my $cmd = shift;
4001 6 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4002 6 my $server = $self->server_name();
4003 6 my $sid = $self->server_sid();
4004 6 my $args = [@_];
4005 6 my $count = @$args;
4006 6 my $ref = [ ];
4007 6 $cmd = uc $cmd;
4008  
4009 SWITCH: {
4010 6 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 2 4 6
4011 2 ▶ if ( $cmd eq 'ETRACE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "ETRACE") 1 1 2
4012 1 push @$ref, ['481'];
4013 1 last SWITCH;
4014 }
4015 1 push @$ref, {
4016 prefix => $server,
4017 command => '262',
4018 params => [
4019 $nick, $server, 'End of TRACE',
4020 ],
4021 };
4022 1 last SWITCH;
4023 }
4024 4 ▶ if ($count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1) 0 4 4
4025 0 my $targ = $self->_state_find_peer($args->[1]);
4026 0 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 0 0
4027 0 push @$ref, [ '402', $args->[1] ];
4028 0 last SWITCH;
4029 }
4030 0 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 0 0 0
4031 0 my $psid = substr $targ, 0, 3;
4032 0 $self->send_output(
4033 {
4034 prefix => $self->state_user_uid($nick),
4035 command => $cmd,
4036 params => [
4037 $args->[0],
4038 $targ,
4039 ],
4040 },
4041 $self->_state_sid_route($psid),
4042 );
4043 0 last SWITCH;
4044 }
4045 }
4046 4 my $uid = $self->state_user_uid($nick);
4047 4 ▶ if ($args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0]) 2 2 4
4048 2 my $targ = $self->_state_find_peer($args->[0]);
4049 2 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 2 2
4050 0 push @$ref, [ '402', $args->[0] ];
4051 0 last SWITCH;
4052 }
4053 2 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 2 0 2
4054 2 my $name;
4055 my $route_id;
4056 2 ▶ if ( length $targ == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $targ == 3) { } 0 2 2
4057 0 $name = $self->{state}{sids}{$targ}{name};
4058 0 $route_id = $self->{state}{sids}{$targ}{route_id};
4059 }
4060 else {
4061 2 $name = $self->{state}{uids}{$targ}{nick};
4062 2 $route_id = $self->{state}{uids}{$targ}{route_id};
4063 }
4064 push @$ref, {
4065 prefix => $server,
4066 command => '200',
4067 params => [
4068 $nick,
4069 'Link',
4070 $self->server_version(),
4071 $name,
4072 $self->{state}{conns}{$route_id}{name},
4073 2 ],
4074 };
4075 2 $self->send_output(
4076 {
4077 prefix => $uid,
4078 command => $cmd,
4079 params => [
4080 $targ,
4081 ],
4082 },
4083 $route_id,
4084 );
4085 2 last SWITCH;
4086 }
4087 }
4088 2 ▶ my $method = ( $cmd eq 'ETRACE' ? '_daemon_do_etrace' : '_daemon_do_trace' );
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq 'ETRACE' ? : 1 1 2
4089 2 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
4090 2 @{ $self->$method($uid, @$args) };
4091 }
4092 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
4093 0 return $ref;
4094 }
4095  
4096 2 ▶sub _daemon_do_etrace {
Subroutine _daemon_do_etrace: called CC=20 SCAR=32.3
4097 2 my $self = shift;
4098 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4099 2 my $server = $self->server_name();
4100 2 my $sid = $self->server_sid();
4101 2 my $args = [@_];
4102 2 my $count = @$args;
4103 2 my $ref = [ ];
4104  
4105 SWITCH: {
4106 2 my $rec = $self->{state}{uids}{$uid};
4107 $self->_send_to_realops(
4108 sprintf(
4109 'ETRACE requested by %s (%s@%s) [%s]',
4110 $rec->{nick},
4111 $rec->{auth}{ident},
4112 $rec->{auth}{hostname},
4113 $rec->{server},
4114 2 ),
4115 'Notice',
4116 'y',
4117 );
4118 2 my $doall = 0;
4119 2 ▶ if (!$args->[0]) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $args->[0]) { } 1 1 2
elsif (uc $args->[0] eq uc $server) { } 0 1 1
elsif ($args->[0] eq $sid) { } 1 0 1
4120 1 $doall = 1;
4121 }
4122 elsif (uc $args->[0] eq uc $server) {
4123 0 $doall = 1;
4124 }
4125 elsif ($args->[0] eq $sid) {
4126 1 $doall = 1;
4127 }
4128 2 my $name = $args->[0];
4129 2 ▶ if ($name && $name =~ m!^[0-9]!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $name =~ /^[0-9]/) 1 1 2
Condition66%2/3
$name and $name =~ /^[0-9]/
!ll&&!rl&&r
101
MC/DC50%1/2
$name and $name =~ /^[0-9]/
$name $name =~ /^[0-9]/
Truth table66%2/3
A and B
A= $nameB= $name =~ /^[0-9]/
ABresult
0X0
100
111
4130 1 $name = $self->state_user_nick($name);
4131 }
4132 2 ▶ $name = uc_irc $name if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 2 2
4133 # Local clients
4134 2 my @connects;
4135 2 my $conns = $self->{state}{conns};
4136 2 foreach my $conn_id ( keys %$conns ) {
4137 12 ▶ next if $conns->{$conn_id}{type} ne 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $conns->{$conn_id}{"type"} ne "c" 6 6 12
4138 6 ▶ next if defined $self->{state}{localops}{ $conn_id };
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"localops"}{$conn_id} 2 4 6
4139 4 push @connects, $conn_id;
4140 }
4141 2 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4142 @connects ) {
4143 4 ▶ next if !$doall || ( $name && $name ne uc_irc $conns->{$conn_id}{nick} );
Branch: 1 branch
BranchTrueFalseTotal
if not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"}) 0 4 4
Condition33%2/6
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
l!l&&r!l&&!r
004
$name and $name ne uc_irc($conns->{$conn_id}{"nick"})
!ll&&!rl&&r
400
MC/DC0%0/3
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
not $doall $name $name ne uc_irc($conns->{$conn_id}{"nick"})
Truth table25%1/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4144 4 my $connrec = $conns->{$conn_id};
4145 push @$ref, {
4146 prefix => $sid,
4147 command => '709',
4148 params => [
4149 $uid,
4150 'User', 'users',
4151 $connrec->{nick},
4152 $connrec->{auth}{ident},
4153 $connrec->{auth}{hostname},
4154 $connrec->{socket}[0],
4155 $connrec->{ircname},
4156 4 ],
4157 };
4158 }
4159 0 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4160 2 keys %{ $self->{state}{localops} } ) {
4161 2 ▶ next if !$doall || ( $name && $name ne uc_irc $conns->{$conn_id}{nick} );
Branch: 1 branch
BranchTrueFalseTotal
if not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"}) 0 2 2
Condition33%2/6
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
l!l&&r!l&&!r
002
$name and $name ne uc_irc($conns->{$conn_id}{"nick"})
!ll&&!rl&&r
200
MC/DC0%0/3
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
not $doall $name $name ne uc_irc($conns->{$conn_id}{"nick"})
Truth table25%1/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4162 2 my $connrec = $conns->{$conn_id};
4163 push @$ref, {
4164 prefix => $sid,
4165 command => '709',
4166 params => [
4167 $uid,
4168 'Oper', 'opers',
4169 $connrec->{nick},
4170 $connrec->{auth}{ident},
4171 $connrec->{auth}{hostname},
4172 $connrec->{socket}[0],
4173 $connrec->{ircname},
4174 2 ],
4175 };
4176 }
4177 # End of ETRACE
4178 2 push @$ref, {
4179 prefix => $sid,
4180 command => '759',
4181 params => [
4182 $uid, $server, 'End of ETRACE',
4183 ],
4184 };
4185 }
4186  
4187 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4188 2 return $ref;
4189 }
4190  
4191 2 ▶sub _daemon_do_trace {
Subroutine _daemon_do_trace: called CC=36 SCAR=41.4
4192 2 my $self = shift;
4193 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4194 2 my $server = $self->server_name();
4195 2 my $sid = $self->server_sid();
4196 2 my $args = [@_];
4197 2 my $count = @$args;
4198 2 my $ref = [ ];
4199  
4200 SWITCH: {
4201 2 my $rec = $self->{state}{uids}{$uid};
4202 $self->_send_to_realops(
4203 sprintf(
4204 'TRACE requested by %s (%s@%s) [%s]',
4205 $rec->{nick},
4206 $rec->{auth}{ident},
4207 $rec->{auth}{hostname},
4208 $rec->{server},
4209 2 ),
4210 'Notice',
4211 'y',
4212 );
4213 2 my $doall = 0;
4214 2 ▶ if (!$args->[0]) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $args->[0]) { } 1 1 2
elsif (uc $args->[0] eq uc $server) { } 0 1 1
elsif ($args->[0] eq $sid) { } 1 0 1
4215 1 $doall = 1;
4216 }
4217 elsif (uc $args->[0] eq uc $server) {
4218 0 $doall = 1;
4219 }
4220 elsif ($args->[0] eq $sid) {
4221 1 $doall = 1;
4222 }
4223 2 my $name = $args->[0];
4224 2 ▶ if ($name && $name =~ m!^[0-9]!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $name =~ /^[0-9]/) 1 1 2
Condition66%2/3
$name and $name =~ /^[0-9]/
!ll&&!rl&&r
101
MC/DC50%1/2
$name and $name =~ /^[0-9]/
$name $name =~ /^[0-9]/
Truth table66%2/3
A and B
A= $nameB= $name =~ /^[0-9]/
ABresult
0X0
100
111
4225 1 $name = $self->state_user_nick($name);
4226 }
4227 2 ▶ $name = uc_irc $name if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 2 2
4228 # Local clients
4229 2 my $conns = $self->{state}{conns};
4230 2 my %connects;
4231 2 foreach my $conn_id ( keys %$conns ) {
4232 12 ▶ next if defined $self->{state}{localops}{ $conn_id };
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"localops"}{$conn_id} 2 10 12
4233 10 push @{ $connects{ $conns->{$conn_id}{type} } }, $conn_id;
4234 }
4235 2 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4236 2 @{ $connects{c} } ) {
4237 4 ▶ next if !$doall || ( $name && $name ne uc_irc $conns->{$conn_id}{nick} );
Branch: 1 branch
BranchTrueFalseTotal
if not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"}) 0 4 4
Condition33%2/6
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
l!l&&r!l&&!r
004
$name and $name ne uc_irc($conns->{$conn_id}{"nick"})
!ll&&!rl&&r
400
MC/DC0%0/3
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
not $doall $name $name ne uc_irc($conns->{$conn_id}{"nick"})
Truth table25%1/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4238 4 my $connrec = $conns->{$conn_id};
4239 push @$ref, {
4240 prefix => $sid,
4241 command => '205',
4242 params => [
4243 $uid,
4244 'User', 'users',
4245 $connrec->{nick},
4246 sprintf('[%s@%s]',$connrec->{auth}{ident},$connrec->{auth}{hostname}),
4247 sprintf('(%s)',$connrec->{socket}[0]),
4248 time - $connrec->{seen},
4249 time - $connrec->{idle_time},
4250 4 ],
4251 colonify => 0,
4252 };
4253 }
4254 0 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4255 2 keys %{ $self->{state}{localops} } ) {
4256 2 ▶ next if !$doall || ( $name && $name ne uc_irc $conns->{$conn_id}{nick} );
Branch: 1 branch
BranchTrueFalseTotal
if not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"}) 0 2 2
Condition33%2/6
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
l!l&&r!l&&!r
002
$name and $name ne uc_irc($conns->{$conn_id}{"nick"})
!ll&&!rl&&r
200
MC/DC0%0/3
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"nick"})
not $doall $name $name ne uc_irc($conns->{$conn_id}{"nick"})
Truth table25%1/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4257 2 my $connrec = $conns->{$conn_id};
4258 push @$ref, {
4259 prefix => $sid,
4260 command => '204',
4261 params => [
4262 $uid,
4263 'Oper', 'opers',
4264 $connrec->{nick},
4265 sprintf('[%s@%s]',$connrec->{auth}{ident},$connrec->{auth}{hostname}),
4266 sprintf('(%s)',$connrec->{socket}[0]),
4267 time - $connrec->{seen},
4268 time - $connrec->{idle_time},
4269 2 ],
4270 colonify => 0,
4271 };
4272 }
4273 # Servers
4274 2 foreach my $conn_id ( sort { $conns->{$a}{name} cmp $conns->{$b}{name} }
4275 2 @{ $connects{p} } ) {
4276 4 ▶ next if !$doall || ( $name && $name ne uc_irc $conns->{$conn_id}{name} );
Branch: 1 branch
BranchTrueFalseTotal
if not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"name"}) 0 4 4
Condition33%2/6
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"name"})
l!l&&r!l&&!r
004
$name and $name ne uc_irc($conns->{$conn_id}{"name"})
!ll&&!rl&&r
400
MC/DC0%0/3
not $doall or $name and $name ne uc_irc($conns->{$conn_id}{"name"})
not $doall $name $name ne uc_irc($conns->{$conn_id}{"name"})
Truth table25%1/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"name"})
ABCresult
1XX1
0111
00X0
0100
4277 4 my $connrec = $conns->{$conn_id};
4278 4 my $srvcnt = 0; my $clicnt = 0;
4279 4 $self->_state_peer_dependents( $connrec->{sid}, \$srvcnt, \$clicnt );
4280 push @$ref, {
4281 prefix => $sid,
4282 command => '206',
4283 params => [
4284 $uid,
4285 'Serv', 'server',
4286 "${srvcnt}S", "${clicnt}C",
4287 sprintf(
4288 '%s[%s@%s]', $connrec->{name},
4289 ( $connrec->{auth}{ident} || 'unknown' ),
4290 ( $connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
4291 sprintf('%s!%s@%s','*','*',$connrec->{name}),
4292 time - $connrec->{conn_time},
4293 4 ▶ ],
Condition40%2/5
$connrec->{'auth'}{'ident'} || 'unknown'
l!l
04
$connrec->{'auth'}{'hostname'} || $connrec->{'socket'}[0]
l!l&&r!l&&!r
040
MC/DC0%0/1
$connrec->{'auth'}{'ident'} || 'unknown'
$connrec->{'auth'}{'ident'}
MC/DC0%0/2
$connrec->{'auth'}{'hostname'} || $connrec->{'socket'}[0]
$connrec->{'auth'}{'hostname'} $connrec->{'socket'}[0]
Truth table50%1/2
A
A= $connrec->{'auth'}{'ident'}
Aresult
11
00
Truth table33%1/3
A || B
A= $connrec->{'auth'}{'hostname'}B= $connrec->{'socket'}[0]
ABresult
1X1
011
000
4294 colonify => 0,
4295 };
4296 }
4297 # Unknowns
4298 0 foreach my $conn_id ( sort { $conns->{$a}{nick} <=> $conns->{$b}{nick} }
4299 2 @{ $connects{u} } ) {
4300 2 ▶ next if !$doall;
Branch: 1 branch
BranchTrueFalseTotal
unless $doall 0 2 2
4301 2 my $connrec = $conns->{$conn_id};
4302 push @$ref, {
4303 prefix => $sid,
4304 command => '203',
4305 params => [
4306 $uid,
4307 '????', 'default',
4308 sprintf(
4309 '[%s@%s]', ( $connrec->{auth}{ident} || 'unknown' ),
4310 ( $connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
4311 sprintf('(%s)',$connrec->{socket}[0]),
4312 time - $connrec->{conn_time},
4313 2 ▶ ],
Condition40%2/5
$connrec->{'auth'}{'ident'} || 'unknown'
l!l
02
$connrec->{'auth'}{'hostname'} || $connrec->{'socket'}[0]
l!l&&r!l&&!r
020
MC/DC0%0/1
$connrec->{'auth'}{'ident'} || 'unknown'
$connrec->{'auth'}{'ident'}
MC/DC0%0/2
$connrec->{'auth'}{'hostname'} || $connrec->{'socket'}[0]
$connrec->{'auth'}{'hostname'} $connrec->{'socket'}[0]
Truth table50%1/2
A
A= $connrec->{'auth'}{'ident'}
Aresult
11
00
Truth table33%1/3
A || B
A= $connrec->{'auth'}{'hostname'}B= $connrec->{'socket'}[0]
ABresult
1X1
011
000
4314 colonify => 0,
4315 };
4316 }
4317 2 ▶ if ($doall) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doall) 2 0 2
4318 2 ▶ my $users = ( defined $connects{c} ? @{ $connects{c} } : 0 );
Branch: 1 branch
BranchTrueFalseTotal
defined $connects{'c'} ? : 2 0 2
4319 2 ▶ my $opers = ( defined $self->{state}{localops} ? keys %{ $self->{state}{localops} } : 0 );
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'state'}{'localops'} ? : 2 0 2
4320 2 ▶ my $servers = ( defined $connects{p} ? @{ $connects{p} } : 0 );;
Branch: 1 branch
BranchTrueFalseTotal
defined $connects{'p'} ? : 2 0 2
4321 2 $users -= $opers;
4322 # 209
4323 2 ▶ if ($servers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($servers) 2 0 2
4324 2 push @$ref, {
4325 prefix => $sid,
4326 command => '209',
4327 params => [
4328 $uid,
4329 'Class', 'server', $servers,
4330 ],
4331 colonify => 0,
4332 };
4333 }
4334 2 ▶ if ($opers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opers) 2 0 2
4335 2 push @$ref, {
4336 prefix => $sid,
4337 command => '209',
4338 params => [
4339 $uid,
4340 'Class', 'opers', $opers,
4341 ],
4342 colonify => 0,
4343 };
4344 }
4345 2 ▶ if ($users) {
Branch: 1 branch
BranchTrueFalseTotal
if ($users) 2 0 2
4346 2 push @$ref, {
4347 prefix => $sid,
4348 command => '209',
4349 params => [
4350 $uid,
4351 'Class', 'users', $users,
4352 ],
4353 colonify => 0,
4354 };
4355 }
4356 }
4357 # End of TRACE
4358 2 push @$ref, {
4359 prefix => $sid,
4360 command => '262',
4361 params => [
4362 $uid, $server, 'End of TRACE',
4363 ],
4364 };
4365 }
4366  
4367 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4368 2 return $ref;
4369 }
4370  
4371 6 ▶sub _state_peer_dependents {
Subroutine _state_peer_dependents: called CC=3 SCAR=11.0
4372 6 my $self = shift;
4373 6 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4374 6 my $srvcnt = shift;
4375 6 my $clicnt = shift;
4376  
4377 6 $$srvcnt++;
4378 6 $$clicnt += keys %{ $self->{state}{sids}{$sid}{uids} };
4379 6 foreach my $psid ( keys %{ $self->{state}{sids}{$sid}{sids} } ) {
4380 2 $self->_state_peer_dependents($psid,$srvcnt,$clicnt);
4381 }
4382 6 return;
4383 }
4384 22 ▶sub _daemon_cmd_nick {
Subroutine _daemon_cmd_nick: called CC=31 SCAR=36.6
4385 22 my $self = shift;
4386 22 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
220
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4387 22 my $new = shift;
4388 22 my $server = uc $self->server_name();
4389 22 my $sid = $self->server_sid();
4390 22 my $ref = [ ];
4391  
4392 SWITCH: {
4393 22 ▶ if (!$new) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($new) 0 22 22
4394 0 push @$ref, ['431'];
4395 0 last SWITCH;
4396 }
4397 22 my $nicklen = $self->server_config('NICKLEN');
4398 22 ▶ $new = substr($new, 0, $nicklen) if length($new) > $nicklen;
Branch: 1 branch
BranchTrueFalseTotal
if length $new > $nicklen 0 22 22
4399 22 ▶ if ($nick eq $new) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick eq $new) 1 21 22
4400 1 last SWITCH;
4401 }
4402 21 ▶ if (!is_valid_nick_name($new)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_nick_name($new)) 0 21 21
4403 0 push @$ref, ['432', $new];
4404 0 last SWITCH;
4405 }
4406 21 my $unick = uc_irc($nick);
4407 21 my $record = $self->{state}{users}{$unick};
4408 21 ▶ if ( my $reason = $self->_state_is_resv( $new, $record->{route_id} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $self->_state_is_resv($new, $record->{"route_id"})) 1 20 21
4409 1 $self->_send_to_realops(
4410 sprintf(
4411 'Forbidding reserved nick %s from user %s',
4412 $new,
4413 $self->state_user_full($nick),
4414 ),
4415 'Notice',
4416 'j',
4417 );
4418 1 push @$ref, {
4419 prefix => $self->server_name(),
4420 command => '432',
4421 params => [
4422 $nick,
4423 $new,
4424 $reason,
4425 ],
4426 };
4427 1 last SWITCH;
4428 }
4429 20 my $unew = uc_irc($new);
4430 20 ▶ if ($self->state_nick_exists($new) && $unick ne $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($new) and $unick ne $unew) 0 20 20
Condition33%1/3
$self->state_nick_exists($new) and $unick ne $unew
!ll&&!rl&&r
2000
MC/DC0%0/2
$self->state_nick_exists($new) and $unick ne $unew
$self->state_nick_exists($new) $unick ne $unew
Truth table33%1/3
A and B
A= $self->state_nick_exists($new)B= $unick ne $unew
ABresult
0X0
100
111
4431 0 push @$ref, ['433', $new];
4432 0 last SWITCH;
4433 }
4434 20 my $full = $record->{full}->();
4435 20 my $common = { $record->{uid} => $record->{route_id} };
4436  
4437 20 my $nonickchange = '';
4438 20 CHANS: for my $chan (keys %{ $record->{chans} }) {
4439 4 my $chanrec = $self->{state}{chans}{$chan};
4440 4 ▶ if ( $chanrec->{mode} =~ /N/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} =~ /N/) 2 2 4
4441 2 ▶ if ( $record->{chans} !~ /[oh]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"chans"} =~ /[oh]/) 2 0 2
4442 2 $nonickchange = $chanrec->{name};
4443 2 last CHANS;
4444 }
4445 }
4446 2 USER: for my $user ( keys %{ $chanrec->{users} } ) {
4447 4 ▶ next USER if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 0 4 4
4448 4 $common->{$user} = $self->_state_uid_route($user);
4449 }
4450 }
4451  
4452 20 ▶ if ($nonickchange) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nonickchange) 2 18 20
4453 2 push @$ref,['447',$nonickchange];
4454 2 last SWITCH;
4455 }
4456  
4457 18 my $lastattempt = $record->{_nick_last};
4458 18 ▶ if ( $lastattempt && ( $lastattempt + $self->{config}{max_nick_time} < time() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastattempt and $lastattempt + $self->{"config"}{"max_nick_time"} < time) 0 18 18
Condition66%2/3
$lastattempt and $lastattempt + $self->{"config"}{"max_nick_time"} < time
!ll&&!rl&&r
1350
MC/DC0%0/2
$lastattempt and $lastattempt + $self->{"config"}{"max_nick_time"} < time
$lastattempt $lastattempt + $self->{"config"}{"max_nick_time"} < time
Truth table66%2/3
A and B
A= $lastattemptB= $lastattempt + $self->{"config"}{"max_nick_time"} < time
ABresult
0X0
100
111
4459 0 $record->{_nick_count} = 0;
4460 }
4461  
4462 18 ▶ if ( ( $self->{config}{anti_nick_flood} && $record->{umode} !~ /o/ ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"config"}{"anti_nick_flood"} and not $record->{"umode"} =~ /o/ and $record->{"_nick_count"} and $record->{"_nick_count"} >= $self->{"config"}{"max_nick_changes"}) 1 17 18
Condition66%6/9
$self->{"config"}{"anti_nick_flood"} and not $record->{"umode"} =~ /o/ and $record->{"_nick_count"} and $record->{"_nick_count"} >= $self->{"config"}{"max_nick_changes"}
!ll&&!rl&&r
1341
$self->{"config"}{"anti_nick_flood"} and not $record->{"umode"} =~ /o/ and $record->{"_nick_count"}
!ll&&!rl&&r
0135
$self->{"config"}{"anti_nick_flood"} and not $record->{"umode"} =~ /o/
!ll&&!rl&&r
0018
MC/DC50%2/4
$self->{"config"}{"anti_nick_flood"} and not $record->{"umode"} =~ /o/ and $record->{"_nick_count"} and $record->{"_nick_count"} >= $self->{"config"}{"max_nick_changes"}
$self->{"config"}{"anti_nick_flood"} not $record->{"umode"} =~ /o/ $record->{"_nick_count"} $record->{"_nick_count"} >= $self->{"config"}{"max_nick_changes"}
Truth table60%3/5
A and not(B) and C and D
A= $self->{"config"}{"anti_nick_flood"}B= not $record->{"umode"} =~ /o/C= $record->{"_nick_count"}D= $record->{"_nick_count"} >= $self->{"config"}{"max_nick_changes"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
4463 $record->{_nick_count} && ( $record->{_nick_count} >= $self->{config}{max_nick_changes} ) ) {
4464 1 push @$ref,['438',$new,$self->{config}{max_nick_time}];
4465 1 last SWITCH;
4466 }
4467  
4468 17 $record->{_nick_last} = time();
4469 17 $record->{_nick_count}++;
4470  
4471 17 ▶ if ($unick eq $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unick eq $unew) { } 0 17 17
4472 0 $record->{nick} = $new;
4473 0 $record->{ts} = time;
4474 }
4475 else {
4476 17 $record->{nick} = $new;
4477 17 $record->{ts} = time;
4478 # Remove from peoples accept lists
4479 17 for (keys %{ $record->{accepts} }) {
4480 0 delete $self->{state}{users}{$_}{accepts}{$unick};
4481 }
4482 17 delete $record->{accepts};
4483 # WATCH ON/OFF
4484 17 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 16 17
4485 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
4486 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
4487 1 my $wrec = $self->{state}{uids}{$wuid};
4488 1 my $laston = time();
4489 1 $self->{state}{watches}{$unick}{laston} = $laston;
4490 $self->send_output(
4491 {
4492 prefix => $record->{server},
4493 command => '605',
4494 params => [
4495 $wrec->{nick},
4496 $nick,
4497 $record->{auth}{ident},
4498 $record->{auth}{hostname},
4499 $laston,
4500 'is offline',
4501 ],
4502 },
4503 $wrec->{route_id},
4504 1 );
4505 }
4506 }
4507 17 ▶ if ( defined $self->{state}{watches}{$unew} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unew}) 1 16 17
4508 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unew}{uids} } ) {
4509 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
4510 1 my $wrec = $self->{state}{uids}{$wuid};
4511 $self->send_output(
4512 {
4513 prefix => $record->{server},
4514 command => '604',
4515 params => [
4516 $wrec->{nick},
4517 $record->{nick},
4518 $record->{auth}{ident},
4519 $record->{auth}{hostname},
4520 $record->{ts},
4521 'is online',
4522 ],
4523 },
4524 $wrec->{route_id},
4525 1 );
4526 }
4527 }
4528 17 delete $self->{state}{users}{$unick};
4529 17 $self->{state}{users}{$unew} = $record;
4530 17 delete $self->{state}{peers}{$server}{users}{$unick};
4531 17 $self->{state}{peers}{$server}{users}{$unew} = $record;
4532 17 ▶ if ( $record->{umode} =~ /r/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /r/) 1 16 17
4533 1 $record->{umode} =~ s/r//g;
4534 $self->send_output(
4535 {
4536 prefix => $full,
4537 command => 'MODE',
4538 params => [
4539 $record->{nick},
4540 '-r',
4541 ],
4542 },
4543 $record->{route_id},
4544 1 );
4545 }
4546 17 unshift @{ $self->{state}{whowas}{$unick} }, {
4547 logoff => time(),
4548 account => $record->{account},
4549 nick => $nick,
4550 user => $record->{auth}{ident},
4551 host => $record->{auth}{hostname},
4552 real => $record->{auth}{realhost},
4553 sock => $record->{socket}[0],
4554 ircname => $record->{ircname},
4555 server => $record->{server},
4556 17 };
4557 }
4558  
4559 17 $self->_send_to_realops(
4560 sprintf(
4561 'Nick change: From %s to %s [%s]',
4562 $nick, $new, (split /!/, $full)[1],
4563 ),
4564 'Notice',
4565 'n',
4566 );
4567  
4568 $self->send_output(
4569 {
4570 prefix => $record->{uid},
4571 command => 'NICK',
4572 17 params => [$new, $record->{ts}],
4573 },
4574 $self->_state_connected_peers(),
4575 );
4576  
4577 17 $self->send_event("daemon_nick", $full, $new);
4578  
4579 17 $self->send_output(
4580 {
4581 prefix => $full,
4582 command => 'NICK',
4583 params => [$new],
4584 },
4585 values %$common,
4586 );
4587 }
4588  
4589 22 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 22 0 22
4590 0 return $ref;
4591 }
4592  
4593 5 ▶sub _daemon_cmd_away {
Subroutine _daemon_cmd_away: called CC=4 SCAR=13.9
4594 5 my $self = shift;
4595 5 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4596 5 my $msg = shift;
4597 5 my $server = $self->server_name();
4598 5 my $ref = [ ];
4599  
4600 SWITCH: {
4601 5 my $rec = $self->{state}{users}{uc_irc($nick)};
4602 5 ▶ if (!$msg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 2 3 5
4603 2 delete $rec->{away};
4604 $self->send_output(
4605 {
4606 prefix => $rec->{uid},
4607 2 command => 'AWAY',
4608 },
4609 $self->_state_connected_peers(),
4610 );
4611 push @$ref, {
4612 prefix => $server,
4613 command => '305',
4614 2 params => [ $rec->{nick}, 'You are no longer marked as being away' ],
4615 };
4616 2 $self->_state_do_away_notify($rec->{uid},'*',$msg);
4617 2 last SWITCH;
4618 }
4619  
4620 3 $rec->{away} = $msg;
4621  
4622 $self->send_output(
4623 {
4624 prefix => $rec->{uid},
4625 3 command => 'AWAY',
4626 params => [$msg],
4627 },
4628 $self->_state_connected_peers(),
4629 );
4630 push @$ref, {
4631 prefix => $server,
4632 command => '306',
4633 3 params => [ $rec->{nick}, 'You have been marked as being away' ],
4634 };
4635 3 $self->_state_do_away_notify($rec->{uid},'*',$msg);
4636 }
4637  
4638 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
4639 0 return $ref;
4640 }
4641  
4642 6 ▶sub _daemon_client_miscell {
Subroutine _daemon_client_miscell: called CC=9 SCAR=25.0
4643 6 my $self = shift;
4644 6 my $cmd = shift;
4645 6 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4646 6 my $target = shift;
4647 6 my $server = $self->server_name();
4648 6 my $ref = [ ];
4649  
4650 SWITCH: {
4651 6 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 6 6
Condition33%1/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
600
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table33%1/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
4652 0 push @$ref, ['402', $target];
4653 0 last SWITCH;
4654 }
4655 6 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 6 6
Condition33%1/3
$target and uc $server ne uc $target
!ll&&!rl&&r
600
MC/DC0%0/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table33%1/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
4656 0 $target = $self->_state_peer_sid($target);
4657 0 $self->send_output(
4658 {
4659 prefix => $self->state_user_uid($nick),
4660 command => uc $cmd,
4661 params => [$target],
4662 },
4663 $self->_state_sid_route($target),
4664 );
4665 0 last SWITCH;
4666 }
4667 6 ▶ if ($cmd =~ m!^(ADMIN|INFO|MOTD)$!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(ADMIN|INFO|MOTD)$/i) 3 3 6
4668 3 $self->_send_to_realops(
4669 sprintf(
4670 '%s requested by %s (%s) [%s]',
4671 $cmd, $nick, (split /!/,$self->state_user_full($nick))[1], $server,
4672 ), qw[Notice y],
4673 );
4674 }
4675 6 my $method = '_daemon_do_' . lc $cmd;
4676 6 my $uid = $self->state_user_uid($nick);
4677 6 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
4678 6 @{ $self->$method($uid) };
4679 }
4680  
4681 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
4682 0 return $ref;
4683 }
4684  
4685 5 ▶sub _daemon_peer_miscell {
Subroutine _daemon_peer_miscell: called CC=8 SCAR=23.8
4686 5 my $self = shift;
4687 5 my $cmd = shift;
4688 5 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4689 5 my $sid = $self->server_sid();
4690 5 my $args = [@_];
4691 5 my $count = @$args;
4692 5 my $ref = [ ];
4693  
4694 SWITCH: {
4695 5 ▶ if ($cmd ne 'STATS' && $args->[0] !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd ne "STATS" and not $args->[0] =~ /^$sid/) 0 5 5
Condition33%1/3
$cmd ne "STATS" and not $args->[0] =~ /^$sid/
!ll&&!rl&&r
050
MC/DC0%0/2
$cmd ne "STATS" and not $args->[0] =~ /^$sid/
$cmd ne "STATS" not $args->[0] =~ /^$sid/
Truth table33%1/3
A and not(B)
A= $cmd ne "STATS"B= not $args->[0] =~ /^$sid/
ABresult
0X0
100
111
4696 0 $self->send_output(
4697 {
4698 prefix => $uid,
4699 command => $cmd,
4700 params => $args,
4701 },
4702 $self->_state_sid_route(substr $args->[0], 0, 3),
4703 );
4704 0 last SWITCH;
4705 }
4706 5 ▶ if ($cmd eq 'STATS' && $args->[1] !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "STATS" and not $args->[1] =~ /^$sid/) 0 5 5
Condition33%1/3
$cmd eq "STATS" and not $args->[1] =~ /^$sid/
!ll&&!rl&&r
500
MC/DC0%0/2
$cmd eq "STATS" and not $args->[1] =~ /^$sid/
$cmd eq "STATS" not $args->[1] =~ /^$sid/
Truth table33%1/3
A and not(B)
A= $cmd eq "STATS"B= not $args->[1] =~ /^$sid/
ABresult
0X0
100
111
4707 0 $self->send_output(
4708 {
4709 prefix => $uid,
4710 command => $cmd,
4711 params => $args,
4712 },
4713 $self->_state_sid_route(substr $args->[1], 0, 3),
4714 );
4715 0 last SWITCH;
4716 }
4717 5 ▶ if ($cmd =~ m!^(ADMIN|INFO|MOTD)$!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(ADMIN|INFO|MOTD)$/i) 3 2 5
4718 3 my $urec = $self->{state}{uids}{$uid};
4719 $self->_send_to_realops(
4720 sprintf(
4721 '%s requested by %s (%s) [%s]',
4722 $cmd, $urec->{nick}, (split /!/,$urec->{full}->())[1], $urec->{server},
4723 3 ), qw[Notice y],
4724 );
4725 }
4726 5 my $method = '_daemon_do_' . lc $cmd;
4727 5 $ref = $self->$method($uid, @$args);
4728 }
4729  
4730 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
4731 0 return $ref;
4732 }
4733  
4734 # Pseudo cmd for ISupport 005 numerics
4735 226 ▶sub _daemon_do_isupport {
Subroutine _daemon_do_isupport: called CC=5 SCAR=16.2
4736 226 my $self = shift;
4737 226 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4738 226 my $sid = $self->server_sid();
4739 226 my $ref = [ ];
4740  
4741 push @$ref, {
4742 prefix => $sid,
4743 command => '005',
4744 params => [
4745 $uid,
4746 join(' ', map {
4747 226 (defined $self->{config}{isupport}{$_}
4748 2486 ▶ ? join '=', $_, $self->{config}{isupport}{$_}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'config'}{'isupport'}{$_} ? : 2034 452 2486
4749 : $_
4750 )
4751 } qw(CALLERID EXCEPTS INVEX MAXCHANNELS MAXLIST MAXTARGETS
4752 NICKLEN TOPICLEN KICKLEN KNOCK DEAF)
4753 ),
4754 'are supported by this server',
4755 ],
4756 };
4757  
4758 push @$ref, {
4759 prefix => $sid,
4760 command => '005',
4761 params => [
4762 $uid,
4763 join(' ', map {
4764 226 (defined $self->{config}{isupport}{$_}
4765 1582 ▶ ? join '=', $_, $self->{config}{isupport}{$_}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'config'}{'isupport'}{$_} ? : 1356 226 1582
4766 : $_
4767 )
4768 } qw(CHANTYPES PREFIX CHANMODES NETWORK CASEMAPPING SAFELIST ELIST)
4769 ), 'are supported by this server',
4770 ],
4771 };
4772  
4773 226 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 226 226
4774 226 return $ref;
4775 }
4776  
4777 2 ▶sub _daemon_do_info {
Subroutine _daemon_do_info: called CC=4 SCAR=14.0
4778 2 my $self = shift;
4779 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4780 2 my $sid = $self->server_sid();
4781 2 my $ref = [ ];
4782  
4783 {
4784 2 for my $info (@{ $self->server_config('Info') }) {
4785 20 push @$ref, {
4786 prefix => $sid,
4787 command => '371',
4788 params => [$uid, $info],
4789 };
4790 }
4791  
4792 2 push @$ref, {
4793 prefix => $sid,
4794 command => '374',
4795 params => [$uid, 'End of /INFO list.'],
4796 };
4797 }
4798  
4799 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4800 2 return $ref;
4801 }
4802  
4803 2 ▶sub _daemon_do_version {
Subroutine _daemon_do_version: called CC=4 SCAR=14.0
4804 2 my $self = shift;
4805 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4806 2 my $sid = $self->server_sid();
4807 2 my $ref = [ ];
4808  
4809 2 push @$ref, {
4810 prefix => $sid,
4811 command => '351',
4812 params => [
4813 $uid,
4814 $self->server_version(),
4815 $self->server_name(),
4816 'eGHIMZ6 TS6ow',
4817 ],
4818 };
4819  
4820 2 push @$ref, $_ for @{ $self->_daemon_do_isupport($uid) };
4821  
4822 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4823 2 return $ref;
4824 }
4825  
4826 2 ▶sub _daemon_do_admin {
Subroutine _daemon_do_admin: called CC=3 SCAR=11.0
4827 2 my $self = shift;
4828 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4829 2 my $sid = $self->server_sid();
4830 2 my $ref = [ ];
4831 2 my $admin = $self->server_config('Admin');
4832  
4833 {
4834 2 push @$ref, {
4835 prefix => $sid,
4836 command => '256',
4837 params => [$uid, $self->server_name(), 'Administrative Info'],
4838 };
4839  
4840 2 push @$ref, {
4841 prefix => $sid,
4842 command => '257',
4843 params => [$uid, $admin->[0]],
4844 };
4845  
4846 2 push @$ref, {
4847 prefix => $sid,
4848 command => '258',
4849 params => [$uid, $admin->[1]],
4850 };
4851  
4852 2 push @$ref, {
4853 prefix => $sid,
4854 command => '259',
4855 params => [$uid, $admin->[2]],
4856 };
4857 }
4858  
4859 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4860 2 return $ref;
4861 }
4862  
4863 0 ▶sub _daemon_cmd_summon {
Subroutine _daemon_cmd_summon: not called CC=3 SCAR=24.8
4864 0 my $self = shift;
4865 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4866 0 my $server = $self->server_name();
4867 0 my $ref = [ ];
4868 0 push @$ref, '445';
4869 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4870 0 return $ref;
4871 }
4872  
4873 3 ▶sub _daemon_do_time {
Subroutine _daemon_do_time: called CC=3 SCAR=11.1
4874 3 my $self = shift;
4875 3 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4876 3 my $sid = $self->server_sid();
4877 3 my $ref = [ ];
4878  
4879 {
4880 3 push @$ref, {
4881 prefix => $sid,
4882 command => '391',
4883 params => [
4884 $uid,
4885 $self->server_name(),
4886 strftime("%A %B %e %Y -- %T %z", localtime),
4887 ],
4888 };
4889 }
4890  
4891 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
4892 3 return $ref;
4893 }
4894  
4895 226 ▶sub _daemon_do_users {
Subroutine _daemon_do_users: called CC=5 SCAR=16.2
4896 226 my $self = shift;
4897 226 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4898 226 my $hidden = shift;
4899 226 my $sid = $self->server_sid();
4900 226 my $ref = [ ];
4901 226 my $global = keys %{ $self->{state}{uids} };
4902 226 ▶ my $local = $hidden ? $global : scalar keys %{ $self->{state}{sids}{$sid}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 220 226
4903 226 ▶ my $maxloc = $hidden ? 'maxglobal' : 'maxlocal';
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 220 226
4904  
4905 push @$ref, {
4906 prefix => $sid,
4907 command => '265',
4908 params => [
4909 $uid,
4910 "Current local users: $local Max: "
4911 226 . $self->{state}{stats}{$maxloc},
4912 ],
4913 };
4914  
4915 push @$ref, {
4916 prefix => $sid,
4917 command => '266',
4918 params => [
4919 $uid,
4920 "Current global users: $global Max: "
4921 . $self->{state}{stats}{maxglobal},
4922 226 ],
4923 };
4924  
4925 226 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 226 0 226
4926 0 return $ref;
4927 }
4928  
4929 2 ▶sub _daemon_cmd_lusers {
Subroutine _daemon_cmd_lusers: called CC=9 SCAR=30.7
4930 2 my $self = shift;
4931 2 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4932 2 my $server = $self->server_name();
4933 2 my $ref = [ ];
4934 2 my $args = [@_];
4935 2 my $count = @$args;
4936  
4937 SWITCH: {
4938 2 ▶ if ($count && $count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and $count > 1) 0 2 2
Condition33%1/3
$count and $count > 1
!ll&&!rl&&r
200
MC/DC0%0/2
$count and $count > 1
$count $count > 1
Truth table33%1/3
A and B
A= $countB= $count > 1
ABresult
0X0
100
111
4939 0 ▶ my $target = ( $self->_state_peer_sid($args->[1]) || $self->state_user_uid($args->[1]) );
Condition0%0/3
$self->_state_peer_sid($args->[1]) || $self->state_user_uid($args->[1])
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_state_peer_sid($args->[1]) || $self->state_user_uid($args->[1])
$self->_state_peer_sid($args->[1]) $self->state_user_uid($args->[1])
Truth table0%0/3
A || B
A= $self->_state_peer_sid($args->[1])B= $self->state_user_uid($args->[1])
ABresult
1X1
011
000
4940 0 ▶ if (!$target) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 0 0
4941 0 push @$ref, ['402', $args->[1]];
4942 0 last SWITCH;
4943 }
4944 0 my $targsid = substr $target, 0, 3;
4945 0 my $sid = $self->server_sid();
4946 0 ▶ if ( $targsid ne $sid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targsid ne $sid) 0 0 0
4947 0 $self->send_output(
4948 {
4949 prefix => $self->state_user_uid($nick),
4950 command => 'LUSERS',
4951 params => [
4952 $args->[0],
4953 $target,
4954 ],
4955 },
4956 $self->_state_sid_route($targsid),
4957 );
4958 0 last SWITCH;
4959 }
4960 }
4961 2 my $uid = $self->state_user_uid($nick);
4962 2 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
4963 2 @{ $self->_daemon_do_lusers($uid) };
4964 }
4965  
4966 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
4967 0 return $ref;
4968 }
4969  
4970 0 ▶sub _daemon_peer_lusers {
Subroutine _daemon_peer_lusers: not called CC=9 SCAR=45.0
4971 0 my $self = shift;
4972 0 ▶ my $uid = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4973 0 my $sid = $self->server_sid();
4974 0 my $ref = [ ];
4975 0 my $args = [@_];
4976 0 my $count = @$args;
4977  
4978 SWITCH: {
4979 0 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 0 0
Condition0%0/3
not $count or $count < 2
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table0%0/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
4980 0 last SWITCH;
4981 }
4982 0 ▶ my $target = ( $self->_state_peer_sid($args->[1]) || $self->state_user_uid($args->[1]) );
Condition0%0/3
$self->_state_peer_sid($args->[1]) || $self->state_user_uid($args->[1])
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_state_peer_sid($args->[1]) || $self->state_user_uid($args->[1])
$self->_state_peer_sid($args->[1]) $self->state_user_uid($args->[1])
Truth table0%0/3
A || B
A= $self->_state_peer_sid($args->[1])B= $self->state_user_uid($args->[1])
ABresult
1X1
011
000
4983 0 ▶ if (!$target) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 0 0
4984 0 push @$ref, ['402', $args->[1]];
4985 0 last SWITCH;
4986 }
4987 0 my $targsid = substr $target, 0, 3;
4988 0 ▶ if ( $targsid ne $sid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targsid ne $sid) 0 0 0
4989 0 $self->send_output(
4990 {
4991 prefix => $uid,
4992 command => 'LUSERS',
4993 params => $args,
4994 },
4995 $self->_state_sid_route($targsid),
4996 );
4997 0 last SWITCH;
4998 }
4999 0 push @$ref, $_ for @{ $self->_daemon_do_lusers($uid) };
5000 }
5001  
5002 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5003 0 return $ref;
5004 }
5005  
5006 226 ▶sub _daemon_do_lusers {
Subroutine _daemon_do_lusers: called CC=11 SCAR=24.0
5007 226 my $self = shift;
5008 226 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5009 226 my $sid = $self->server_sid();
5010 226 my $ref = [ ];
5011 226 ▶ my $hidden = ( $self->{config}{'hidden_servers'} && $self->{state}{uids}{$uid}{umode} !~ /o/ );
Condition66%2/3
$self->{'config'}{'hidden_servers'} && !($self->{'state'}{'uids'}{$uid}{'umode'} =~ /o/)
!ll&&!rl&&r
22006
MC/DC50%1/2
$self->{'config'}{'hidden_servers'} && !($self->{'state'}{'uids'}{$uid}{'umode'} =~ /o/)
$self->{'config'}{'hidden_servers'} !($self->{'state'}{'uids'}{$uid}{'umode'} =~ /o/)
Truth table66%2/3
A && not(B)
A= $self->{'config'}{'hidden_servers'}B= !($self->{'state'}{'uids'}{$uid}{'umode'} =~ /o/)
ABresult
0X0
100
111
5012 226 my $invisible = $self->{state}{stats}{invisible};
5013 226 my $users = keys(%{ $self->{state}{uids} }) - $invisible;
5014 226 ▶ my $servers = $hidden ? 1 : scalar keys %{ $self->{state}{sids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 220 226
5015 226 my $chans = keys %{ $self->{state}{chans} };
5016 226 ▶ my $local = $hidden ? ( $users + $invisible ) : scalar keys %{ $self->{state}{sids}{$sid}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 220 226
5017 226 ▶ my $peers = $hidden ? 0 : scalar keys %{ $self->{state}{sids}{$sid}{sids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 220 226
5018 226 my $totalconns = $self->{state}{stats}{conns_cumlative};
5019 226 my $mlocal = $self->{state}{stats}{maxlocal};
5020 226 my $conns = $self->{state}{stats}{maxconns};
5021  
5022 226 push @$ref, {
5023 prefix => $sid,
5024 command => '251',
5025 params => [
5026 $uid,
5027 "There are $users users and $invisible invisible on "
5028 . "$servers servers",
5029 ],
5030 };
5031  
5032 226 $servers--;
5033  
5034 push @$ref, {
5035 prefix => $sid,
5036 command => '252',
5037 params => [
5038 $uid,
5039 $self->{state}{stats}{ops_online},
5040 "IRC Operators online",
5041 ]
5042 226 ▶ } if $self->{state}{stats}{ops_online};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"stats"}{"ops_online"} 163 63 226
5043  
5044 226 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if $chans 59 167 226
5045 prefix => $sid,
5046 command => '254',
5047 params => [$uid, $chans, "channels formed"],
5048 } if $chans;
5049  
5050 226 push @$ref, {
5051 prefix => $sid,
5052 command => '255',
5053 params => [$uid, "I have $local clients and $peers servers"],
5054 };
5055  
5056 226 push @$ref, $_ for $self->_daemon_do_users($uid, $hidden);
5057  
5058 226 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
unless $hidden 220 6 226
5059 prefix => $sid,
5060 command => '250',
5061 params => [
5062 $uid, "Highest connection count: $conns ($mlocal clients) "
5063 . "($totalconns connections received)",
5064 ],
5065 } if !$hidden;
5066  
5067 226 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 226 226
5068 226 return $ref;
5069 }
5070  
5071 226 ▶sub _daemon_do_motd {
Subroutine _daemon_do_motd: called CC=6 SCAR=18.0
5072 226 my $self = shift;
5073 226 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5074 226 my $sid = $self->server_sid();
5075 226 my $server = $self->server_name();
5076 226 my $ref = [ ];
5077 226 my $motd = $self->server_config('MOTD');
5078  
5079 {
5080 226 ▶ if ($motd && ref $motd eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($motd and ref $motd eq 'ARRAY') { } 2 224 226
Condition66%2/3
$motd and ref $motd eq "ARRAY"
!ll&&!rl&&r
22402
MC/DC50%1/2
$motd and ref $motd eq "ARRAY"
$motd ref $motd eq "ARRAY"
Truth table66%2/3
A and B
A= $motdB= ref $motd eq "ARRAY"
ABresult
0X0
100
111
5081 2 push @$ref, {
5082 prefix => $sid,
5083 command => '375',
5084 params => [$uid, "- $server Message of the day - "],
5085 };
5086 push @$ref, {
5087 prefix => $sid,
5088 command => '372',
5089 params => [$uid, "- $_"]
5090 2 } for @$motd;
5091 2 push @$ref, {
5092 prefix => $sid,
5093 command => '376',
5094 params => [$uid, "End of MOTD command"],
5095 };
5096 }
5097 else {
5098 push @$ref, {
5099 prefix => $sid,
5100 command => '422',
5101 224 params => [$uid, $self->{Error_Codes}{'422'}[1]],
5102 };
5103 }
5104 }
5105  
5106 226 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 226 226
5107 226 return $ref;
5108 }
5109  
5110 22 ▶sub _daemon_cmd_stats {
Subroutine _daemon_cmd_stats: called CC=14 SCAR=27.2
5111 22 my $self = shift;
5112 22 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
220
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5113 22 my $char = shift;
5114 22 my $target = shift;
5115 22 my $server = $self->server_name();
5116 22 my $sid = $self->server_sid();
5117 22 my $ref = [ ];
5118  
5119 SWITCH: {
5120 22 ▶ if (!$char) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($char) 0 22 22
5121 0 push @$ref, ['461', 'STATS'];
5122 0 last SWITCH;
5123 }
5124 22 $char = substr $char, 0, 1;
5125 22 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 21 1 22
5126 21 my $lastuse = $self->{state}{lastuse}{stats};
5127 21 my $pacewait = $self->{config}{pace_wait};
5128 21 ▶ if ( $lastuse && $pacewait && ( $lastuse + $pacewait ) > time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastuse and $pacewait and $lastuse + $pacewait > time) 1 20 21
Condition83%5/6
$lastuse and $pacewait and $lastuse + $pacewait > time
!ll&&!rl&&r
2001
$lastuse and $pacewait
!ll&&!rl&&r
3171
MC/DC66%2/3
$lastuse and $pacewait and $lastuse + $pacewait > time
$lastuse $pacewait $lastuse + $pacewait > time
Truth table75%3/4
A and B and C
A= $lastuseB= $pacewaitC= $lastuse + $pacewait > time
ABCresult
0XX0
10X0
1100
1111
5129 1 push @$ref, ['263', 'STATS'];
5130 1 last SWITCH;
5131 }
5132 20 $self->{state}{lastuse}{stats} = time();
5133 }
5134 21 ▶ if ($char =~ /^[Ll]$/ && !$target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Ll]$/ and not $target) 2 19 21
Condition66%2/3
$char =~ /^[Ll]$/ and not $target
!ll&&!rl&&r
1902
MC/DC50%1/2
$char =~ /^[Ll]$/ and not $target
$char =~ /^[Ll]$/ not $target
Truth table66%2/3
A and not(B)
A= $char =~ /^[Ll]$/B= not $target
ABresult
0X0
100
111
5135 2 push @$ref, ['461', 'STATS'];
5136 2 last SWITCH;
5137 }
5138 19 ▶ if ($target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 18 19
5139 1 my $targ = $self->_state_find_peer($target);
5140 1 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 1 1
5141 0 push @$ref, [ '402', $target ];
5142 0 last SWITCH;
5143 }
5144 1 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 1 0 1
5145 1 my $psid = substr $targ, 0, 3;
5146 1 $self->send_output(
5147 {
5148 prefix => $self->state_user_uid($nick),
5149 command => 'STATS',
5150 params => [
5151 $char,
5152 $targ,
5153 ],
5154 },
5155 $self->_state_sid_route($psid),
5156 );
5157 1 last SWITCH;
5158 }
5159 }
5160 18 my $uid = $self->state_user_uid($nick);
5161 18 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
5162 18 @{ $self->_daemon_do_stats($uid, $char, $target) };
5163 }
5164  
5165 22 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 22 0 22
5166 0 return $ref;
5167 }
5168  
5169 4 ▶sub _rbytes {
Subroutine _rbytes: called CC=7 SCAR=27.8
5170 4 my $bytes=shift;
5171 4 my $d=2;
5172 4 ▶ return undef if !defined $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 4 4
5173 4 ▶ return [ $bytes, 'Bytes' ] if abs($bytes) <= 2** 0*1000;
Branch: 1 branch
BranchTrueFalseTotal
if abs $bytes <= 1000 2 2 4
5174 2 ▶ return [ sprintf("%.*f",$d,$bytes/2**10), 'Kilobytes' ] if abs($bytes) < 2**10*1000;
Branch: 1 branch
BranchTrueFalseTotal
if abs $bytes < 1024000 2 0 2
5175 0 ▶ return [ sprintf("%.*f",$d,$bytes/2**20), 'Megabytes' ] if abs($bytes) < 2**20*1000;
Branch: 1 branch
BranchTrueFalseTotal
if abs $bytes < 1048576000 0 0 0
5176 0 ▶ return [ sprintf("%.*f",$d,$bytes/2**30), 'Gigabytes' ] if abs($bytes) < 2**30*1000;
Branch: 1 branch
BranchTrueFalseTotal
if abs $bytes < '1073741824000' 0 0 0
5177 0 ▶ return [ sprintf("%.*f",$d,$bytes/2**40), 'Terabytes' ] if abs($bytes) < 2**40*1000;
Branch: 1 branch
BranchTrueFalseTotal
if abs $bytes < '1099511627776000' 0 0 0
5178 0 return [ sprintf("%.*f",$d,$bytes/2**50), 'Petabytes' ];
5179 }
5180  
5181 18 ▶sub _daemon_do_stats {
Subroutine _daemon_do_stats: called CC=100 SCAR=84.3
5182 18 my $self = shift;
5183 18 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
180
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5184 18 my $char = shift;
5185 18 my $targ = shift;
5186 18 my $server = $self->server_name();
5187 18 my $sid = $self->server_sid();
5188 18 my $ref = [ ];
5189  
5190 18 my $rec = $self->{state}{uids}{$uid};
5191 18 my $is_oper = ( $rec->{umode} =~ /o/ );
5192 18 my $is_admin = ( $rec->{umode} =~ /a/ );
5193  
5194 18 my %perms = (
5195 admin => qr/[AaEFf]/,
5196 oper => qr/[OoCcDdeHhIiKkLlQqSsTtUvXxYyz?]/,
5197 );
5198  
5199 $self->_send_to_realops(
5200 sprintf(
5201 'STATS %s requested by %s (%s@%s) [%s]',
5202 $char, $rec->{nick}, $rec->{auth}{ident},
5203 $rec->{auth}{hostname}, $rec->{server},
5204 18 ), qw[Notice y],
5205 );
5206  
5207 SWITCH: {
5208 18 ▶ if (($char =~ $perms{admin} && !$is_admin) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /$perms{"admin"}/ and not $is_admin or $char =~ /$perms{"oper"}/ and not $is_oper) 17 1 18
Condition77%7/9
$char =~ /$perms{"admin"}/ and not $is_admin or $char =~ /$perms{"oper"}/ and not $is_oper
l!l&&r!l&&!r
3141
$char =~ /$perms{"admin"}/ and not $is_admin
!ll&&!rl&&r
1503
$char =~ /$perms{"oper"}/ and not $is_oper
!ll&&!rl&&r
0114
MC/DC50%2/4
$char =~ /$perms{"admin"}/ and not $is_admin or $char =~ /$perms{"oper"}/ and not $is_oper
$char =~ /$perms{"admin"}/ not $is_admin $char =~ /$perms{"oper"}/ not $is_oper
Truth table42%3/7
A and not(B) or C and not(D)
A= $char =~ /$perms{"admin"}/B= not $is_adminC= $char =~ /$perms{"oper"}/D= not $is_oper
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
5209 ($char =~ $perms{oper} && !$is_oper)) {
5210 17 push @$ref, {
5211 prefix => $sid,
5212 command => '481',
5213 params => [
5214 $uid,
5215 'Permission denied - You are not an IRC operator',
5216 ],
5217 };
5218 17 last SWITCH;
5219 }
5220 1 ▶ if ($char =~ /^[aA]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[aA]$/) 0 1 1
5221 0 require Net::DNS::Resolver;
5222 0 foreach my $ns ( Net::DNS::Resolver->new()->nameservers ) {
5223 0 push @$ref, {
5224 prefix => $sid,
5225 command => '226',
5226 params => [
5227 $uid,
5228 $ns,
5229 ],
5230 };
5231 }
5232 0 last SWITCH;
5233 }
5234 1 ▶ if ($char =~ /^[cC]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[cC]$/) 0 1 1
5235 0 foreach my $peer ( sort keys %{ $self->{config}{peers} } ) {
5236 0 my $cblk = $self->{config}{peers}{$peer};
5237 0 my $feat;
5238 0 ▶ $feat .= 'A' if $cblk->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $cblk->{"auto"} 0 0 0
5239 0 ▶ $feat .= 'S' if $cblk->{ssl};
Branch: 1 branch
BranchTrueFalseTotal
if $cblk->{"ssl"} 0 0 0
5240 0 ▶ $feat = '*' if !length $feat;
Branch: 1 branch
BranchTrueFalseTotal
unless length $feat 0 0 0
5241 push @$ref, {
5242 prefix => $sid,
5243 command => '213',
5244 params => [
5245 $uid, 'C',
5246 ( $cblk->{raddress} || $cblk->{sockaddr} ),
5247 $feat,
5248 $cblk->{name},
5249 0 ▶ ( $cblk->{rport} || $cblk->{sockport} ),
Condition0%0/6
$cblk->{'raddress'} || $cblk->{'sockaddr'}
l!l&&r!l&&!r
000
$cblk->{'rport'} || $cblk->{'sockport'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cblk->{'raddress'} || $cblk->{'sockaddr'}
$cblk->{'raddress'} $cblk->{'sockaddr'}
MC/DC0%0/2
$cblk->{'rport'} || $cblk->{'sockport'}
$cblk->{'rport'} $cblk->{'sockport'}
Truth table0%0/3
A || B
A= $cblk->{'raddress'}B= $cblk->{'sockaddr'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $cblk->{'rport'}B= $cblk->{'sockport'}
ABresult
1X1
011
000
5250 'server',
5251 ],
5252 colonify => 0,
5253 };
5254 }
5255 0 last SWITCH;
5256 }
5257 1 ▶ if ($char eq 's') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "s") 0 1 1
5258 0 foreach my $pseudo ( sort keys %{ $self->{config}{pseudo} } ) {
5259 0 my $prec = $self->{config}{pseudo}{$pseudo};
5260 push @$ref, {
5261 prefix => $sid,
5262 command => '227',
5263 params => [
5264 $uid, 's',
5265 $prec->{cmd},
5266 $prec->{name},
5267 join( '@', $prec->{nick},
5268 $prec->{host}),
5269 0 ▶ ( $prec->{prepend} || '*' ),
Condition0%0/2
$prec->{'prepend'} || '*'
l!l
00
MC/DC0%0/1
$prec->{'prepend'} || '*'
$prec->{'prepend'}
Truth table0%0/2
A
A= $prec->{'prepend'}
Aresult
11
00
5270 ],
5271 };
5272 }
5273 0 last SWITCH;
5274 }
5275 1 ▶ if ($char eq 'S') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "S") 0 1 1
5276 0 foreach my $service ( sort keys %{ $self->{state}{services} } ) {
5277 0 my $srec = $self->{state}{services}{$service};
5278 push @$ref, {
5279 prefix => $sid,
5280 command => '246',
5281 params => [
5282 $uid, 'S', '*', '*',
5283 0 $srec->{name}, 0, 0,
5284 ],
5285 colonify => 0,
5286 };
5287 }
5288 0 last SWITCH;
5289 }
5290 1 ▶ if ($char =~ /^[Dd]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Dd]$/) 0 1 1
5291 0 my $tdline = ( $char eq 'd' );
5292 0 foreach my $dline ( @{ $self->{state}{dlines} } ) {
5293 0 ▶ next if $tdline && !$dline->{duration};
Branch: 1 branch
BranchTrueFalseTotal
if $tdline and not $dline->{"duration"} 0 0 0
Condition0%0/3
$tdline and not $dline->{"duration"}
!ll&&!rl&&r
000
MC/DC0%0/2
$tdline and not $dline->{"duration"}
$tdline not $dline->{"duration"}
Truth table0%0/3
A and not(B)
A= $tdlineB= not $dline->{"duration"}
ABresult
0X0
100
111
5294 0 ▶ next if !$tdline && $dline->{duration};
Branch: 1 branch
BranchTrueFalseTotal
if not $tdline and $dline->{"duration"} 0 0 0
Condition0%0/3
not $tdline and $dline->{"duration"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $tdline and $dline->{"duration"}
not $tdline $dline->{"duration"}
Truth table0%0/3
not(A) and B
A= not $tdlineB= $dline->{"duration"}
ABresult
0X0
100
111
5295 push @$ref, {
5296 prefix => $sid,
5297 command => '225',
5298 params => [
5299 $uid, $char,
5300 $dline->{mask}, $dline->{reason},
5301 0 ],
5302 };
5303 }
5304 0 last SWITCH;
5305 }
5306 1 ▶ if ($char eq 'e') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "e") 0 1 1
5307 0 foreach my $mask ( sort keys %{ $self->{exemptions} } ) {
5308 0 push @$ref, {
5309 prefix => $sid,
5310 command => '225',
5311 params => [
5312 $uid, $char,
5313 $mask, '',
5314 ],
5315 };
5316 }
5317 0 last SWITCH;
5318 }
5319 1 ▶ if ($char =~ /^[Xx]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Xx]$/) 0 1 1
5320 0 my $txline = ( $char eq 'x' );
5321 0 foreach my $xline ( @{ $self->{state}{xlines} } ) {
5322 0 ▶ next if $txline && !$xline->{duration};
Branch: 1 branch
BranchTrueFalseTotal
if $txline and not $xline->{"duration"} 0 0 0
Condition0%0/3
$txline and not $xline->{"duration"}
!ll&&!rl&&r
000
MC/DC0%0/2
$txline and not $xline->{"duration"}
$txline not $xline->{"duration"}
Truth table0%0/3
A and not(B)
A= $txlineB= not $xline->{"duration"}
ABresult
0X0
100
111
5323 0 ▶ next if !$txline && $xline->{duration};
Branch: 1 branch
BranchTrueFalseTotal
if not $txline and $xline->{"duration"} 0 0 0
Condition0%0/3
not $txline and $xline->{"duration"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $txline and $xline->{"duration"}
not $txline $xline->{"duration"}
Truth table0%0/3
not(A) and B
A= not $txlineB= $xline->{"duration"}
ABresult
0X0
100
111
5324 push @$ref, {
5325 prefix => $sid,
5326 command => '247',
5327 params => [
5328 $uid, $char,
5329 $xline->{mask}, $xline->{reason},
5330 0 ],
5331 };
5332 }
5333 0 last SWITCH;
5334 }
5335 1 ▶ if ($char =~ /^[Kk]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Kk]$/) 0 1 1
5336 0 my $tkline = ( $char eq 'k' );
5337 0 foreach my $kline ( @{ $self->{state}{klines} } ) {
5338 0 ▶ next if $tkline && !$kline->{duration};
Branch: 1 branch
BranchTrueFalseTotal
if $tkline and not $kline->{"duration"} 0 0 0
Condition0%0/3
$tkline and not $kline->{"duration"}
!ll&&!rl&&r
000
MC/DC0%0/2
$tkline and not $kline->{"duration"}
$tkline not $kline->{"duration"}
Truth table0%0/3
A and not(B)
A= $tklineB= not $kline->{"duration"}
ABresult
0X0
100
111
5339 0 ▶ next if !$tkline && $kline->{duration};
Branch: 1 branch
BranchTrueFalseTotal
if not $tkline and $kline->{"duration"} 0 0 0
Condition0%0/3
not $tkline and $kline->{"duration"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $tkline and $kline->{"duration"}
not $tkline $kline->{"duration"}
Truth table0%0/3
not(A) and B
A= not $tklineB= $kline->{"duration"}
ABresult
0X0
100
111
5340 push @$ref, {
5341 prefix => $sid,
5342 command => '216',
5343 params => [
5344 $uid, $char,
5345 $kline->{host}, '*',
5346 $kline->{user}, $kline->{reason},
5347 0 ],
5348 };
5349 }
5350 0 last SWITCH;
5351 }
5352 1 ▶ if ($char eq 'v') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "v") 0 1 1
5353 0 my $srec = $self->{state}{sids}{$sid};
5354 0 my $count = 0;
5355 0 foreach my $psid ( keys %{ $srec->{sids} } ) {
5356 0 my $prec = $srec->{sids}{$psid};
5357 0 my $peer = $self->{config}{peers}{uc $prec->{name}};
5358 0 my $type = '*';
5359 0 ▶ $type = 'AutoConn.' if $peer->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $peer->{"auto"} 0 0 0
5360 0 ▶ $type = 'Remote.' if $peer->{type} ne 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $peer->{"type"} ne "r" 0 0 0
5361 push @$ref, {
5362 prefix => $sid,
5363 command => '249',
5364 params => [
5365 $uid, 'v',
5366 $prec->{name},
5367 sprintf('(%s!%s@%s)', $type, '*', '*'),
5368 'Idle:',
5369 0 ( time() - $prec->{seen} ),
5370 ],
5371 colonify => 0,
5372 };
5373 0 $count++;
5374 }
5375 0 push @$ref, {
5376 prefix => $sid,
5377 command => '249',
5378 params => [
5379 $uid, 'v',
5380 "$count Server(s)",
5381 ],
5382 };
5383 0 last SWITCH;
5384 }
5385 1 ▶ if ($char eq 'P') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "P") 0 1 1
5386 0 foreach my $listener ( keys %{ $self->{listeners} } ) {
5387 0 my $lrec = $self->{listeners}{$listener};
5388 push @$ref, {
5389 prefix => $sid,
5390 command => '220',
5391 params => [
5392 $uid, 'P',
5393 $lrec->{port},
5394 ( $is_admin ?
5395 ( $lrec->{bindaddr} || '*' ) : $server ),
5396 '*',
5397 0 ▶ ( $lrec->{usessl} ? 's' : 'S' ),
Branch: 2 branches
BranchTrueFalseTotal
$is_admin ? : 0 0 0
$lrec->{'usessl'} ? : 0 0 0
Condition0%0/2
$lrec->{"bindaddr"} or "*"
l!l
00
MC/DC0%0/1
$lrec->{"bindaddr"} or "*"
$lrec->{"bindaddr"}
Truth table0%0/2
A
A= $lrec->{"bindaddr"}
Aresult
11
00
5398 'active',
5399 ],
5400 };
5401 }
5402 0 last SWITCH;
5403 }
5404 1 ▶ if ($char eq 'u') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "u") 0 1 1
5405 0 my $uptime = time - $self->server_config('created');
5406 0 my $days = int $uptime / 86400;
5407 0 my $remain = $uptime % 86400;
5408 0 my $hours = int $remain / 3600;
5409 0 $remain %= 3600;
5410 0 my $mins = int $remain / 60;
5411 0 $remain %= 60;
5412  
5413 0 push @$ref, {
5414 prefix => $sid,
5415 command => '242',
5416 params => [
5417 $uid,
5418 sprintf("Server Up %d days, %2.2d:%2.2d:%2.2d",
5419 $days, $hours, $mins, $remain),
5420 ],
5421 };
5422  
5423 0 my $totalconns = $self->{state}{stats}{conns_cumlative};
5424 0 my $local = $self->{state}{stats}{maxlocal};
5425 0 my $conns = $self->{state}{stats}{maxconns};
5426  
5427 0 push @$ref, {
5428 prefix => $sid,
5429 command => '250',
5430 params => [
5431 $uid, 'u',
5432 "Highest connection count: $conns ($local "
5433 ."clients) ($totalconns connections received)",
5434 ],
5435 };
5436 0 last SWITCH;
5437 }
5438 1 ▶ if ($char =~ /^[mM]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[mM]$/) 0 1 1
5439 0 my $cmds = $self->{state}{stats}{cmds};
5440 push @$ref, {
5441 prefix => $sid,
5442 command => '212',
5443 params => [
5444 $uid, 'M',
5445 $_,
5446 $cmds->{$_}{local},
5447 $cmds->{$_}{bytes},
5448 $cmds->{$_}{remote},
5449 ],
5450 0 } for sort keys %$cmds;
5451 0 last SWITCH;
5452 }
5453 1 ▶ if ($char eq 'p') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "p") 0 1 1
5454 0 my @ops = map { $self->_client_nickname( $_ ) }
5455 0 keys %{ $self->{state}{localops} };
5456 0 for my $op (sort @ops) {
5457 0 my $record = $self->{state}{users}{uc_irc($op)};
5458 0 ▶ next if $record->{umode} =~ /H/ && !$is_oper;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /H/ and not $is_oper 0 0 0
Condition0%0/3
$record->{"umode"} =~ /H/ and not $is_oper
!ll&&!rl&&r
000
MC/DC0%0/2
$record->{"umode"} =~ /H/ and not $is_oper
$record->{"umode"} =~ /H/ not $is_oper
Truth table0%0/3
A and not(B)
A= $record->{"umode"} =~ /H/B= not $is_oper
ABresult
0X0
100
111
5459 push @$ref, {
5460 prefix => $sid,
5461 command => '249',
5462 params => [
5463 $uid, 'p',
5464 sprintf("[O] %s (%s\@%s) Idle: %u",
5465 $record->{nick}, $record->{auth}{ident},
5466 $record->{auth}{hostname},
5467 0 time - $record->{idle_time}),
5468 ],
5469 colonify => 0,
5470 };
5471 }
5472  
5473 0 push @$ref, {
5474 prefix => $sid,
5475 command => '249',
5476 params => [$uid, scalar @ops . " OPER(s)"],
5477 };
5478 0 last SWITCH;
5479 }
5480 1 ▶ if ($char =~ /^[Oo]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Oo]$/) 0 1 1
5481 0 foreach my $op ( keys %{ $self->{config}{ops} } ) {
5482 0 my $orec = $self->{config}{ops}{$op};
5483 0 my $mask = 'localhost';
5484 0 ▶ if ( $orec->{ipmask} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orec->{"ipmask"}) 0 0 0
5485 0 ▶ if (ref $orec->{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $orec->{'ipmask'} eq 'ARRAY') { } 0 0 0
5486 0 $mask = '<masks>';
5487 }
5488 else {
5489 0 $mask = $orec->{ipmask};
5490 }
5491 }
5492 push @$ref, {
5493 prefix => $sid,
5494 command => '243',
5495 params => [
5496 $uid, 'O',
5497 sprintf('%s@%s','*', $mask ),
5498 '*', $orec->{username},
5499 0 $orec->{umode}, 'opers',
5500 ],
5501 };
5502 }
5503 0 last SWITCH;
5504 }
5505 1 ▶ if ($char =~ /^[Qq]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Qq]$/) 0 1 1
5506 0 my @chans; my @nicks;
5507 0 foreach my $mask ( sort keys %{ $self->{state}{resvs} } ) {
5508 0 ▶ if ($mask =~ m!^\#!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask =~ /^\#/) { } 0 0 0
5509 0 push @chans, $mask;
5510 }
5511 else {
5512 0 push @nicks, $mask;
5513 }
5514 }
5515 0 foreach my $mask (@chans,@nicks) {
5516 0 my $resv = $self->{state}{resvs}{$mask};
5517 push @$ref, {
5518 prefix => $sid,
5519 command => '217',
5520 params => [
5521 $uid,
5522 ( $resv->{duration} ? 'q' : 'Q' ),
5523 $resv->{mask}, $resv->{reason},
5524 0 ▶ ],
Branch: 1 branch
BranchTrueFalseTotal
$resv->{'duration'} ? : 0 0 0
5525 };
5526 }
5527 0 last SWITCH;
5528 }
5529 1 ▶ if ($char =~ /^[Ll]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Ll]$/) 0 1 1
5530 0 my $doall = 0;
5531 0 ▶ if (uc $targ eq uc $server) {
Branch: 2 branches
BranchTrueFalseTotal
if (uc $targ eq uc $server) { } 0 0 0
elsif ($targ eq $sid) { } 0 0 0
5532 0 $doall = 1;
5533 }
5534 elsif ($targ eq $sid) {
5535 0 $doall = 1;
5536 }
5537 0 my $name = $targ;
5538 0 ▶ if (!$doall && $name =~ m!^[0-9]!) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $doall and $name =~ /^[0-9]/) 0 0 0
Condition0%0/3
not $doall and $name =~ /^[0-9]/
!ll&&!rl&&r
000
MC/DC0%0/2
not $doall and $name =~ /^[0-9]/
not $doall $name =~ /^[0-9]/
Truth table0%0/3
not(A) and B
A= not $doallB= $name =~ /^[0-9]/
ABresult
0X0
100
111
5539 0 $name = $self->state_user_nick($name);
5540 }
5541 0 my $conns = $self->{state}{conns};
5542 0 my %connects;
5543 0 foreach my $conn_id ( keys %$conns ) {
5544 0 push @{ $connects{ $conns->{$conn_id}{type} } }, $conn_id;
5545 }
5546 # unknown
5547 0 ▶ foreach my $conn_id ( @{ ( $doall ? $connects{u} : [] ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
$doall ? : 0 0 0
5548 0 my $connrec = $conns->{$conn_id};
5549 0 my $send = $connrec->{stats}->send();
5550 0 my $recv = $connrec->{stats}->recv();
5551 0 my $msgs = $self->connection_msgs($conn_id);
5552 push @$ref, {
5553 prefix => $sid,
5554 command => '211',
5555 params => [
5556 $uid,
5557 sprintf(
5558 '%s[%s@%s]', ( $connrec->{nick} || '' ),
5559 ( $connrec->{auth}{ident} || 'unknown' ),
5560 ( $char eq 'L' ? $connrec->{socket}[0] :
5561 ($connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
5562 ), '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5563 sprintf(
5564 '%s %s -',
5565 ( time - $connrec->{conn_time} ),
5566 0 ▶ ( time > $connrec->{seen} ? ( time - $connrec->{seen} ) : 0 ),
Branch: 2 branches
BranchTrueFalseTotal
$char eq 'L' ? : 0 0 0
time > $connrec->{'seen'} ? : 0 0 0
Condition0%0/7
$connrec->{'nick'} || ''
l!l
00
$connrec->{'auth'}{'ident'} || 'unknown'
l!l
00
$connrec->{"auth"}{"hostname"} or $connrec->{"socket"}[0]
l!l&&r!l&&!r
000
MC/DC0%0/1
$connrec->{'nick'} || ''
$connrec->{'nick'}
MC/DC0%0/1
$connrec->{'auth'}{'ident'} || 'unknown'
$connrec->{'auth'}{'ident'}
MC/DC0%0/2
$connrec->{"auth"}{"hostname"} or $connrec->{"socket"}[0]
$connrec->{"auth"}{"hostname"} $connrec->{"socket"}[0]
Truth table0%0/2
A
A= $connrec->{'nick'}
Aresult
11
00
Truth table0%0/2
A
A= $connrec->{'auth'}{'ident'}
Aresult
11
00
Truth table0%0/3
A or B
A= $connrec->{"auth"}{"hostname"}B= $connrec->{"socket"}[0]
ABresult
1X1
011
000
5567 ),
5568 ],
5569 };
5570 }
5571 # clients
5572 0 foreach my $conn_id ( sort { $conns->{$a}{nick} <=> $conns->{$b}{nick} }
5573 0 @{ $connects{c} } ) {
5574 0 ▶ next if !$doall && !matches_mask($name,$conns->{$conn_id}{nick});
Branch: 1 branch
BranchTrueFalseTotal
unless $doall or matches_mask($name, $conns->{$conn_id}{"nick"}) 0 0 0
Condition0%0/3
$doall or matches_mask($name, $conns->{$conn_id}{"nick"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$doall or matches_mask($name, $conns->{$conn_id}{"nick"})
$doall matches_mask($name, $conns->{$conn_id}{"nick"})
Truth table0%0/3
A or B
A= $doallB= matches_mask($name, $conns->{$conn_id}{"nick"})
ABresult
1X1
011
000
5575 0 my $connrec = $conns->{$conn_id};
5576 0 my $send = $connrec->{stats}->send();
5577 0 my $recv = $connrec->{stats}->recv();
5578 0 my $msgs = $self->connection_msgs($conn_id);
5579 push @$ref, {
5580 prefix => $sid,
5581 command => '211',
5582 params => [
5583 $uid,
5584 sprintf(
5585 '%s[%s@%s]', ( $connrec->{nick} || '' ),
5586 ( $connrec->{auth}{ident} || 'unknown' ),
5587 ( $char eq 'L' ? $connrec->{socket}[0] :
5588 ($connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
5589 ), '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5590 sprintf(
5591 '%s %s -',
5592 ( time - $connrec->{conn_time} ),
5593 0 ▶ ( time > $connrec->{seen} ? ( time - $connrec->{seen} ) : 0 ),
Branch: 2 branches
BranchTrueFalseTotal
$char eq 'L' ? : 0 0 0
time > $connrec->{'seen'} ? : 0 0 0
Condition0%0/7
$connrec->{'nick'} || ''
l!l
00
$connrec->{'auth'}{'ident'} || 'unknown'
l!l
00
$connrec->{"auth"}{"hostname"} or $connrec->{"socket"}[0]
l!l&&r!l&&!r
000
MC/DC0%0/1
$connrec->{'nick'} || ''
$connrec->{'nick'}
MC/DC0%0/1
$connrec->{'auth'}{'ident'} || 'unknown'
$connrec->{'auth'}{'ident'}
MC/DC0%0/2
$connrec->{"auth"}{"hostname"} or $connrec->{"socket"}[0]
$connrec->{"auth"}{"hostname"} $connrec->{"socket"}[0]
Truth table0%0/2
A
A= $connrec->{'nick'}
Aresult
11
00
Truth table0%0/2
A
A= $connrec->{'auth'}{'ident'}
Aresult
11
00
Truth table0%0/3
A or B
A= $connrec->{"auth"}{"hostname"}B= $connrec->{"socket"}[0]
ABresult
1X1
011
000
5594 ),
5595 ],
5596 };
5597 }
5598 # servers
5599 0 foreach my $conn_id ( sort { $conns->{$a}{name} cmp $conns->{$b}{name} }
5600 0 @{ $connects{p} } ) {
5601 0 ▶ next if !$doall && !matches_mask($name,$conns->{$conn_id}{name});
Branch: 1 branch
BranchTrueFalseTotal
unless $doall or matches_mask($name, $conns->{$conn_id}{"name"}) 0 0 0
Condition0%0/3
$doall or matches_mask($name, $conns->{$conn_id}{"name"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$doall or matches_mask($name, $conns->{$conn_id}{"name"})
$doall matches_mask($name, $conns->{$conn_id}{"name"})
Truth table0%0/3
A or B
A= $doallB= matches_mask($name, $conns->{$conn_id}{"name"})
ABresult
1X1
011
000
5602 0 my $connrec = $conns->{$conn_id};
5603 0 my $send = $connrec->{stats}->send();
5604 0 my $recv = $connrec->{stats}->recv();
5605 0 my $msgs = $self->connection_msgs($conn_id);
5606 push @$ref, {
5607 prefix => $sid,
5608 command => '211',
5609 params => [
5610 $uid,
5611 sprintf(
5612 '%s[%s@%s]', ( $connrec->{name} || '' ),
5613 ( $connrec->{auth}{ident} || 'unknown' ),
5614 ( $char eq 'L' ? $connrec->{socket}[0] :
5615 ($connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
5616 ), '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5617 sprintf(
5618 '%s %s %s',
5619 ( time - $connrec->{conn_time} ),
5620 ( time > $connrec->{seen} ? ( time - $connrec->{seen} ) : 0 ),
5621 0 ▶ join ' ', @{ $connrec->{capab} },
Branch: 2 branches
BranchTrueFalseTotal
$char eq 'L' ? : 0 0 0
time > $connrec->{'seen'} ? : 0 0 0
Condition0%0/7
$connrec->{'name'} || ''
l!l
00
$connrec->{'auth'}{'ident'} || 'unknown'
l!l
00
$connrec->{"auth"}{"hostname"} or $connrec->{"socket"}[0]
l!l&&r!l&&!r
000
MC/DC0%0/1
$connrec->{'name'} || ''
$connrec->{'name'}
MC/DC0%0/1
$connrec->{'auth'}{'ident'} || 'unknown'
$connrec->{'auth'}{'ident'}
MC/DC0%0/2
$connrec->{"auth"}{"hostname"} or $connrec->{"socket"}[0]
$connrec->{"auth"}{"hostname"} $connrec->{"socket"}[0]
Truth table0%0/2
A
A= $connrec->{'name'}
Aresult
11
00
Truth table0%0/2
A
A= $connrec->{'auth'}{'ident'}
Aresult
11
00
Truth table0%0/3
A or B
A= $connrec->{"auth"}{"hostname"}B= $connrec->{"socket"}[0]
ABresult
1X1
011
000
5622 ),
5623 ],
5624 };
5625 }
5626 0 last SWITCH;
5627 }
5628 1 ▶ if ($char eq '?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "?") 1 0 1
5629 1 my $trecv = my $tsent = 0; my $scnt = 0;
5630 1 foreach my $link ( sort keys %{ $self->{state}{sids}{$sid}{sids} } ) {
5631 2 $scnt++;
5632 2 my $srec = $self->{state}{sids}{$link};
5633 2 my $send = $srec->{stats}->send();
5634 2 my $recv = $srec->{stats}->recv();
5635 2 my $msgs = $self->connection_msgs($srec->{route_id});
5636 2 $trecv += $recv; $tsent += $send;
5637 push @$ref, {
5638 prefix => $sid,
5639 command => '211',
5640 params => [
5641 $uid,
5642 sprintf('%s[unknown@%s]', $srec->{name}, $srec->{socket}[0]),
5643 '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5644 sprintf(
5645 '%s %s %s',
5646 ( time - $srec->{conn_time} ),
5647 ( time > $srec->{seen} ? ( time - $srec->{seen} ) : 0 ),
5648 2 ▶ join(' ', @{ $srec->{capab} })
Branch: 1 branch
BranchTrueFalseTotal
time > $srec->{'seen'} ? : 0 2 2
5649 ),
5650 ],
5651 };
5652 }
5653 1 push @$ref, {
5654 prefix => $sid,
5655 command => '249',
5656 params => [ $uid, '?', "$scnt total server(s)", ],
5657 };
5658 push @$ref, {
5659 prefix => $sid,
5660 command => '249',
5661 params => [
5662 1 $uid, '?', sprintf('Sent total: %s %s', @{ _rbytes($tsent) }),
5663 ],
5664 };
5665 push @$ref, {
5666 prefix => $sid,
5667 command => '249',
5668 params => [
5669 1 $uid, '?', sprintf('Recv total: %s %s', @{ _rbytes($trecv) }),
5670 ],
5671 };
5672 1 my $uptime = time - $self->server_config('created');
5673 push @$ref, {
5674 prefix => $sid,
5675 command => '249',
5676 params => [
5677 $uid, '?', sprintf(
5678 'Server send: %s %s (%4.1f K/s)',
5679 1 ▶ @{ _rbytes($self->{_globalstats}{sent}) },
Branch: 1 branch
BranchTrueFalseTotal
$uptime == 0 ? : 1 0 1
5680 ( $uptime == 0 ? 0 :
5681 1 ( ($self->{_globalstats}{sent} >> 10) / $uptime )
5682 ),
5683 ),
5684 ],
5685 };
5686 push @$ref, {
5687 prefix => $sid,
5688 command => '249',
5689 params => [
5690 $uid, '?', sprintf(
5691 'Server recv: %s %s (%4.1f K/s)',
5692 1 ▶ @{ _rbytes($self->{_globalstats}{recv}) },
Branch: 1 branch
BranchTrueFalseTotal
$uptime == 0 ? : 1 0 1
5693 ( $uptime == 0 ? 0 :
5694 1 ( ($self->{_globalstats}{sent} >> 10) / $uptime )
5695 ),
5696 ),
5697 ],
5698 };
5699 1 last SWITCH;
5700 }
5701 }
5702  
5703 18 push @$ref, {
5704 prefix => $sid,
5705 command => '219',
5706 params => [$uid, $char, 'End of /STATS report'],
5707 };
5708  
5709 18 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 18 18
5710 18 return $ref;
5711 }
5712  
5713 1 ▶sub _daemon_cmd_userhost {
Subroutine _daemon_cmd_userhost: called CC=12 SCAR=25.9
5714 1 my $self = shift;
5715 1 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5716 1 my $server = $self->server_name();
5717 1 my $ref = [ ];
5718 1 my $str = '';
5719 1 my $cnt = 0;
5720  
5721 1 for my $query (@_) {
5722 3 ▶ last if $cnt >= 5;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt >= 5 0 3 3
5723 3 $cnt++;
5724 3 my $uid = $self->state_user_uid($query);
5725 3 ▶ next if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 3 3
5726 3 my $urec = $self->{state}{uids}{$uid};
5727 3 my ($name,$uh) = split /!/, $urec->{full}->();
5728 3 ▶ if ( $nick eq $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick eq $name) 1 2 3
5729 1 $uh = join '@', (split /\@/, $uh)[0], $urec->{socket}[0];
5730 }
5731 3 my $status = '';
5732 3 ▶ if ( $urec->{umode} =~ /o/ && ( $urec->{umode} !~ /H/ ||
Branch: 1 branch
BranchTrueFalseTotal
if ($urec->{"umode"} =~ /o/ and !($urec->{"umode"} =~ /H/) || $self->state_user_is_operator($nick)) 1 2 3
Condition50%3/6
$urec->{"umode"} =~ /o/ and !($urec->{"umode"} =~ /H/) || $self->state_user_is_operator($nick)
!ll&&!rl&&r
201
not $urec->{"umode"} =~ /H/ or $self->state_user_is_operator($nick)
l!l&&r!l&&!r
100
MC/DC33%1/3
$urec->{"umode"} =~ /o/ and !($urec->{"umode"} =~ /H/) || $self->state_user_is_operator($nick)
$urec->{"umode"} =~ /o/ not $urec->{"umode"} =~ /H/ $self->state_user_is_operator($nick)
Truth table50%2/4
A and not(B) or C
A= $urec->{"umode"} =~ /o/B= not $urec->{"umode"} =~ /H/C= $self->state_user_is_operator($nick)
ABCresult
0XX0
1000
11X1
1011
5733 $self->state_user_is_operator($nick) ) ) {
5734 1 $status .= '*';
5735 }
5736 3 $status .= '=';
5737 3 ▶ $status .= ( defined $urec->{away} ? '-' : '+' );
Branch: 1 branch
BranchTrueFalseTotal
defined $urec->{'away'} ? : 0 3 3
5738 3 $str = join ' ', $str, $name . $status . $uh;
5739 3 $str =~ s!^ !!g;
5740 }
5741  
5742 1 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
$str ? : 1 0 1
5743 prefix => $server,
5744 command => '302',
5745 params => [$nick, ($str ? $str : ':')],
5746 };
5747  
5748 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
5749 0 return $ref;
5750 }
5751  
5752 0 ▶sub _daemon_cmd_ison {
Subroutine _daemon_cmd_ison: not called CC=5 SCAR=34.0
5753 0 my $self = shift;
5754 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
5755 0 my $server = $self->server_name();
5756 0 my $ref = [ ];
5757 0 my $args = [@_];
5758 0 my $count = @$args;
5759  
5760 SWITCH: {
5761 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
5762 0 push @$ref, ['461', 'ISON'];
5763 0 last SWITCH;
5764 }
5765 0 my $string = '';
5766 $string = join ' ', map {
5767 $self->{state}{users}{uc_irc($_)}{nick}
5768 0 } grep { $self->state_nick_exists($_) } @$args;
5769  
5770 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
$string =~ /\s+/ ? : 0 0 0
5771 prefix => $server,
5772 command => '303',
5773 params => [$nick, ($string =~ /\s+/ ? $string : ":$string")],
5774 };
5775 }
5776  
5777 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5778 0 return $ref;
5779 }
5780  
5781 130 ▶sub _daemon_do_safelist {
Subroutine _daemon_do_safelist: called CC=37 SCAR=44.3
5782 130 my ($kernel,$self,$client) = @_[KERNEL,OBJECT,ARG0];
5783 130 my $server = $self->server_name();
5784 130 my $mask = $client->{safelist};
5785 130 ▶ return if !$mask;
Branch: 1 branch
BranchTrueFalseTotal
unless $mask 1 129 130
5786 129 my $start = delete $mask->{start};
5787  
5788 129 ▶ if ($start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start) { } 7 122 129
5789 $self->send_output(
5790 {
5791 prefix => $server,
5792 command => '321',
5793 params => [$client->{nick}, 'Channel', 'Users Name'],
5794 },
5795 $client->{route_id},
5796 7 );
5797 7 $mask->{chans} = [ keys %{ $self->{state}{chans} } ];
5798 7 $kernel->yield('_daemon_do_safelist',$client);
5799 7 return;
5800 }
5801 else {
5802 122 my $chan = shift @{ $mask->{chans} };
5803 122 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 6 116 122
5804 $self->send_output(
5805 {
5806 prefix => $server,
5807 command => '323',
5808 params => [$client->{nick}, 'End of /LIST'],
5809 },
5810 $client->{route_id},
5811 6 );
5812 6 delete $client->{safelist};
5813 6 return;
5814 }
5815 116 my $show = 0;
5816 SWITCH: {
5817 116 ▶ last SWITCH if !defined $self->{state}{chans}{$chan};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"chans"}{$chan} 0 116 116
5818 116 ▶ if ($mask->{all}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"all"}) 30 86 116
5819 30 $show = 1;
5820 30 last SWITCH;
5821 }
5822 86 ▶ if ($mask->{hide}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"hide"}) 0 86 86
5823 0 my $match = matches_mask_array($mask->{hide},[$chan]);
5824 0 ▶ $show = 0 if keys %$match;
Branch: 1 branch
BranchTrueFalseTotal
if keys %$match 0 0 0
5825 0 last SWITCH;
5826 }
5827 86 ▶ if ($mask->{show}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"show"}) 30 56 86
5828 30 my $match = matches_mask_array($mask->{show},[$chan]);
5829 30 ▶ if ( keys %$match ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$match) { } 8 22 30
5830 8 $show = 1;
5831 }
5832 else {
5833 22 $show = 0;
5834 22 last SWITCH;
5835 }
5836 }
5837 64 ▶ if ($mask->{users_max} || $mask->{users_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"users_max"} or $mask->{"users_min"}) 28 36 64
Condition66%2/3
$mask->{"users_max"} or $mask->{"users_min"}
l!l&&r!l&&!r
02836
MC/DC50%1/2
$mask->{"users_max"} or $mask->{"users_min"}
$mask->{"users_max"} $mask->{"users_min"}
Truth table66%2/3
A or B
A= $mask->{"users_max"}B= $mask->{"users_min"}
ABresult
1X1
011
000
5838 28 my $usercnt = keys %{ $self->{state}{chans}{$chan}{users} };
5839 28 ▶ if ($mask->{users_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"users_max"}) 0 28 28
5840 0 ▶ if ($usercnt > $mask->{users_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($usercnt > $mask->{'users_max'}) { } 0 0 0
5841 0 $show = 1;
5842 }
5843 else {
5844 0 $show = 0;
5845 }
5846 }
5847 28 ▶ if ($mask->{users_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"users_min"}) 28 0 28
5848 28 ▶ if ($usercnt < $mask->{users_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($usercnt < $mask->{'users_min'}) { } 6 22 28
5849 6 $show = 1;
5850 }
5851 else {
5852 22 $show = 0;
5853 }
5854 }
5855 }
5856 64 ▶ if ($mask->{create_max} || $mask->{create_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"create_max"} or $mask->{"create_min"}) 0 64 64
Condition33%1/3
$mask->{"create_max"} or $mask->{"create_min"}
l!l&&r!l&&!r
0064
MC/DC0%0/2
$mask->{"create_max"} or $mask->{"create_min"}
$mask->{"create_max"} $mask->{"create_min"}
Truth table33%1/3
A or B
A= $mask->{"create_max"}B= $mask->{"create_min"}
ABresult
1X1
011
000
5857 0 my $chants = $self->{state}{chans}{$chan}{ts};
5858 0 ▶ if ($mask->{create_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"create_max"}) 0 0 0
5859 0 ▶ if ($chants > $mask->{create_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chants > $mask->{'create_max'}) { } 0 0 0
5860 0 $show = 1;
5861 }
5862 else {
5863 0 $show = 0;
5864 }
5865 }
5866 0 ▶ if ($mask->{create_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"create_min"}) 0 0 0
5867 0 ▶ if ($chants < $mask->{create_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chants < $mask->{'create_min'}) { } 0 0 0
5868 0 $show = 1;
5869 }
5870 else {
5871 0 $show = 0;
5872 }
5873 }
5874 }
5875 64 ▶ if ($mask->{topic_max} || $mask->{topic_min} || $mask->{topic_msk}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_max"} or $mask->{"topic_min"} or $mask->{"topic_msk"}) 28 36 64
Condition50%3/6
$mask->{"topic_max"} or $mask->{"topic_min"} or $mask->{"topic_msk"}
l!l&&r!l&&!r
02836
$mask->{"topic_max"} or $mask->{"topic_min"}
l!l&&r!l&&!r
0064
MC/DC33%1/3
$mask->{"topic_max"} or $mask->{"topic_min"} or $mask->{"topic_msk"}
$mask->{"topic_max"} $mask->{"topic_min"} $mask->{"topic_msk"}
Truth table50%2/4
A or B or C
A= $mask->{"topic_max"}B= $mask->{"topic_min"}C= $mask->{"topic_msk"}
ABCresult
1XX1
01X1
0011
0000
5876 28 my $chantopic = $self->{state}{chans}{$chan}{topic};
5877 28 ▶ if (!$chantopic) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $chantopic) { } 24 4 28
5878 24 $show = 0;
5879 }
5880 else {
5881 4 ▶ if ($mask->{topic_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_max"}) 0 4 4
5882 0 ▶ if($mask->{topic_max} > $chantopic->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{'topic_max'} > $chantopic->[2]) { } 0 0 0
5883 0 $show = 1;
5884 }
5885 else {
5886 0 $show = 0;
5887 }
5888 }
5889 4 ▶ if ($mask->{topic_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_min"}) 0 4 4
5890 0 ▶ if($mask->{topic_min} < $chantopic->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{'topic_min'} < $chantopic->[2]) { } 0 0 0
5891 0 $show = 1;
5892 }
5893 else {
5894 0 $show = 0;
5895 }
5896 }
5897 4 ▶ if ($mask->{topic_msk}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_msk"}) 4 0 4
5898 4 ▶ if(matches_mask($mask->{topic_msk},$chantopic->[0],'ascii')) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($mask->{'topic_msk'}, $chantopic->[0], 'ascii')) { } 2 2 4
5899 2 $show = 1;
5900 }
5901 else {
5902 2 $show = 0;
5903 }
5904 }
5905 }
5906 }
5907 }
5908 116 my $hidden = ( $self->{state}{chans}{$chan}{mode} =~ m![ps]! );
5909 116 ▶ if ($show && $hidden && !defined $client->{chans}{$chan}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show and $hidden and not defined $client->{"chans"}{$chan}) 2 114 116
Condition83%5/6
$show and $hidden and not defined $client->{"chans"}{$chan}
!ll&&!rl&&r
11402
$show and $hidden
!ll&&!rl&&r
70442
MC/DC66%2/3
$show and $hidden and not defined $client->{"chans"}{$chan}
$show $hidden not defined $client->{"chans"}{$chan}
Truth table75%3/4
A and B and not(C)
A= $showB= $hiddenC= not defined $client->{"chans"}{$chan}
ABCresult
0XX0
10X0
1100
1111
5910 2 $show = 0;
5911 }
5912 116 ▶ if ($show) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show) 44 72 116
5913 44 my $chanrec = $self->{state}{chans}{$chan};
5914 44 my $bluf = sprintf('[+%s]', $chanrec->{mode});
5915 44 ▶ if ( defined $chanrec->{topic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chanrec->{"topic"}) 11 33 44
5916 11 $bluf = join ' ', $bluf, $chanrec->{topic}[0];
5917 }
5918 $self->send_output(
5919 {
5920 prefix => $server,
5921 command => '322',
5922 params => [
5923 $client->{nick},
5924 $chanrec->{name},
5925 44 scalar keys %{ $chanrec->{users} },
5926 $bluf,
5927 ],
5928 },
5929 $client->{route_id},
5930 44 );
5931 }
5932 116 $kernel->yield('_daemon_do_safelist',$client);
5933 }
5934 116 return;
5935 }
5936  
5937 8 ▶sub _daemon_cmd_list {
Subroutine _daemon_cmd_list: called CC=22 SCAR=41.3
5938 8 my $self = shift;
5939 8 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
80
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5940 8 my $server = $self->server_name();
5941 8 my $ref = [ ];
5942 8 my $args = [@_];
5943 8 my $count = @$args;
5944  
5945 SWITCH: {
5946 8 my $rec = $self->{state}{users}{uc_irc $nick};
5947 8 my $task = { start => 1 };
5948 8 my $errors;
5949 8 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count) { } 3 5 8
5950 3 ▶ if ($rec->{safelist}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"safelist"}) 1 2 3
5951 1 delete $rec->{safelist};
5952 1 push @$ref, {
5953 prefix => $server,
5954 command => '323',
5955 params => [$nick, 'End of /LIST'],
5956 };
5957 1 last SWITCH;
5958 }
5959 2 $task->{all} = 1;
5960 }
5961 else {
5962 5 OPTS: foreach my $opt ( split /,/, $args->[0] ) {
5963 5 ▶ if ($opt =~ m!^T!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^T/i) 1 4 5
5964 1 ▶ if ($opt !~ m!^T:!i && $opt !~ m!^T[<>]\d+$!i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^T:/i or $opt =~ /^T[<>]\d+$/i) 0 1 1
Condition33%1/3
$opt =~ /^T:/i or $opt =~ /^T[<>]\d+$/i
l!l&&r!l&&!r
100
MC/DC0%0/2
$opt =~ /^T:/i or $opt =~ /^T[<>]\d+$/i
$opt =~ /^T:/i $opt =~ /^T[<>]\d+$/i
Truth table33%1/3
A or B
A= $opt =~ /^T:/iB= $opt =~ /^T[<>]\d+$/i
ABresult
1X1
011
000
5965 0 $errors++;
5966 0 last OPTS;
5967 }
5968 1 my ($pre,$act,$mins) = $opt =~ m!^(T)([<>:])(.+)$!i;
5969 1 ▶ if ($act eq '<') {
Branch: 2 branches
BranchTrueFalseTotal
if ($act eq '<') { } 0 1 1
elsif ($act eq '>') { } 0 1 1
5970 0 $task->{topic_min} = time() - ( $mins * 60 );
5971 }
5972 elsif ($act eq '>') {
5973 0 $task->{topic_max} = time() - ( $mins * 60 );
5974 }
5975 else {
5976 1 $task->{topic_msk} = $mins;
5977 }
5978 1 next OPTS;
5979 }
5980 4 ▶ if ($opt =~ m!^C!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^C/i) 0 4 4
5981 0 ▶ if ($opt !~ m!^C[<>]\d+$!i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^C[<>]\d+$/i) 0 0 0
5982 0 $errors++;
5983 0 last OPTS;
5984 }
5985 0 my ($pre,$act,$mins) = $opt =~ m!^(C)([<>])(\d+)$!i;
5986 0 ▶ if ($act eq '<') {
Branch: 1 branch
BranchTrueFalseTotal
if ($act eq '<') { } 0 0 0
5987 0 $task->{create_min} = time() - ( $mins * 60 );
5988 }
5989 else {
5990 0 $task->{create_max} = time() - ( $mins * 60 );
5991 }
5992 0 next OPTS;
5993 }
5994 4 ▶ if ($opt =~ m!^\<!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^\</) 1 3 4
5995 1 ▶ if ($opt !~ m!^\<\d+$!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^\<\d+$/) 0 1 1
5996 0 $errors++;
5997 0 last OPTS;
5998 }
5999 1 my ($act,$users) = $opt =~ m!^(\<)(\d+)$!;
6000 1 $task->{users_min} = $users;
6001 1 next OPTS;
6002 }
6003 3 ▶ if ($opt =~ m!^\>!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^\>/) 0 3 3
6004 0 ▶ if ($opt !~ m!^\>\d+$!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^\>\d+$/) 0 0 0
6005 0 $errors++;
6006 0 last OPTS;
6007 }
6008 0 my ($act,$users) = $opt =~ m!^(\>)(\d+)$!;
6009 0 $task->{users_max} = $users;
6010 0 next OPTS;
6011 }
6012 3 my ($hide) = $opt =~ s/^!//;
6013 3 ▶ if ($opt !~ m![\x2A\x3F]! && $opt !~ m!^[#&]! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /[\x2A\x3F]/ or $opt =~ /^[#&]/) 0 3 3
Condition66%2/3
$opt =~ /[\x2A\x3F]/ or $opt =~ /^[#&]/
l!l&&r!l&&!r
120
MC/DC0%0/2
$opt =~ /[\x2A\x3F]/ or $opt =~ /^[#&]/
$opt =~ /[\x2A\x3F]/ $opt =~ /^[#&]/
Truth table66%2/3
A or B
A= $opt =~ /[\x2A\x3F]/B= $opt =~ /^[#&]/
ABresult
1X1
011
000
6014 0 $errors++;
6015 0 last OPTS;
6016 }
6017 3 ▶ if ( $hide ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hide) { } 0 3 3
6018 0 push @{ $task->{hide} }, $opt;
6019 }
6020 else {
6021 3 push @{ $task->{show} }, $opt;
6022 }
6023 }
6024 }
6025 7 ▶ if ( $errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errors) 0 7 7
6026 0 push @$ref, ['521'];
6027 0 last SWITCH;
6028 }
6029 7 $rec->{safelist} = $task;
6030 7 $poe_kernel->yield('_daemon_do_safelist',$rec);
6031 }
6032  
6033 8 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 8 0 8
6034 0 return $ref;
6035 }
6036  
6037 108 ▶sub _daemon_cmd_names {
Subroutine _daemon_cmd_names: called CC=28 SCAR=43.8
6038 108 my $self = shift;
6039 108 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
1080
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6040 108 my $server = $self->server_name();
6041 108 my $ref = [ ];
6042 108 my $args = [@_];
6043 108 my $count = @$args;
6044  
6045 # TODO: hybrid only seems to support NAMES #channel so fix this
6046 SWITCH: {
6047 108 my (@chans, $query);
6048 108 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 108 108
6049 0 @chans = $self->state_user_chans($nick);
6050 0 $query = '*';
6051 }
6052 108 my $last = pop @$args;
6053 108 ▶ if ($count && $last !~ /^[#&]/
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)) 0 108 108
Condition33%2/6
$count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)
!ll&&!rl&&r
10800
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
01080
MC/DC0%0/3
$count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)
$count not $last =~ /^[#&]/ not $self->state_peer_exists($last)
Truth table25%1/4
A and not(B) and not(C)
A= $countB= not $last =~ /^[#&]/C= not $self->state_peer_exists($last)
ABCresult
0XX0
10X0
1100
1111
6054 && !$self->state_peer_exists($last)) {
6055 0 push @$ref, ['401', $last];
6056 0 last SWITCH;
6057 }
6058 108 ▶ if ($count && $last !~ /^[#&]/ & uc $last ne uc $server) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and !($last =~ /^[#&]/) & uc $last ne uc $server) 0 108 108
Condition33%1/3
$count and !($last =~ /^[#&]/) & uc $last ne uc $server
!ll&&!rl&&r
01080
MC/DC0%0/2
$count and !($last =~ /^[#&]/) & uc $last ne uc $server
$count !($last =~ /^[#&]/) & uc $last ne uc $server
Truth table33%1/3
A and not(B)
A= $countB= !($last =~ /^[#&]/) & uc $last ne uc $server
ABresult
0X0
100
111
6059 0 $self->send_output(
6060 {
6061 prefix => $nick,
6062 command => 'NAMES',
6063 params => [@$args, $self->_state_peer_name($last)],
6064 },
6065 $self->_state_peer_route($last),
6066 );
6067 0 last SWITCH;
6068 }
6069 108 ▶ if ($count && $last !~ /^[#&]/ && @$args == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and @$args == 0) 0 108 108
Condition33%2/6
$count and not $last =~ /^[#&]/ and @$args == 0
!ll&&!rl&&r
10800
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
01080
MC/DC0%0/3
$count and not $last =~ /^[#&]/ and @$args == 0
$count not $last =~ /^[#&]/ @$args == 0
Truth table25%1/4
A and not(B) and C
A= $countB= not $last =~ /^[#&]/C= @$args == 0
ABCresult
0XX0
10X0
1100
1111
6070 0 @chans = $self->state_user_chans($nick);
6071 0 $query = '*';
6072 }
6073 108 ▶ if ($count && $last !~ /^[#&]/ && @$args == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and @$args == 1) 0 108 108
Condition33%2/6
$count and not $last =~ /^[#&]/ and @$args == 1
!ll&&!rl&&r
10800
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
01080
MC/DC0%0/3
$count and not $last =~ /^[#&]/ and @$args == 1
$count not $last =~ /^[#&]/ @$args == 1
Truth table25%1/4
A and not(B) and C
A= $countB= not $last =~ /^[#&]/C= @$args == 1
ABCresult
0XX0
10X0
1100
1111
6074 0 $last = pop @$args;
6075 }
6076 108 ▶ if ($count && $last =~ /^[#&]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and $last =~ /^[#&]/) 108 0 108
Condition33%1/3
$count and $last =~ /^[#&]/
!ll&&!rl&&r
00108
MC/DC0%0/2
$count and $last =~ /^[#&]/
$count $last =~ /^[#&]/
Truth table33%1/3
A and B
A= $countB= $last =~ /^[#&]/
ABresult
0X0
100
111
6077 my ($chan) = grep {
6078 108 ▶ $_ && $self->state_chan_exists($_)
Condition33%2/6
$_ && $self->state_chan_exists($_) && $self->state_is_chan_member($nick, $_)
!ll&&!rl&&r
00108
$_ and $self->state_chan_exists($_)
!ll&&!rl&&r
00108
MC/DC0%0/3
$_ && $self->state_chan_exists($_) && $self->state_is_chan_member($nick, $_)
$_ $self->state_chan_exists($_) $self->state_is_chan_member($nick, $_)
Truth table25%1/4
A and B && C
A= $_B= $self->state_chan_exists($_)C= $self->state_is_chan_member($nick, $_)
ABCresult
0XX0
10X0
1100
1111
6079 && $self->state_is_chan_member($nick, $_)
6080 } split /,/, $last;
6081 108 @chans = ();
6082  
6083 108 ▶ if ($chan) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chan) { } 108 0 108
6084 108 push @chans, $chan;
6085 108 $query = $self->_state_chan_name($chan);
6086 }
6087 else {
6088 0 $query = '*';
6089 }
6090 }
6091  
6092 108 my $chan_prefix_method = 'state_chan_list_prefixed';
6093 108 my $uid = $self->state_user_uid($nick);
6094 $chan_prefix_method = 'state_chan_list_multi_prefixed'
6095 108 ▶ if $self->{state}{uids}{$uid}{caps}{'multi-prefix'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"uids"}{$uid}{"caps"}{"multi-prefix"} 14 94 108
6096  
6097 108 ▶ my $flag = ( $self->{state}{uids}{$uid}{caps}{'userhost-in-names'} ? 'FULL' : '' );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'state'}{'uids'}{$uid}{'caps'}{'userhost-in-names'} ? : 6 102 108
6098  
6099 108 for my $chan (@chans) {
6100 108 my $record = $self->{state}{chans}{uc_irc($chan)};
6101 108 my $type = '=';
6102 108 ▶ $type = '@' if $record->{mode} =~ /s/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /s/ 0 108 108
6103 108 ▶ $type = '*' if $record->{mode} =~ /p/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /p/ 0 108 108
6104 108 my $length = length($server)+3+length($chan)+length($nick)+7;
6105 108 my $buffer = '';
6106  
6107 108 for my $name (sort $self->$chan_prefix_method($record->{name},$flag)) {
6108 190 ▶ if (length(join ' ', $buffer, $name) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buffer, $name) + $length > 510) 0 190 190
6109 push @$ref, {
6110 prefix => $server,
6111 command => '353',
6112 0 params => [$nick, $type, $record->{name}, $buffer]
6113 };
6114 0 $buffer = $name;
6115 0 next;
6116 }
6117 190 ▶ if ($buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) { } 82 108 190
6118 82 $buffer = join ' ', $buffer, $name;
6119 }
6120 else {
6121 108 $buffer = $name;
6122 }
6123 }
6124 push @$ref, {
6125 prefix => $server,
6126 command => '353',
6127 108 params => [$nick, $type, $record->{name}, $buffer],
6128 };
6129 }
6130 108 push @$ref, {
6131 prefix => $server,
6132 command => '366',
6133 params => [$nick, $query, 'End of NAMES list'],
6134 };
6135 }
6136  
6137 108 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 108 0 108
6138 0 return $ref;
6139 }
6140  
6141 6 ▶sub _daemon_cmd_whois {
Subroutine _daemon_cmd_whois: called CC=22 SCAR=34.5
6142 6 my $self = shift;
6143 6 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6144 6 my $server = $self->server_name();
6145 6 my $ref = [ ];
6146 6 my ($first, $second) = @_;
6147  
6148 SWITCH: {
6149 6 ▶ if (!$first && !$second) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($first or $second) 0 6 6
Condition33%1/3
$first or $second
l!l&&r!l&&!r
600
MC/DC0%0/2
$first or $second
$first $second
Truth table33%1/3
A or B
A= $firstB= $second
ABresult
1X1
011
000
6150 0 push @$ref, ['431'];
6151 0 last SWITCH;
6152 }
6153 6 ▶ if (!$second && $first) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $second and $first) 5 1 6
Condition66%2/3
not $second and $first
!ll&&!rl&&r
105
MC/DC50%1/2
not $second and $first
not $second $first
Truth table66%2/3
not(A) and B
A= not $secondB= $first
ABresult
0X0
100
111
6154 5 $second = (split /,/, $first)[0];
6155 5 $first = $server;
6156 }
6157 6 ▶ if ($first && $second) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first and $second) 6 0 6
Condition33%1/3
$first and $second
!ll&&!rl&&r
006
MC/DC0%0/2
$first and $second
$first $second
Truth table33%1/3
A and B
A= $firstB= $second
ABresult
0X0
100
111
6158 6 $second = (split /,/, $second)[0];
6159 }
6160 6 ▶ if (uc_irc($first) eq uc_irc($second)
Branch: 1 branch
BranchTrueFalseTotal
if (uc_irc($first) eq uc_irc($second) and $self->state_nick_exists($second)) 1 5 6
Condition66%2/3
uc_irc($first) eq uc_irc($second) and $self->state_nick_exists($second)
!ll&&!rl&&r
501
MC/DC50%1/2
uc_irc($first) eq uc_irc($second) and $self->state_nick_exists($second)
uc_irc($first) eq uc_irc($second) $self->state_nick_exists($second)
Truth table66%2/3
A and B
A= uc_irc($first) eq uc_irc($second)B= $self->state_nick_exists($second)
ABresult
0X0
100
111
6161 && $self->state_nick_exists($second)) {
6162 1 $first = $self->state_user_server($second);
6163 }
6164 6 my $query;
6165 my $target;
6166 6 ▶ $query = $first if !$second;
Branch: 1 branch
BranchTrueFalseTotal
unless $second 0 6 6
6167 6 ▶ $query = $second if $second;
Branch: 1 branch
BranchTrueFalseTotal
if $second 6 0 6
6168 6 ▶ $target = $first if $second && uc $first ne uc $server;
Branch: 1 branch
BranchTrueFalseTotal
if $second and uc $first ne uc $server 1 5 6
Condition66%2/3
$second and uc $first ne uc $server
!ll&&!rl&&r
051
MC/DC50%1/2
$second and uc $first ne uc $server
$second uc $first ne uc $server
Truth table66%2/3
A and B
A= $secondB= uc $first ne uc $server
ABresult
0X0
100
111
6169 6 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 6 6
Condition66%2/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
510
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table66%2/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
6170 0 push @$ref, ['402', $target];
6171 0 last SWITCH;
6172 }
6173 6 ▶ if ($target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 5 6
6174 }
6175 # Okay we got here *phew*
6176 6 ▶ if (!$self->state_nick_exists($query)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->state_nick_exists($query)) { } 0 6 6
6177 0 push @$ref, ['401', $query];
6178 }
6179 else {
6180 6 my $uid = $self->state_user_uid($nick);
6181 6 my $who = $self->state_user_uid($query);
6182 6 ▶ if ( $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 5 6
6183 1 my $tsid = $self->_state_peer_sid($target);
6184 1 ▶ if ( $who =~ m!^$tsid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($who =~ /^$tsid/) 1 0 1
6185 1 $self->send_output(
6186 {
6187 prefix => $self->state_user_uid($nick),
6188 command => 'WHOIS',
6189 params => [
6190 $tsid,
6191 $query,
6192 ],
6193 },
6194 $self->_state_sid_route($tsid),
6195 );
6196 1 last SWITCH;
6197 }
6198 }
6199 5 $ref = $self->_daemon_do_whois($uid,$who);
6200 5 foreach my $reply ( @$ref ) {
6201 30 $reply->{prefix} = $server;
6202 30 $reply->{params}[0] = $nick;
6203 }
6204 }
6205 }
6206  
6207 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
6208 0 return $ref;
6209 }
6210  
6211 2 ▶sub _daemon_peer_whois {
Subroutine _daemon_peer_whois: called CC=4 SCAR=14.0
6212 2 my $self = shift;
6213 2 my $peer_id = shift;
6214 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6215 2 my $sid = $self->server_sid();
6216 2 my $ref = [ ];
6217 2 my ($first, $second) = @_;
6218  
6219 2 my $targ = substr $first, 0, 3;
6220 SWITCH: {
6221 2 ▶ if ( $targ !~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 1 1 2
6222 1 $self->send_output(
6223 {
6224 prefix => $uid,
6225 command => 'WHOIS',
6226 params => [
6227 $first,
6228 $second,
6229 ],
6230 },
6231 $self->_state_sid_route($targ),
6232 );
6233 1 last SWITCH;
6234 }
6235 1 my $who = $self->state_user_uid($second);
6236 1 $ref = $self->_daemon_do_whois($uid,$who);
6237 }
6238  
6239 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
6240 0 return $ref;
6241 }
6242  
6243 6 ▶sub _daemon_do_whois {
Subroutine _daemon_do_whois: called CC=48 SCAR=45.7
6244 6 my $self = shift;
6245 6 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6246 6 my $sid = $self->server_sid();
6247 6 my $server = $self->server_name();
6248 6 my $nicklen = $self->server_config('NICKLEN');
6249 6 my $ref = [ ];
6250 6 my $query = shift;
6251  
6252 6 my $querier = $self->{state}{uids}{$uid};
6253 6 my $record = $self->{state}{uids}{$query};
6254  
6255 push @$ref, {
6256 prefix => $sid,
6257 command => '311',
6258 params => [
6259 $uid,
6260 $record->{nick},
6261 $record->{auth}{ident},
6262 $record->{auth}{hostname},
6263 '*',
6264 $record->{ircname},
6265 6 ],
6266 };
6267 6 my @chans;
6268 6 ▶ my $noshow = ( $record->{umode} =~ m!p! && $querier->{umode} !~ m!o! && $uid ne $query );
Condition33%2/6
$record->{'umode'} =~ /p/ && !($querier->{'umode'} =~ /o/) && $uid ne $query
!ll&&!rl&&r
600
$record->{"umode"} =~ /p/ and not $querier->{"umode"} =~ /o/
!ll&&!rl&&r
600
MC/DC0%0/3
$record->{'umode'} =~ /p/ && !($querier->{'umode'} =~ /o/) && $uid ne $query
$record->{"umode"} =~ /p/ not $querier->{"umode"} =~ /o/ $uid ne $query
Truth table25%1/4
A and not(B) && C
A= $record->{"umode"} =~ /p/B= not $querier->{"umode"} =~ /o/C= $uid ne $query
ABCresult
0XX0
10X0
1100
1111
6269 6 LOOP: for my $chan (keys %{ $record->{chans} }) {
6270 6 ▶ next LOOP if $noshow;
Branch: 1 branch
BranchTrueFalseTotal
if $noshow 0 6 6
6271 6 ▶ if ($self->{state}{chans}{$chan}{mode} =~ /[ps]/
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ and not defined $self->{"state"}{"chans"}{$chan}{"users"}{$uid}) 0 6 6
Condition33%1/3
$self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ and not defined $self->{"state"}{"chans"}{$chan}{"users"}{$uid}
!ll&&!rl&&r
600
MC/DC0%0/2
$self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ and not defined $self->{"state"}{"chans"}{$chan}{"users"}{$uid}
$self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ not defined $self->{"state"}{"chans"}{$chan}{"users"}{$uid}
Truth table33%1/3
A and not(B)
A= $self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/B= not defined $self->{"state"}{"chans"}{$chan}{"users"}{$uid}
ABresult
0X0
100
111
6272 && !defined $self->{state}{chans}{$chan}{users}{$uid}) {
6273 0 next LOOP;
6274 }
6275 6 my $prefix = '';
6276 6 ▶ $prefix .= '@' if $record->{chans}{$chan} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /o/ 6 0 6
6277 6 ▶ $prefix .= '%' if $record->{chans}{$chan} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /h/ 0 6 6
6278 6 ▶ $prefix .= '+' if $record->{chans}{$chan} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /v/ 0 6 6
6279 6 push @chans, $prefix . $self->{state}{chans}{$chan}{name};
6280 }
6281 6 ▶ if (@chans) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chans) 6 0 6
6282 6 my $buffer = '';
6283 my $length = length($server) + 3 + $nicklen
6284 6 + length($record->{nick}) + 7;
6285  
6286 6 LOOP2: for my $chan (@chans) {
6287 6 ▶ if (length(join ' ', $buffer, $chan) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buffer, $chan) + $length > 510) 0 6 6
6288 push @$ref, {
6289 prefix => $sid,
6290 command => '319',
6291 0 params => [$uid, $record->{nick}, $buffer],
6292 };
6293 0 $buffer = $chan;
6294 0 next LOOP2;
6295 }
6296 6 ▶ if ($buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) { } 0 6 6
6297 0 $buffer = join ' ', $buffer, $chan;
6298 }
6299 else {
6300 6 $buffer = $chan;
6301 }
6302 }
6303 push @$ref, {
6304 prefix => $sid,
6305 command => '319',
6306 6 params => [$uid, $record->{nick}, $buffer],
6307 };
6308 }
6309 # RPL_WHOISSERVER
6310 6 ▶ my $hidden = ( $self->{config}{'hidden_servers'} && ( $querier->{umode} !~ /o/ || $uid ne $query ) );
Condition50%3/6
$self->{'config'}{'hidden_servers'} && (!($querier->{'umode'} =~ /o/) || $uid ne $query)
!ll&&!rl&&r
402
not $querier->{"umode"} =~ /o/ or $uid ne $query
l!l&&r!l&&!r
200
MC/DC33%1/3
$self->{'config'}{'hidden_servers'} && (!($querier->{'umode'} =~ /o/) || $uid ne $query)
$self->{'config'}{'hidden_servers'} not $querier->{"umode"} =~ /o/ $uid ne $query
Truth table50%2/4
A && not(B) or C
A= $self->{'config'}{'hidden_servers'}B= not $querier->{"umode"} =~ /o/C= $uid ne $query
ABCresult
0XX0
1000
11X1
1011
6311 push @$ref, {
6312 prefix => $sid,
6313 command => '312',
6314 params => [
6315 $uid,
6316 $record->{nick},
6317 ( $hidden ? $self->{config}{'hidden_servers'} : $record->{server} ),
6318 6 ▶ ( $hidden ? $self->server_config('NETWORKDESC') : $self->_state_peer_desc($record->{server}) ),
Branch: 2 branches
BranchTrueFalseTotal
$hidden ? : 2 4 6
$hidden ? : 2 4 6
6319 ],
6320 };
6321 # RPL_WHOISREGNICK
6322 push @$ref, {
6323 prefix => $sid,
6324 command => '307',
6325 params => [
6326 $uid,
6327 $record->{nick},
6328 'has identified for this nick'
6329 ],
6330 6 ▶ } if $record->{umode} =~ m!r!;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /r/ 0 6 6
6331 # RPL_WHOISACCOUNT
6332 push @$ref, {
6333 prefix => $sid,
6334 command => '330',
6335 params => [
6336 $uid,
6337 $record->{nick},
6338 $record->{account},
6339 'is logged in as'
6340 ],
6341 6 ▶ } if $record->{account} ne '*';
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"account"} ne "*" 4 2 6
6342 # RPL_AWAY
6343 push @$ref, {
6344 prefix => $sid,
6345 command => '301',
6346 params => [
6347 $uid,
6348 $record->{nick},
6349 $record->{away},
6350 ],
6351 6 ▶ } if $record->{type} eq 'c' && $record->{away};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"type"} eq "c" and $record->{"away"} 0 6 6
Condition66%2/3
$record->{"type"} eq "c" and $record->{"away"}
!ll&&!rl&&r
420
MC/DC0%0/2
$record->{"type"} eq "c" and $record->{"away"}
$record->{"type"} eq "c" $record->{"away"}
Truth table66%2/3
A and B
A= $record->{"type"} eq "c"B= $record->{"away"}
ABresult
0X0
100
111
6352 6 ▶ if ($record->{umode} !~ m!H! || $querier->{umode} =~ m!o!) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $record->{"umode"} =~ /H/ or $querier->{"umode"} =~ /o/) 6 0 6
Condition33%1/3
not $record->{"umode"} =~ /H/ or $querier->{"umode"} =~ /o/
l!l&&r!l&&!r
600
MC/DC0%0/2
not $record->{"umode"} =~ /H/ or $querier->{"umode"} =~ /o/
not $record->{"umode"} =~ /H/ $querier->{"umode"} =~ /o/
Truth table33%1/3
not(A) or B
A= not $record->{"umode"} =~ /H/B= $querier->{"umode"} =~ /o/
ABresult
1X1
011
000
6353 6 my $operstring;
6354 6 ▶ if ( $record->{svstags}{313} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{'svstags'}{'313'}) { } 1 5 6
6355 1 $operstring = $record->{svstags}{313}{tagline};
6356 }
6357 else {
6358 5 ▶ $operstring = 'is a Network Service' if $self->_state_sid_serv($record->{sid});
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_sid_serv($record->{"sid"}) 0 5 5
6359 5 ▶ $operstring = 'is a Server Administrator' if $record->{umode} =~ m!a! && !$operstring;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /a/ and not $operstring 3 2 5
Condition66%2/3
$record->{"umode"} =~ /a/ and not $operstring
!ll&&!rl&&r
203
MC/DC50%1/2
$record->{"umode"} =~ /a/ and not $operstring
$record->{"umode"} =~ /a/ not $operstring
Truth table66%2/3
A and not(B)
A= $record->{"umode"} =~ /a/B= not $operstring
ABresult
0X0
100
111
6360 5 ▶ $operstring = 'is an IRC Operator' if $record->{umode} =~ m!o! && !$operstring;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ and not $operstring 0 5 5
Condition66%2/3
$record->{"umode"} =~ /o/ and not $operstring
!ll&&!rl&&r
230
MC/DC0%0/2
$record->{"umode"} =~ /o/ and not $operstring
$record->{"umode"} =~ /o/ not $operstring
Truth table66%2/3
A and not(B)
A= $record->{"umode"} =~ /o/B= not $operstring
ABresult
0X0
100
111
6361 }
6362 push @$ref, {
6363 prefix => $sid,
6364 command => '313',
6365 6 ▶ params => [$uid, $record->{nick}, $operstring],
Branch: 1 branch
BranchTrueFalseTotal
if $operstring 4 2 6
6366 } if $operstring;
6367 }
6368 6 ▶ if ($record->{type} eq 'c' && ($uid eq $query || $querier->{umode} =~ m!o!) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"type"} eq "c" and $uid eq $query || $querier->{"umode"} =~ /o/) 2 4 6
Condition66%4/6
$record->{"type"} eq "c" and $uid eq $query || $querier->{"umode"} =~ /o/
!ll&&!rl&&r
402
$uid eq $query or $querier->{"umode"} =~ /o/
l!l&&r!l&&!r
110
MC/DC33%1/3
$record->{"type"} eq "c" and $uid eq $query || $querier->{"umode"} =~ /o/
$record->{"type"} eq "c" $uid eq $query $querier->{"umode"} =~ /o/
Truth table75%3/4
A and B or C
A= $record->{"type"} eq "c"B= $uid eq $queryC= $querier->{"umode"} =~ /o/
ABCresult
0XX0
1000
11X1
1011
6369 2 my $umodes = join '', '+', sort split //, $record->{umode};
6370 push @$ref, {
6371 prefix => $sid,
6372 command => '379',
6373 params => [
6374 $uid,
6375 $record->{nick},
6376 2 "is using modes $umodes"
6377 ],
6378 };
6379 }
6380 6 ▶ if ($record->{type} eq 'c'
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"type"} eq "c" and $self->server_config("whoisactually") || $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/) 1 5 6
Condition83%5/6
$record->{"type"} eq "c" and $self->server_config("whoisactually") || $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/
!ll&&!rl&&r
411
$self->server_config("whoisactually") or $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/
l!l&&r!l&&!r
011
MC/DC66%2/3
$record->{"type"} eq "c" and $self->server_config("whoisactually") || $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/
$record->{"type"} eq "c" $self->server_config("whoisactually") $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/
Truth table75%3/4
A and B or C
A= $record->{"type"} eq "c"B= $self->server_config("whoisactually")C= $self->{"state"}{"uids"}{$uid}{"umode"} =~ /o/
ABCresult
0XX0
1000
11X1
1011
6381 && ($self->server_config('whoisactually')
6382 or $self->{state}{uids}{$uid}{umode} =~ /o/)) {
6383 push @$ref, {
6384 prefix => $sid,
6385 command => '338',
6386 params => [
6387 $uid,
6388 $record->{nick},
6389 join('@', $record->{auth}{ident}, $record->{auth}{realhost}),
6390 1 ▶ ( $record->{ipaddress} || 'fake.hidden' ),
Condition50%1/2
$record->{'ipaddress'} || 'fake.hidden'
l!l
10
MC/DC0%0/1
$record->{'ipaddress'} || 'fake.hidden'
$record->{'ipaddress'}
Truth table50%1/2
A
A= $record->{'ipaddress'}
Aresult
11
00
6391 'Actual user@host, actual IP',
6392 ],
6393 };
6394 }
6395 6 ▶ if ($record->{type} eq 'c') {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"type"} eq "c") 2 4 6
6396 push @$ref, {
6397 prefix => $sid,
6398 command => '317',
6399 params => [
6400 $uid,
6401 $record->{nick},
6402 time - $record->{idle_time},
6403 $record->{conn_time},
6404 'seconds idle, signon time',
6405 ],
6406 2 ▶ } if $record->{umode} !~ m!q! || $querier->{umode} =~ m!o! || $uid eq $query;
Branch: 1 branch
BranchTrueFalseTotal
if not $record->{"umode"} =~ /q/ or $querier->{"umode"} =~ /o/ or $uid eq $query 2 0 2
Condition33%2/6
not $record->{"umode"} =~ /q/ or $querier->{"umode"} =~ /o/ or $uid eq $query
l!l&&r!l&&!r
200
not $record->{"umode"} =~ /q/ or $querier->{"umode"} =~ /o/
l!l&&r!l&&!r
200
MC/DC0%0/3
not $record->{"umode"} =~ /q/ or $querier->{"umode"} =~ /o/ or $uid eq $query
not $record->{"umode"} =~ /q/ $querier->{"umode"} =~ /o/ $uid eq $query
Truth table25%1/4
not(A) or B or C
A= not $record->{"umode"} =~ /q/B= $querier->{"umode"} =~ /o/C= $uid eq $query
ABCresult
1XX1
01X1
0011
0000
6407 }
6408 push @$ref, {
6409 prefix => $sid,
6410 command => '318',
6411 6 params => [$uid, $record->{nick}, 'End of /WHOIS list.'],
6412 };
6413  
6414 6 ▶ if ($record->{umode} =~ m!y! && $uid ne $query) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /y/ and $uid ne $query) 4 2 6
Condition66%2/3
$record->{"umode"} =~ /y/ and $uid ne $query
!ll&&!rl&&r
204
MC/DC50%1/2
$record->{"umode"} =~ /y/ and $uid ne $query
$record->{"umode"} =~ /y/ $uid ne $query
Truth table66%2/3
A and B
A= $record->{"umode"} =~ /y/B= $uid ne $query
ABresult
0X0
100
111
6415 # Send NOTICE
6416 4 my $local = ( $record->{sid} eq $sid );
6417 $self->send_output(
6418 {
6419 prefix => ( $local ? $self->server_name() : $sid ),
6420 command => 'NOTICE',
6421 params => [
6422 ( $local ? $record->{nick} : $record->{uid} ),
6423 sprintf('*** Notice -- %s (%s@%s) [%s] is doing a /whois on you',
6424 $querier->{nick}, $querier->{auth}{ident}, $querier->{auth}{hostname},
6425 $querier->{server},
6426 ),
6427 ],
6428 },
6429 $record->{route_id},
6430 4 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
$local ? : 0 4 4
$local ? : 0 4 4
6431 }
6432 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
6433 6 return $ref;
6434 }
6435  
6436 3 ▶sub _daemon_cmd_whowas {
Subroutine _daemon_cmd_whowas: called CC=12 SCAR=32.8
6437 3 my $self = shift;
6438 3 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6439 3 my $server = $self->server_name();
6440 3 my $sid = $self->server_sid();
6441 3 my $ref = [ ];
6442 3 my $args = [@_];
6443 3 my $count = @$args;
6444  
6445 SWITCH: {
6446 3 ▶ if (!$args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0]) 0 3 3
6447 0 push @$ref, ['431'];
6448 0 last SWITCH;
6449 }
6450 3 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 3 0 3
6451 3 my $lastuse = $self->{state}{lastuse}{whowas};
6452 3 my $pacewait = $self->{config}{pace_wait};
6453 3 ▶ if ( $lastuse && $pacewait && ( $lastuse + $pacewait ) > time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastuse and $pacewait and $lastuse + $pacewait > time) 0 3 3
Condition33%2/6
$lastuse and $pacewait and $lastuse + $pacewait > time
!ll&&!rl&&r
300
$lastuse and $pacewait
!ll&&!rl&&r
300
MC/DC0%0/3
$lastuse and $pacewait and $lastuse + $pacewait > time
$lastuse $pacewait $lastuse + $pacewait > time
Truth table25%1/4
A and B and C
A= $lastuseB= $pacewaitC= $lastuse + $pacewait > time
ABCresult
0XX0
10X0
1100
1111
6454 0 push @$ref, ['263', 'WHOWAS'];
6455 0 last SWITCH;
6456 }
6457 3 $self->{state}{lastuse}{whowas} = time();
6458 }
6459 3 my $query = (split /,/, $args->[0])[0];
6460 3 ▶ if ($args->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2]) 0 3 3
6461 0 my $targ = $self->_state_find_peer($args->[2]);
6462 0 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 0 0
6463 0 push @$ref, [ '402', $args->[2] ];
6464 0 last SWITCH;
6465 }
6466 0 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 0 0 0
6467 0 my $psid = substr $targ, 0, 3;
6468 0 $self->send_output(
6469 {
6470 prefix => $self->state_user_uid($nick),
6471 command => 'WHOWAS',
6472 params => [
6473 $args->[0], $args->[1], $targ,
6474 ],
6475 },
6476 $self->_state_sid_route($psid),
6477 );
6478 0 last SWITCH;
6479 }
6480 }
6481 3 my $uid = $self->state_user_uid($nick);
6482 3 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
6483 3 @{ $self->_daemon_do_whowas($uid,@$args) };
6484 }
6485  
6486 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
6487 0 return $ref;
6488 }
6489  
6490 2 ▶sub _daemon_peer_whowas {
Subroutine _daemon_peer_whowas: called CC=5 SCAR=16.4
6491 2 my $self = shift;
6492 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6493 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6494 2 my $server = $self->server_name();
6495 2 my $sid = $self->server_sid();
6496 2 my $ref = [ ];
6497 2 my ($first, $second, $third) = @_;
6498  
6499 2 my $targ = substr $third, 0, 3;
6500 SWITCH: {
6501 2 ▶ if ( $targ !~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 1 1 2
6502 1 $self->send_output(
6503 {
6504 prefix => $uid,
6505 command => 'WHOWAS',
6506 params => [
6507 $first,
6508 $second,
6509 $third,
6510 ],
6511 },
6512 $self->_state_sid_route($targ),
6513 );
6514 1 last SWITCH;
6515 }
6516 1 $ref = $self->_daemon_do_whowas($uid,$first,$second);
6517 }
6518  
6519 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
6520 0 return $ref;
6521 }
6522  
6523 4 ▶sub _daemon_do_whowas {
Subroutine _daemon_do_whowas: called CC=15 SCAR=27.6
6524 4 my $self = shift;
6525 4 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6526 4 my $server = $self->server_name();
6527 4 my $sid = $self->server_sid();
6528 4 my $ref = [ ];
6529 4 my $args = [@_];
6530 4 my $query = shift @$args;
6531  
6532 SWITCH: {
6533 4 my $is_oper = ( $self->{state}{uids}{$uid}{umode} =~ /o/ );
6534 4 my $max = shift @$args;
6535 4 ▶ if ( $uid !~ m!^$sid! && ( !$max || $max < 0 || $max > 20 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $uid =~ /^$sid/ and !$max || $max < 0 || $max > 20) 1 3 4
Condition44%4/9
not $uid =~ /^$sid/ and !$max || $max < 0 || $max > 20
!ll&&!rl&&r
301
not $max or $max < 0 or $max > 20
l!l&&r!l&&!r
010
not $max or $max < 0
l!l&&r!l&&!r
001
MC/DC25%1/4
not $uid =~ /^$sid/ and !$max || $max < 0 || $max > 20
not $uid =~ /^$sid/ not $max $max < 0 $max > 20
Truth table40%2/5
not(A) and not(B) or C or D
A= not $uid =~ /^$sid/B= not $maxC= $max < 0D= $max > 20
ABCDresult
0XXX0
10000
11XX1
101X1
10011
6536 1 $max = 20;
6537 }
6538 4 ▶ if (!$self->{state}{whowas}{uc_irc $query}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"state"}{"whowas"}{uc_irc($query)}) 1 3 4
6539 1 push @$ref, {
6540 prefix => $sid,
6541 command => '406',
6542 params => [$uid, $query, 'There was no such nickname'],
6543 };
6544 1 last SWITCH;
6545 }
6546 3 my $cnt = 0;
6547 3 WASNOTWAS: foreach my $was ( @{ $self->{state}{whowas}{uc_irc $query} } ) {
6548 push @$ref, {
6549 prefix => $sid,
6550 command => '314',
6551 params => [
6552 $uid,
6553 $was->{nick}, $was->{user}, $was->{host}, '*',
6554 $was->{ircname},
6555 26 ],
6556 };
6557 push @$ref, {
6558 prefix => $sid,
6559 command => '338',
6560 params => [
6561 $uid,
6562 $was->{nick},
6563 join('@', $was->{user}, $was->{real}),
6564 $was->{sock},
6565 26 ▶ 'Actual user@host, actual IP',
Branch: 1 branch
BranchTrueFalseTotal
if $is_oper 20 6 26
6566 ],
6567 } if $is_oper;
6568 push @$ref, {
6569 prefix => $sid,
6570 command => '330',
6571 params => [
6572 $uid,
6573 $was->{nick},
6574 $was->{account},
6575 'was logged in as',
6576 ],
6577 26 ▶ } if $was->{account} ne '*';
Branch: 1 branch
BranchTrueFalseTotal
if $was->{"account"} ne "*" 26 0 26
6578 push @$ref, {
6579 prefix => $sid,
6580 command => '312',
6581 params => [
6582 $uid,
6583 $was->{nick},
6584 ( ( $self->{config}{'hidden_servers'} && !$is_oper )
6585 ? ( $self->{config}{'hidden_servers'}, $self->{config}{NETWORKDESC} ) : $was->{server} ),
6586 26 ▶ strftime("%a %b %e %T %Y", localtime($was->{logoff})),
Branch: 1 branch
BranchTrueFalseTotal
$self->{'config'}{'hidden_servers'} && !$is_oper ? : 3 23 26
Condition66%2/3
$self->{"config"}{"hidden_servers"} and not $is_oper
!ll&&!rl&&r
2303
MC/DC50%1/2
$self->{"config"}{"hidden_servers"} and not $is_oper
$self->{"config"}{"hidden_servers"} not $is_oper
Truth table66%2/3
A and not(B)
A= $self->{"config"}{"hidden_servers"}B= not $is_oper
ABresult
0X0
100
111
6587 ],
6588 };
6589 26 ++$cnt;
6590 26 ▶ last WASNOTWAS if $max && $cnt >= $max;
Branch: 1 branch
BranchTrueFalseTotal
if $max and $cnt >= $max 1 25 26
Condition100%3/3
$max and $cnt >= $max
!ll&&!rl&&r
6191
MC/DC100%2/2
$max and $cnt >= $max
$max $cnt >= $max
Truth table100%3/3
A and B
A= $maxB= $cnt >= $max
ABresult
0X0
100
111
6591 }
6592 }
6593  
6594 4 push @$ref, {
6595 prefix => $sid,
6596 command => '369',
6597 params => [$uid, $query, 'End of WHOWAS'],
6598 };
6599  
6600 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
6601 4 return $ref;
6602 }
6603  
6604 6 ▶sub _daemon_cmd_who {
Subroutine _daemon_cmd_who: called CC=16 SCAR=33.8
6605 6 my $self = shift;
6606 6 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6607 6 my ($who, $op_only) = @_;
6608 6 my $server = $self->server_name();
6609 6 my $ref = [ ];
6610 6 my $orig = $who;
6611  
6612 SWITCH: {
6613 6 ▶ if (!$who) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($who) 0 6 6
6614 0 push @$ref, ['461', 'WHO'];
6615 0 last SWITCH;
6616 }
6617 6 ▶ if ($self->state_chan_exists($who)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_exists($who) and $self->state_is_chan_member($nick, $who)) 6 0 6
Condition33%1/3
$self->state_chan_exists($who) and $self->state_is_chan_member($nick, $who)
!ll&&!rl&&r
006
MC/DC0%0/2
$self->state_chan_exists($who) and $self->state_is_chan_member($nick, $who)
$self->state_chan_exists($who) $self->state_is_chan_member($nick, $who)
Truth table33%1/3
A and B
A= $self->state_chan_exists($who)B= $self->state_is_chan_member($nick, $who)
ABresult
0X0
100
111
6618 && $self->state_is_chan_member($nick, $who)) {
6619 6 my $uid = $self->state_user_uid($nick);
6620 6 my $multiprefix = $self->{state}{uids}{$uid}{caps}{'multi-prefix'};
6621 6 my $record = $self->{state}{chans}{uc_irc($who)};
6622 6 $who = $record->{name};
6623 6 for my $member (keys %{ $record->{users} }) {
6624 16 my $rpl_who = {
6625 prefix => $server,
6626 command => '352',
6627 params => [$nick, $who],
6628 };
6629 16 my $memrec = $self->{state}{uids}{$member};
6630 16 push @{ $rpl_who->{params} }, $memrec->{auth}{ident};
6631 16 push @{ $rpl_who->{params} }, $memrec->{auth}{hostname};
6632 16 push @{ $rpl_who->{params} }, $memrec->{server};
6633 16 push @{ $rpl_who->{params} }, $memrec->{nick};
6634 16 ▶ my $status = ($memrec->{away} ? 'G' : 'H');
Branch: 1 branch
BranchTrueFalseTotal
$memrec->{'away'} ? : 0 16 16
6635 16 ▶ $status .= '*' if $memrec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $memrec->{"umode"} =~ /o/ 0 16 16
6636 {
6637 16 my $stat = $record->{users}{$member};
6638 16 ▶ if ( $stat ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stat) 6 10 16
6639 6 ▶ if ( !$multiprefix ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $multiprefix) { } 2 4 6
6640 2 ▶ $stat =~ s![vh]!!g if $stat =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $stat =~ /o/ 2 0 2
6641 2 ▶ $stat =~ s![v]!!g if $stat =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $stat =~ /h/ 0 2 2
6642 }
6643 else {
6644 4 my $ostat = join '', grep { $stat =~ m!$_! } qw[o h v];
6645 4 $stat = $ostat;
6646 }
6647 6 $stat =~ tr/ohv/@%+/;
6648 6 $status .= $stat;
6649 }
6650 }
6651 16 push @{ $rpl_who->{params} }, $status;
6652 16 push @{ $rpl_who->{params} }, "$memrec->{hops} "
6653 16 . $memrec->{ircname};
6654 16 push @$ref, $rpl_who;
6655 }
6656 }
6657 6 ▶ if ($self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($who)) 0 6 6
6658 0 my $nickrec = $self->{state}{users}{uc_irc($who)};
6659 0 $who = $nickrec->{nick};
6660 0 my $rpl_who = {
6661 prefix => $server,
6662 command => '352',
6663 params => [$nick, '*'],
6664 };
6665 0 push @{ $rpl_who->{params} }, $nickrec->{auth}{ident};
6666 0 push @{ $rpl_who->{params} }, $nickrec->{auth}{hostname};
6667 0 push @{ $rpl_who->{params} }, $nickrec->{server};
6668 0 push @{ $rpl_who->{params} }, $nickrec->{nick};
6669 0 ▶ my $status = ($nickrec->{away} ? 'G' : 'H');
Branch: 1 branch
BranchTrueFalseTotal
$nickrec->{'away'} ? : 0 0 0
6670 0 ▶ $status .= '*' if $nickrec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $nickrec->{"umode"} =~ /o/ 0 0 0
6671 0 push @{ $rpl_who->{params} }, $status;
6672 0 push @{ $rpl_who->{params} }, "$nickrec->{hops} "
6673 0 . $nickrec->{ircname};
6674 0 push @$ref, $rpl_who;
6675 }
6676 6 push @$ref, {
6677 prefix => $server,
6678 command => '315',
6679 params => [$nick, $orig, 'End of WHO list'],
6680 };
6681 }
6682  
6683 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
6684 0 return $ref;
6685 }
6686  
6687 53 ▶sub _daemon_cmd_mode {
Subroutine _daemon_cmd_mode: called CC=103 SCAR=73.0
6688 53 my $self = shift;
6689 53 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6690 53 my $chan = shift;
6691 53 my $server = $self->server_name();
6692 53 my $sid = $self->server_sid();
6693 53 my $maxmodes = $self->server_config('MODES');
6694 53 my $ref = [ ];
6695 53 my $args = [@_];
6696 53 my $count = @$args;
6697  
6698 SWITCH: {
6699 53 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 53 53
6700 0 push @$ref, ['403', $chan];
6701 0 last SWITCH;
6702 }
6703  
6704 53 my $record = $self->{state}{chans}{uc_irc($chan)};
6705 53 $chan = $record->{name};
6706  
6707 53 ▶ if (!$count && !$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count or $self->state_is_chan_member($nick, $chan)) 0 53 53
Condition66%2/3
$count or $self->state_is_chan_member($nick, $chan)
l!l&&r!l&&!r
40130
MC/DC0%0/2
$count or $self->state_is_chan_member($nick, $chan)
$count $self->state_is_chan_member($nick, $chan)
Truth table66%2/3
A or B
A= $countB= $self->state_is_chan_member($nick, $chan)
ABresult
1X1
011
000
6708 push @$ref, {
6709 prefix => $server,
6710 command => '324',
6711 0 params => [$nick, $chan, '+' . $record->{mode}],
6712 colonify => 0,
6713 };
6714 push @$ref, {
6715 prefix => $server,
6716 command => '329',
6717 0 params => [$nick, $chan, $record->{ts}],
6718 colonify => 0,
6719 };
6720 0 last SWITCH;
6721 }
6722 53 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 13 40 53
6723 push @$ref, {
6724 prefix => $server,
6725 command => '324',
6726 params => [
6727 $nick,
6728 $chan,
6729 '+' . $record->{mode},
6730 ($record->{ckey} || ()),
6731 13 ▶ ($record->{climit} || ()),
Condition33%2/6
$record->{'ckey'} || ()
l!l&&r!l&&!r
0130
$record->{'climit'} || ()
l!l&&r!l&&!r
0130
MC/DC0%0/2
$record->{'ckey'} || ()
$record->{'ckey'} ()
MC/DC0%0/2
$record->{'climit'} || ()
$record->{'climit'} ()
Truth table33%1/3
A || B
A= $record->{'ckey'}B= ()
ABresult
1X1
011
000
Truth table33%1/3
A || B
A= $record->{'climit'}B= ()
ABresult
1X1
011
000
6732 ],
6733 colonify => 0,
6734 };
6735 push @$ref, {
6736 prefix => $server,
6737 command => '329',
6738 13 params => [$nick, $chan, $record->{ts}],
6739 colonify => 0,
6740 };
6741 13 last SWITCH;
6742 }
6743  
6744 40 my $unknown = 0;
6745 40 my $notop = 0;
6746 40 my $notoper = 0;
6747 40 my $nick_is_op = $self->state_is_chan_op($nick, $chan);
6748 40 my $nick_is_hop = $self->state_is_chan_hop($nick, $chan);
6749 40 my $nick_is_oper = $self->state_user_is_operator($nick);
6750 40 ▶ my $no_see_bans = ( $record->{mode} =~ /u/ && !( $nick_is_op || $nick_is_hop ) );
Condition83%5/6
$record->{'mode'} =~ /u/ && !($nick_is_op || $nick_is_hop)
!ll&&!rl&&r
3622
$nick_is_op || $nick_is_hop
l!l&&r!l&&!r
202
MC/DC66%2/3
$record->{'mode'} =~ /u/ && !($nick_is_op || $nick_is_hop)
$record->{'mode'} =~ /u/ $nick_is_op $nick_is_hop
Truth table75%3/4
A && not(B || C)
A= $record->{'mode'} =~ /u/B= $nick_is_opC= $nick_is_hop
ABCresult
0XX0
11X0
1010
1001
6751 40 my $mode_u_set = ( $record->{mode} =~ /u/ );
6752 40 my $reply;
6753 40 my @reply_args; my %subs;
6754 40 my $parsed_mode = parse_mode_line(@$args);
6755 40 my $mode_count = 0;
6756  
6757 40 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 59 40 99
6758 59 ▶ if ($mode !~ /[CceIbkMNRSTLOlimnpstohuv]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mode =~ /[CceIbkMNRSTLOlimnpstohuv]/) 0 59 59
6759 0 ▶ push @$ref, [
Branch: 1 branch
BranchTrueFalseTotal
unless $unknown 0 0 0
6760 '472',
6761 (split //, $mode)[1],
6762 $chan,
6763 ] if !$unknown;
6764 0 $unknown++;
6765 0 next;
6766 }
6767  
6768 59 my $arg;
6769 59 ▶ if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) 45 14 59
6770 45 $arg = shift @{ $parsed_mode->{args} };
6771 }
6772 59 ▶ if ($mode =~ /[-+]b/ && !defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[-+]b/ and not defined $arg) 2 57 59
Condition100%3/3
$mode =~ /[-+]b/ and not defined $arg
!ll&&!rl&&r
5612
MC/DC100%2/2
$mode =~ /[-+]b/ and not defined $arg
$mode =~ /[-+]b/ not defined $arg
Truth table100%3/3
A and not(B)
A= $mode =~ /[-+]b/B= not defined $arg
ABresult
0X0
100
111
6773 push @$ref, {
6774 prefix => $server,
6775 command => '367',
6776 params => [
6777 $nick,
6778 $chan,
6779 0 @{ $record->{bans}{$_} },
6780 ]
6781 2 } for grep { !$no_see_bans } keys %{ $record->{bans} };
6782 2 push @$ref, {
6783 prefix => $server,
6784 command => '368',
6785 params => [$nick, $chan, 'End of Channel Ban List'],
6786 };
6787 2 next;
6788 }
6789 57 ▶ if ($mode =~ m![OL]! && !$nick_is_oper) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[OL]/ and not $nick_is_oper) 1 56 57
Condition100%3/3
$mode =~ /[OL]/ and not $nick_is_oper
!ll&&!rl&&r
5511
MC/DC100%2/2
$mode =~ /[OL]/ and not $nick_is_oper
$mode =~ /[OL]/ not $nick_is_oper
Truth table100%3/3
A and not(B)
A= $mode =~ /[OL]/B= not $nick_is_oper
ABresult
0X0
100
111
6790 1 ▶ push @$ref, ['481'] if !$notoper;
Branch: 1 branch
BranchTrueFalseTotal
unless $notoper 1 0 1
6791 1 $notoper++;
6792 1 next;
6793 }
6794 56 ▶ if (!$nick_is_op && !$nick_is_hop && $mode !~ m![OL]!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nick_is_op or $nick_is_hop or $mode =~ /[OL]/) 0 56 56
Condition33%2/6
$nick_is_op or $nick_is_hop or $mode =~ /[OL]/
l!l&&r!l&&!r
5600
$nick_is_op or $nick_is_hop
l!l&&r!l&&!r
5600
MC/DC0%0/3
$nick_is_op or $nick_is_hop or $mode =~ /[OL]/
$nick_is_op $nick_is_hop $mode =~ /[OL]/
Truth table25%1/4
A or B or C
A= $nick_is_opB= $nick_is_hopC= $mode =~ /[OL]/
ABCresult
1XX1
01X1
0011
0000
6795 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
6796 0 $notop++;
6797 0 next;
6798 }
6799 56 ▶ if ($mode =~ /[-+]I/ && !defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[-+]I/ and not defined $arg) 0 56 56
Condition33%1/3
$mode =~ /[-+]I/ and not defined $arg
!ll&&!rl&&r
5600
MC/DC0%0/2
$mode =~ /[-+]I/ and not defined $arg
$mode =~ /[-+]I/ not defined $arg
Truth table33%1/3
A and not(B)
A= $mode =~ /[-+]I/B= not defined $arg
ABresult
0X0
100
111
6800 push @$ref, {
6801 prefix => $server,
6802 command => '346',
6803 params => [
6804 $nick,
6805 $chan,
6806 0 @{ $record->{invex}{$_} },
6807 ],
6808 0 } for grep { !$no_see_bans } keys %{ $record->{invex} };
6809 0 push @$ref, {
6810 prefix => $server,
6811 command => '347',
6812 params => [$nick, $chan, 'End of Channel Invite List']
6813 };
6814 0 next;
6815 }
6816 56 ▶ if ($mode =~ /[-+]e/ && !defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[-+]e/ and not defined $arg) 0 56 56
Condition33%1/3
$mode =~ /[-+]e/ and not defined $arg
!ll&&!rl&&r
5600
MC/DC0%0/2
$mode =~ /[-+]e/ and not defined $arg
$mode =~ /[-+]e/ not defined $arg
Truth table33%1/3
A and not(B)
A= $mode =~ /[-+]e/B= not defined $arg
ABresult
0X0
100
111
6817 push @$ref, {
6818 prefix => $server,
6819 command => '348',
6820 0 params => [$nick, $chan, @{ $record->{excepts}{$_} } ]
6821 0 } for grep { !$no_see_bans } keys %{ $record->{excepts} };
6822 0 push @$ref, {
6823 prefix => $server,
6824 command => '349',
6825 params => [
6826 $nick,
6827 $chan,
6828 'End of Channel Exception List',
6829 ],
6830 };
6831 0 next;
6832 }
6833 56 ▶ if (!$nick_is_op && $nick_is_hop && $mode =~ /[op]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $nick_is_op and $nick_is_hop and $mode =~ /[op]/) 0 56 56
Condition33%2/6
not $nick_is_op and $nick_is_hop and $mode =~ /[op]/
!ll&&!rl&&r
5600
not $nick_is_op and $nick_is_hop
!ll&&!rl&&r
5600
MC/DC0%0/3
not $nick_is_op and $nick_is_hop and $mode =~ /[op]/
not $nick_is_op $nick_is_hop $mode =~ /[op]/
Truth table25%1/4
not(A) and B and C
A= not $nick_is_opB= $nick_is_hopC= $mode =~ /[op]/
ABCresult
0XX0
10X0
1100
1111
6834 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
6835 0 $notop++;
6836 0 next;
6837 }
6838 56 ▶ if (!$nick_is_op && $nick_is_hop && $record->{mode} =~ /p/
Branch: 1 branch
BranchTrueFalseTotal
if (not $nick_is_op and $nick_is_hop and $record->{"mode"} =~ /p/ and $mode =~ /h/) 0 56 56
Condition33%3/9
not $nick_is_op and $nick_is_hop and $record->{"mode"} =~ /p/ and $mode =~ /h/
!ll&&!rl&&r
5600
not $nick_is_op and $nick_is_hop and $record->{"mode"} =~ /p/
!ll&&!rl&&r
5600
not $nick_is_op and $nick_is_hop
!ll&&!rl&&r
5600
MC/DC0%0/4
not $nick_is_op and $nick_is_hop and $record->{"mode"} =~ /p/ and $mode =~ /h/
not $nick_is_op $nick_is_hop $record->{"mode"} =~ /p/ $mode =~ /h/
Truth table20%1/5
not(A) and B and C and D
A= not $nick_is_opB= $nick_is_hopC= $record->{"mode"} =~ /p/D= $mode =~ /h/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
6839 && $mode =~ /h/) {
6840 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
6841 0 $notop++;
6842 0 next;
6843 }
6844 56 ▶ if (($mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/)
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/ and not defined $arg) 0 56 56
Condition66%4/6
$mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/ and not defined $arg
!ll&&!rl&&r
14420
$mode =~ /^[-+][ohv]/ or $mode =~ /^\+[lk]/
l!l&&r!l&&!r
42014
MC/DC0%0/3
$mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/ and not defined $arg
$mode =~ /^[-+][ohv]/ $mode =~ /^\+[lk]/ not defined $arg
Truth table40%2/5
A or B and not(C)
A= $mode =~ /^[-+][ohv]/B= $mode =~ /^\+[lk]/C= not defined $arg
ABCresult
00X0
1X00
0100
1X11
0111
6845 && !defined $arg) {
6846 0 next;
6847 }
6848 56 ▶ if ($mode =~ /^[-+][ohv]/ && !$self->state_nick_exists($arg)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^[-+][ohv]/ and not $self->state_nick_exists($arg)) 0 56 56
Condition66%2/3
$mode =~ /^[-+][ohv]/ and not $self->state_nick_exists($arg)
!ll&&!rl&&r
14420
MC/DC0%0/2
$mode =~ /^[-+][ohv]/ and not $self->state_nick_exists($arg)
$mode =~ /^[-+][ohv]/ not $self->state_nick_exists($arg)
Truth table66%2/3
A and not(B)
A= $mode =~ /^[-+][ohv]/B= not $self->state_nick_exists($arg)
ABresult
0X0
100
111
6849 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6850 0 push @$ref, ['401', $arg];
6851 0 next;
6852 }
6853 56 ▶ if ($mode =~ /^[-+][ohv]/
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^[-+][ohv]/ and not $self->state_is_chan_member($arg, $chan)) 0 56 56
Condition66%2/3
$mode =~ /^[-+][ohv]/ and not $self->state_is_chan_member($arg, $chan)
!ll&&!rl&&r
14420
MC/DC0%0/2
$mode =~ /^[-+][ohv]/ and not $self->state_is_chan_member($arg, $chan)
$mode =~ /^[-+][ohv]/ not $self->state_is_chan_member($arg, $chan)
Truth table66%2/3
A and not(B)
A= $mode =~ /^[-+][ohv]/B= not $self->state_is_chan_member($arg, $chan)
ABresult
0X0
100
111
6854 && !$self->state_is_chan_member($arg, $chan)) {
6855 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6856 0 push @$ref, ['441', $chan, $self->state_user_nick($arg)];
6857 0 next;
6858 }
6859 56 ▶ if (my ($flag, $char) = $mode =~ /^([-+])([ohv])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^([-+])([ohv])/) 42 14 56
6860 42 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 42 42
6861  
6862 42 ▶ if ($flag eq '+'
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/) 30 12 42
Condition66%2/3
$flag eq "+" and not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
!ll&&!rl&&r
01230
MC/DC50%1/2
$flag eq "+" and not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
$flag eq "+" not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
Truth table66%2/3
A and not(B)
A= $flag eq "+"B= not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
ABresult
0X0
100
111
6863 && $record->{users}{$self->state_user_uid($arg)} !~ /$char/) {
6864 # Update user and chan record
6865 30 $arg = $self->state_user_uid($arg);
6866 $record->{users}{$arg} = join('', sort
6867 30 split //, $record->{users}{$arg} . $char);
6868 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
6869 30 = $record->{users}{$arg};
6870 30 $reply .= $mode;
6871 30 my $anick = $self->state_user_nick($arg);
6872 30 $subs{$anick} = $arg;
6873 30 push @reply_args, $anick;
6874 }
6875  
6876 42 ▶ if ($flag eq '-' && $record->{users}{uc_irc($arg)}
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/) 0 42 42
Condition33%1/3
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
!ll&&!rl&&r
4200
MC/DC0%0/2
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
$flag eq "-" $record->{"users"}{uc_irc($arg)} =~ /$char/
Truth table33%1/3
A and B
A= $flag eq "-"B= $record->{"users"}{uc_irc($arg)} =~ /$char/
ABresult
0X0
100
111
6877 =~ /$char/) {
6878 # Update user and chan record
6879 0 $arg = $self->state_user_uid($arg);
6880 0 $record->{users}{$arg} =~ s/$char//g;
6881 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
6882 0 = $record->{users}{$arg};
6883 0 $reply .= $mode;
6884 0 my $anick = $self->state_user_nick($arg);
6885 0 $subs{$anick} = $arg;
6886 0 push @reply_args, $anick;
6887 }
6888 42 next;
6889 }
6890 14 ▶ if ($mode eq '+l' && $arg =~ /^\d+$/ && $arg > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0) 0 14 14
Condition33%2/6
$mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0
!ll&&!rl&&r
1400
$mode eq "+l" and $arg =~ /^\d+$/
!ll&&!rl&&r
1400
MC/DC0%0/3
$mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0
$mode eq "+l" $arg =~ /^\d+$/ $arg > 0
Truth table25%1/4
A and B and C
A= $mode eq "+l"B= $arg =~ /^\d+$/C= $arg > 0
ABCresult
0XX0
10X0
1100
1111
6891 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6892 0 $reply .= $mode;
6893 0 push @reply_args, $arg;
6894 0 ▶ if ($record->{mode} !~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /l/) 0 0 0
6895 $record->{mode} = join('', sort
6896 0 split //, $record->{mode} . 'l');
6897 }
6898 0 $record->{climit} = $arg;
6899 0 next;
6900 }
6901 14 ▶ if ($mode eq '-l' && $record->{mode} =~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "-l" and $record->{"mode"} =~ /l/) 0 14 14
Condition33%1/3
$mode eq "-l" and $record->{"mode"} =~ /l/
!ll&&!rl&&r
1400
MC/DC0%0/2
$mode eq "-l" and $record->{"mode"} =~ /l/
$mode eq "-l" $record->{"mode"} =~ /l/
Truth table33%1/3
A and B
A= $mode eq "-l"B= $record->{"mode"} =~ /l/
ABresult
0X0
100
111
6902 0 $record->{mode} =~ s/l//g;
6903 0 delete $record->{climit};
6904 0 $reply .= $mode;
6905 0 next;
6906 }
6907 14 ▶ if ($mode eq '+k' && $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+k" and $arg) 0 14 14
Condition33%1/3
$mode eq "+k" and $arg
!ll&&!rl&&r
1400
MC/DC0%0/2
$mode eq "+k" and $arg
$mode eq "+k" $arg
Truth table33%1/3
A and B
A= $mode eq "+k"B= $arg
ABresult
0X0
100
111
6908 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6909 0 $reply .= $mode;
6910 0 push @reply_args, $arg;
6911 0 ▶ if ($record->{mode} !~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /k/) 0 0 0
6912 $record->{mode} = join('', sort
6913 0 split //, $record->{mode} . 'k');
6914 }
6915 0 $record->{ckey} = $arg;
6916 0 next;
6917 }
6918 14 ▶ if ($mode eq '-k' && $record->{mode} =~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "-k" and $record->{"mode"} =~ /k/) 0 14 14
Condition33%1/3
$mode eq "-k" and $record->{"mode"} =~ /k/
!ll&&!rl&&r
1400
MC/DC0%0/2
$mode eq "-k" and $record->{"mode"} =~ /k/
$mode eq "-k" $record->{"mode"} =~ /k/
Truth table33%1/3
A and B
A= $mode eq "-k"B= $record->{"mode"} =~ /k/
ABresult
0X0
100
111
6919 0 $reply .= $mode;
6920 0 push @reply_args, '*';
6921 0 $record->{mode} =~ s/k//g;
6922 0 delete $record->{ckey};
6923 0 next;
6924 }
6925 # Bans
6926 14 ▶ my $maxbans = ( $record->{mode} =~ m!L! ? $self->{config}{max_bans_large} : $self->{config}{MAXBANS} );
Branch: 1 branch
BranchTrueFalseTotal
$record->{'mode'} =~ /L/ ? : 0 14 14
6927 14 ▶ if (my ($flag) = $mode =~ /([-+])b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])b/) 1 13 14
6928 1 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 1 1
6929 1 my $mask = normalize_mask($arg);
6930 1 my $umask = uc_irc $mask;
6931 1 ▶ if ($flag eq '+' && !$record->{bans}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"bans"}{$umask}) 1 0 1
Condition33%1/3
$flag eq "+" and not $record->{"bans"}{$umask}
!ll&&!rl&&r
001
MC/DC0%0/2
$flag eq "+" and not $record->{"bans"}{$umask}
$flag eq "+" not $record->{"bans"}{$umask}
Truth table33%1/3
A and not(B)
A= $flag eq "+"B= not $record->{"bans"}{$umask}
ABresult
0X0
100
111
6932 1 ▶ if ( keys %{ $record->{bans} } >= $maxbans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$record{"bans"};} >= $maxbans) 0 1 1
6933 0 push @$ref, [ '478', $record->{name}, 'b' ];
6934 0 next;
6935 }
6936 1 $record->{bans}{$umask}
6937 = [$mask, $self->state_user_full($nick), time];
6938 1 $reply .= $mode;
6939 1 push @reply_args, $mask;
6940 }
6941 1 ▶ if ($flag eq '-' && $record->{bans}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"bans"}{$umask}) 0 1 1
Condition33%1/3
$flag eq "-" and $record->{"bans"}{$umask}
!ll&&!rl&&r
100
MC/DC0%0/2
$flag eq "-" and $record->{"bans"}{$umask}
$flag eq "-" $record->{"bans"}{$umask}
Truth table33%1/3
A and B
A= $flag eq "-"B= $record->{"bans"}{$umask}
ABresult
0X0
100
111
6942 0 delete $record->{bans}{$umask};
6943 0 $reply .= $mode;
6944 0 push @reply_args, $mask;
6945 }
6946 1 next;
6947 }
6948 # Invex
6949 13 ▶ if (my ($flag) = $mode =~ /([-+])I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])I/) 0 13 13
6950 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6951 0 my $mask = normalize_mask( $arg );
6952 0 my $umask = uc_irc $mask;
6953  
6954 0 ▶ if ($flag eq '+' && !$record->{invex}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"invex"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"invex"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"invex"}{$umask}
$flag eq "+" not $record->{"invex"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"invex"}{$umask}
ABresult
0X0
100
111
6955 0 ▶ if ( keys %{ $record->{invex} } >= $maxbans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$record{"invex"};} >= $maxbans) 0 0 0
6956 0 push @$ref, [ '478', $record->{name}, 'I' ];
6957 0 next;
6958 }
6959 0 $record->{invex}{$umask}
6960 = [$mask, $self->state_user_full($nick), time];
6961 0 $reply .= $mode;
6962 0 push @reply_args, $mask;
6963 }
6964 0 ▶ if ($flag eq '-' && $record->{invex}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"invex"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"invex"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"invex"}{$umask}
$flag eq "-" $record->{"invex"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"invex"}{$umask}
ABresult
0X0
100
111
6965 0 delete $record->{invex}{$umask};
6966 0 $reply .= $mode;
6967 0 push @reply_args, $mask;
6968 }
6969 0 next;
6970 }
6971 # Exceptions
6972 13 ▶ if (my ($flag) = $mode =~ /([-+])e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])e/) 0 13 13
6973 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6974 0 my $mask = normalize_mask($arg);
6975 0 my $umask = uc_irc($mask);
6976  
6977 0 ▶ if ($flag eq '+' && !$record->{excepts}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"excepts"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"excepts"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"excepts"}{$umask}
$flag eq "+" not $record->{"excepts"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"excepts"}{$umask}
ABresult
0X0
100
111
6978 0 ▶ if ( keys %{ $record->{excepts} } >= $maxbans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$record{"excepts"};} >= $maxbans) 0 0 0
6979 0 push @$ref, [ '478', $record->{name}, 'e' ];
6980 0 next;
6981 }
6982 0 $record->{excepts}{$umask}
6983 = [$mask, $self->state_user_full($nick), time];
6984 0 $reply .= $mode;
6985 0 push @reply_args, $mask;
6986 }
6987 0 ▶ if ($flag eq '-' && $record->{excepts}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"excepts"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"excepts"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"excepts"}{$umask}
$flag eq "-" $record->{"excepts"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"excepts"}{$umask}
ABresult
0X0
100
111
6988 0 delete $record->{excepts}{$umask};
6989 0 $reply .= $mode;
6990 0 push @reply_args, $mask;
6991 }
6992 0 next;
6993 }
6994 # The rest should be argumentless.
6995 13 my ($flag, $char) = split //, $mode;
6996 13 ▶ if ($flag eq '+' && $record->{mode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"mode"} =~ /$char/) 10 3 13
Condition66%2/3
$flag eq "+" and not $record->{"mode"} =~ /$char/
!ll&&!rl&&r
3010
MC/DC50%1/2
$flag eq "+" and not $record->{"mode"} =~ /$char/
$flag eq "+" not $record->{"mode"} =~ /$char/
Truth table66%2/3
A and not(B)
A= $flag eq "+"B= not $record->{"mode"} =~ /$char/
ABresult
0X0
100
111
6997 10 $reply .= $mode;
6998 $record->{mode} = join('', sort
6999 10 split //, $record->{mode} . $char);
7000 10 next;
7001 }
7002 3 ▶ if ($flag eq '-' && $record->{mode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"mode"} =~ /$char/) 3 0 3
Condition33%1/3
$flag eq "-" and $record->{"mode"} =~ /$char/
!ll&&!rl&&r
003
MC/DC0%0/2
$flag eq "-" and $record->{"mode"} =~ /$char/
$flag eq "-" $record->{"mode"} =~ /$char/
Truth table33%1/3
A and B
A= $flag eq "-"B= $record->{"mode"} =~ /$char/
ABresult
0X0
100
111
7003 3 $reply .= $mode;
7004 3 $record->{mode} =~ s/$char//g;
7005 3 next;
7006 }
7007 } # while
7008  
7009 40 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 31 9 40
7010 31 $reply = unparse_mode_line($reply);
7011 my @reply_args_peer = map {
7012 31 ▶ ( defined $subs{$_} ? $subs{$_} : $_ )
Branch: 1 branch
BranchTrueFalseTotal
defined $subs{$_} ? : 30 1 31
7013 } @reply_args;
7014 $self->send_output(
7015 {
7016 prefix => $self->state_user_uid($nick),
7017 command => 'TMODE',
7018 31 params => [$record->{ts}, $chan, $reply, @reply_args_peer],
7019 colonify => 0,
7020 },
7021 $self->_state_connected_peers(),
7022 );
7023 31 my $full = $self->state_user_full($nick);
7024 $self->_send_output_channel_local(
7025 $record->{name},
7026 {
7027 prefix => $full,
7028 command => 'MODE',
7029 colonify => 0,
7030 params => [
7031 $record->{name},
7032 31 ▶ $reply,
Branch: 1 branch
BranchTrueFalseTotal
$mode_u_set ? : 2 29 31
7033 @reply_args,
7034 ],
7035 },
7036 '', ( $mode_u_set ? 'oh' : '' ),
7037 );
7038 31 ▶ if ($mode_u_set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode_u_set) 2 29 31
7039 2 my $bparse = parse_mode_line( $reply, @reply_args );
7040 2 my $breply; my @breply_args;
7041 2 ▶ while (my $bmode = shift (@{ $bparse->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bmode = shift @{$$bparse{"modes"};}) 2 2 4
7042 2 my $arg;
7043 2 ▶ $arg = shift @{ $bparse->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 1 1 2
7044 if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
7045 2 ▶ next if $bmode =~ m!^[+-][beI]$!;
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^[+-][beI]$/ 1 1 2
7046 1 $breply .= $bmode;
7047 1 ▶ push @breply_args, $arg if $arg;
Branch: 1 branch
BranchTrueFalseTotal
if $arg 0 1 1
7048 }
7049 2 ▶ if ($breply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breply) 1 1 2
7050 1 my $parsed_line = unparse_mode_line($breply);
7051 $self->_send_output_channel_local(
7052 $record->{name},
7053 {
7054 prefix => $full,
7055 command => 'MODE',
7056 colonify => 0,
7057 params => [
7058 $record->{name},
7059 1 $parsed_line,
7060 @breply_args,
7061 ],
7062 },
7063 '','-oh',
7064 );
7065 }
7066 }
7067 }
7068 } # SWITCH
7069  
7070 53 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 53 0 53
7071 0 return $ref;
7072 }
7073  
7074 114 ▶sub _daemon_cmd_join {
Subroutine _daemon_cmd_join: called CC=50 SCAR=50.6
7075 114 my $self = shift;
7076 114 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
1140
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7077 114 my $server = $self->server_name();
7078 114 my $sid = $self->server_sid();
7079 114 my $ref = [ ];
7080 114 my $args = [@_];
7081 114 my $count = @$args;
7082 114 my $route_id = $self->_state_user_route($nick);
7083 114 my $uid = $self->state_user_uid($nick);
7084 114 my $unick = uc_irc($nick);
7085  
7086 SWITCH: {
7087 114 my (@channels, @chankeys);
7088 114 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 114 114
7089 0 push @$ref, ['461', 'JOIN'];
7090 0 last SWITCH;
7091 }
7092  
7093 114 @channels = split /,/, $args->[0];
7094 114 ▶ @chankeys = split /,/, $args->[1] if $args->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[1] 0 114 114
7095 114 my $channel_length = $self->server_config('CHANNELLEN');
7096 114 my $nick_is_oper = $self->state_user_is_operator($nick);
7097  
7098 114 LOOP: for my $channel (@channels) {
7099 114 my $uchannel = uc_irc($channel);
7100 114 ▶ if ($channel eq '0'
Branch: 1 branch
BranchTrueFalseTotal
if ($channel eq 0 and my(@chans) = $self->state_user_chans($nick)) 0 114 114
Condition33%1/3
$channel eq 0 and my(@chans) = $self->state_user_chans($nick)
!ll&&!rl&&r
11400
MC/DC0%0/2
$channel eq 0 and my(@chans) = $self->state_user_chans($nick)
$channel eq 0 my(@chans) = $self->state_user_chans($nick)
Truth table33%1/3
A and B
A= $channel eq 0B= my(@chans) = $self->state_user_chans($nick)
ABresult
0X0
100
111
7101 and my @chans = $self->state_user_chans($nick)) {
7102 $self->_send_output_to_client(
7103 $route_id,
7104 (ref $_ eq 'ARRAY' ? @$_ : $_),
7105 0 ▶ ) for map { $self->_daemon_cmd_part($nick, $_) } @chans;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
7106 0 next LOOP;
7107 }
7108 # Channel isn't valid
7109 114 ▶ if (!is_valid_chan_name($channel)
Branch: 1 branch
BranchTrueFalseTotal
if (not is_valid_chan_name($channel) or length $channel > $channel_length) 0 114 114
Condition33%1/3
not is_valid_chan_name($channel) or length $channel > $channel_length
l!l&&r!l&&!r
00114
MC/DC0%0/2
not is_valid_chan_name($channel) or length $channel > $channel_length
not is_valid_chan_name($channel) length $channel > $channel_length
Truth table33%1/3
not(A) or B
A= not is_valid_chan_name($channel)B= length $channel > $channel_length
ABresult
1X1
011
000
7110 || length $channel > $channel_length) {
7111 0 $self->_send_output_to_client(
7112 $route_id,
7113 '403',
7114 $channel,
7115 );
7116 0 next LOOP;
7117 }
7118 # Too many channels
7119 114 ▶ if ($self->state_user_chans($nick)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") and not $nick_is_oper) 0 114 114
Condition33%1/3
$self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") and not $nick_is_oper
!ll&&!rl&&r
11400
MC/DC0%0/2
$self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") and not $nick_is_oper
$self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") not $nick_is_oper
Truth table33%1/3
A and not(B)
A= $self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS")B= not $nick_is_oper
ABresult
0X0
100
111
7120 >= $self->server_config('MAXCHANNELS')
7121 && !$nick_is_oper) {
7122 0 $self->_send_output_to_client(
7123 $route_id,
7124 '405',
7125 $channel,
7126 );
7127 0 next LOOP;
7128 }
7129 # Channel is RESV
7130 114 ▶ if (my $reason = $self->_state_is_resv($channel,$route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $reason = $self->_state_is_resv($channel, $route_id)) 1 113 114
7131 1 ▶ if ( !$nick_is_oper ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nick_is_oper) 1 0 1
7132 1 $self->_send_to_realops(
7133 sprintf(
7134 'Forbidding reserved channel %s from user %s',
7135 $channel,
7136 $self->state_user_full($nick),
7137 ),
7138 'Notice',
7139 'j',
7140 );
7141 1 $self->_send_output_to_client(
7142 $route_id,
7143 '485',
7144 $channel,
7145 $reason,
7146 );
7147 1 next LOOP;
7148 }
7149 }
7150 # Channel doesn't exist
7151 113 ▶ if (!$self->state_chan_exists($channel)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($channel)) 55 58 113
7152 55 my $record = {
7153 name => $channel,
7154 ts => time,
7155 mode => 'nt',
7156 users => { $uid => 'o' },
7157 };
7158 55 $self->{state}{chans}{$uchannel} = $record;
7159 55 $self->{state}{users}{$unick}{chans}{$uchannel} = 'o';
7160 55 my @peers = $self->_state_connected_peers();
7161 $self->send_output(
7162 {
7163 prefix => $sid,
7164 command => 'SJOIN',
7165 params => [
7166 $record->{ts},
7167 $channel,
7168 '+' . $record->{mode},
7169 55 ▶ '@' . $uid,
Branch: 1 branch
BranchTrueFalseTotal
unless $channel =~ /^&/ 55 0 55
7170 ],
7171 },
7172 @peers,
7173 ) if $channel !~ /^&/;
7174 55 my $output = {
7175 prefix => $self->state_user_full($nick),
7176 command => 'JOIN',
7177 params => [$channel],
7178 };
7179 55 $self->send_output($output, $route_id);
7180 $self->send_event(
7181 "daemon_join",
7182 $output->{prefix},
7183 55 $channel,
7184 );
7185 $self->send_output(
7186 {
7187 prefix => $server,
7188 command => 'MODE',
7189 55 params => [$channel, '+' . $record->{mode}],
7190 },
7191 $route_id,
7192 );
7193 $self->_send_output_to_client(
7194 $route_id,
7195 (ref $_ eq 'ARRAY' ? @$_ : $_),
7196 55 ▶ ) for $self->_daemon_cmd_names($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 110 110
7197 55 next LOOP;
7198 }
7199 # Numpty user is already on channel
7200 58 ▶ if ($self->state_is_chan_member($nick, $channel)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($nick, $channel)) 0 58 58
7201 0 next LOOP;
7202 }
7203 58 my $chanrec = $self->{state}{chans}{$uchannel};
7204 58 my $bypass;
7205 58 ▶ if ($nick_is_oper && $self->{config}{OPHACKS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick_is_oper and $self->{"config"}{"OPHACKS"}) 0 58 58
Condition66%2/3
$nick_is_oper and $self->{"config"}{"OPHACKS"}
!ll&&!rl&&r
5620
MC/DC0%0/2
$nick_is_oper and $self->{"config"}{"OPHACKS"}
$nick_is_oper $self->{"config"}{"OPHACKS"}
Truth table66%2/3
A and B
A= $nick_is_operB= $self->{"config"}{"OPHACKS"}
ABresult
0X0
100
111
7206 0 $bypass = 1;
7207 }
7208 # OPER only channel +O
7209 58 ▶ if ($chanrec->{mode} =~ /O/ && !$nick_is_oper) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} =~ /O/ and not $nick_is_oper) 0 58 58
Condition33%1/3
$chanrec->{"mode"} =~ /O/ and not $nick_is_oper
!ll&&!rl&&r
5800
MC/DC0%0/2
$chanrec->{"mode"} =~ /O/ and not $nick_is_oper
$chanrec->{"mode"} =~ /O/ not $nick_is_oper
Truth table33%1/3
A and not(B)
A= $chanrec->{"mode"} =~ /O/B= not $nick_is_oper
ABresult
0X0
100
111
7210 0 push @$ref, ['520',$chanrec->{name}];
7211 0 next LOOP;
7212 }
7213 58 my $umode = $self->state_user_umode($nick);
7214 # SSL only channel +S
7215 58 ▶ if ($chanrec->{mode} =~ /S/ && $umode !~ /S/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} =~ /S/ and not $umode =~ /S/) 0 58 58
Condition33%1/3
$chanrec->{"mode"} =~ /S/ and not $umode =~ /S/
!ll&&!rl&&r
5800
MC/DC0%0/2
$chanrec->{"mode"} =~ /S/ and not $umode =~ /S/
$chanrec->{"mode"} =~ /S/ not $umode =~ /S/
Truth table33%1/3
A and not(B)
A= $chanrec->{"mode"} =~ /S/B= not $umode =~ /S/
ABresult
0X0
100
111
7216 0 push @$ref, ['489',$chanrec->{name}];
7217 0 next LOOP;
7218 }
7219 # Registered users only +R
7220 58 ▶ if($chanrec->{mode} =~ /R/ && $umode !~ /r/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} =~ /R/ and not $umode =~ /r/) 2 56 58
Condition66%2/3
$chanrec->{"mode"} =~ /R/ and not $umode =~ /r/
!ll&&!rl&&r
5602
MC/DC50%1/2
$chanrec->{"mode"} =~ /R/ and not $umode =~ /r/
$chanrec->{"mode"} =~ /R/ not $umode =~ /r/
Truth table66%2/3
A and not(B)
A= $chanrec->{"mode"} =~ /R/B= not $umode =~ /r/
ABresult
0X0
100
111
7221 2 push @$ref, ['477',$chanrec->{name}];
7222 2 next LOOP;
7223 }
7224 # Channel is full
7225 56 ▶ if (!$bypass && $chanrec->{mode} =~ /l/
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}) 0 56 56
Condition33%2/6
not $bypass and $chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
!ll&&!rl&&r
5600
not $bypass and $chanrec->{"mode"} =~ /l/
!ll&&!rl&&r
0560
MC/DC0%0/3
not $bypass and $chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
not $bypass $chanrec->{"mode"} =~ /l/ keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
Truth table25%1/4
not(A) and B and C
A= not $bypassB= $chanrec->{"mode"} =~ /l/C= keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
ABCresult
0XX0
10X0
1100
1111
7226 0 && keys %{$chanrec->{users}} >= $chanrec->{climit}) {
7227 0 $self->_send_output_to_client($route_id, '471', $channel);
7228 0 next LOOP;
7229 }
7230 56 my $chankey;
7231 56 ▶ $chankey = shift @chankeys if $chanrec->{mode} =~ /k/;
Branch: 1 branch
BranchTrueFalseTotal
if $chanrec->{"mode"} =~ /k/ 0 56 56
7232 # Channel +k and no key or invalid key provided
7233 56 ▶ if (!$bypass && $chanrec->{mode} =~ /k/
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $chanrec->{"mode"} =~ /k/ and !$chankey || $chankey ne $chanrec->{"ckey"}) 0 56 56
Condition22%2/9
not $bypass and $chanrec->{"mode"} =~ /k/ and !$chankey || $chankey ne $chanrec->{"ckey"}
!ll&&!rl&&r
5600
not $bypass and $chanrec->{"mode"} =~ /k/
!ll&&!rl&&r
0560
not $chankey or $chankey ne $chanrec->{"ckey"}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $bypass and $chanrec->{"mode"} =~ /k/ and !$chankey || $chankey ne $chanrec->{"ckey"}
not $bypass $chanrec->{"mode"} =~ /k/ not $chankey $chankey ne $chanrec->{"ckey"}
Truth table20%1/5
not(A) and B and not(C) or D
A= not $bypassB= $chanrec->{"mode"} =~ /k/C= not $chankeyD= $chankey ne $chanrec->{"ckey"}
ABCDresult
0XXX0
10XX0
11000
111X1
11011
7234 && (!$chankey || $chankey ne $chanrec->{ckey})) {
7235 0 $self->_send_output_to_client($route_id, '475', $channel);
7236 0 next LOOP;
7237 }
7238 # Channel +i and not INVEX
7239 56 ▶ if (!$bypass && $chanrec->{mode} =~ /i/
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $chanrec->{"mode"} =~ /i/ and not $self->_state_user_invited($nick, $channel)) 3 53 56
Condition83%5/6
not $bypass and $chanrec->{"mode"} =~ /i/ and not $self->_state_user_invited($nick, $channel)
!ll&&!rl&&r
5213
not $bypass and $chanrec->{"mode"} =~ /i/
!ll&&!rl&&r
0524
MC/DC66%2/3
not $bypass and $chanrec->{"mode"} =~ /i/ and not $self->_state_user_invited($nick, $channel)
not $bypass $chanrec->{"mode"} =~ /i/ not $self->_state_user_invited($nick, $channel)
Truth table75%3/4
not(A) and B and not(C)
A= not $bypassB= $chanrec->{"mode"} =~ /i/C= not $self->_state_user_invited($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
7240 && !$self->_state_user_invited($nick, $channel)) {
7241 3 $self->_send_output_to_client($route_id, '473', $channel);
7242 3 next LOOP;
7243 }
7244 # Channel +b and no exception
7245 53 ▶ if (!$bypass && $self->_state_user_banned($nick, $channel)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $self->_state_user_banned($nick, $channel)) 0 53 53
Condition33%1/3
not $bypass and $self->_state_user_banned($nick, $channel)
!ll&&!rl&&r
0530
MC/DC0%0/2
not $bypass and $self->_state_user_banned($nick, $channel)
not $bypass $self->_state_user_banned($nick, $channel)
Truth table33%1/3
not(A) and B
A= not $bypassB= $self->_state_user_banned($nick, $channel)
ABresult
0X0
100
111
7246 0 $self->_send_output_to_client($route_id, '474', $channel);
7247 0 next LOOP;
7248 }
7249 # Spambot checks
7250 53 ▶ $self->state_check_spambot_warning($nick,$channel) if !$nick_is_oper;
Branch: 1 branch
BranchTrueFalseTotal
unless $nick_is_oper 51 2 53
7251 53 ▶ $self->state_check_joinflood_warning($nick,$channel) if !$nick_is_oper;
Branch: 1 branch
BranchTrueFalseTotal
unless $nick_is_oper 51 2 53
7252 # JOIN the channel
7253 53 delete $self->{state}{users}{$unick}{invites}{$uchannel};
7254 53 delete $self->{state}{chans}{$uchannel}{invites}{$uid};
7255 # Add user
7256 53 $self->{state}{uids}{$uid}{chans}{$uchannel} = '';
7257 53 $self->{state}{chans}{$uchannel}{users}{$uid} = '';
7258 # Send JOIN message to peers and local users.
7259 $self->send_output(
7260 {
7261 prefix => $uid,
7262 command => 'JOIN',
7263 53 ▶ params => [$chanrec->{ts}, $channel, '+'],
Branch: 1 branch
BranchTrueFalseTotal
unless $channel =~ /^&/ 53 0 53
7264 },
7265 $self->_state_connected_peers(),
7266 ) if $channel !~ /^&/;
7267  
7268 53 my $output = {
7269 prefix => $self->state_user_full($nick),
7270 command => 'JOIN',
7271 params => [$channel],
7272 };
7273 my $extout = {
7274 prefix => $self->state_user_full($nick),
7275 command => 'JOIN',
7276 params => [
7277 $channel,
7278 $self->{state}{uids}{$uid}{account},
7279 $self->{state}{uids}{$uid}{ircname},
7280 53 ],
7281 };
7282 53 $self->_send_output_to_client($route_id, $output);
7283 53 $self->_send_output_channel_local($channel, $output, $route_id, '', '', 'extended-join');
7284 53 $self->_send_output_channel_local($channel, $extout, $route_id, '', 'extended-join');
7285  
7286 # Send NAMES and TOPIC to client
7287 $self->_send_output_to_client(
7288 $route_id,
7289 (ref $_ eq 'ARRAY' ? @$_ : $_),
7290 53 ▶ ) for $self->_daemon_cmd_names($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 106 106
7291 $self->_send_output_to_client(
7292 $route_id,
7293 (ref $_ eq 'ARRAY' ? @$_ : $_),
7294 53 ▶ ) for $self->_daemon_cmd_topic($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 53 53
7295  
7296 53 ▶ if ( $self->{state}{uids}{$uid}{away} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"uids"}{$uid}{"away"}) 1 52 53
7297 1 $self->_state_do_away_notify($uid,$channel,$self->{state}{uids}{$uid}{away});
7298 }
7299 }
7300 }
7301  
7302 114 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 113 1 114
7303 1 return $ref;
7304 }
7305  
7306 8 ▶sub _daemon_cmd_part {
Subroutine _daemon_cmd_part: called CC=14 SCAR=29.7
7307 8 my $self = shift;
7308 8 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
80
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7309 8 my $chan = shift;
7310 8 my $server = $self->server_name();
7311 8 my $ref = [ ];
7312 8 my $args = [@_];
7313 8 my $count = @$args;
7314  
7315 SWITCH: {
7316 8 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 0 8 8
7317 0 push @$ref, ['461', 'PART'];
7318 0 last SWITCH;
7319 }
7320 8 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 8 8
7321 0 push @$ref, ['403', $chan];
7322 0 last SWITCH;
7323 }
7324 8 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 8 8
7325 0 push @$ref, ['442', $chan];
7326 0 last SWITCH;
7327 }
7328  
7329 8 $chan = $self->_state_chan_name($chan);
7330 8 my $uid = $self->state_user_uid($nick);
7331 8 my $urec = $self->{state}{uids}{$uid};
7332  
7333 8 my $pmsg = $args->[0];
7334 8 my $params = [ $chan ];
7335  
7336 8 ▶ if ( $pmsg and my $msgtime = $self->{config}{anti_spam_exit_message_time} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}) 0 8 8
Condition66%2/3
$pmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
!ll&&!rl&&r
260
MC/DC0%0/2
$pmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
$pmsg my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
Truth table66%2/3
A and B
A= $pmsgB= my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
ABresult
0X0
100
111
7337 0 ▶ $pmsg = '' if time - $urec->{conn_time} < $msgtime;
Branch: 1 branch
BranchTrueFalseTotal
if time - $urec->{"conn_time"} < $msgtime 0 0 0
7338 }
7339  
7340 8 ▶ if ( $pmsg && !$self->state_can_send_to_channel($nick,$chan,$pmsg,'PART') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pmsg and not $self->state_can_send_to_channel($nick, $chan, $pmsg, "PART")) 0 8 8
Condition66%2/3
$pmsg and not $self->state_can_send_to_channel($nick, $chan, $pmsg, "PART")
!ll&&!rl&&r
260
MC/DC0%0/2
$pmsg and not $self->state_can_send_to_channel($nick, $chan, $pmsg, "PART")
$pmsg not $self->state_can_send_to_channel($nick, $chan, $pmsg, "PART")
Truth table66%2/3
A and not(B)
A= $pmsgB= not $self->state_can_send_to_channel($nick, $chan, $pmsg, "PART")
ABresult
0X0
100
111
7341 0 $pmsg = '';
7342 }
7343  
7344 8 ▶ push @$params, $pmsg if $pmsg;
Branch: 1 branch
BranchTrueFalseTotal
if $pmsg 6 2 8
7345  
7346 8 ▶ $self->state_check_spambot_warning($nick) if $urec->{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $urec->{"umode"} =~ /o/ 7 1 8
7347  
7348 8 $self->send_output(
7349 {
7350 prefix => $uid,
7351 command => 'PART',
7352 params => $params,
7353 },
7354 $self->_state_connected_peers(),
7355 );
7356 8 $self->_send_output_channel_local(
7357 $chan,
7358 {
7359 prefix => $self->state_user_full($nick),
7360 command => 'PART',
7361 params => $params,
7362 },
7363 );
7364  
7365 8 $chan = uc_irc($chan);
7366 8 delete $self->{state}{chans}{$chan}{users}{$uid};
7367 8 delete $self->{state}{uids}{$uid}{chans}{$chan};
7368 8 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 5 3 8
7369 5 delete $self->{state}{chans}{$chan};
7370 }
7371 }
7372  
7373 8 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 8 0 8
7374 0 return $ref;
7375 }
7376  
7377 7 ▶sub _daemon_cmd_kick {
Subroutine _daemon_cmd_kick: called CC=15 SCAR=31.1
7378 7 my $self = shift;
7379 7 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7380 7 my $server = $self->server_name();
7381 7 my $ref = [ ];
7382 7 my $args = [@_];
7383 7 my $count = @$args;
7384  
7385 SWITCH: {
7386 7 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 7 7
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
007
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
7387 0 push @$ref, ['461', 'KICK'];
7388 0 last SWITCH;
7389 }
7390 7 my $chan = (split /,/, $args->[0])[0];
7391 7 my $who = (split /,/, $args->[1])[0];
7392 7 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 7 7
7393 0 push @$ref, ['403', $chan];
7394 0 last SWITCH;
7395 }
7396 7 $chan = $self->_state_chan_name($chan);
7397 7 ▶ if (!$self->state_is_chan_op($nick, $chan) && !$self->state_is_chan_hop($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_op($nick, $chan) or $self->state_is_chan_hop($nick, $chan)) 0 7 7
Condition66%2/3
$self->state_is_chan_op($nick, $chan) or $self->state_is_chan_hop($nick, $chan)
l!l&&r!l&&!r
160
MC/DC0%0/2
$self->state_is_chan_op($nick, $chan) or $self->state_is_chan_hop($nick, $chan)
$self->state_is_chan_op($nick, $chan) $self->state_is_chan_hop($nick, $chan)
Truth table66%2/3
A or B
A= $self->state_is_chan_op($nick, $chan)B= $self->state_is_chan_hop($nick, $chan)
ABresult
1X1
011
000
7398 0 push @$ref, ['482', $chan];
7399 0 last SWITCH;
7400 }
7401 7 ▶ if (!$self->state_nick_exists($who) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 7 7
7402 0 push @$ref, ['401', $who];
7403 0 last SWITCH;
7404 }
7405 7 $who = $self->state_user_nick($who);
7406 7 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 3 4 7
7407 3 push @$ref, ['441', $who, $chan];
7408 3 last SWITCH;
7409 }
7410 4 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan) and $self->state_is_chan_op($who, $chan)) 3 1 4
Condition66%4/6
$self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan) and $self->state_is_chan_op($who, $chan)
!ll&&!rl&&r
103
$self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan)
!ll&&!rl&&r
103
MC/DC33%1/3
$self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan) and $self->state_is_chan_op($who, $chan)
$self->state_is_chan_hop($nick, $chan) not $self->state_is_chan_op($nick, $chan) $self->state_is_chan_op($who, $chan)
Truth table50%2/4
A and not(B) and C
A= $self->state_is_chan_hop($nick, $chan)B= not $self->state_is_chan_op($nick, $chan)C= $self->state_is_chan_op($who, $chan)
ABCresult
0XX0
10X0
1100
1111
7411 $self->state_is_chan_hop($nick, $chan) &&
7412 !$self->state_is_chan_op($nick, $chan) &&
7413 $self->state_is_chan_op($who, $chan)
7414 ) {
7415 3 push @$ref, ['482', $chan];
7416 3 last SWITCH;
7417 }
7418 1 ▶ my $comment = $args->[2] || $who;
Condition33%1/3
$args->[2] || $who
l!l&&r!l&&!r
100
MC/DC0%0/2
$args->[2] || $who
$args->[2] $who
Truth table33%1/3
A || B
A= $args->[2]B= $who
ABresult
1X1
011
000
7419 1 my $uid = $self->state_user_uid($nick);
7420 1 my $wuid = $self->state_user_uid($who);
7421 1 $self->send_output(
7422 {
7423 prefix => $uid,
7424 command => 'KICK',
7425 params => [$chan, $wuid, $comment],
7426 },
7427 $self->_state_connected_peers(),
7428 );
7429 1 $self->_send_output_channel_local(
7430 $chan,
7431 {
7432 prefix => $self->state_user_full($nick),
7433 command => 'KICK',
7434 params => [$chan, $who, $comment],
7435 },
7436 );
7437 1 $chan = uc_irc($chan);
7438 1 delete $self->{state}{chans}{$chan}{users}{$wuid};
7439 1 delete $self->{state}{uids}{$wuid}{chans}{$chan};
7440 1 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 1 1
7441 0 delete $self->{state}{chans}{$chan};
7442 }
7443 }
7444  
7445 7 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 7 0 7
7446 0 return $ref;
7447 }
7448  
7449 3 ▶sub _daemon_cmd_remove {
Subroutine _daemon_cmd_remove: called CC=15 SCAR=30.8
7450 3 my $self = shift;
7451 3 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7452 3 my $server = $self->server_name();
7453 3 my $ref = [ ];
7454 3 my $args = [@_];
7455 3 my $count = @$args;
7456  
7457 SWITCH: {
7458 3 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 3 3
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
003
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
7459 0 push @$ref, ['461', 'REMOVE'];
7460 0 last SWITCH;
7461 }
7462 3 my $chan = (split /,/, $args->[0])[0];
7463 3 my $who = (split /,/, $args->[1])[0];
7464 3 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 3 3
7465 0 push @$ref, ['403', $chan];
7466 0 last SWITCH;
7467 }
7468 3 $chan = $self->_state_chan_name($chan);
7469 3 ▶ if (!$self->state_is_chan_op($nick, $chan) && !$self->state_is_chan_hop($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_op($nick, $chan) or $self->state_is_chan_hop($nick, $chan)) 0 3 3
Condition66%2/3
$self->state_is_chan_op($nick, $chan) or $self->state_is_chan_hop($nick, $chan)
l!l&&r!l&&!r
120
MC/DC0%0/2
$self->state_is_chan_op($nick, $chan) or $self->state_is_chan_hop($nick, $chan)
$self->state_is_chan_op($nick, $chan) $self->state_is_chan_hop($nick, $chan)
Truth table66%2/3
A or B
A= $self->state_is_chan_op($nick, $chan)B= $self->state_is_chan_hop($nick, $chan)
ABresult
1X1
011
000
7470 0 push @$ref, ['482', $chan];
7471 0 last SWITCH;
7472 }
7473 3 ▶ if (!$self->state_nick_exists($who) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 3 3
7474 0 push @$ref, ['401', $who];
7475 0 last SWITCH;
7476 }
7477 3 $who = $self->state_user_nick($who);
7478 3 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 1 2 3
7479 1 push @$ref, ['441', $who, $chan];
7480 1 last SWITCH;
7481 }
7482 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan) and $self->state_is_chan_op($who, $chan)) 1 1 2
Condition66%4/6
$self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan) and $self->state_is_chan_op($who, $chan)
!ll&&!rl&&r
101
$self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan)
!ll&&!rl&&r
101
MC/DC33%1/3
$self->state_is_chan_hop($nick, $chan) and not $self->state_is_chan_op($nick, $chan) and $self->state_is_chan_op($who, $chan)
$self->state_is_chan_hop($nick, $chan) not $self->state_is_chan_op($nick, $chan) $self->state_is_chan_op($who, $chan)
Truth table50%2/4
A and not(B) and C
A= $self->state_is_chan_hop($nick, $chan)B= not $self->state_is_chan_op($nick, $chan)C= $self->state_is_chan_op($who, $chan)
ABCresult
0XX0
10X0
1100
1111
7483 $self->state_is_chan_hop($nick, $chan) &&
7484 !$self->state_is_chan_op($nick, $chan) &&
7485 $self->state_is_chan_op($who, $chan)
7486 ) {
7487 1 push @$ref, ['482', $chan];
7488 1 last SWITCH;
7489 }
7490 1 my $comment = "Requested by $nick";
7491 1 ▶ $comment .= qq{ "$args->[2]"} if $args->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[2] 1 0 1
7492 1 my $uid = $self->state_user_uid($who);
7493 1 $self->send_output(
7494 {
7495 prefix => $uid,
7496 command => 'PART',
7497 params => [$chan, $comment],
7498 },
7499 $self->_state_connected_peers(),
7500 );
7501 1 $self->_send_output_channel_local(
7502 $chan,
7503 {
7504 prefix => $self->state_user_full($who),
7505 command => 'PART',
7506 params => [$chan, $comment],
7507 },
7508 );
7509 1 $chan = uc_irc($chan);
7510 1 delete $self->{state}{chans}{$chan}{users}{$uid};
7511 1 delete $self->{state}{uids}{$uid}{chans}{$chan};
7512 1 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 1 1
7513 0 delete $self->{state}{chans}{$chan};
7514 }
7515 }
7516  
7517 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
7518 0 return $ref;
7519 }
7520  
7521 0 ▶sub _daemon_cmd_invite {
Subroutine _daemon_cmd_invite: not called CC=18 SCAR=58.3
7522 0 my $self = shift;
7523 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
7524 0 my $server = $self->server_name();
7525 0 my $sid = $self->server_sid();
7526 0 my $ref = [ ];
7527 0 my $args = [@_];
7528 0 my $count = @$args;
7529  
7530 SWITCH: {
7531 0 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 0 0
Condition0%0/3
not $count or $count < 2
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table0%0/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
7532 0 push @$ref, ['461', 'INVITE'];
7533 0 last SWITCH;
7534 }
7535 0 my ($who, $chan) = @$args;
7536 0 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
7537 0 push @$ref, ['401', $who];
7538 0 last SWITCH;
7539 }
7540 0 $who = $self->state_user_nick($who);
7541 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
7542 0 push @$ref, ['403', $chan];
7543 0 last SWITCH;
7544 }
7545 0 $chan = $self->_state_chan_name($chan);
7546 0 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 0 0
7547 0 push @$ref, ['442', $chan];
7548 0 last SWITCH;
7549 }
7550 0 ▶ if ($self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($who, $chan)) 0 0 0
7551 0 push @$ref, ['443', $who, $chan];
7552 0 last SWITCH;
7553 }
7554 0 ▶ if ($self->state_chan_mode_set($chan, 'i')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_mode_set($chan, "i") and not $self->state_is_chan_op($nick, $chan) && $self->state_is_chan_hop($nick, $chan)) 0 0 0
Condition0%0/6
$self->state_chan_mode_set($chan, "i") and not $self->state_is_chan_op($nick, $chan) && $self->state_is_chan_hop($nick, $chan)
!ll&&!rl&&r
000
$self->state_is_chan_op($nick, $chan) && $self->state_is_chan_hop($nick, $chan)
!ll&&!rl&&r
000
MC/DC0%0/3
$self->state_chan_mode_set($chan, "i") and not $self->state_is_chan_op($nick, $chan) && $self->state_is_chan_hop($nick, $chan)
$self->state_chan_mode_set($chan, "i") $self->state_is_chan_op($nick, $chan) $self->state_is_chan_hop($nick, $chan)
Truth table0%0/4
A and not(B && C)
A= $self->state_chan_mode_set($chan, "i")B= $self->state_is_chan_op($nick, $chan)C= $self->state_is_chan_hop($nick, $chan)
ABCresult
0XX0
1110
10X1
1101
7555 && ( !$self->state_is_chan_op($nick, $chan)
7556 || !$self->state_is_chan_hop($nick, $chan) ) ) {
7557 0 push @$ref, ['482', $chan];
7558 0 last SWITCH;
7559 }
7560 0 my $local; my $invite_only;
7561 0 my $wuid = $self->state_user_uid($who);
7562 0 my $settime = time;
7563 # Only store the INVITE if the channel is invite-only
7564 0 ▶ if ($self->state_chan_mode_set($chan, 'i')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_mode_set($chan, "i")) 0 0 0
7565 0 $self->{state}{chans}{uc_irc $chan}{invites}{$wuid} = $settime;
7566 0 ▶ if ($self->_state_is_local_uid($wuid)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_uid($wuid)) 0 0 0
7567 0 my $record = $self->{state}{uids}{$wuid};
7568 0 $record->{invites}{uc_irc($chan)} = $settime;
7569 0 $local = 1;
7570 }
7571 0 $invite_only = 1;
7572 }
7573 0 my $invite;
7574 {
7575 0 my $route_id = $self->_state_uid_route($wuid);
7576 0 $invite = {
7577 prefix => $self->state_user_full($nick),
7578 command => 'INVITE',
7579 params => [$who, $chan],
7580 colonify => 0,
7581 };
7582 0 ▶ if ($route_id eq 'spoofed') {
Branch: 2 branches
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
elsif ($local) { } 0 0 0
7583 $self->send_event(
7584 "daemon_invite",
7585 $invite->{prefix},
7586 0 @{ $invite->{params} }
7587 );
7588 }
7589 elsif ( $local ) {
7590 0 $self->send_output($invite, $route_id);
7591 }
7592 }
7593 # Send INVITE to all connected peers
7594 $self->send_output(
7595 {
7596 0 prefix => $self->state_user_uid($nick),
7597 command => 'INVITE',
7598 params => [ $wuid, $chan, $self->_state_chan_timestamp($chan) ],
7599 colonify => 0,
7600 },
7601 $self->_state_connected_peers(),
7602 );
7603 0 push @$ref, {
7604 prefix => $server,
7605 command => '341',
7606 params => [$chan, $who],
7607 };
7608 # Send NOTICE to local channel +oh users or invite-notify if applicable
7609 0 ▶ if ( $invite_only ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invite_only) 0 0 0
7610 0 my $notice = {
7611 prefix => $server,
7612 command => 'NOTICE',
7613 params => [
7614 $chan,
7615 sprintf(
7616 "%s is inviting %s to %s.",
7617 $nick,
7618 $who,
7619 $chan,
7620 ),
7621 ],
7622 };
7623 0 $self->_send_output_channel_local($chan,$notice,'','oh','','invite-notify'); # Traditional NOTICE
7624 0 $self->_send_output_channel_local($chan,$invite,'','oh','invite-notify',''); # invite-notify extension
7625 }
7626 0 my $away = $self->{state}{uids}{$wuid}{away};
7627 0 ▶ if (defined $away) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $away) 0 0 0
7628 0 push @$ref, {
7629 prefix => $server,
7630 command => '301',
7631 params => [$nick, $who, $away],
7632 };
7633 }
7634 }
7635  
7636 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
7637 0 return $ref;
7638 }
7639  
7640 228 ▶sub _daemon_cmd_umode {
Subroutine _daemon_cmd_umode: called CC=22 SCAR=37.1
7641 228 my $self = shift;
7642 228 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
2280
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7643 228 my $args = [ @_ ];
7644 228 my $count = @$args;
7645 228 my $server = $self->server_name();
7646 228 my $ref = [ ];
7647 228 my $record = $self->{state}{users}{uc_irc($nick)};
7648  
7649 228 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count) { } 2 226 228
7650 push @$ref, {
7651 prefix => $server,
7652 command => '221',
7653 2 params => [$nick, '+' . $record->{umode}],
7654 };
7655 }
7656 else {
7657 226 my $modestring = join('', @$args);
7658 226 $modestring =~ s/\s+//g;
7659 226 my $cnt += $modestring =~ s/[^a-zA-Z+-]+//g;
7660 226 $cnt += $modestring =~ s/[^DFGHRSWXabcdefgijklnopqrsuwy+-]+//g;
7661  
7662 # These can only be set by servers/services
7663 226 $modestring =~ s/[SWr]+//g;
7664  
7665 # These can only be set by an OPER
7666 226 ▶ $cnt += $modestring =~ s/[FHXabcdefjklnsuy]+//g if $record->{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"umode"} =~ /o/ 226 0 226
7667  
7668 226 ▶ push @$ref, ['501'] if $cnt;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt 1 225 226
7669  
7670 226 my $umode = unparse_mode_line($modestring);
7671 226 my $peer_ignore;
7672 226 my $parsed_mode = parse_mode_line($umode);
7673 226 my $route_id = $self->_state_user_route($nick);
7674 226 my $previous = $record->{umode};
7675  
7676 226 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 225 226 451
7677 225 ▶ next if $mode eq '+o';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+o" 0 225 225
7678 225 my ($action, $char) = split //, $mode;
7679 225 ▶ if ($action eq '+' && $record->{umode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and not $record->{"umode"} =~ /$char/) 225 0 225
Condition33%1/3
$action eq "+" and not $record->{"umode"} =~ /$char/
!ll&&!rl&&r
00225
MC/DC0%0/2
$action eq "+" and not $record->{"umode"} =~ /$char/
$action eq "+" not $record->{"umode"} =~ /$char/
Truth table33%1/3
A and not(B)
A= $action eq "+"B= not $record->{"umode"} =~ /$char/
ABresult
0X0
100
111
7680 225 $record->{umode} .= $char;
7681 225 ▶ if ($char eq 'i') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "i") 224 1 225
7682 224 $self->{state}{stats}{invisible}++;
7683 224 $peer_ignore = delete $record->{_ignore_i_umode};
7684 }
7685 225 ▶ if ($char eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w") 0 225 225
7686 0 $self->{state}{wallops}{$route_id} = time;
7687 }
7688 225 ▶ if ($char eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l") 0 225 225
7689 0 $self->{state}{locops}{$route_id} = time;
7690 }
7691 }
7692 225 ▶ if ($action eq '-' && $record->{umode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "-" and $record->{"umode"} =~ /$char/) 0 225 225
Condition33%1/3
$action eq "-" and $record->{"umode"} =~ /$char/
!ll&&!rl&&r
22500
MC/DC0%0/2
$action eq "-" and $record->{"umode"} =~ /$char/
$action eq "-" $record->{"umode"} =~ /$char/
Truth table33%1/3
A and B
A= $action eq "-"B= $record->{"umode"} =~ /$char/
ABresult
0X0
100
111
7693 0 $record->{umode} =~ s/$char//g;
7694 0 ▶ $self->{state}{stats}{invisible}-- if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
7695  
7696 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
7697 0 $self->{state}{stats}{ops_online}--;
7698 0 delete $self->{state}{localops}{$route_id};
7699 0 $self->antiflood( $route_id, 1);
7700 0 delete $record->{svstags}{313};
7701 }
7702 0 ▶ if ($char eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w") 0 0 0
7703 0 delete $self->{state}{wallops}{$route_id};
7704 }
7705 0 ▶ if ($char eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l") 0 0 0
7706 0 delete $self->{state}{locops}{$route_id};
7707 }
7708 }
7709 }
7710  
7711 226 $record->{umode} = join '', sort split //, $record->{umode};
7712 226 my $set = gen_mode_change($previous, $record->{umode});
7713 226 ▶ if ($set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set) 225 1 226
7714 225 my $full = $self->state_user_full($nick);
7715 $self->send_output(
7716 {
7717 prefix => $record->{uid},
7718 command => 'MODE',
7719 225 ▶ params => [$record->{uid}, $set],
Branch: 1 branch
BranchTrueFalseTotal
unless $peer_ignore 1 224 225
7720 },
7721 $self->_state_connected_peers(),
7722 ) if !$peer_ignore;
7723 225 my $hashref = {
7724 prefix => $full,
7725 command => 'MODE',
7726 params => [$nick, $set],
7727 };
7728 225 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
unless $peer_ignore 1 224 225
7729 "daemon_umode",
7730 $full,
7731 $set,
7732 ) if !$peer_ignore;
7733 225 push @$ref, $hashref;
7734 }
7735 }
7736  
7737 228 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 228 0 228
7738 0 return $ref;
7739 }
7740  
7741 59 ▶sub _daemon_cmd_topic {
Subroutine _daemon_cmd_topic: called CC=15 SCAR=34.2
7742 59 my $self = shift;
7743 59 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
590
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7744 59 my $server = $self->server_name();
7745 59 my $ref = [ ];
7746 59 my $args = [@_];
7747 59 my $count = @$args;
7748  
7749 SWITCH:{
7750 59 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 59 59
7751 0 push @$ref, ['461', 'TOPIC'];
7752 0 last SWITCH;
7753 }
7754 59 ▶ if (!$self->state_chan_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($args->[0])) 0 59 59
7755 0 push @$ref, ['403', $args->[0]];
7756 0 last SWITCH;
7757 }
7758 59 ▶ if ($self->state_chan_mode_set($args->[0], 's')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_mode_set($args->[0], "s") and not $self->state_is_chan_member($nick, $args->[0])) 0 59 59
Condition33%1/3
$self->state_chan_mode_set($args->[0], "s") and not $self->state_is_chan_member($nick, $args->[0])
!ll&&!rl&&r
5900
MC/DC0%0/2
$self->state_chan_mode_set($args->[0], "s") and not $self->state_is_chan_member($nick, $args->[0])
$self->state_chan_mode_set($args->[0], "s") not $self->state_is_chan_member($nick, $args->[0])
Truth table33%1/3
A and not(B)
A= $self->state_chan_mode_set($args->[0], "s")B= not $self->state_is_chan_member($nick, $args->[0])
ABresult
0X0
100
111
7759 && !$self->state_is_chan_member($nick, $args->[0])) {
7760 0 push @$ref, ['442', $args->[0]];
7761 0 last SWITCH;
7762 }
7763 59 my $chan_name = $self->_state_chan_name($args->[0]);
7764 59 ▶ if ($count == 1
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 1 and my $topic = $self->state_chan_topic($args->[0])) 0 59 59
Condition66%2/3
$count == 1 and my $topic = $self->state_chan_topic($args->[0])
!ll&&!rl&&r
3560
MC/DC0%0/2
$count == 1 and my $topic = $self->state_chan_topic($args->[0])
$count == 1 my $topic = $self->state_chan_topic($args->[0])
Truth table66%2/3
A and B
A= $count == 1B= my $topic = $self->state_chan_topic($args->[0])
ABresult
0X0
100
111
7765 and my $topic = $self->state_chan_topic($args->[0])) {
7766 0 push @$ref, {
7767 prefix => $server,
7768 command => '332',
7769 params => [$nick, $chan_name, $topic->[0]],
7770 };
7771 push @$ref, {
7772 prefix => $server,
7773 command => '333',
7774 0 params => [$nick, $chan_name, @{ $topic }[1..2]],
7775 };
7776 0 last SWITCH;
7777 }
7778 59 ▶ if ($count == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 1) 56 3 59
7779 56 push @$ref, {
7780 prefix => $server,
7781 command => '331',
7782 params => [$nick, $chan_name, 'No topic is set'],
7783 };
7784 56 last SWITCH;
7785 }
7786 3 ▶ if (!$self->state_is_chan_member($nick, $args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $args->[0])) 0 3 3
7787 0 push @$ref, ['442', $args->[0]];
7788 0 last SWITCH;
7789 }
7790 3 ▶ if ($self->state_chan_mode_set($args->[0], 't')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_mode_set($args->[0], "t") and not $self->state_is_chan_op($nick, $args->[0])) 0 3 3
Condition33%1/3
$self->state_chan_mode_set($args->[0], "t") and not $self->state_is_chan_op($nick, $args->[0])
!ll&&!rl&&r
030
MC/DC0%0/2
$self->state_chan_mode_set($args->[0], "t") and not $self->state_is_chan_op($nick, $args->[0])
$self->state_chan_mode_set($args->[0], "t") not $self->state_is_chan_op($nick, $args->[0])
Truth table33%1/3
A and not(B)
A= $self->state_chan_mode_set($args->[0], "t")B= not $self->state_is_chan_op($nick, $args->[0])
ABresult
0X0
100
111
7791 && !$self->state_is_chan_op($nick, $args->[0])) {
7792 0 push @$ref, ['482', $args->[0]];
7793 0 last SWITCH;
7794 }
7795 3 my $record = $self->{state}{chans}{uc_irc($args->[0])};
7796 3 my $topic_length = $self->server_config('TOPICLEN');
7797 3 ▶ if (length $args->[0] > $topic_length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $args->[0] > $topic_length) 0 3 3
7798 0 $args->[1] = substr $args->[0], 0, $topic_length;
7799 }
7800 3 ▶ if ($args->[1] eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] eq '') { } 1 2 3
7801 1 delete $record->{topic};
7802 }
7803 else {
7804 $record->{topic} = [
7805 2 $args->[1],
7806 $self->state_user_full($nick),
7807 time,
7808 ];
7809 }
7810 3 $self->send_output(
7811 {
7812 prefix => $self->state_user_uid($nick),
7813 command => 'TOPIC',
7814 params => [$chan_name, $args->[1]],
7815 },
7816 $self->_state_connected_peers(),
7817 );
7818  
7819 3 $self->_send_output_channel_local(
7820 $args->[0],
7821 {
7822 prefix => $self->state_user_full($nick),
7823 command => 'TOPIC',
7824 params => [$chan_name, $args->[1]],
7825 },
7826 );
7827 }
7828  
7829 59 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 59 0 59
7830 0 return $ref;
7831 }
7832  
7833 3 ▶sub _daemon_cmd_map {
Subroutine _daemon_cmd_map: called CC=8 SCAR=22.5
7834 3 my $self = shift;
7835 3 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7836 3 my $server = $self->server_name();
7837 3 my $sid = $self->server_sid();
7838 3 my $ref = [ ];
7839 3 my $isoper = $self->state_user_is_operator($nick);
7840  
7841 SWITCH: {
7842 3 ▶ if ( !$isoper ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($isoper) 2 1 3
7843 2 my $lastuse = $self->{state}{lastuse}{map};
7844 2 my $pacewait = $self->{config}{pace_wait};
7845 2 ▶ if ( $lastuse && $pacewait && ( $lastuse + $pacewait ) > time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastuse and $pacewait and $lastuse + $pacewait > time) 0 2 2
Condition33%2/6
$lastuse and $pacewait and $lastuse + $pacewait > time
!ll&&!rl&&r
200
$lastuse and $pacewait
!ll&&!rl&&r
200
MC/DC0%0/3
$lastuse and $pacewait and $lastuse + $pacewait > time
$lastuse $pacewait $lastuse + $pacewait > time
Truth table25%1/4
A and B and C
A= $lastuseB= $pacewaitC= $lastuse + $pacewait > time
ABCresult
0XX0
10X0
1100
1111
7846 0 push @$ref, ['263', 'MAP'];
7847 0 last SWITCH;
7848 }
7849 2 $self->{state}{lastuse}{map} = time();
7850 }
7851  
7852 3 my $full = $self->state_user_full($nick);
7853 3 my $msg = sprintf('MAP requested by %s (%s) [%s]',
7854 $nick, (split /!/,$full)[1], $server,
7855 );
7856  
7857 3 $self->_send_to_realops( $msg, 'Notice', 'y' );
7858  
7859 3 push @$ref, $_ for
7860 $self->_state_do_map( $nick, $sid, $isoper, 0 );
7861  
7862 3 push @$ref, {
7863 prefix => $server,
7864 command => '017',
7865 params => [
7866 $nick,
7867 'End of /MAP',
7868 ],
7869 };
7870 }
7871  
7872 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
7873 0 return $ref;
7874 }
7875  
7876 7 ▶sub _daemon_cmd_links {
Subroutine _daemon_cmd_links: called CC=13 SCAR=25.7
7877 7 my $self = shift;
7878 7 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7879 7 my $server = $self->server_name();
7880 7 my $sid = $self->server_sid();
7881 7 my $args = [ @_ ];
7882 7 my $count = @$args;
7883 7 my $ref = [ ];
7884  
7885 SWITCH:{
7886 7 my $target;
7887 7 ▶ if ($count > 1 && !$self->state_peer_exists( $args->[0] )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1 and not $self->state_peer_exists($args->[0])) 1 6 7
Condition100%3/3
$count > 1 and not $self->state_peer_exists($args->[0])
!ll&&!rl&&r
511
MC/DC100%2/2
$count > 1 and not $self->state_peer_exists($args->[0])
$count > 1 not $self->state_peer_exists($args->[0])
Truth table100%3/3
A and not(B)
A= $count > 1B= not $self->state_peer_exists($args->[0])
ABresult
0X0
100
111
7888 1 push @$ref, ['402', $args->[0]];
7889 1 last SWITCH;
7890 }
7891 6 my $lastuse = $self->{state}{lastuse}{links};
7892 6 my $pacewait = $self->{config}{pace_wait};
7893 6 ▶ if ( $lastuse && $pacewait && ( $lastuse + $pacewait ) > time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lastuse and $pacewait and $lastuse + $pacewait > time) 1 5 6
Condition83%5/6
$lastuse and $pacewait and $lastuse + $pacewait > time
!ll&&!rl&&r
501
$lastuse and $pacewait
!ll&&!rl&&r
231
MC/DC66%2/3
$lastuse and $pacewait and $lastuse + $pacewait > time
$lastuse $pacewait $lastuse + $pacewait > time
Truth table75%3/4
A and B and C
A= $lastuseB= $pacewaitC= $lastuse + $pacewait > time
ABCresult
0XX0
10X0
1100
1111
7894 1 push @$ref, ['263', 'LINKS'];
7895 1 last SWITCH;
7896 }
7897 5 $self->{state}{lastuse}{links} = time();
7898 5 ▶ if ( $count > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1) 1 4 5
7899 1 $target = shift @$args;
7900 }
7901 5 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 1 4 5
Condition66%2/3
$target and uc $server ne uc $target
!ll&&!rl&&r
401
MC/DC50%1/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table66%2/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
7902 1 $self->send_output(
7903 {
7904 prefix => $self->state_user_uid($nick),
7905 command => 'LINKS',
7906 params => [
7907 $self->_state_peer_sid($target),
7908 $args->[0],
7909 ],
7910 },
7911 $self->_state_peer_route($target)
7912 );
7913 1 last SWITCH;
7914 }
7915  
7916 $self->_send_to_realops(
7917 4 sprintf(
7918 'LINKS requested by %s (%s) [%s]',
7919 $nick, (split /!/,$self->state_user_full($nick))[1], $server,
7920 ), qw[Notice y],
7921 );
7922  
7923 4 ▶ my $mask = shift @$args || '*';
Condition100%2/2
shift @$args || '*'
l!l
22
MC/DC100%1/1
shift @$args || '*'
shift @$args
Truth table100%2/2
A
A= shift @$args
Aresult
11
00
7924  
7925 4 push @$ref, $_ for
7926 4 @{ $self->_daemon_do_links($nick,$server,$mask) };
7927 }
7928  
7929 7 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 7 0 7
7930 0 return $ref;
7931 }
7932  
7933 5 ▶sub _daemon_do_links {
Subroutine _daemon_do_links: called CC=7 SCAR=19.8
7934 5 my $self = shift;
7935 5 ▶ my $client = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7936 5 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7937 5 ▶ my $mask = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7938 5 my $sid = $self->server_sid();
7939 5 my $server = $self->server_name();
7940 5 my $ref = [ ];
7941  
7942 5 for ($self->_state_sid_links($sid, $prefix, $client, $mask)) {
7943 13 push @$ref, $_;
7944 }
7945 5 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($mask, $server) 4 1 5
7946 prefix => $prefix,
7947 command => '364',
7948 params => [
7949 $client,
7950 $server,
7951 $server,
7952 join( ' ', '0', $self->server_config('serverdesc'))
7953 ],
7954 } if matches_mask($mask, $server);
7955 5 push @$ref, {
7956 prefix => $prefix,
7957 command => '365',
7958 params => [$client, $mask, 'End of /LINKS list.'],
7959 };
7960  
7961 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 5 5
7962 5 return $ref;
7963 }
7964  
7965 7 ▶sub _daemon_cmd_knock {
Subroutine _daemon_cmd_knock: called CC=19 SCAR=32.9
7966 7 my $self = shift;
7967 7 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7968 7 my $server = $self->server_name();
7969 7 my $sid = $self->server_sid();
7970 7 my $args = [ @_ ];
7971 7 my $count = @$args;
7972 7 my $ref = [ ];
7973  
7974 SWITCH:{
7975 7 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 7 7
7976 0 push @$ref, ['461', 'KNOCK'];
7977 0 last SWITCH;
7978 }
7979 7 my $channel = shift @$args;
7980 7 ▶ if ( !$self->state_chan_exists($channel) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($channel)) 0 7 7
7981 0 push @$ref, ['401', $channel];
7982 0 last SWITCH;
7983 }
7984 7 ▶ if ( $self->state_is_chan_member($nick,$channel) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($nick, $channel)) 0 7 7
7985 0 push @$ref, ['714', $channel];
7986 0 last SWITCH;
7987 }
7988 7 my $chanrec = $self->{state}{chans}{uc_irc $channel};
7989 7 ▶ if ( !( $chanrec->{mode} =~ /i/ || $chanrec->{ckey} || ($chanrec->{mode} =~ /l/
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /i/ or $chanrec->{"ckey"} or $chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}) 1 6 7
Condition55%5/9
$chanrec->{"mode"} =~ /i/ or $chanrec->{"ckey"} or $chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
l!l&&r!l&&!r
601
$chanrec->{"mode"} =~ /i/ or $chanrec->{"ckey"}
l!l&&r!l&&!r
601
$chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
!ll&&!rl&&r
010
MC/DC25%1/4
$chanrec->{"mode"} =~ /i/ or $chanrec->{"ckey"} or $chanrec->{"mode"} =~ /l/ and keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
$chanrec->{"mode"} =~ /i/ $chanrec->{"ckey"} $chanrec->{"mode"} =~ /l/ keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
Truth table40%2/5
A or B or C and D
A= $chanrec->{"mode"} =~ /i/B= $chanrec->{"ckey"}C= $chanrec->{"mode"} =~ /l/D= keys %{$$chanrec{"users"};} >= $chanrec->{"climit"}
ABCDresult
1XXX1
01XX1
00111
000X0
00100
7990 1 && keys %{$chanrec->{users}} >= $chanrec->{climit}) ) ) {
7991 1 push @$ref, ['713', $channel];
7992 1 last SWITCH;
7993 }
7994 6 ▶ if ( $chanrec->{mode} =~ /p/ || $self->_state_user_banned($nick,$channel) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} =~ /p/ or $self->_state_user_banned($nick, $channel)) 0 6 6
Condition33%1/3
$chanrec->{"mode"} =~ /p/ or $self->_state_user_banned($nick, $channel)
l!l&&r!l&&!r
006
MC/DC0%0/2
$chanrec->{"mode"} =~ /p/ or $self->_state_user_banned($nick, $channel)
$chanrec->{"mode"} =~ /p/ $self->_state_user_banned($nick, $channel)
Truth table33%1/3
A or B
A= $chanrec->{"mode"} =~ /p/B= $self->_state_user_banned($nick, $channel)
ABresult
1X1
011
000
7995 0 push @$ref, ['404', $channel];
7996 0 next SWITCH;
7997 }
7998  
7999 6 my $uid = $self->state_user_uid($nick);
8000 6 my $rec = $self->{state}{uids}{$uid};
8001  
8002 6 ▶ if ( !$rec->{last_knock} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rec->{"last_knock"}) 3 3 6
8003 3 $rec->{knock_count} = 0;
8004 }
8005 6 ▶ if ( $rec->{last_knock} && ( $rec->{last_knock} + $self->{config}{knock_client_time} ) < time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"last_knock"} and $rec->{"last_knock"} + $self->{"config"}{"knock_client_time"} < time) 0 6 6
Condition66%2/3
$rec->{"last_knock"} and $rec->{"last_knock"} + $self->{"config"}{"knock_client_time"} < time
!ll&&!rl&&r
330
MC/DC0%0/2
$rec->{"last_knock"} and $rec->{"last_knock"} + $self->{"config"}{"knock_client_time"} < time
$rec->{"last_knock"} $rec->{"last_knock"} + $self->{"config"}{"knock_client_time"} < time
Truth table66%2/3
A and B
A= $rec->{"last_knock"}B= $rec->{"last_knock"} + $self->{"config"}{"knock_client_time"} < time
ABresult
0X0
100
111
8006 0 $rec->{knock_count} = 0;
8007 }
8008 6 ▶ if ( $rec->{knock_count} && $rec->{knock_count} > $self->{config}{knock_client_count} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"knock_count"} and $rec->{"knock_count"} > $self->{"config"}{"knock_client_count"}) 1 5 6
Condition100%3/3
$rec->{"knock_count"} and $rec->{"knock_count"} > $self->{"config"}{"knock_client_count"}
!ll&&!rl&&r
321
MC/DC100%2/2
$rec->{"knock_count"} and $rec->{"knock_count"} > $self->{"config"}{"knock_client_count"}
$rec->{"knock_count"} $rec->{"knock_count"} > $self->{"config"}{"knock_client_count"}
Truth table100%3/3
A and B
A= $rec->{"knock_count"}B= $rec->{"knock_count"} > $self->{"config"}{"knock_client_count"}
ABresult
0X0
100
111
8009 1 push @$ref, ['712', $channel,'user'];
8010 1 last SWITCH;
8011 }
8012 5 ▶ if ( $chanrec->{last_knock} && ( $chanrec->{last_knock} + $self->{config}{knock_delay_channel} ) > time() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"last_knock"} and $chanrec->{"last_knock"} + $self->{"config"}{"knock_delay_channel"} > time) 1 4 5
Condition66%2/3
$chanrec->{"last_knock"} and $chanrec->{"last_knock"} + $self->{"config"}{"knock_delay_channel"} > time
!ll&&!rl&&r
401
MC/DC50%1/2
$chanrec->{"last_knock"} and $chanrec->{"last_knock"} + $self->{"config"}{"knock_delay_channel"} > time
$chanrec->{"last_knock"} $chanrec->{"last_knock"} + $self->{"config"}{"knock_delay_channel"} > time
Truth table66%2/3
A and B
A= $chanrec->{"last_knock"}B= $chanrec->{"last_knock"} + $self->{"config"}{"knock_delay_channel"} > time
ABresult
0X0
100
111
8013 1 push @$ref, ['712', $channel,'channel'];
8014 1 last SWITCH;
8015 }
8016  
8017 4 $rec->{last_knock} = time();
8018 4 $rec->{knock_count}++;
8019  
8020 4 push @$ref, ['711', $channel]; # KNOCK Delivered
8021  
8022 4 $chanrec->{last_knock} = time();
8023  
8024 $self->_send_output_channel_local(
8025 $channel,
8026 {
8027 prefix => $server,
8028 command => 'NOTICE',
8029 params => [
8030 $chanrec->{name},
8031 sprintf("KNOCK: %s (%s [%s] has asked for an invite)",
8032 4 $chanrec->{name}, split /!/, $rec->{full}->() ),
8033 ],
8034 },
8035 '', 'oh',
8036 );
8037 $self->send_output(
8038 {
8039 prefix => $uid,
8040 command => 'KNOCK',
8041 colonify => 0,
8042 params => [ $chanrec->{name} ],
8043 },
8044 4 grep { $self->_state_peer_capab($_,'KNOCK') }
8045 $self->_state_connected_peers(),
8046 );
8047 }
8048  
8049 7 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 7 0 7
8050 0 return $ref;
8051 }
8052  
8053 0 ▶sub _daemon_peer_certfp {
Subroutine _daemon_peer_certfp: not called CC=7 SCAR=40.3
8054 0 my $self = shift;
8055 0 ▶ my $peer_id = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
8056 0 ▶ my $prefix = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
8057 0 my $ref = [ ];
8058 0 my $args = [@_];
8059  
8060 SWITCH: {
8061 0 ▶ if ($prefix !~ $uid_re) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($prefix =~ /$uid_re/) 0 0 0
8062 0 last SWITCH;
8063 }
8064 0 ▶ if(!$args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0]) 0 0 0
8065 0 last SWITCH;
8066 }
8067 0 my $uid = $self->state_user_uid($prefix);
8068 0 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 0 0
8069 0 $self->{state}{uids}{$uid}{certfp} = $args->[0];
8070 $self->send_output(
8071 {
8072 prefix => $prefix,,
8073 command => 'CERTFP',
8074 colonify => 0,
8075 params => $args,
8076 },
8077 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
8078 );
8079 }
8080  
8081 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
8082 0 return $ref;
8083 }
8084  
8085 1 ▶sub _daemon_peer_knock {
Subroutine _daemon_peer_knock: called CC=7 SCAR=20.4
8086 1 my $self = shift;
8087 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8088 1 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8089 1 my $sid = $self->server_sid();
8090 1 my $ref = [ ];
8091 1 my $args = [ @_ ];
8092 1 my $count = @$args;
8093  
8094 SWITCH: {
8095 1 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 1 1
8096 0 last SWITCH;
8097 }
8098 1 my $channel = shift @$args;
8099 1 ▶ if ( !$self->state_chan_exists($channel) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($channel)) 0 1 1
8100 0 last SWITCH;
8101 }
8102 1 my $chanrec = $self->{state}{chans}{uc_irc $channel};
8103 1 $chanrec->{last_knock} = time();
8104 $self->_send_output_channel_local(
8105 $channel,
8106 {
8107 prefix => $self->server_name(),
8108 command => 'NOTICE',
8109 params => [
8110 $chanrec->{name},
8111 sprintf("KNOCK: %s (%s [%s] has asked for an invite)",
8112 1 $chanrec->{name}, split /!/, $self->state_user_full($prefix) ),
8113 ],
8114 },
8115 '', 'oh',
8116 );
8117 $self->send_output(
8118 {
8119 prefix => $prefix,,
8120 command => 'KNOCK',
8121 colonify => 0,
8122 params => [ $chanrec->{name} ],
8123 },
8124 1 ▶ grep { $_ ne $peer_id && $self->_state_peer_capab($_,'KNOCK') }
Condition66%2/3
$_ ne $peer_id && $self->_state_peer_capab($_, 'KNOCK')
!ll&&!rl&&r
101
MC/DC50%1/2
$_ ne $peer_id && $self->_state_peer_capab($_, 'KNOCK')
$_ ne $peer_id $self->_state_peer_capab($_, 'KNOCK')
Truth table66%2/3
A && B
A= $_ ne $peer_idB= $self->_state_peer_capab($_, 'KNOCK')
ABresult
0X0
100
111
8125 $self->_state_connected_peers(),
8126 );
8127 }
8128  
8129 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
8130 1 return $ref;
8131 }
8132  
8133 226 ▶sub _daemon_peer_squit {
Subroutine _daemon_peer_squit: called CC=17 SCAR=30.0
8134 226 my $self = shift;
8135 226 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8136 226 my $sid = $self->server_sid();
8137 226 my $ref = [ ];
8138 226 my $args = [ @_ ];
8139 226 my $count = @$args;
8140 226 ▶ return if !$self->state_sid_exists($args->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($args->[0]) 0 226 226
8141  
8142 SWITCH: {
8143 226 ▶ if ($peer_id ne $self->_state_sid_route($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer_id ne $self->_state_sid_route($args->[0])) 0 226 226
8144 0 $self->send_output(
8145 {
8146 command => 'SQUIT',
8147 params => $args,
8148 },
8149 $self->_state_sid_route($args->[0]),
8150 );
8151 0 last SWITCH;
8152 }
8153 226 ▶ if ($peer_id eq $self->_state_sid_route($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer_id eq $self->_state_sid_route($args->[0])) 226 0 226
8154 $self->send_output(
8155 {
8156 command => 'SQUIT',
8157 params => $args,
8158 },
8159 226 grep { $_ ne $peer_id } $self->_state_connected_peers(),
8160 );
8161 226 my $qsid = $args->[0];
8162 226 my $qpeer = $self->_state_sid_name($qsid);
8163 226 $self->send_event("daemon_squit", $qpeer, $args->[1]);
8164 my $quit_msg = join ' ',
8165 226 $self->{state}{sids}{$qsid}{peer}, $qpeer;
8166  
8167 226 ▶ if ($sid eq $self->{state}{sids}{$qsid}{psid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $self->{'state'}{'sids'}{$qsid}{'psid'}) { } 225 1 226
8168 225 my $stats = $self->{state}{conns}{$peer_id}{stats}->stats();
8169 $self->_send_to_realops(
8170 sprintf(
8171 '%s was connected for %s. %s/%s sendK/recvK.',
8172 225 $qpeer, _duration(time() - $self->{state}{sids}{$qsid}{conn_time}),
8173 ( $stats->[0] >> 10 ), ( $stats->[1] >> 10 ),
8174 ), qw[Notice e],
8175 );
8176 }
8177 else {
8178 $self->_send_to_realops(
8179 sprintf(
8180 'Server %s split from %s',
8181 $qpeer, $self->{state}{sids}{$qsid}{peer},
8182 1 ), qw[Notice e],
8183 );
8184 }
8185 226 for my $uid ($self->_state_server_squit($qsid)) {
8186 517 my $output = {
8187 prefix => $self->state_user_full($uid),
8188 command => 'QUIT',
8189 params => [$quit_msg],
8190 };
8191 517 my $common = { };
8192 517 for my $uchan ( keys %{ $self->{state}{uids}{$uid}{chans} } ) {
8193 1988 delete $self->{state}{chans}{$uchan}{users}{$uid};
8194 1988 for my $user ( keys %{ $self->{state}{chans}{$uchan}{users} } ) {
8195 124631 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 124626 5 124631
8196 5 $common->{$user} = $self->_state_uid_route($user);
8197 }
8198 1988 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 57 1931 1988
8199 57 delete $self->{state}{chans}{$uchan};
8200 }
8201 }
8202 517 $self->send_output($output, values %$common);
8203 $self->send_event(
8204 "daemon_quit",
8205 $output->{prefix},
8206 517 $output->{params}[0],
8207 );
8208 517 my $record = delete $self->{state}{uids}{$uid};
8209 517 my $nick = uc_irc $record->{nick};
8210 517 delete $self->{state}{users}{$nick};
8211 # WATCH LOGOFF
8212 517 ▶ if ( defined $self->{state}{watches}{$nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$nick}) 0 517 517
8213 0 my $laston = time();
8214 0 $self->{state}{watches}{$nick}{laston} = $laston;
8215 0 foreach my $wuid ( keys %{ $self->{state}{watches}{$nick}{uids} } ) {
8216 0 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 0 0
8217 0 my $wrec = $self->{state}{uids}{$wuid};
8218 $self->send_output(
8219 {
8220 prefix => $record->{server},
8221 command => '601',
8222 params => [
8223 $wrec->{nick},
8224 $record->{nick},
8225 $record->{auth}{ident},
8226 $record->{auth}{hostname},
8227 $laston,
8228 'logged offline',
8229 ],
8230 },
8231 $wrec->{route_id},
8232 0 );
8233 }
8234 }
8235 517 ▶ if ($record->{umode} =~ /o/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /o/) 214 303 517
8236 214 $self->{state}{stats}{ops_online}--;
8237 }
8238 517 ▶ if ($record->{umode} =~ /i/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /i/) 517 0 517
8239 517 $self->{state}{stats}{invisible}--;
8240 }
8241 517 unshift @{ $self->{state}{whowas}{$nick} }, {
8242 logoff => time(),
8243 account => $record->{account},
8244 nick => $record->{nick},
8245 user => $record->{auth}{ident},
8246 host => $record->{auth}{hostname},
8247 real => $record->{auth}{realhost},
8248 sock => $record->{ipaddress},
8249 ircname => $record->{ircname},
8250 server => $record->{server},
8251 517 };
8252 }
8253 226 last SWITCH;
8254 }
8255 }
8256  
8257 226 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 226 226
8258 226 return $ref;
8259 }
8260  
8261 2 ▶sub _daemon_peer_resv {
Subroutine _daemon_peer_resv: called CC=16 SCAR=30.7
8262 2 my $self = shift;
8263 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8264 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8265 2 my $server = $self->server_name();
8266 2 my $sid = $self->server_sid();
8267 2 my $ref = [ ];
8268 2 my $args = [ @_ ];
8269 2 my $count = @$args;
8270  
8271 SWITCH: {
8272 2 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 2 2
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
8273 0 last SWITCH;
8274 }
8275 2 my ($peermask,$duration,$mask,$reason) = @$args;
8276 2 ▶ $reason = '<No reason supplied>' if !$reason;
Branch: 1 branch
BranchTrueFalseTotal
unless $reason 0 2 2
8277 2 my $us = 0;
8278 {
8279 2 my %targpeers;
8280 2 my $sids = $self->{state}{sids};
8281 2 foreach my $psid ( keys %{ $sids } ) {
8282 8 ▶ if (matches_mask($peermask, $sids->{$psid}{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $sids->{$psid}{"name"})) 8 0 8
8283 8 ▶ if ($sid eq $psid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $psid) { } 2 6 8
8284 2 $us = 1;
8285 }
8286 else {
8287 6 $targpeers{ $sids->{$psid}{route_id} }++;
8288 }
8289 }
8290 }
8291 2 delete $targpeers{$peer_id};
8292 $self->send_output(
8293 {
8294 prefix => $uid,
8295 command => 'RESV',
8296 params => [
8297 $peermask,
8298 $duration,
8299 $mask,
8300 $reason,
8301 ],
8302 },
8303 2 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
8304 );
8305 }
8306  
8307 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
8308  
8309 2 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 0 2 2
8310 0 ▶ $reason = shift @$args || '<No reason supplied>';
Condition0%0/2
shift @$args || '<No reason supplied>'
l!l
00
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table0%0/2
A
A= shift @$args
Aresult
11
00
8311 }
8312  
8313 2 ▶ if ( $self->_state_have_resv($mask) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_have_resv($mask)) 0 2 2
8314 0 push @$ref, {
8315 prefix => $sid,
8316 command => 'NOTICE',
8317 params => [ $uid, "A RESV has already been placed on: $mask" ],
8318 };
8319 0 last SWITCH;
8320 }
8321  
8322 2 my $full = $self->state_user_full($uid);
8323  
8324 2 ▶ last SWITCH if !$self->_state_add_drkx_line( 'resv', $full, time(), $server,
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("resv", $full, time, $server, $duration, $mask, $reason) 0 2 2
8325 $duration, $mask, $reason );
8326 2 my $minutes = $duration / 60;
8327  
8328 2 $self->send_event(
8329 "daemon_resv",
8330 $full,
8331 $mask,
8332 $minutes,
8333 $reason,
8334 );
8335  
8336 2 ▶ my $temp = $duration ? "temporary $minutes min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 0 2
8337  
8338 2 my $reply_notice = "Added ${temp}RESV [$mask]";
8339 2 my $locop_notice = "$full added ${temp}RESV for [$mask] [$reason]";
8340  
8341 2 push @$ref, {
8342 prefix => $sid,
8343 command => 'NOTICE',
8344 params => [ $uid, $reply_notice ],
8345 };
8346  
8347 2 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
8348 }
8349  
8350 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
8351 0 return $ref;
8352 }
8353  
8354 1 ▶sub _daemon_peer_unresv {
Subroutine _daemon_peer_unresv: called CC=11 SCAR=25.3
8355 1 my $self = shift;
8356 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8357 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8358 1 my $server = $self->server_name();
8359 1 my $sid = $self->server_sid();
8360 1 my $ref = [ ];
8361 1 my $args = [ @_ ];
8362 1 my $count = @$args;
8363  
8364  
8365 SWITCH: {
8366 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
8367 0 last SWITCH;
8368 }
8369 1 my ($peermask,$unmask) = @$args;
8370 1 my $us = 0;
8371 {
8372 1 my %targpeers;
8373 1 my $sids = $self->{state}{sids};
8374 1 foreach my $psid ( keys %{ $sids } ) {
8375 4 ▶ if (matches_mask($peermask, $sids->{$psid}{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $sids->{$psid}{"name"})) 4 0 4
8376 4 ▶ if ($sid eq $psid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $psid) { } 1 3 4
8377 1 $us = 1;
8378 }
8379 else {
8380 3 $targpeers{ $sids->{$psid}{route_id} }++;
8381 }
8382 }
8383 }
8384 1 delete $targpeers{$peer_id};
8385 $self->send_output(
8386 {
8387 prefix => $uid,
8388 command => 'UNRESV',
8389 params => [
8390 $peermask,
8391 $unmask,
8392 ],
8393 colonify => 0,
8394 },
8395 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
8396 );
8397 }
8398  
8399 1 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 1 1
8400  
8401 1 my $result = $self->_state_del_drkx_line( 'resv', $unmask );
8402  
8403 1 my $full = $self->state_user_full($uid);
8404  
8405 1 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 1 1
8406 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $uid, "No RESV for [$unmask] found" ] };
8407 0 last SWITCH;
8408 }
8409  
8410 $self->send_event(
8411 1 "daemon_unresv",
8412 $full,
8413 $unmask,
8414 );
8415  
8416 1 push @$ref, {
8417 prefix => $sid,
8418 command => 'NOTICE',
8419 params => [ $uid, "RESV for [$unmask] is removed" ],
8420 };
8421  
8422 1 $self->_send_to_realops( "$full has removed the RESV for: [$unmask]", 'Notice', 's' );
8423  
8424 }
8425  
8426 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
8427 0 return $ref;
8428 }
8429  
8430 2 ▶sub _daemon_peer_xline {
Subroutine _daemon_peer_xline: called CC=15 SCAR=29.2
8431 2 my $self = shift;
8432 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8433 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8434 2 my $server = $self->server_name();
8435 2 my $sid = $self->server_sid();
8436 2 my $ref = [ ];
8437 2 my $args = [ @_ ];
8438 2 my $count = @$args;
8439  
8440 SWITCH: {
8441 2 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 2 2
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
8442 0 last SWITCH;
8443 }
8444 2 my ($peermask,$duration,$mask,$reason) = @$args;
8445 2 ▶ $reason = '<No reason supplied>' if !$reason;
Branch: 1 branch
BranchTrueFalseTotal
unless $reason 0 2 2
8446 2 my $us = 0;
8447 {
8448 2 my %targpeers;
8449 2 my $sids = $self->{state}{sids};
8450 2 foreach my $psid ( keys %{ $sids } ) {
8451 8 ▶ if (matches_mask($peermask, $sids->{$psid}{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $sids->{$psid}{"name"})) 8 0 8
8452 8 ▶ if ($sid eq $psid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $psid) { } 2 6 8
8453 2 $us = 1;
8454 }
8455 else {
8456 6 $targpeers{ $sids->{$psid}{route_id} }++;
8457 }
8458 }
8459 }
8460 2 delete $targpeers{$peer_id};
8461 $self->send_output(
8462 {
8463 prefix => $uid,
8464 command => 'XLINE',
8465 params => [
8466 $peermask,
8467 $duration,
8468 $mask,
8469 $reason,
8470 ],
8471 },
8472 2 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
8473 );
8474 }
8475  
8476 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
8477  
8478 2 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 0 2 2
8479 0 ▶ $reason = shift @$args || '<No reason supplied>';
Condition0%0/2
shift @$args || '<No reason supplied>'
l!l
00
MC/DC0%0/1
shift @$args || '<No reason supplied>'
shift @$args
Truth table0%0/2
A
A= shift @$args
Aresult
11
00
8480 }
8481  
8482 2 my $full = $self->state_user_full($uid);
8483  
8484 2 ▶ last SWITCH if !$self->_state_add_drkx_line( 'xline', $full, time(), $server,
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("xline", $full, time, $server, $duration, $mask, $reason) 0 2 2
8485 $duration, $mask, $reason );
8486 2 my $minutes = $duration / 60;
8487  
8488 2 $self->send_event(
8489 "daemon_xline",
8490 $full,
8491 $mask,
8492 $minutes,
8493 $reason,
8494 );
8495  
8496 2 ▶ my $temp = $duration ? "temporary $minutes min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 0 2
8497  
8498 2 my $reply_notice = "Added ${temp}X-Line [$mask]";
8499 2 my $locop_notice = "$full added ${temp}X-Line for [$mask] [$reason]";
8500  
8501 2 push @$ref, {
8502 prefix => $sid,
8503 command => 'NOTICE',
8504 params => [ $uid, $reply_notice ],
8505 };
8506  
8507 2 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
8508  
8509 2 $self->_state_do_local_users_match_xline($mask,$reason);
8510 }
8511  
8512 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
8513 0 return $ref;
8514 }
8515  
8516 1 ▶sub _daemon_peer_unxline {
Subroutine _daemon_peer_unxline: called CC=11 SCAR=25.3
8517 1 my $self = shift;
8518 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8519 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8520 1 my $server = $self->server_name();
8521 1 my $sid = $self->server_sid();
8522 1 my $ref = [ ];
8523 1 my $args = [ @_ ];
8524 1 my $count = @$args;
8525  
8526  
8527 SWITCH: {
8528 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
8529 0 last SWITCH;
8530 }
8531 1 my ($peermask,$unmask) = @$args;
8532 1 my $us = 0;
8533 {
8534 1 my %targpeers;
8535 1 my $sids = $self->{state}{sids};
8536 1 foreach my $psid ( keys %{ $sids } ) {
8537 4 ▶ if (matches_mask($peermask, $sids->{$psid}{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $sids->{$psid}{"name"})) 4 0 4
8538 4 ▶ if ($sid eq $psid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $psid) { } 1 3 4
8539 1 $us = 1;
8540 }
8541 else {
8542 3 $targpeers{ $sids->{$psid}{route_id} }++;
8543 }
8544 }
8545 }
8546 1 delete $targpeers{$peer_id};
8547 $self->send_output(
8548 {
8549 prefix => $uid,
8550 command => 'UNXLINE',
8551 params => [
8552 $peermask,
8553 $unmask,
8554 ],
8555 colonify => 0,
8556 },
8557 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
8558 );
8559 }
8560  
8561 1 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 1 1
8562  
8563 1 my $result = $self->_state_del_drkx_line( 'xline', $unmask );
8564  
8565 1 my $full = $self->state_user_full($uid);
8566  
8567 1 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 1 1
8568 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $uid, "No X-Line for [$unmask] found" ] };
8569 0 last SWITCH;
8570 }
8571  
8572 $self->send_event(
8573 1 "daemon_unxline",
8574 $full,
8575 $unmask,
8576 );
8577  
8578 1 push @$ref, {
8579 prefix => $sid,
8580 command => 'NOTICE',
8581 params => [ $uid, "X-Line for [$unmask] is removed" ],
8582 };
8583  
8584 1 $self->_send_to_realops( "$full has removed the X-Line for: [$unmask]", 'Notice', 's' );
8585  
8586 }
8587  
8588 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
8589 0 return $ref;
8590 }
8591  
8592 2 ▶sub _daemon_peer_dline {
Subroutine _daemon_peer_dline: called CC=14 SCAR=27.6
8593 2 my $self = shift;
8594 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8595 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8596 2 my $server = $self->server_name();
8597 2 my $sid = $self->server_sid();
8598 2 my $ref = [ ];
8599 2 my $args = [ @_ ];
8600 2 my $count = @$args;
8601  
8602 SWITCH: {
8603 2 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 2 2
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
8604 0 last SWITCH;
8605 }
8606 2 my ($peermask,$duration,$netmask,$reason) = @$args;
8607 2 ▶ $reason = '<No reason supplied>' if !$reason;
Branch: 1 branch
BranchTrueFalseTotal
unless $reason 0 2 2
8608 2 my $us = 0;
8609 {
8610 2 my %targpeers;
8611 2 my $sids = $self->{state}{sids};
8612 2 foreach my $psid ( keys %{ $sids } ) {
8613 8 ▶ if (matches_mask($peermask, $sids->{$psid}{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $sids->{$psid}{"name"})) 8 0 8
8614 8 ▶ if ($sid eq $psid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $psid) { } 2 6 8
8615 2 $us = 1;
8616 }
8617 else {
8618 6 $targpeers{ $sids->{$psid}{route_id} }++;
8619 }
8620 }
8621 }
8622 2 delete $targpeers{$peer_id};
8623 $self->send_output(
8624 {
8625 prefix => $uid,
8626 command => 'DLINE',
8627 params => [
8628 $peermask,
8629 $duration,
8630 $netmask,
8631 $reason,
8632 ],
8633 },
8634 2 grep { $self->_state_peer_capab($_, 'DLN') } keys %targpeers,
8635 );
8636 }
8637  
8638 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
8639  
8640 2 $netmask = Net::CIDR::cidrvalidate($netmask);
8641  
8642 2 ▶ last SWITCH if !$netmask;
Branch: 1 branch
BranchTrueFalseTotal
unless $netmask 0 2 2
8643  
8644 2 my $full = $self->state_user_full($uid);
8645  
8646 2 my $minutes = $duration / 60;
8647  
8648 2 ▶ last SWITCH if !$self->_state_add_drkx_line( 'dline',
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("dline", $full, time, $server, $duration, $netmask, $reason) 0 2 2
8649 $full, time, $server, $duration,
8650 $netmask, $reason );
8651  
8652 2 $self->send_event(
8653 "daemon_dline",
8654 $full,
8655 $netmask,
8656 $minutes,
8657 $reason,
8658 );
8659  
8660 2 $self->add_denial( $netmask, 'You have been D-lined.' );
8661  
8662 2 ▶ my $temp = $duration ? "temporary $minutes min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 0 2
8663  
8664 2 my $reply_notice = "Added ${temp}D-Line [$netmask]";
8665 2 my $locop_notice = "$full added ${temp}D-Line for [$netmask] [$reason]";
8666  
8667 2 push @$ref, {
8668 prefix => $sid,
8669 command => 'NOTICE',
8670 params => [ $uid, $reply_notice ],
8671 };
8672  
8673 2 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
8674  
8675 2 $self->_state_do_local_users_match_dline($netmask,$reason);
8676 }
8677  
8678 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
8679 0 return $ref;
8680 }
8681  
8682 1 ▶sub _daemon_peer_undline {
Subroutine _daemon_peer_undline: called CC=11 SCAR=25.3
8683 1 my $self = shift;
8684 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8685 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8686 1 my $server = $self->server_name();
8687 1 my $sid = $self->server_sid();
8688 1 my $ref = [ ];
8689 1 my $args = [ @_ ];
8690 1 my $count = @$args;
8691  
8692  
8693 SWITCH: {
8694 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
8695 0 last SWITCH;
8696 }
8697 1 my ($peermask,$unmask) = @$args;
8698 1 my $us = 0;
8699 {
8700 1 my %targpeers;
8701 1 my $sids = $self->{state}{sids};
8702 1 foreach my $psid ( keys %{ $sids } ) {
8703 4 ▶ if (matches_mask($peermask, $sids->{$psid}{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $sids->{$psid}{"name"})) 4 0 4
8704 4 ▶ if ($sid eq $psid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $psid) { } 1 3 4
8705 1 $us = 1;
8706 }
8707 else {
8708 3 $targpeers{ $sids->{$psid}{route_id} }++;
8709 }
8710 }
8711 }
8712 1 delete $targpeers{$peer_id};
8713 $self->send_output(
8714 {
8715 prefix => $uid,
8716 command => 'UNDLINE',
8717 params => [
8718 $peermask,
8719 $unmask,
8720 ],
8721 colonify => 0,
8722 },
8723 1 grep { $self->_state_peer_capab($_, 'UNDLN') } keys %targpeers,
8724 );
8725 }
8726  
8727 1 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 1 1
8728  
8729 1 my $result = $self->_state_del_drkx_line( 'dline', $unmask );
8730  
8731 1 my $full = $self->state_user_full($uid);
8732  
8733 1 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 1 1
8734 0 push @$ref, { prefix => $sid, command => 'NOTICE', params => [ $uid, "No D-Line for [$unmask] found" ] };
8735 0 last SWITCH;
8736 }
8737  
8738 $self->send_event(
8739 1 "daemon_undline",
8740 $full,
8741 $unmask,
8742 );
8743  
8744 1 $self->del_denial( $unmask );
8745  
8746 1 push @$ref, {
8747 prefix => $sid,
8748 command => 'NOTICE',
8749 params => [ $uid, "D-Line for [$unmask] is removed" ],
8750 };
8751  
8752 1 $self->_send_to_realops( "$full has removed the D-Line for: [$unmask]", 'Notice', 's' );
8753  
8754 }
8755  
8756 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
8757 0 return $ref;
8758 }
8759  
8760 2 ▶sub _daemon_peer_encap {
Subroutine _daemon_peer_encap: called CC=10 SCAR=23.8
8761 2 my $self = shift;
8762 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8763 2 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8764 2 my $server = $self->server_name();
8765 2 my $ref = [ ];
8766 2 my $args = [ @_ ];
8767 2 my $count = @$args;
8768  
8769 SWITCH: {
8770 2 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
8771 0 last SWITCH;
8772 }
8773 2 my $target = $args->[0];
8774 2 my $us = 0;
8775 2 my $ucserver = uc $server;
8776 2 my %targets;
8777  
8778 2 for my $peer (keys %{ $self->{state}{peers} }) {
8779 8 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 8 0 8
8780 8 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 2 6 8
8781 2 $us = 1;
8782 }
8783 else {
8784 6 $targets{$self->_state_peer_route($peer)}++;
8785 }
8786 }
8787 }
8788 2 delete $targets{$peer_id};
8789 $self->send_output(
8790 {
8791 prefix => $prefix,
8792 command => 'ENCAP',
8793 params => $args,
8794 colonify => 1,
8795 },
8796 2 grep { $self->_state_peer_capab($_, 'ENCAP') } keys %targets,
8797 );
8798  
8799 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
8800  
8801 2 ▶ $self->send_event(
Condition33%1/3
$self->_state_sid_name($prefix) || $self->state_user_full($prefix)
l!l&&r!l&&!r
200
MC/DC0%0/2
$self->_state_sid_name($prefix) || $self->state_user_full($prefix)
$self->_state_sid_name($prefix) $self->state_user_full($prefix)
Truth table33%1/3
A || B
A= $self->_state_sid_name($prefix)B= $self->state_user_full($prefix)
ABresult
1X1
011
000
8802 'daemon_encap',
8803 ( $self->_state_sid_name($prefix) || $self->state_user_full($prefix) ),
8804 @$args,
8805 );
8806  
8807 # Add ENCAP subcommand handling here if required.
8808 }
8809  
8810 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
8811 2 return $ref;
8812 }
8813  
8814 2 ▶sub _daemon_peer_kline {
Subroutine _daemon_peer_kline: called CC=12 SCAR=25.9
8815 2 my $self = shift;
8816 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8817 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8818 2 my $server = $self->server_name();
8819 2 my $ref = [ ];
8820 2 my $args = [ @_ ];
8821 2 my $count = @$args;
8822  
8823 SWITCH: {
8824 2 ▶ if (!$count || $count < 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 5) 0 2 2
Condition33%1/3
not $count or $count < 5
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 5
not $count $count < 5
Truth table33%1/3
not(A) or B
A= not $countB= $count < 5
ABresult
1X1
011
000
8825 0 last SWITCH;
8826 }
8827 2 my $full = $self->state_user_full($uid);
8828 2 my $target = $args->[0];
8829 2 my $us = 0;
8830 2 my $ucserver = uc $server;
8831 2 my %targets;
8832  
8833 2 for my $peer (keys %{ $self->{state}{peers} }) {
8834 8 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 8 0 8
8835 8 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 2 6 8
8836 2 $us = 1;
8837 }
8838 else {
8839 6 $targets{$self->_state_peer_route($peer)}++;
8840 }
8841 }
8842 }
8843 2 delete $targets{$peer_id};
8844 $self->send_output(
8845 {
8846 prefix => $uid,
8847 command => 'KLINE',
8848 params => $args,
8849 colonify => 0,
8850 },
8851 2 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
8852 );
8853  
8854 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
8855  
8856 2 ▶ last SWITCH if !$self->_state_add_drkx_line( 'kline', $full, time(), @$args );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_add_drkx_line("kline", $full, time, @$args) 0 2 2
8857  
8858 2 my $minutes = $args->[1] / 60;
8859 2 $args->[1] = $minutes;
8860  
8861 2 $self->send_event("daemon_kline", $full, @$args);
8862  
8863 2 ▶ my $temp = $minutes ? "temporary $minutes min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$minutes ? : 2 0 2
8864  
8865 2 my $reply_notice = sprintf('Added %sK-Line [%s@%s]', $temp, $args->[2], $args->[3]);
8866 2 my $locop_notice = sprintf('%s added %sK-Line for [%s@%s] [%s]',
8867 $full, $temp, $args->[2], $args->[3], $args->[4] );
8868  
8869 2 push @$ref, {
8870 prefix => $self->server_sid(),
8871 command => 'NOTICE',
8872 params => [ $uid, $reply_notice ],
8873 };
8874  
8875 2 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
8876  
8877 2 $self->_state_do_local_users_match_kline($args->[2], $args->[3], $args->[4]);
8878 }
8879  
8880 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
8881 0 return $ref;
8882 }
8883  
8884 1 ▶sub _daemon_peer_unkline {
Subroutine _daemon_peer_unkline: called CC=11 SCAR=25.3
8885 1 my $self = shift;
8886 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8887 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
8888 1 my $server = $self->server_name();
8889 1 my $ref = [ ];
8890 1 my $args = [ @_ ];
8891 1 my $count = @$args;
8892  
8893 # :klanker UNKLINE logserv.gumbynet.org.uk * moos.loud.me.uk
8894 SWITCH: {
8895 1 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 1 1
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
8896 0 last SWITCH;
8897 }
8898 1 my $full = $self->state_user_full($uid);
8899 1 my $target = $args->[0];
8900 1 my $us = 0;
8901 1 my $ucserver = uc $server;
8902 1 my %targets;
8903  
8904 1 for my $peer (keys %{ $self->{state}{peers} }) {
8905 4 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 4 0 4
8906 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
8907 1 $us = 1;
8908 }
8909 else {
8910 3 $targets{$self->_state_peer_route($peer)}++;
8911 }
8912 }
8913 }
8914 1 delete $targets{$peer_id};
8915 $self->send_output(
8916 {
8917 prefix => $uid,
8918 command => 'UNKLINE',
8919 params => $args,
8920 colonify => 0,
8921 },
8922 1 grep { $self->_state_peer_capab($_, 'UNKLN') } keys %targets,
8923 );
8924  
8925 1 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 1 1
8926  
8927 1 my $result = $self->_state_del_drkx_line( 'kline', $args->[1], $args->[2] );
8928  
8929 1 my $sid = $self->server_sid();
8930  
8931 1 my $unmask = join '@', $args->[1], $args->[2];
8932  
8933 1 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 1 1
8934 0 push @$ref, { prefix => $sid, command => 'NOTICE', params => [ $uid, "No K-Line for [$unmask] found" ] };
8935 0 last SWITCH;
8936 }
8937  
8938 1 $self->send_event("daemon_unkline", $full, @$args);
8939  
8940 1 push @$ref, {
8941 prefix => $sid,
8942 command => 'NOTICE',
8943 params => [ $uid, "K-Line for [$unmask] is removed" ],
8944 };
8945  
8946 1 $self->_send_to_realops( "$full has removed the K-Line for: [$unmask]", 'Notice', 's' );
8947 }
8948  
8949 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
8950 0 return $ref;
8951 }
8952  
8953 0 ▶sub _daemon_peer_wallops {
Subroutine _daemon_peer_wallops: not called CC=5 SCAR=34.0
8954 0 my $self = shift;
8955 0 ▶ my $peer_id = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
8956 0 ▶ my $prefix = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
8957 0 my $ref = [ ];
8958 0 my $args = [ @_ ];
8959 0 my $count = @$args;
8960  
8961 SWITCH: {
8962 0 $self->send_output(
8963 {
8964 prefix => $prefix,
8965 command => 'WALLOPS',
8966 params => [$args->[0]],
8967 },
8968 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
8969 );
8970 # Prefix can either be SID or UID
8971 0 my $full = $self->_state_sid_name( $prefix );
8972 0 ▶ $full = $self->state_user_full( $prefix ) if !$full;
Branch: 1 branch
BranchTrueFalseTotal
unless $full 0 0 0
8973  
8974 $self->send_output(
8975 {
8976 prefix => $full,
8977 command => 'WALLOPS',
8978 params => [$args->[0]],
8979 },
8980 0 keys %{ $self->{state}{wallops} },
8981 );
8982 0 $self->send_event("daemon_wallops", $full, $args->[0]);
8983 }
8984  
8985 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
8986 0 return $ref;
8987 }
8988  
8989 0 ▶sub _daemon_peer_globops {
Subroutine _daemon_peer_globops: not called CC=5 SCAR=34.0
8990 0 my $self = shift;
8991 0 ▶ my $peer_id = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
8992 0 ▶ my $prefix = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
8993 0 my $ref = [ ];
8994 0 my $args = [ @_ ];
8995 0 my $count = @$args;
8996  
8997 SWITCH: {
8998 # Hot potato
8999 0 $self->send_output(
9000 {
9001 prefix => $prefix,
9002 command => 'GLOBOPS',
9003 params => [$args->[0]],
9004 },
9005 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
9006 );
9007 # Prefix can either be SID or UID
9008 0 my $full = $self->_state_sid_name( $prefix );
9009 0 ▶ $full = $self->state_user_nick( $prefix ) if !$full;
Branch: 1 branch
BranchTrueFalseTotal
unless $full 0 0 0
9010  
9011 0 my $msg = "from $full: " . $args->[0];
9012  
9013 0 $self->_send_to_realops(
9014 $msg, 'globops', 's',
9015 );
9016  
9017 0 $self->send_event("daemon_globops", $full, $args->[0]);
9018 }
9019  
9020 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
9021 0 return $ref;
9022 }
9023  
9024 382 ▶sub _daemon_peer_eob {
Subroutine _daemon_peer_eob: called CC=5 SCAR=16.3
9025 382 my $self = shift;
9026 382 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
3820
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9027 382 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
3820
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9028 382 my $ref = [ ];
9029 382 ▶ if ($self->{state}{conns}{$peer_id}{sid} eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"conns"}{$peer_id}{"sid"} eq $peer) 254 128 382
9030 254 my $crec = $self->{state}{conns}{$peer_id};
9031 $self->_send_to_realops(
9032 sprintf(
9033 'End of burst from %s (%u seconds)',
9034 254 $crec->{name}, ( time() - $crec->{conn_time} ),
9035 ),
9036 'Notice',
9037 's',
9038 );
9039 }
9040 382 $self->send_event('daemon_eob', $self->{state}{sids}{$peer}{name}, $peer);
9041 382 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 382 382
9042 382 return $ref;
9043 }
9044  
9045 5 ▶sub _daemon_peer_kill {
Subroutine _daemon_peer_kill: called CC=9 SCAR=33.3
9046 5 my $self = shift;
9047 5 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9048 5 ▶ my $killer = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9049 5 my $server = $self->server_name();
9050 5 my $ref = [ ];
9051 5 my $args = [ @_ ];
9052 5 my $count = @$args;
9053  
9054 SWITCH: {
9055 5 ▶ if ($self->state_sid_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_sid_exists($args->[0])) 0 5 5
9056 0 last SWITCH;
9057 }
9058 5 ▶ if (!$self->state_uid_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_uid_exists($args->[0])) 5 0 5
9059 5 last SWITCH;
9060 }
9061  
9062 0 my $target = $args->[0];
9063 0 my $comment = $args->[1];
9064 0 ▶ if ($self->_state_is_local_uid($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_uid($target)) { } 0 0 0
9065 0 my $route_id = $self->_state_uid_route($target);
9066 $self->send_output(
9067 {
9068 prefix => $killer,
9069 command => 'KILL',
9070 params => [
9071 $target,
9072 join('!', $server, $comment),
9073 ],
9074 0 }, grep { $_ ne $peer_id } $self->_state_connected_peers()
9075 );
9076  
9077 0 ▶ $self->send_output(
Condition0%0/3
$self->_state_sid_name($killer) || $self->state_user_full($killer)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_state_sid_name($killer) || $self->state_user_full($killer)
$self->_state_sid_name($killer) $self->state_user_full($killer)
Truth table0%0/3
A || B
A= $self->_state_sid_name($killer)B= $self->state_user_full($killer)
ABresult
1X1
011
000
9078 {
9079 prefix => ( $self->_state_sid_name($killer) || $self->state_user_full($killer) ),
9080 command => 'KILL',
9081 params => [
9082 $target,
9083 join('!', $server, $comment),
9084 ],
9085 },
9086 $route_id,
9087 );
9088  
9089 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
9090 0 $self->call(
9091 'del_spoofed_nick',
9092 $target,
9093 "Killed ($comment)",
9094 );
9095 }
9096 else {
9097 0 $self->{state}{conns}{$route_id}{killed} = 1;
9098 0 $self->_terminate_conn_error(
9099 $route_id,
9100 "Killed ($comment)",
9101 );
9102 }
9103 }
9104 else {
9105 0 $self->{state}{uids}{$target}{killed} = 1;
9106 $self->send_output(
9107 {
9108 prefix => $killer,
9109 command => 'KILL',
9110 params => [$target, join('!', $server, $comment)],
9111 },
9112 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
9113 );
9114 $self->send_output(
9115 0 @{ $self->_daemon_peer_quit(
9116 $target, "Killed ($killer ($comment))" ) },
9117 );
9118 }
9119 }
9120  
9121 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 5 5
9122 5 return $ref;
9123 }
9124  
9125 255 ▶sub _daemon_peer_svinfo {
Subroutine _daemon_peer_svinfo: called CC=5 SCAR=16.3
9126 255 my $self = shift;
9127 255 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2550
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9128 255 my $ref = [ ];
9129 255 my $args = [ @_ ];
9130 255 my $count = @$args;
9131 # SVINFO 6 6 0 :1525185763
9132 255 ▶ if ( !( $args->[0] eq '6' && $args->[1] eq '6' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0] eq 6 and $args->[1] eq 6) 1 254 255
Condition66%2/3
$args->[0] eq 6 and $args->[1] eq 6
!ll&&!rl&&r
01254
MC/DC50%1/2
$args->[0] eq 6 and $args->[1] eq 6
$args->[0] eq 6 $args->[1] eq 6
Truth table66%2/3
A and B
A= $args->[0] eq 6B= $args->[1] eq 6
ABresult
0X0
100
111
9133 1 $self->_terminate_conn_error($peer_id, 'Incompatible TS version');
9134 1 return;
9135 }
9136 254 $self->{state}{conns}{$peer_id}{svinfo} = $args;
9137 254 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 254 254
9138 254 return $ref;
9139 }
9140  
9141 250 ▶sub _daemon_peer_ping {
Subroutine _daemon_peer_ping: called CC=9 SCAR=26.3
9142 250 my $self = shift;
9143 250 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2500
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9144 250 my $server = $self->server_name();
9145 250 my $sid = $self->server_sid();
9146 250 my $ref = [ ];
9147 250 my $prefix = shift;
9148 250 my $args = [ @_ ];
9149 250 my $count = @$args;
9150  
9151 SWITCH: {
9152 250 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 250 250
9153 0 last SWITCH;
9154 }
9155 250 ▶ if ($count >= 2 && $sid ne $args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and $sid ne $args->[1]) 2 248 250
Condition66%2/3
$count >= 2 and $sid ne $args->[1]
!ll&&!rl&&r
24802
MC/DC50%1/2
$count >= 2 and $sid ne $args->[1]
$count >= 2 $sid ne $args->[1]
Truth table66%2/3
A and B
A= $count >= 2B= $sid ne $args->[1]
ABresult
0X0
100
111
9156 2 ▶ if ( $self->state_sid_exists($args->[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_sid_exists($args->[1])) 2 0 2
9157 2 $self->send_output(
9158 {
9159 prefix => $prefix,
9160 command => 'PING',
9161 params => $args,
9162 },
9163 $self->_state_sid_route($args->[1]),
9164 );
9165 2 last SWITCH;
9166 }
9167 0 ▶ if ( $self->state_uid_exists($args->[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_uid_exists($args->[1])) 0 0 0
9168 0 my $route_id = $self->_state_uid_route($args->[1]);
9169 0 ▶ if ( $args->[1] =~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] =~ /^$sid/) { } 0 0 0
9170 0 $self->send_output(
9171 {
9172 prefix => $self->_state_sid_name($prefix),
9173 command => 'PING',
9174 params => [ $args->[0], $self->state_user_nick($args->[1]) ],
9175 },
9176 $route_id,
9177 );
9178 }
9179 else {
9180 0 $self->send_output(
9181 {
9182 prefix => $prefix,
9183 command => 'PING',
9184 params => $args,
9185 },
9186 $route_id,
9187 );
9188 }
9189 }
9190 0 last SWITCH;
9191 }
9192 $self->send_output(
9193 {
9194 248 prefix => $sid,
9195 command => 'PONG',
9196 params => [$server, $args->[0]],
9197 },
9198 $peer_id,
9199 );
9200 }
9201  
9202 250 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 250 250
9203 250 return $ref;
9204 }
9205  
9206 3 ▶sub _daemon_peer_pong {
Subroutine _daemon_peer_pong: called CC=9 SCAR=24.0
9207 3 my $self = shift;
9208 3 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9209 3 my $server = $self->server_name();
9210 3 my $sid = $self->server_sid();
9211 3 my $ref = [ ];
9212 3 my $prefix = shift;
9213 3 my $args = [ @_ ];
9214 3 my $count = @$args;
9215  
9216 SWITCH: {
9217 3 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 3 3
9218 0 last SWITCH;
9219 }
9220 3 ▶ if ($count >= 2 && uc $sid ne $args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and uc $sid ne $args->[1]) 3 0 3
Condition33%1/3
$count >= 2 and uc $sid ne $args->[1]
!ll&&!rl&&r
003
MC/DC0%0/2
$count >= 2 and uc $sid ne $args->[1]
$count >= 2 uc $sid ne $args->[1]
Truth table33%1/3
A and B
A= $count >= 2B= uc $sid ne $args->[1]
ABresult
0X0
100
111
9221 3 ▶ if ( $self->state_sid_exists($args->[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_sid_exists($args->[1])) 0 3 3
9222 0 $self->send_output(
9223 {
9224 prefix => $prefix,
9225 command => 'PONG',
9226 params => $args,
9227 },
9228 $self->_state_sid_route($args->[1]),
9229 );
9230 0 last SWITCH;
9231 }
9232 3 ▶ if ( $self->state_uid_exists($args->[1]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_uid_exists($args->[1])) 3 0 3
9233 3 my $route_id = $self->_state_uid_route($args->[1]);
9234 3 ▶ if ( $args->[1] =~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] =~ /^$sid/) { } 1 2 3
9235 1 $self->send_output(
9236 {
9237 prefix => $self->_state_sid_name($prefix),
9238 command => 'PONG',
9239 params => [ $args->[0], $self->state_user_nick($args->[1]) ],
9240 },
9241 $route_id,
9242 );
9243 }
9244 else {
9245 2 $self->send_output(
9246 {
9247 prefix => $prefix,
9248 command => 'PONG',
9249 params => $args,
9250 },
9251 $route_id,
9252 );
9253 }
9254 3 last SWITCH;
9255 }
9256 }
9257 0 delete $self->{state}{conns}{$peer_id}{pinged};
9258 }
9259  
9260 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
9261 3 return $ref;
9262 }
9263  
9264 130 ▶sub _daemon_peer_sid {
Subroutine _daemon_peer_sid: called CC=15 SCAR=28.6
9265 130 my $self = shift;
9266 130 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
1300
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9267 130 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
1300
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9268 130 my $server = $self->server_name();
9269 130 my $ref = [ ];
9270 130 my $args = [ @_ ];
9271 130 my $count = @$args;
9272 130 my $peer = $self->{state}{conns}{$peer_id}{name};
9273  
9274 # 0 1 2 3
9275 # :8H8 SID rhyg.dummy.net 2 0FU :ircd-hybrid test server
9276 # :0FU SID llestr.dummy.net 3 7UP :ircd-hybrid test server
9277  
9278 SWITCH: {
9279 130 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 130 130
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
00130
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
9280 0 last SWITCH;
9281 }
9282 130 ▶ if ($args->[0] !~ $host_re) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0] =~ /$host_re/) 0 130 130
9283 $self->_send_to_realops(
9284 sprintf(
9285 'Link %s[unknown@%s] introduced server with bogus server name %s',
9286 0 $peer->{name}, $peer->{socket}[0], $args->[0],
9287 ), 'Notice', 's',
9288 );
9289 0 $self->_terminate_conn_error($peer_id, 'Bogus server name introduced');
9290 0 last SWITCH;
9291 }
9292 130 ▶ if ($args->[2] !~ $sid_re) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[2] =~ /$sid_re/) 0 130 130
9293 $self->_send_to_realops(
9294 sprintf(
9295 'Link %s[unknown@%s] introduced server with bogus server ID %s',
9296 0 $peer->{name}, $peer->{socket}[0], $args->[2],
9297 ), 'Notice', 's',
9298 );
9299 0 $self->_terminate_conn_error($peer_id, 'Bogus server ID introduced');
9300 0 last SWITCH;
9301 }
9302 130 ▶ if ($self->state_sid_exists($args->[2])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_sid_exists($args->[2])) 1 129 130
9303 1 my $prec = $self->{state}{conns}{$peer_id};
9304 $self->_send_to_realops(
9305 sprintf(
9306 'Link %s[unknown@%s] cancelled, server ID %s already exists',
9307 1 $prec->{name}, $prec->{socket}[0], $args->[2],
9308 ), 'Notice', 's',
9309 );
9310 1 $self->_terminate_conn_error($peer_id, 'Link cancelled, server ID already exists');
9311 1 last SWITCH;
9312 }
9313 129 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 1 128 129
9314 1 my $prec = $self->{state}{conns}{$peer_id};
9315 $self->_send_to_realops(
9316 sprintf(
9317 'Link %s[unknown@%s] cancelled, server %s already exists',
9318 1 $prec->{name}, $prec->{socket}[0], $args->[0],
9319 ), 'Notice', 's',
9320 );
9321 1 $self->_terminate_conn_error($peer_id, 'Server exists');
9322 1 last SWITCH;
9323 }
9324 128 ▶ my $record = {
Condition50%1/2
$args->[3] || ''
l!l
1280
MC/DC0%0/1
$args->[3] || ''
$args->[3]
Truth table50%1/2
A
A= $args->[3]
Aresult
11
00
9325 name => $args->[0],
9326 hops => $args->[1],
9327 sid => $args->[2],
9328 desc => ( $args->[3] || '' ),
9329 route_id => $peer_id,
9330 type => 'r',
9331 psid => $prefix,
9332 peer => $self->_state_sid_name( $prefix ),
9333 peers => { },
9334 users => { },
9335 };
9336 128 ▶ if ( $record->{desc} && $record->{desc} =~ m!^\(H\) ! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"desc"} and $record->{"desc"} =~ /^\(H\) /) 1 127 128
Condition66%2/3
$record->{"desc"} and $record->{"desc"} =~ /^\(H\) /
!ll&&!rl&&r
01271
MC/DC50%1/2
$record->{"desc"} and $record->{"desc"} =~ /^\(H\) /
$record->{"desc"} $record->{"desc"} =~ /^\(H\) /
Truth table66%2/3
A and B
A= $record->{"desc"}B= $record->{"desc"} =~ /^\(H\) /
ABresult
0X0
100
111
9337 1 $record->{hidden} = 1;
9338 1 $record->{desc} =~ s!^\(H\) !!;
9339 }
9340 128 $self->{state}{sids}{ $prefix }{sids}{ $record->{sid} } = $record;
9341 128 $self->{state}{sids}{ $record->{sid} } = $record;
9342 128 my $uname = uc $record->{name};
9343 128 ▶ $record->{serv} = 1 if $self->{state}{services}{$uname};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"services"}{$uname} 42 86 128
9344 128 $self->{state}{peers}{$uname} = $record;
9345 128 $self->{state}{peers}{ uc $record->{peer} }{peers}{$uname} = $record;
9346 $self->send_output(
9347 {
9348 prefix => $prefix,
9349 command => 'SID',
9350 params => [
9351 $record->{name},
9352 $record->{hops} + 1,
9353 $record->{sid},
9354 ( $record->{hidden} ? '(H) ' : '' ) .
9355 $record->{desc},
9356 ],
9357 },
9358 128 ▶ grep { $_ ne $peer_id } $self->_state_connected_peers(),
Branch: 1 branch
BranchTrueFalseTotal
$record->{'hidden'} ? : 1 127 128
9359 );
9360 $self->_send_to_realops(
9361 sprintf(
9362 'Server %s being introduced by %s',
9363 $record->{name}, $record->{peer},
9364 128 ),
9365 'Notice',
9366 'e',
9367 );
9368 $self->send_event(
9369 'daemon_sid',
9370 $record->{name},
9371 $prefix,
9372 $record->{hops},
9373 $record->{sid},
9374 $record->{desc},
9375 128 );
9376 $self->send_event(
9377 'daemon_server',
9378 $record->{name},
9379 $prefix,
9380 $record->{hops},
9381 $record->{desc},
9382 128 );
9383 }
9384 130 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 130 130
9385 130 return $ref;
9386 }
9387  
9388 5 ▶sub _daemon_peer_quit {
Subroutine _daemon_peer_quit: called CC=18 SCAR=31.8
9389 5 my $self = shift;
9390 5 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9391 5 ▶ my $qmsg = shift || 'Client Quit';
Condition50%1/2
shift() || 'Client Quit'
l!l
50
MC/DC0%0/1
shift() || 'Client Quit'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9392 5 my $conn_id = shift;
9393 5 my $ref = [ ];
9394 5 my $sid = $self->server_sid();
9395  
9396 5 my $record = delete $self->{state}{uids}{$uid};
9397 5 ▶ return $ref if !$record;
Branch: 1 branch
BranchTrueFalseTotal
unless $record 2 3 5
9398 3 my $full = $record->{full}->();
9399 3 my $nick = uc_irc($record->{nick});
9400 3 delete $self->{state}{users}{$nick};
9401 3 delete $self->{state}{sids}{ $record->{sid} }{users}{$nick};
9402 3 delete $self->{state}{sids}{ $record->{sid} }{uids}{$uid};
9403 $self->send_output(
9404 {
9405 prefix => $uid,
9406 command => 'QUIT',
9407 params => [$qmsg],
9408 },
9409 4 ▶ grep { !$conn_id || $_ ne $conn_id }
Condition66%2/3
!$conn_id || $_ ne $conn_id
l!l&&r!l&&!r
022
MC/DC50%1/2
!$conn_id || $_ ne $conn_id
!$conn_id $_ ne $conn_id
Truth table66%2/3
not(A) || B
A= !$conn_idB= $_ ne $conn_id
ABresult
1X1
011
000
9410 $self->_state_connected_peers(),
9411 3 ▶ ) if !$record->{killed};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"killed"} 2 1 3
9412  
9413 3 push @$ref, {
9414 prefix => $full,
9415 command => 'QUIT',
9416 params => [$qmsg],
9417 };
9418  
9419 $self->_send_to_realops(
9420 sprintf(
9421 'Client exiting at %s: %s (%s@%s) [%s] [%s]',
9422 $record->{server}, $record->{nick}, $record->{auth}{ident},
9423 3 $record->{auth}{realhost}, $record->{ipaddress}, $qmsg,
9424 ),
9425 'Notice', 'F',
9426 );
9427  
9428 3 $self->send_event("daemon_quit", $full, $qmsg);
9429  
9430 # Remove for peoples accept lists
9431 delete $self->{state}{users}{$_}{accepts}{uc_irc($nick)}
9432 3 for keys %{ $record->{accepts} };
9433  
9434 # WATCH LOGOFF
9435 3 ▶ if ( defined $self->{state}{watches}{$nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$nick}) 1 2 3
9436 1 my $laston = time();
9437 1 $self->{state}{watches}{$nick}{laston} = $laston;
9438 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$nick}{uids} } ) {
9439 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
9440 1 my $wrec = $self->{state}{uids}{$wuid};
9441 $self->send_output(
9442 {
9443 prefix => $record->{server},
9444 command => '601',
9445 params => [
9446 $wrec->{nick},
9447 $record->{nick},
9448 $record->{auth}{ident},
9449 $record->{auth}{hostname},
9450 $laston,
9451 'logged offline',
9452 ],
9453 },
9454 $wrec->{route_id},
9455 1 );
9456 }
9457 }
9458 # Okay, all 'local' users who share a common channel with user.
9459 3 my $common = { };
9460 3 for my $uchan (keys %{ $record->{chans} }) {
9461 0 delete $self->{state}{chans}{$uchan}{users}{$uid};
9462 0 for my $user ( keys %{ $self->{state}{chans}{$uchan}{users} } ) {
9463 0 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 0 0 0
9464 0 $common->{$user} = $self->_state_uid_route($user);
9465 }
9466 0 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 0 0 0
9467 0 delete $self->{state}{chans}{$uchan};
9468 }
9469 }
9470  
9471 3 push @$ref, $common->{$_} for keys %$common;
9472 3 ▶ $self->{state}{stats}{ops_online}-- if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 0 3 3
9473 3 ▶ $self->{state}{stats}{invisible}-- if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 3 0 3
9474 3 delete $self->{state}{peers}{uc $record->{server}}{users}{$nick};
9475 3 unshift @{ $self->{state}{whowas}{$nick} }, {
9476 logoff => time(),
9477 account => $record->{account},
9478 nick => $record->{nick},
9479 user => $record->{auth}{ident},
9480 host => $record->{auth}{hostname},
9481 real => $record->{auth}{realhost},
9482 sock => $record->{ipaddress},
9483 ircname => $record->{ircname},
9484 server => $record->{server},
9485 3 };
9486 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
9487 3 return $ref;
9488 }
9489  
9490 553 ▶sub _daemon_peer_uid {
Subroutine _daemon_peer_uid: called CC=20 SCAR=30.3
9491 553 my $self = shift;
9492 553 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
5530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9493 553 my $prefix = shift;
9494 553 my $server = $self->server_name();
9495 553 my $mysid = $self->server_sid();
9496 553 my $ref = [ ];
9497 553 my $args = [ @_ ];
9498 553 my $count = @$args;
9499 553 ▶ my $rhost = ( $self->_state_our_capab('RHOST')
Condition66%2/3
$self->_state_our_capab('RHOST') && $self->_state_peer_capab($peer_id, 'RHOST')
!ll&&!rl&&r
05476
MC/DC50%1/2
$self->_state_our_capab('RHOST') && $self->_state_peer_capab($peer_id, 'RHOST')
$self->_state_our_capab('RHOST') $self->_state_peer_capab($peer_id, 'RHOST')
Truth table66%2/3
A && B
A= $self->_state_our_capab('RHOST')B= $self->_state_peer_capab($peer_id, 'RHOST')
ABresult
0X0
100
111
9500 && $self->_state_peer_capab( $peer_id, 'RHOST') );
9501  
9502  
9503 SWITCH: {
9504 553 ▶ if (!$count || $count < 9) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 9) 0 553 553
Condition33%1/3
not $count or $count < 9
l!l&&r!l&&!r
00553
MC/DC0%0/2
not $count or $count < 9
not $count $count < 9
Truth table33%1/3
not(A) or B
A= not $countB= $count < 9
ABresult
1X1
011
000
9505 0 $self->_terminate_conn_error(
9506 $peer_id,
9507 'Not enough arguments to server command.',
9508 );
9509 0 last SWITCH;
9510 }
9511 553 ▶ if ( $self->state_nick_exists( $args->[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($args->[0])) 12 541 553
9512 12 my $unick = uc_irc($args->[0]);
9513 12 my $exist = $self->{state}{users}{ $unick };
9514 12 my $userhost = ( split /!/, $self->state_user_full($args->[0]) )[1];
9515 12 my $incoming = join '@', @{ $args }[4..5];
9516 # Received TS < Existing TS
9517 12 ▶ if ( $args->[2] < $exist->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2] < $exist->{"ts"}) 6 6 12
9518 # If userhosts different, collide existing user
9519 6 ▶ if ( $incoming ne $userhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incoming ne $userhost) { } 5 1 6
9520 # Send KILL for existing user UID to all servers
9521 5 $exist->{nick_collision} = 1;
9522 5 $self->daemon_server_kill( $exist->{uid}, 'Nick Collision' );
9523 }
9524 # If userhosts same, collide new user
9525 else {
9526 # Send KILL for new user UID back to sending peer
9527 1 $self->send_output(
9528 {
9529 prefix => $mysid,
9530 command => 'KILL',
9531 params => [$args->[7+$rhost], 'Nick Collision'],
9532 },
9533 $peer_id,
9534 );
9535 1 last SWITCH;
9536 }
9537 }
9538 # Received TS == Existing TS
9539 11 ▶ if ( $args->[2] == $exist->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2] == $exist->{"ts"}) 1 10 11
9540 # Collide both
9541 1 $exist->{nick_collision} = 1;
9542 1 $self->daemon_server_kill( $exist->{uid}, 'Nick Collision', $peer_id);
9543 1 $self->send_output(
9544 {
9545 prefix => $mysid,
9546 command => 'KILL',
9547 params => [$args->[7+$rhost], 'Nick Collision'],
9548 },
9549 $peer_id,
9550 );
9551 1 last SWITCH;
9552 }
9553 # Received TS > Existing TS
9554 10 ▶ if ( $args->[2] > $exist->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2] > $exist->{"ts"}) 5 5 10
9555 # If userhosts same, collide existing user
9556 5 ▶ if ( $incoming eq $userhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incoming eq $userhost) { } 1 4 5
9557 # Send KILL for existing user UID to all servers
9558 1 $exist->{nick_collision} = 1;
9559 1 $self->daemon_server_kill( $exist->{uid}, 'Nick Collision' );
9560 }
9561 # If userhosts different, collide new user, drop message
9562 else {
9563 # Send KILL for new user UID back to sending peer
9564 4 $self->send_output(
9565 {
9566 prefix => $mysid,
9567 command => 'KILL',
9568 params => [$args->[7+$rhost], 'Nick Collision'],
9569 },
9570 $peer_id,
9571 );
9572 4 last SWITCH;
9573 }
9574 }
9575 #last SWITCH;
9576 }
9577  
9578 # check if we have RHOST set and they do, if so then there will be 11 args not 10
9579  
9580 547 ▶ my $record = {
Condition50%1/2
$$args[9 + $rhost] || ''
l!l
5470
MC/DC0%0/1
$$args[9 + $rhost] || ''
$$args[9 + $rhost]
Truth table50%1/2
A
A= $$args[9 + $rhost]
Aresult
11
00
9581 server => $self->_state_sid_name( $prefix ),
9582 type => 'r',
9583 route_id => $peer_id,
9584 sid => $prefix,
9585 nick => $args->[0],
9586 hops => $args->[1],
9587 ts => $args->[2],
9588 umode => $args->[3],
9589 auth => {
9590 ident => $args->[4],
9591 hostname => $args->[5],
9592 },
9593 ipaddress => $args->[6+$rhost],
9594 uid => $args->[7+$rhost],
9595 account => $args->[8+$rhost],
9596 ircname => ( $args->[9+$rhost] || '' ),
9597 };
9598  
9599 2553 ▶ $record->{full} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
9600 return sprintf('%s!%s@%s',
9601 $record->{nick},
9602 $record->{auth}{ident},
9603 2553 $record->{auth}{hostname});
9604 547 };
9605  
9606 547 ▶ if ( $rhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rhost) { } 3 544 547
9607 3 $record->{auth}{realhost} = $args->[6];
9608 }
9609 else {
9610 544 $record->{auth}{realhost} = $record->{auth}{hostname};
9611 }
9612  
9613 547 my $unick = uc_irc( $args->[0] );
9614  
9615 547 $self->{state}{users}{ $unick } = $record;
9616 547 $self->{state}{uids}{ $record->{uid} } = $record;
9617 547 ▶ $self->{state}{stats}{ops_online}++ if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 238 309 547
9618 547 ▶ $self->{state}{stats}{invisible}++ if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 547 0 547
9619 547 $self->{state}{sids}{$prefix}{users}{$unick} = $record;
9620 547 $self->{state}{sids}{$prefix}{uids}{ $record->{uid} } = $record;
9621 547 $self->_state_update_stats();
9622  
9623 547 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 546 547
9624 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
9625 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
9626 1 my $wrec = $self->{state}{uids}{$wuid};
9627 $self->send_output(
9628 {
9629 prefix => $server,
9630 command => '600',
9631 params => [
9632 $wrec->{nick},
9633 $record->{nick},
9634 $record->{auth}{ident},
9635 $record->{auth}{hostname},
9636 $record->{ts},
9637 'logged online',
9638 ],
9639 },
9640 $wrec->{route_id},
9641 1 );
9642 }
9643 }
9644  
9645 $self->send_output(
9646 {
9647 prefix => $prefix,
9648 command => 'UID',
9649 params => $args,
9650 },
9651 547 grep { $_ ne $peer_id } $self->_state_connected_peers(),
9652 );
9653  
9654 $self->_send_to_realops(
9655 sprintf(
9656 'Client connecting at %s: %s (%s@%s) [%s] [%s] <%s>',
9657 $record->{server}, $record->{nick}, $record->{auth}{ident},
9658 $record->{auth}{realhost}, $record->{ipaddress},
9659 $record->{ircname}, $record->{uid},
9660 547 ),
9661 'Notice', 'F',
9662 );
9663  
9664 547 $self->send_event('daemon_uid', $prefix, @$args);
9665 547 ▶ $self->send_event('daemon_nick', @{ $args }[0..5], $record->{server}, ( $args->[9+$rhost] || '' ) );
Condition50%1/2
$$args[9 + $rhost] || ''
l!l
5470
MC/DC0%0/1
$$args[9 + $rhost] || ''
$$args[9 + $rhost]
Truth table50%1/2
A
A= $$args[9 + $rhost]
Aresult
11
00
9666  
9667 }
9668  
9669 553 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 553 553
9670 553 return $ref;
9671 }
9672  
9673 2 ▶sub _daemon_peer_nick {
Subroutine _daemon_peer_nick: called CC=26 SCAR=43.4
9674 2 my $self = shift;
9675 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9676 2 my $prefix = shift;
9677 2 my $mysid = $self->server_sid();
9678 2 my $ref = [ ];
9679 2 my $args = [ @_ ];
9680 2 my $count = @$args;
9681 2 my $peer = $self->{state}{conns}{$peer_id}{name};
9682 2 my $nicklen = $self->server_config('NICKLEN');
9683  
9684 SWITCH: {
9685 2 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 2 2
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
9686 0 last SWITCH;
9687 }
9688 2 ▶ if ( !$self->state_uid_exists( $prefix ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_uid_exists($prefix)) 0 2 2
9689 0 last SWITCH;
9690 }
9691 2 my $newts = $args->[1];
9692 2 ▶ if ( $self->state_nick_exists($args->[0]) && $prefix ne $self->state_user_uid($args->[0]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($args->[0]) and $prefix ne $self->state_user_uid($args->[0])) 0 2 2
Condition33%1/3
$self->state_nick_exists($args->[0]) and $prefix ne $self->state_user_uid($args->[0])
!ll&&!rl&&r
200
MC/DC0%0/2
$self->state_nick_exists($args->[0]) and $prefix ne $self->state_user_uid($args->[0])
$self->state_nick_exists($args->[0]) $prefix ne $self->state_user_uid($args->[0])
Truth table33%1/3
A and B
A= $self->state_nick_exists($args->[0])B= $prefix ne $self->state_user_uid($args->[0])
ABresult
0X0
100
111
9693 0 my $unick = uc_irc($args->[0]);
9694 0 my $exist = $self->{state}{users}{ $unick };
9695 0 my $userhost = ( split /!/, $self->state_user_full($args->[0]) )[1];
9696 0 my $incoming = ( split /!/, $self->state_user_full($prefix) )[1];
9697 # Received TS < Existing TS
9698 0 ▶ if ( $newts < $exist->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newts < $exist->{"ts"}) 0 0 0
9699 # If userhosts different, collide existing user
9700 0 ▶ if ( $incoming ne $userhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incoming ne $userhost) { } 0 0 0
9701 # Send KILL for existing user UID to all servers
9702 0 $exist->{nick_collision} = 1;
9703 0 $self->daemon_server_kill( $exist->{uid}, 'Nick Collision' );
9704 }
9705 # If userhosts same, collide new user
9706 else {
9707 # Send KILL for new user UID back to sending peer
9708 0 $self->send_output(
9709 {
9710 prefix => $mysid,
9711 command => 'KILL',
9712 params => [$prefix, 'Nick Collision'],
9713 },
9714 $peer_id,
9715 );
9716 0 last SWITCH;
9717 }
9718 }
9719 # Received TS == Existing TS
9720 0 ▶ if ( $args->[2] == $exist->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2] == $exist->{"ts"}) 0 0 0
9721 # Collide both
9722 0 $exist->{nick_collision} = 1;
9723 0 $self->daemon_server_kill( $exist->{uid}, 'Nick Collision', $peer_id);
9724 0 $self->send_output(
9725 {
9726 prefix => $mysid,
9727 command => 'KILL',
9728 params => [$prefix, 'Nick Collision'],
9729 },
9730 $peer_id,
9731 );
9732 0 last SWITCH;
9733 }
9734 # Received TS > Existing TS
9735 0 ▶ if ( $newts > $exist->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newts > $exist->{"ts"}) 0 0 0
9736 # If userhosts same, collide existing user
9737 0 ▶ if ( $incoming eq $userhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incoming eq $userhost) { } 0 0 0
9738 # Send KILL for existing user UID to all servers
9739 0 $exist->{nick_collision} = 1;
9740 0 $self->daemon_server_kill( $exist->{uid}, 'Nick Collision' );
9741 }
9742 # If userhosts different, collide new user, drop message
9743 else {
9744 # Send KILL for new user UID back to sending peer
9745 0 $self->send_output(
9746 {
9747 prefix => $mysid,
9748 command => 'KILL',
9749 params => [$prefix, 'Nick Collision'],
9750 },
9751 $peer_id,
9752 );
9753 0 last SWITCH;
9754 }
9755 }
9756 #last SWITCH;
9757 }
9758  
9759 2 my $new = $args->[0];
9760 2 my $unew = uc_irc($new);
9761 2 ▶ my $ts = $args->[1] || time;
Condition50%1/2
$args->[1] || time
l!l
20
MC/DC0%0/1
$args->[1] || time
$args->[1]
Truth table50%1/2
A
A= $args->[1]
Aresult
11
00
9762 2 my $record = $self->{state}{uids}{$prefix};
9763 2 my $unick = uc_irc($record->{nick});
9764 2 my $sid = $record->{sid};
9765 2 my $full = $record->{full}->();
9766  
9767 2 ▶ if ($unick eq $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unick eq $unew) { } 0 2 2
9768 0 $record->{nick} = $new;
9769 0 $record->{ts} = $ts;
9770 }
9771 else {
9772 2 my $nick = $record->{nick};
9773 2 $record->{nick} = $new;
9774 2 $record->{ts} = $ts;
9775 # Remove from peoples accept lists
9776 # WATCH OFF
9777 2 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 1 2
9778 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
9779 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
9780 1 my $wrec = $self->{state}{uids}{$wuid};
9781 1 my $laston = time();
9782 1 $self->{state}{watches}{$unick}{laston} = $laston;
9783 $self->send_output(
9784 {
9785 prefix => $record->{server},
9786 command => '605',
9787 params => [
9788 $wrec->{nick},
9789 $nick,
9790 $record->{auth}{ident},
9791 $record->{auth}{hostname},
9792 $laston,
9793 'is offline',
9794 ],
9795 },
9796 $wrec->{route_id},
9797 1 );
9798 }
9799 }
9800 2 ▶ if ( defined $self->{state}{watches}{$unew} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unew}) 1 1 2
9801 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unew}{uids} } ) {
9802 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
9803 1 my $wrec = $self->{state}{uids}{$wuid};
9804 $self->send_output(
9805 {
9806 prefix => $record->{server},
9807 command => '604',
9808 params => [
9809 $wrec->{nick},
9810 $record->{nick},
9811 $record->{auth}{ident},
9812 $record->{auth}{hostname},
9813 $record->{ts},
9814 'is online',
9815 ],
9816 },
9817 $wrec->{route_id},
9818 1 );
9819 }
9820 }
9821 delete $self->{state}{users}{$_}{accepts}{$unick}
9822 2 for keys %{ $record->{accepts} };
9823 2 delete $record->{accepts};
9824 2 delete $self->{state}{users}{$unick};
9825 2 $self->{state}{users}{$unew} = $record;
9826 2 delete $self->{state}{sids}{$sid}{users}{$unick};
9827 2 $self->{state}{sids}{$sid}{users}{$unew} = $record;
9828 2 ▶ if ( $record->{umode} =~ /r/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /r/) 0 2 2
9829 0 $record->{umode} =~ s/r//g;
9830 }
9831 2 unshift @{ $self->{state}{whowas}{$unick} }, {
9832 logoff => time(),
9833 account => $record->{account},
9834 nick => $nick,
9835 user => $record->{auth}{ident},
9836 host => $record->{auth}{hostname},
9837 real => $record->{auth}{realhost},
9838 sock => $record->{ipaddress},
9839 ircname => $record->{ircname},
9840 server => $record->{server},
9841 2 };
9842 }
9843 2 my $common = { };
9844 2 for my $chan (keys %{ $record->{chans} }) {
9845 0 for my $user ( keys %{ $self->{state}{chans}{uc_irc $chan}{users} } ) {
9846 0 ▶ next if $user !~ m!^$mysid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$mysid/ 0 0 0
9847 0 $common->{$user} = $self->_state_uid_route($user);
9848 }
9849 }
9850 {
9851 2 my ($nick,$userhost) = split /!/, $full;
9852 2 $self->_send_to_realops(
9853 sprintf(
9854 'Nick change: From %s to %s [%s]',
9855 $nick, $new, $userhost,
9856 ),
9857 'Notice',
9858 'n',
9859 );
9860 }
9861 $self->send_output(
9862 {
9863 prefix => $prefix,
9864 command => 'NICK',
9865 params => $args,
9866 },
9867 2 grep { $_ ne $peer_id } $self->_state_connected_peers(),
9868 );
9869 $self->send_output(
9870 {
9871 prefix => $full,
9872 command => 'NICK',
9873 params => [$new],
9874 },
9875 0 map{ $common->{$_} } keys %{ $common },
9876 );
9877 2 $self->send_event("daemon_nick", $full, $new);
9878 }
9879  
9880 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
9881 2 return $ref;
9882 }
9883  
9884 1 ▶sub _daemon_peer_part {
Subroutine _daemon_peer_part: called CC=10 SCAR=25.5
9885 1 my $self = shift;
9886 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9887 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9888 1 my $chan = shift;
9889 1 my $ref = [ ];
9890 1 my $args = [ @_ ];
9891 1 my $count = @$args;
9892  
9893 SWITCH: {
9894 1 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 0 1 1
9895 0 last SWITCH;
9896 }
9897 1 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 1 1
9898 0 last SWITCH;
9899 }
9900 1 ▶ if (!$self->state_uid_chan_member($uid, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_uid_chan_member($uid, $chan)) 0 1 1
9901 0 last SWITCH;
9902 }
9903 $self->send_output(
9904 {
9905 prefix => $uid,
9906 command => 'PART',
9907 params => [$chan, ($args->[0] || '')],
9908 },
9909 1 ▶ grep { $_ ne $peer_id } $self->_state_connected_peers(),
Condition50%1/2
$args->[0] || ''
l!l
10
MC/DC0%0/1
$args->[0] || ''
$args->[0]
Truth table50%1/2
A
A= $args->[0]
Aresult
11
00
9910 );
9911 1 ▶ $self->_send_output_channel_local(
Condition50%1/2
$args->[0] || ''
l!l
10
MC/DC0%0/1
$args->[0] || ''
$args->[0]
Truth table50%1/2
A
A= $args->[0]
Aresult
11
00
9912 $chan, {
9913 prefix => $self->state_user_full($uid),
9914 command => 'PART',
9915 params => [$chan, ($args->[0] || '')],
9916 },
9917 );
9918 1 my $uchan = uc_irc($chan);
9919 1 delete $self->{state}{chans}{$uchan}{users}{$uid};
9920 1 delete $self->{state}{uids}{$uid}{chans}{$uchan};
9921 1 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 0 1 1
9922 0 delete $self->{state}{chans}{$uchan};
9923 }
9924 }
9925  
9926 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
9927 1 return $ref;
9928 }
9929  
9930 1 ▶sub _daemon_peer_kick {
Subroutine _daemon_peer_kick: called CC=11 SCAR=27.2
9931 1 my $self = shift;
9932 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9933 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9934 1 my $ref = [ ];
9935 1 my $args = [ @_ ];
9936 1 my $count = @$args;
9937  
9938 SWITCH: {
9939 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
9940 0 last SWITCH;
9941 }
9942 1 my $chan = (split /,/, $args->[0])[0];
9943 1 my $wuid = (split /,/, $args->[1])[0];
9944 1 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 1 1
9945 0 last SWITCH;
9946 }
9947 1 ▶ if ( !$self->state_uid_exists($wuid)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_uid_exists($wuid)) 0 1 1
9948 0 last SWITCH;
9949 }
9950 1 ▶ if (!$self->state_uid_chan_member($wuid, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_uid_chan_member($wuid, $chan)) 0 1 1
9951 0 last SWITCH;
9952 }
9953 1 my $who = $self->state_user_nick($wuid);
9954 1 ▶ my $comment = $args->[2] || $who;
Condition33%1/3
$args->[2] || $who
l!l&&r!l&&!r
100
MC/DC0%0/2
$args->[2] || $who
$args->[2] $who
Truth table33%1/3
A || B
A= $args->[2]B= $who
ABresult
1X1
011
000
9955 $self->send_output(
9956 {
9957 prefix => $uid,
9958 command => 'KICK',
9959 params => [$chan, $wuid, $comment],
9960 },
9961 1 grep { $_ ne $peer_id } $self->_state_connected_peers(),
9962 );
9963 1 $self->_send_output_channel_local(
9964 $chan, {
9965 prefix => $self->state_user_full($uid),
9966 command => 'KICK',
9967 params => [$chan, $who, $comment],
9968 },
9969 );
9970 1 my $uchan = uc_irc($chan);
9971 1 delete $self->{state}{chans}{$uchan}{users}{$wuid};
9972 1 delete $self->{state}{uids}{$wuid}{chans}{$uchan};
9973 1 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 0 1 1
9974 0 delete $self->{state}{chans}{$uchan};
9975 }
9976 }
9977  
9978 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
9979 1 return $ref;
9980 }
9981  
9982 125 ▶sub _daemon_peer_sjoin {
Subroutine _daemon_peer_sjoin: called CC=1 SCAR=0.0
9983 125 my $self = shift;
9984 125 my $peer_id = shift;
9985 125 $self->_daemon_do_joins( $peer_id, 'SJOIN', @_ );
9986 }
9987  
9988 1 ▶sub _daemon_peer_join {
Subroutine _daemon_peer_join: called CC=1 SCAR=0.0
9989 1 my $self = shift;
9990 1 my $peer_id = shift;
9991 1 $self->_daemon_do_joins( $peer_id, 'JOIN', @_ );
9992 }
9993  
9994 126 ▶sub _daemon_do_joins {
Subroutine _daemon_do_joins: called CC=95 SCAR=62.2
9995 126 my $self = shift;
9996 126 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
1260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9997 126 my $cmd = shift;
9998 126 my $prefix = shift;
9999 126 my $ref = [ ];
10000 126 my $args = [ @_ ];
10001 126 my $count = @$args;
10002 126 my $server = $self->server_name();
10003  
10004 # We have to handle either SJOIN or JOIN
10005 # :<SID> SJOIN <TS> <CHANNAME> +<CHANMODES> :<UIDS>
10006 # :<UID> JOIN <TS> <CHANNAME> +
10007  
10008 SWITCH: {
10009 126 ▶ if ($cmd eq 'SJOIN' && ( !$count || $count < 4) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SJOIN" and !$count || $count < 4) 0 126 126
Condition50%3/6
$cmd eq "SJOIN" and !$count || $count < 4
!ll&&!rl&&r
11250
not $count or $count < 4
l!l&&r!l&&!r
00125
MC/DC0%0/3
$cmd eq "SJOIN" and !$count || $count < 4
$cmd eq "SJOIN" not $count $count < 4
Truth table50%2/4
A and not(B) or C
A= $cmd eq "SJOIN"B= not $countC= $count < 4
ABCresult
0XX0
1000
11X1
1011
10010 0 last SWITCH;
10011 }
10012 126 ▶ if ($cmd eq 'JOIN' && ( !$count || $count < 3) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "JOIN" and !$count || $count < 3) 0 126 126
Condition50%3/6
$cmd eq "JOIN" and !$count || $count < 3
!ll&&!rl&&r
12510
not $count or $count < 3
l!l&&r!l&&!r
001
MC/DC0%0/3
$cmd eq "JOIN" and !$count || $count < 3
$cmd eq "JOIN" not $count $count < 3
Truth table50%2/4
A and not(B) or C
A= $cmd eq "JOIN"B= not $countC= $count < 3
ABCresult
0XX0
1000
11X1
1011
10013 0 last SWITCH;
10014 }
10015 126 my $ts = $args->[0];
10016 126 my $chan = $args->[1];
10017 126 my $uids;
10018 126 ▶ if ( $cmd eq 'JOIN' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq 'JOIN') { } 1 125 126
10019 1 $uids = $prefix;
10020 }
10021 else {
10022 125 $uids = pop @{ $args };
10023 }
10024 126 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 50 76 126
10025 50 my $chanrec = { name => $chan, ts => $ts };
10026 50 my @args = @{ $args }[2..$#{ $args }];
10027 50 my $cmode = shift @args;
10028 50 $cmode =~ s/^\+//g;
10029 50 $chanrec->{mode} = $cmode;
10030 50 for my $mode (split //, $cmode) {
10031 108 my $arg;
10032 108 ▶ $arg = shift @args if $mode =~ /[lk]/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /[lk]/ 1 107 108
10033 108 ▶ $chanrec->{climit} = $arg if $mode eq 'l';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "l" 1 107 108
10034 108 ▶ $chanrec->{ckey} = $arg if $mode eq 'k';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "k" 0 108 108
10035 }
10036 50 push @$args, $uids;
10037 50 my $uchan = uc_irc($chanrec->{name});
10038 50 for my $uid (split /\s+/, $uids) {
10039 733 my $umode = '';
10040 733 ▶ $umode .= 'o' if $uid =~ s/\@//g;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ s/\@//g 19 714 733
10041 733 ▶ $umode .= 'h' if $uid =~ s/\%//g;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ s/\%//g 0 733 733
10042 733 ▶ $umode .= 'v' if $uid =~ s/\+//g;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ s/\+//g 0 733 733
10043 733 $chanrec->{users}{$uid} = $umode;
10044 733 $self->{state}{uids}{$uid}{chans}{$uchan} = $umode;
10045  
10046 733 $self->send_event(
10047 'daemon_join',
10048 $self->state_user_full($uid),
10049 $chan,
10050 );
10051 733 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $umode 19 714 733
10052 'daemon_mode',
10053 $server,
10054 $chan,
10055 '+' . $umode,
10056 $self->state_user_nick($uid),
10057 ) if $umode;
10058 }
10059 50 $self->{state}{chans}{$uchan} = $chanrec;
10060 $self->send_output(
10061 {
10062 prefix => $prefix,
10063 command => $cmd,
10064 params => $args,
10065 },
10066 50 grep { $_ ne $peer_id } $self->_state_connected_peers(),
10067 );
10068 50 last SWITCH;
10069 }
10070  
10071 # :8H8 SJOIN 1526826863 #ooby +cmntlk 699 secret :@7UPAAAAAA
10072  
10073 76 my $chanrec = $self->{state}{chans}{uc_irc($chan)};
10074 76 my @local_users; my @local_extjoin; my @local_nextjoin;
10075 {
10076 76 my @tmp_users =
10077 3266 grep { $self->_state_is_local_uid($_) }
10078 76 keys %{ $chanrec->{users} };
10079  
10080 0 @local_extjoin = map { $self->_state_uid_route($_) }
10081 76 grep { $self->{state}{uids}{$_}{caps}{'extended-join'} }
10082 @tmp_users;
10083  
10084 24 @local_nextjoin = map { $self->_state_uid_route($_) }
10085 76 grep { !$self->{state}{uids}{$_}{caps}{'extended-join'} }
10086 @tmp_users;
10087  
10088 76 @local_users = ( @local_extjoin, @local_nextjoin );
10089  
10090 }
10091 # If the TS received is lower than our TS of the channel a TS6 server must
10092 # remove status modes (+ov etc) and channel modes (+nt etc). If the
10093 # originating server is TS6 capable (ie, it has a SID), the server must
10094 # also remove any ban modes (+b etc). The new modes and statuses are then
10095 # accepted.
10096  
10097 76 ▶ if ( $ts < $chanrec->{ts} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ts < $chanrec->{'ts'}) { } 4 72 76
elsif ($ts == $chanrec->{'ts'}) { } 68 4 72
10098 4 my @deop;
10099 my @deop_list;
10100 4 my $common = { };
10101  
10102 # Remove all +ovh
10103 4 for my $user (keys %{ $chanrec->{users} }) {
10104 7 ▶ $common->{$user} = $self->_state_uid_route($user)
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_is_local_uid($user) 4 3 7
10105 if $self->_state_is_local_uid($user);
10106 7 ▶ next if !$chanrec->{users}{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless $chanrec->{"users"}{$user} 3 4 7
10107 4 my $current = $chanrec->{users}{$user};
10108 4 my $proper = $self->state_user_nick($user);
10109 4 $chanrec->{users}{$user} = '';
10110 4 $self->{state}{uids}{$user}{chans}{uc_irc($chanrec->{name})} = '';
10111 4 push @deop, "-$current";
10112 4 push @deop_list, $proper for split //, $current;
10113 }
10114  
10115 4 ▶ if (keys %$common && @deop) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$common and @deop) 4 0 4
Condition33%1/3
keys %$common and @deop
!ll&&!rl&&r
004
MC/DC0%0/2
keys %$common and @deop
keys %$common @deop
Truth table33%1/3
A and B
A= keys %$commonB= @deop
ABresult
0X0
100
111
10116 $self->send_event(
10117 "daemon_mode",
10118 $server,
10119 $chanrec->{name},
10120 4 unparse_mode_line(join '', @deop),
10121 @deop_list,
10122 );
10123 4 my @output_modes;
10124 4 my $length = length($server) + 4
10125 + length($chan) + 4;
10126 4 my @buffer = ('', '');
10127 4 for my $deop (@deop) {
10128 4 my $arg = shift @deop_list;
10129 4 my $mode_line = unparse_mode_line($buffer[0].$deop);
10130 4 ▶ if (length(join ' ', $mode_line, $buffer[1],
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $mode_line, $buffer[1], $arg) + $length > 510) 0 4 4
10131 $arg) + $length > 510) {
10132 push @output_modes, {
10133 prefix => $server,
10134 command => 'MODE',
10135 colonify => 0,
10136 params => [
10137 $chanrec->{name},
10138 0 $buffer[0],
10139 split /\s+/,
10140 $buffer[1],
10141 ],
10142 };
10143 0 $buffer[0] = $deop;
10144 0 $buffer[1] = $arg;
10145 0 next;
10146 }
10147 4 $buffer[0] = $mode_line;
10148 4 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 4 4
10149 0 $buffer[1] = join ' ', $buffer[1], $arg;
10150 }
10151 else {
10152 4 $buffer[1] = $arg;
10153 }
10154 }
10155 push @output_modes, {
10156 prefix => $server,
10157 command => 'MODE',
10158 colonify => 0,
10159 params => [
10160 $chanrec->{name},
10161 4 $buffer[0],
10162 split /\s+/, $buffer[1],
10163 ],
10164 };
10165 $self->send_output($_, values %$common)
10166 4 for @output_modes;
10167 }
10168  
10169 # Remove all +beI modes
10170 4 ▶ if ( $cmd eq 'SJOIN' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SJOIN") 4 0 4
10171 4 my $tmap = { bans => 'b', excepts => 'e', invex => 'I' };
10172 4 my @types; my @mask_list;
10173 4 foreach my $type ( qw[bans excepts invex] ) {
10174 12 ▶ next if !$chanrec->{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless $chanrec->{$type} 3 9 12
10175 9 foreach my $umask ( keys %{ $chanrec->{$type} } ) {
10176 0 my $rec = delete $chanrec->{$type}{$umask};
10177 0 push @types, '-' . $tmap->{$type};
10178 0 push @mask_list, $rec->[0];
10179 }
10180 }
10181 $self->send_event(
10182 "daemon_mode",
10183 $server,
10184 $chanrec->{name},
10185 4 unparse_mode_line(join '', @types),
10186 @mask_list,
10187 );
10188 4 ▶ if ( @local_users && @types ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local_users and @types) 0 4 4
Condition33%1/3
@local_users and @types
!ll&&!rl&&r
040
MC/DC0%0/2
@local_users and @types
@local_users @types
Truth table33%1/3
A and B
A= @local_usersB= @types
ABresult
0X0
100
111
10189 0 my @output_modes;
10190 0 my $length = length($server) + 4
10191 + length($chan) + 4;
10192 0 my @buffer = ('', '');
10193 0 for my $type (@types) {
10194 0 my $arg = shift @mask_list;
10195 0 my $mode_line = unparse_mode_line($buffer[0].$type);
10196 0 ▶ if (length(join ' ', $mode_line, $buffer[1],
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $mode_line, $buffer[1], $arg) + $length > 510) 0 0 0
10197 $arg) + $length > 510) {
10198 push @output_modes, {
10199 prefix => $server,
10200 command => 'MODE',
10201 colonify => 0,
10202 params => [
10203 $chanrec->{name},
10204 0 $buffer[0],
10205 split /\s+/,
10206 $buffer[1],
10207 ],
10208 };
10209 0 $buffer[0] = $type;
10210 0 $buffer[1] = $arg;
10211 0 next;
10212 }
10213 0 $buffer[0] = $mode_line;
10214 0 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 0 0
10215 0 $buffer[1] = join ' ', $buffer[1], $arg;
10216 }
10217 else {
10218 0 $buffer[1] = $arg;
10219 }
10220 }
10221 push @output_modes, {
10222 prefix => $server,
10223 command => 'MODE',
10224 colonify => 0,
10225 params => [
10226 $chanrec->{name},
10227 0 $buffer[0],
10228 split /\s+/, $buffer[1],
10229 ],
10230 };
10231 $self->send_output($_, @local_users)
10232 0 for @output_modes;
10233 }
10234 }
10235  
10236 # Remove TOPIC
10237 4 ▶ if ( $chanrec->{topic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"topic"}) 1 3 4
10238 1 delete $chanrec->{topic};
10239 1 $self->send_output(
10240 {
10241 prefix => $server,
10242 command => 'TOPIC',
10243 params => [$chan, ''],
10244 },
10245 @local_users,
10246 );
10247 }
10248 # Set TS to incoming TS and send NOTICE
10249 $self->send_output(
10250 {
10251 prefix => $server,
10252 command => 'NOTICE',
10253 params => [
10254 $chanrec->{name},
10255 "*** Notice -- TS for " . $chanrec->{name}
10256 . " changed from " . $chanrec->{ts}
10257 4 . " to $ts",
10258 ],
10259 },
10260 @local_users,
10261 );
10262 4 $chanrec->{ts} = $ts;
10263 # Remove invites
10264 4 ▶ my $invites = delete $chanrec->{invites} || {};
Condition50%1/2
delete $chanrec->{'invites'} || {}
l!l
04
MC/DC0%0/1
delete $chanrec->{'invites'} || {}
delete $chanrec->{'invites'}
Truth table50%1/2
A
A= delete $chanrec->{'invites'}
Aresult
11
00
10265 4 foreach my $invite ( keys %{ $invites } ) {
10266 0 ▶ next unless $self->state_uid_exists( $invite );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($invite) 0 0 0
10267 0 ▶ next unless $self->_state_is_local_uid( $invite );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_is_local_uid($invite) 0 0 0
10268 0 delete $self->{state}{uids}{$invite}{invites}{uc_irc $chanrec->{name}};
10269 }
10270 # Remove channel modes and apply incoming modes
10271 4 my $origmode = $chanrec->{mode};
10272 4 my @args = @{ $args }[2..$#{ $args }];
10273 4 my $chanmode = shift @args;
10274 4 my $reply = '';
10275 4 my @reply_args;
10276 4 for my $mode (grep { $_ ne '+' } split //, $chanmode) {
10277 8 my $arg;
10278 8 ▶ $arg = shift @args if $mode =~ /[lk]/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /[lk]/ 0 8 8
10279 8 ▶ if ($mode eq 'l' && ($chanrec->{mode} !~ /l/
Branch: 3 branches
BranchTrueFalseTotal
if ($mode eq 'l' and !($chanrec->{'mode'} =~ /l/) || $arg ne $chanrec->{'climit'}) { } 0 8 8
elsif ($mode eq 'k' and !($chanrec->{'mode'} =~ /k/) || $arg ne $chanrec->{'ckey'}) { } 0 8 8
elsif (not $chanrec->{'mode'} =~ /$mode/) { } 0 8 8
Condition16%1/6
$mode eq "l" and !($chanrec->{"mode"} =~ /l/) || $arg ne $chanrec->{"climit"}
!ll&&!rl&&r
800
not $chanrec->{"mode"} =~ /l/ or $arg ne $chanrec->{"climit"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$mode eq "l" and !($chanrec->{"mode"} =~ /l/) || $arg ne $chanrec->{"climit"}
$mode eq "l" not $chanrec->{"mode"} =~ /l/ $arg ne $chanrec->{"climit"}
Truth table25%1/4
A and not(B) or C
A= $mode eq "l"B= not $chanrec->{"mode"} =~ /l/C= $arg ne $chanrec->{"climit"}
ABCresult
0XX0
1000
11X1
1011
10280 || $arg ne $chanrec->{climit})) {
10281 0 $reply .= '+' . $mode;
10282 0 push @reply_args, $arg;
10283 0 ▶ if ($chanrec->{mode} !~ /$mode/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /$mode/) 0 0 0
10284 0 $chanrec->{mode} .= $mode;
10285 }
10286 $chanrec->{mode} = join '', sort split //,
10287 0 $chanrec->{mode};
10288 0 $chanrec->{climit} = $arg;
10289 }
10290 ▶ elsif ($mode eq 'k' && ($chanrec->{mode} !~ /k/
Condition16%1/6
$mode eq "k" and !($chanrec->{"mode"} =~ /k/) || $arg ne $chanrec->{"ckey"}
!ll&&!rl&&r
800
not $chanrec->{"mode"} =~ /k/ or $arg ne $chanrec->{"ckey"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$mode eq "k" and !($chanrec->{"mode"} =~ /k/) || $arg ne $chanrec->{"ckey"}
$mode eq "k" not $chanrec->{"mode"} =~ /k/ $arg ne $chanrec->{"ckey"}
Truth table25%1/4
A and not(B) or C
A= $mode eq "k"B= not $chanrec->{"mode"} =~ /k/C= $arg ne $chanrec->{"ckey"}
ABCresult
0XX0
1000
11X1
1011
10291 || $arg ne $chanrec->{ckey})) {
10292 0 $reply .= '+' . $mode;
10293 0 push @reply_args, $arg;
10294 0 ▶ if ($chanrec->{mode} !~ /$mode/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /$mode/) 0 0 0
10295 0 $chanrec->{mode} .= $mode;
10296 }
10297 $chanrec->{mode} = join '', sort split //,
10298 0 $chanrec->{mode};
10299 0 $chanrec->{ckey} = $arg;
10300 }
10301 elsif ($chanrec->{mode} !~ /$mode/) {
10302 0 $reply .= '+' . $mode;
10303 $chanrec->{mode} = join '', sort split //,
10304 0 $chanrec->{mode};
10305 }
10306 }
10307 4 ▶ $origmode = join '', grep { $chanmode !~ /$_/ }
Condition50%1/2
$origmode || ''
l!l
40
MC/DC0%0/1
$origmode || ''
$origmode
Truth table50%1/2
A
A= $origmode
Aresult
11
00
10308 split //, ($origmode || '');
10309 4 ▶ $chanrec->{mode} =~ s/[$origmode]//g if $origmode;
Branch: 1 branch
BranchTrueFalseTotal
if $origmode 0 4 4
10310 4 ▶ $reply = '-' . $origmode . $reply if $origmode;
Branch: 1 branch
BranchTrueFalseTotal
if $origmode 0 4 4
10311 4 ▶ if ($origmode && $origmode =~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($origmode and $origmode =~ /k/) 0 4 4
Condition33%1/3
$origmode and $origmode =~ /k/
!ll&&!rl&&r
400
MC/DC0%0/2
$origmode and $origmode =~ /k/
$origmode $origmode =~ /k/
Truth table33%1/3
A and B
A= $origmodeB= $origmode =~ /k/
ABresult
0X0
100
111
10312 0 unshift @reply_args, '*';
10313 0 delete $chanrec->{ckey};
10314 }
10315 4 ▶ if ($origmode and $origmode =~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($origmode and $origmode =~ /l/) 0 4 4
Condition33%1/3
$origmode and $origmode =~ /l/
!ll&&!rl&&r
400
MC/DC0%0/2
$origmode and $origmode =~ /l/
$origmode $origmode =~ /l/
Truth table33%1/3
A and B
A= $origmodeB= $origmode =~ /l/
ABresult
0X0
100
111
10316 0 delete $chanrec->{climit};
10317 }
10318 $self->send_output(
10319 {
10320 prefix => $server,
10321 command => 'MODE',
10322 colonify => 0,
10323 params => [
10324 $chanrec->{name},
10325 4 ▶ unparse_mode_line($reply),
Branch: 1 branch
BranchTrueFalseTotal
if $reply 0 4 4
10326 @reply_args,
10327 ],
10328 },
10329 @local_users,
10330 ) if $reply;
10331 # Take incomers and announce +ovh
10332 # Actually do it later
10333 }
10334  
10335 # If the TS received is equal to our TS of the channel the server should keep
10336 # its current modes and accept the received modes and statuses.
10337  
10338 elsif ( $ts == $chanrec->{ts} ) {
10339 # Have to merge chanmodes
10340 68 my $origmode = $chanrec->{mode};
10341 68 my @args = @{ $args }[2..$#{ $args }];
10342 68 my $chanmode = shift @args;
10343 68 my $reply = '';
10344 68 my @reply_args;
10345 68 for my $mode (grep { $_ ne '+' } split //, $chanmode) {
10346 141 my $arg;
10347 141 ▶ $arg = shift @args if $mode =~ /[lk]/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /[lk]/ 1 140 141
10348 141 ▶ if ($mode eq 'l' && ($chanrec->{mode} !~ /l/
Branch: 3 branches
BranchTrueFalseTotal
if ($mode eq 'l' and !($chanrec->{'mode'} =~ /l/) || $arg > $chanrec->{'climit'}) { } 0 141 141
elsif ($mode eq 'k' and !($chanrec->{'mode'} =~ /k/) || ($arg cmp $chanrec->{'ckey'}) > 0) { } 0 141 141
elsif (not $chanrec->{'mode'} =~ /$mode/) { } 0 141 141
Condition50%3/6
$mode eq "l" and !($chanrec->{"mode"} =~ /l/) || $arg > $chanrec->{"climit"}
!ll&&!rl&&r
14010
not $chanrec->{"mode"} =~ /l/ or $arg > $chanrec->{"climit"}
l!l&&r!l&&!r
001
MC/DC0%0/3
$mode eq "l" and !($chanrec->{"mode"} =~ /l/) || $arg > $chanrec->{"climit"}
$mode eq "l" not $chanrec->{"mode"} =~ /l/ $arg > $chanrec->{"climit"}
Truth table50%2/4
A and not(B) or C
A= $mode eq "l"B= not $chanrec->{"mode"} =~ /l/C= $arg > $chanrec->{"climit"}
ABCresult
0XX0
1000
11X1
1011
10349 || $arg > $chanrec->{climit})) {
10350 0 $reply .= '+' . $mode;
10351 0 push @reply_args, $arg;
10352 0 ▶ if ($chanrec->{mode} !~ /$mode/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /$mode/) 0 0 0
10353 0 $chanrec->{mode} .= $mode;
10354 }
10355 $chanrec->{mode} = join '', sort split //,
10356 0 $chanrec->{mode};
10357 0 $chanrec->{climit} = $arg;
10358 }
10359 ▶ elsif ($mode eq 'k' && ($chanrec->{mode} !~ /k/
Condition16%1/6
$mode eq "k" and !($chanrec->{"mode"} =~ /k/) || ($arg cmp $chanrec->{"ckey"}) > 0
!ll&&!rl&&r
14100
not $chanrec->{"mode"} =~ /k/ or ($arg cmp $chanrec->{"ckey"}) > 0
l!l&&r!l&&!r
000
MC/DC0%0/3
$mode eq "k" and !($chanrec->{"mode"} =~ /k/) || ($arg cmp $chanrec->{"ckey"}) > 0
$mode eq "k" not $chanrec->{"mode"} =~ /k/ ($arg cmp $chanrec->{"ckey"}) > 0
Truth table25%1/4
A and not(B) or C
A= $mode eq "k"B= not $chanrec->{"mode"} =~ /k/C= ($arg cmp $chanrec->{"ckey"}) > 0
ABCresult
0XX0
1000
11X1
1011
10360 || ($arg cmp $chanrec->{ckey}) > 0 )) {
10361 0 $reply .= '+' . $mode;
10362 0 push @reply_args, $arg;
10363 0 ▶ if ($chanrec->{mode} !~ /$mode/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /$mode/) 0 0 0
10364 0 $chanrec->{mode} .= $mode;
10365 }
10366 $chanrec->{mode} = join '', sort split //,
10367 0 $chanrec->{mode};
10368 0 $chanrec->{ckey} = $arg;
10369 }
10370 elsif ($chanrec->{mode} !~ /$mode/) {
10371 0 $reply .= '+' . $mode;
10372 $chanrec->{mode} = join '', sort split //,
10373 0 $chanrec->{mode};
10374 }
10375 }
10376 $self->send_output(
10377 {
10378 prefix => $server,
10379 command => 'MODE',
10380 colonify => 0,
10381 params => [
10382 $chanrec->{name},
10383 68 ▶ unparse_mode_line($reply),
Branch: 1 branch
BranchTrueFalseTotal
if $reply 0 68 68
10384 @reply_args,
10385 ],
10386 },
10387 @local_users,
10388 ) if $reply;
10389 }
10390  
10391 # If the TS received is higher than our TS of the channel the server should keep
10392 # its current modes and ignore the received modes and statuses. Any statuses
10393 # given in the received message will be removed.
10394  
10395 else {
10396 4 $uids = join ' ', map { my $s = $_; $s =~ s/[@%+]//g; $s; }
10397 split /\s+/, $uids;
10398 }
10399 # Send it on
10400 $self->send_output(
10401 {
10402 prefix => $prefix,
10403 command => $cmd,
10404 params => [ @$args, $uids ]
10405 },
10406 76 grep { $_ ne $peer_id } $self->_state_connected_peers(),
10407 );
10408 # Joins and modes for new arrivals
10409 76 my $uchan = uc_irc($chanrec->{name});
10410 76 my $modes;
10411 my @aways;
10412 76 my @mode_parms;
10413 76 for my $uid (split /\s+/, $uids) {
10414 1273 my $umode = '';
10415 1273 my @op_list;
10416 1273 ▶ $umode .= 'o' if $uid =~ s/\@//g;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ s/\@//g 20 1253 1273
10417 1273 ▶ $umode .= 'h' if $uid =~ s/\%//g;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ s/\%//g 0 1273 1273
10418 1273 ▶ $umode .= 'v' if $uid =~ s/\+//g;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ s/\+//g 0 1273 1273
10419 1273 ▶ next if !defined $self->{state}{uids}{$uid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$uid} 16 1257 1273
10420 1257 $chanrec->{users}{$uid} = $umode;
10421 1257 $self->{state}{uids}{$uid}{chans}{$uchan} = $umode;
10422 1257 push @op_list, $self->state_user_nick($uid) for split //, $umode;
10423 1257 my $full = $self->state_user_full($uid);
10424 1257 ▶ if ( @local_nextjoin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local_nextjoin) 20 1237 1257
10425 my $output = {
10426 prefix => $full,
10427 command => 'JOIN',
10428 20 params => [$chanrec->{name}],
10429 };
10430 20 $self->send_output($output, @local_nextjoin);
10431 }
10432 1257 ▶ if ( @local_extjoin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local_extjoin) 0 1257 1257
10433 my $extout = {
10434 prefix => $full,
10435 command => 'JOIN',
10436 params => [
10437 $chanrec->{name},
10438 $self->{state}{uids}{$uid}{account},
10439 $self->{state}{uids}{$uid}{ircname},
10440 0 ],
10441 };
10442 0 $self->send_output($extout, @local_extjoin);
10443 }
10444 $self->send_event(
10445 "daemon_join",
10446 $full,
10447 $chanrec->{name},
10448 1257 );
10449 1257 ▶ if ($umode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umode) 20 1237 1257
10450 20 $modes .= $umode;
10451 20 push @mode_parms, @op_list;
10452 }
10453 1257 ▶ if ( $self->{state}{uids}{$uid}{away} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"uids"}{$uid}{"away"}) 2 1255 1257
10454 2 push @aways, { uid => $uid, msg => $self->{state}{uids}{$uid}{away} };
10455 }
10456 }
10457 76 ▶ if ($modes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modes) 20 56 76
10458 $self->send_event(
10459 "daemon_mode",
10460 $server,
10461 $chanrec->{name},
10462 20 '+' . $modes,
10463 @mode_parms,
10464 );
10465 20 my @output_modes;
10466 20 my $length = length($server) + 4 + length($chan) + 4;
10467 20 my @buffer = ('+', '');
10468 20 for my $umode (split //, $modes) {
10469 20 my $arg = shift @mode_parms;
10470 20 ▶ if (length(join ' ', @buffer, $arg) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", @buffer, $arg) + $length > 510) 0 20 20
10471 push @output_modes, {
10472 prefix => $server,
10473 command => 'MODE',
10474 colonify => 0,
10475 params => [
10476 $chanrec->{name},
10477 0 $buffer[0],
10478 split /\s+/,
10479 $buffer[1],
10480 ],
10481 };
10482 0 $buffer[0] = "+$umode";
10483 0 $buffer[1] = $arg;
10484 0 next;
10485 }
10486 20 $buffer[0] .= $umode;
10487 20 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 20 20
10488 0 $buffer[1] = join ' ', $buffer[1], $arg;
10489 }
10490 else {
10491 20 $buffer[1] = $arg;
10492 }
10493 }
10494 push @output_modes, {
10495 prefix => $server,
10496 command => 'MODE',
10497 colonify => 0,
10498 params => [
10499 $chanrec->{name},
10500 20 $buffer[0],
10501 split /\s+/,
10502 $buffer[1],
10503 ],
10504 };
10505 $self->send_output($_, @local_users)
10506 20 for @output_modes;
10507 }
10508 76 ▶ if ( @aways ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@aways) 2 74 76
10509 $self->_state_do_away_notify($_->{uid},$chanrec->{name},$_->{msg})
10510 2 for @aways;
10511 }
10512 }
10513  
10514 126 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 126 126
10515 126 return $ref;
10516 }
10517  
10518 0 ▶sub _daemon_peer_tmode {
Subroutine _daemon_peer_tmode: not called CC=58 SCAR=81.4
10519 0 my $self = shift;
10520 0 ▶ my $peer_id = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
10521 0 ▶ my $uid = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
10522 0 my $ts = shift;
10523 0 my $chan = shift;
10524 0 my $server = $self->server_name();
10525 0 my $sid = $self->server_sid();
10526 0 my $ref = [ ];
10527 0 my $args = [ @_ ];
10528 0 my $count = scalar @$args;
10529  
10530 SWITCH: {
10531 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
10532 0 last SWITCH;
10533 }
10534 0 my $record = $self->{state}{chans}{uc_irc($chan)};
10535 0 ▶ if ( $ts > $record->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ts > $record->{"ts"}) 0 0 0
10536 0 last SWITCH;
10537 }
10538 0 $chan = $record->{name};
10539 0 my $mode_u_set = ( $record->{mode} =~ /u/ );
10540 0 my $full;
10541 0 ▶ $full = $self->state_user_full($uid)
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_uid_exists($uid) 0 0 0
10542 if $self->state_uid_exists($uid);
10543 0 my $reply;
10544 0 my @reply_args; my %subs;
10545 0 my $parsed_mode = parse_mode_line(@$args);
10546  
10547 0 ▶ while (my $mode = shift (@{ $parsed_mode->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 0 0 0
10548 0 my $arg;
10549 0 ▶ $arg = shift @{ $parsed_mode->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 0 0 0
10550 if $mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
10551 0 ▶ if (my ($flag,$char) = $mode =~ /^(\+|-)([ohv])/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^(\+|-)([ohv])/) 0 0 0
10552 0 ▶ if ($flag eq '+'
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"users"}{uc_irc($arg)} =~ /$char/) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"users"}{uc_irc($arg)} =~ /$char/
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"users"}{uc_irc($arg)} =~ /$char/
$flag eq "+" not $record->{"users"}{uc_irc($arg)} =~ /$char/
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"users"}{uc_irc($arg)} =~ /$char/
ABresult
0X0
100
111
10553 && $record->{users}{uc_irc($arg)} !~ /$char/) {
10554 # Update user and chan record
10555 $record->{users}{$arg} = join('', sort split //,
10556 0 $record->{users}{$arg} . $char);
10557 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
10558 0 = $record->{users}{$arg};
10559 0 $reply .= "+$char";
10560 0 $subs{$arg} = $self->state_user_nick($arg);
10561 0 push @reply_args, $arg;
10562 }
10563 0 ▶ if ($flag eq '-' && $record->{users}{uc_irc($arg)}
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
$flag eq "-" $record->{"users"}{uc_irc($arg)} =~ /$char/
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"users"}{uc_irc($arg)} =~ /$char/
ABresult
0X0
100
111
10564 =~ /$char/) {
10565 # Update user and chan record
10566 0 $record->{users}{$arg} =~ s/$char//g;
10567 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
10568 0 = $record->{users}{$arg};
10569 0 $reply .= "-$char";
10570 0 $subs{$arg} = $self->state_user_nick($arg);
10571 0 push @reply_args, $arg;
10572 }
10573 0 next;
10574 }
10575 0 ▶ if ($mode eq '+l' && $arg =~ /^\d+$/ && $arg > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0) 0 0 0
Condition0%0/6
$mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0
!ll&&!rl&&r
000
$mode eq "+l" and $arg =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/3
$mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0
$mode eq "+l" $arg =~ /^\d+$/ $arg > 0
Truth table0%0/4
A and B and C
A= $mode eq "+l"B= $arg =~ /^\d+$/C= $arg > 0
ABCresult
0XX0
10X0
1100
1111
10576 $record->{mode} = join('', sort split //,
10577 0 ▶ $record->{mode} . 'l' ) if $record->{mode} !~ /l/;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"mode"} =~ /l/ 0 0 0
10578 0 $record->{climit} = $arg;
10579 0 $reply .= '+l';
10580 0 push @reply_args, $arg;
10581 0 next;
10582 }
10583 0 ▶ if ($mode eq '-l' && $record->{mode} =~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "-l" and $record->{"mode"} =~ /l/) 0 0 0
Condition0%0/3
$mode eq "-l" and $record->{"mode"} =~ /l/
!ll&&!rl&&r
000
MC/DC0%0/2
$mode eq "-l" and $record->{"mode"} =~ /l/
$mode eq "-l" $record->{"mode"} =~ /l/
Truth table0%0/3
A and B
A= $mode eq "-l"B= $record->{"mode"} =~ /l/
ABresult
0X0
100
111
10584 0 $record->{mode} =~ s/l//g;
10585 0 delete $record->{climit};
10586 0 $reply .= '-l';
10587 0 next;
10588 }
10589 0 ▶ if ($mode eq '+k' && $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+k" and $arg) 0 0 0
Condition0%0/3
$mode eq "+k" and $arg
!ll&&!rl&&r
000
MC/DC0%0/2
$mode eq "+k" and $arg
$mode eq "+k" $arg
Truth table0%0/3
A and B
A= $mode eq "+k"B= $arg
ABresult
0X0
100
111
10590 $record->{mode} = join('', sort split //,
10591 0 ▶ $record->{mode} . 'k') if $record->{mode} !~ /k/;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"mode"} =~ /k/ 0 0 0
10592 0 $record->{ckey} = $arg;
10593 0 $reply .= '+k';
10594 0 push @reply_args, $arg;
10595 0 next;
10596 }
10597 0 ▶ if ($mode eq '-k' && $record->{mode} =~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "-k" and $record->{"mode"} =~ /k/) 0 0 0
Condition0%0/3
$mode eq "-k" and $record->{"mode"} =~ /k/
!ll&&!rl&&r
000
MC/DC0%0/2
$mode eq "-k" and $record->{"mode"} =~ /k/
$mode eq "-k" $record->{"mode"} =~ /k/
Truth table0%0/3
A and B
A= $mode eq "-k"B= $record->{"mode"} =~ /k/
ABresult
0X0
100
111
10598 0 $record->{mode} =~ s/k//g;
10599 0 delete $record->{ckey};
10600 0 $reply .= '-k';
10601 0 next;
10602 }
10603 # Bans
10604 0 ▶ if (my ($flag) = $mode =~ /(\+|-)b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)b/) 0 0 0
10605 0 my $mask = normalize_mask($arg);
10606 0 my $umask = uc_irc($mask);
10607 0 ▶ if ($flag eq '+' && !$record->{bans}{$umask} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"bans"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"bans"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"bans"}{$umask}
$flag eq "+" not $record->{"bans"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"bans"}{$umask}
ABresult
0X0
100
111
10608 0 ▶ $record->{bans}{$umask}
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
10609 = [$mask, ($full || $server), time];
10610 0 $reply .= '+b';
10611 0 push @reply_args, $mask;
10612 }
10613 0 ▶ if ($flag eq '-' && $record->{bans}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"bans"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"bans"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"bans"}{$umask}
$flag eq "-" $record->{"bans"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"bans"}{$umask}
ABresult
0X0
100
111
10614 0 delete $record->{bans}{$umask};
10615 0 $reply .= '-b';
10616 0 push @reply_args, $mask;
10617 }
10618 0 next;
10619 }
10620 # Invex
10621 0 ▶ if (my ($flag) = $mode =~ /(\+|-)I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)I/) 0 0 0
10622 0 my $mask = normalize_mask($arg);
10623 0 my $umask = uc_irc($mask);
10624 0 ▶ if ($flag eq '+' && !$record->{invex}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"invex"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"invex"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"invex"}{$umask}
$flag eq "+" not $record->{"invex"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"invex"}{$umask}
ABresult
0X0
100
111
10625 0 ▶ $record->{invex}{$umask}
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
10626 = [$mask, ($full || $server), time];
10627 0 $reply .= '+I';
10628 0 push @reply_args, $mask;
10629 }
10630 0 ▶ if ($flag eq '-' && $record->{invex}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"invex"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"invex"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"invex"}{$umask}
$flag eq "-" $record->{"invex"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"invex"}{$umask}
ABresult
0X0
100
111
10631 0 delete $record->{invex}{$umask};
10632 0 $reply .= '-I';
10633 0 push @reply_args, $mask;
10634 }
10635 0 next;
10636 }
10637 # Exceptions
10638 0 ▶ if (my ($flag) = $mode =~ /(\+|-)e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)e/) 0 0 0
10639 0 my $mask = normalize_mask($arg);
10640 0 my $umask = uc_irc($mask);
10641 0 ▶ if ($flag eq '+' && !$record->{excepts}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"excepts"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"excepts"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"excepts"}{$umask}
$flag eq "+" not $record->{"excepts"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"excepts"}{$umask}
ABresult
0X0
100
111
10642 0 ▶ $record->{excepts}{$umask}
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
10643 = [$mask, ($full || $server), time];
10644 0 $reply .= '+e';
10645 0 push @reply_args, $mask;
10646 }
10647 0 ▶ if ($flag eq '-' && $record->{excepts}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"excepts"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"excepts"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"excepts"}{$umask}
$flag eq "-" $record->{"excepts"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"excepts"}{$umask}
ABresult
0X0
100
111
10648 0 delete $record->{excepts}{$umask};
10649 0 $reply .= '-e';
10650 0 push @reply_args, $mask;
10651 }
10652 0 next;
10653 }
10654 # The rest should be argumentless.
10655 0 my ($flag, $char) = split //, $mode;
10656 0 ▶ if ( $flag eq '+' && $record->{mode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"mode"} =~ /$char/) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"mode"} =~ /$char/
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"mode"} =~ /$char/
$flag eq "+" not $record->{"mode"} =~ /$char/
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"mode"} =~ /$char/
ABresult
0X0
100
111
10657 $record->{mode} = join('', sort split //,
10658 0 $record->{mode} . $char);
10659 0 $reply .= "+$char";
10660 0 next;
10661 }
10662 0 ▶ if ($flag eq '-' && $record->{mode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"mode"} =~ /$char/) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"mode"} =~ /$char/
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"mode"} =~ /$char/
$flag eq "-" $record->{"mode"} =~ /$char/
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"mode"} =~ /$char/
ABresult
0X0
100
111
10663 0 $record->{mode} =~ s/$char//g;
10664 0 $reply .= "-$char";
10665 0 next;
10666 }
10667 } # while
10668  
10669 0 unshift @$args, $record->{name};
10670 0 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 0 0 0
10671 0 my $parsed_line = unparse_mode_line($reply);
10672 $self->send_output(
10673 {
10674 prefix => $uid,
10675 command => 'TMODE',
10676 colonify => 0,
10677 params => [
10678 $record->{name},
10679 $parsed_line,
10680 @reply_args,
10681 ],
10682 },
10683 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
10684 );
10685 my @reply_args_chan = map {
10686 0 ▶ ( defined $subs{$_} ? $subs{$_} : $_ )
Branch: 1 branch
BranchTrueFalseTotal
defined $subs{$_} ? : 0 0 0
10687 } @reply_args;
10688  
10689 $self->send_event(
10690 "daemon_mode",
10691 ($full || $server),
10692 $record->{name},
10693 0 ▶ $parsed_line,
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
10694 @reply_args_chan,
10695 );
10696  
10697 $self->_send_output_channel_local(
10698 $record->{name},
10699 {
10700 prefix => ($full || $server),
10701 command => 'MODE',
10702 colonify => 0,
10703 params => [
10704 $record->{name},
10705 0 ▶ $parsed_line,
Branch: 1 branch
BranchTrueFalseTotal
$mode_u_set ? : 0 0 0
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
10706 @reply_args_chan,
10707 ],
10708 },
10709 '',
10710 ( $mode_u_set ? 'oh' : '' ),
10711 );
10712 0 ▶ if ($mode_u_set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode_u_set) 0 0 0
10713 0 my $bparse = parse_mode_line( join ' ', $parsed_line, @reply_args_chan );
10714 0 my $breply; my @breply_args;
10715 0 ▶ while (my $bmode = shift (@{ $bparse->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bmode = shift @{$$bparse{"modes"};}) 0 0 0
10716 0 my $arg;
10717 0 ▶ $arg = shift @{ $bparse->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 0 0 0
10718 if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
10719 0 ▶ next if $bmode =~ m!^[+-][beI]$!;
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^[+-][beI]$/ 0 0 0
10720 0 $breply .= $bmode;
10721 0 push @breply_args, $arg;
10722 }
10723 0 ▶ if ($breply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breply) 0 0 0
10724 0 $parsed_line = unparse_mode_line($breply);
10725 $self->_send_output_channel_local(
10726 $record->{name},
10727 {
10728 prefix => ($full || $server),
10729 command => 'MODE',
10730 colonify => 0,
10731 params => [
10732 $record->{name},
10733 0 ▶ $parsed_line,
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
10734 @breply_args,
10735 ],
10736 },
10737 '','-oh',
10738 );
10739 }
10740 }
10741 }
10742 } # SWITCH
10743  
10744 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
10745 0 return $ref;
10746 }
10747  
10748 # :<SID> BMASK <TS> <CHANNAME> <TYPE> :<MASKS>
10749 72 ▶sub _daemon_peer_bmask {
Subroutine _daemon_peer_bmask: called CC=18 SCAR=29.4
10750 72 my $self = shift;
10751 72 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
720
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10752 72 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
720
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10753 72 my $ref = [ ];
10754 72 my $args = [ @_ ];
10755 72 my $count = scalar @$args;
10756 72 my %map = qw(b bans e excepts I invex);
10757  
10758 SWITCH: {
10759 72 ▶ if ( !$count || $count < 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 4) 0 72 72
Condition33%1/3
not $count or $count < 4
l!l&&r!l&&!r
0072
MC/DC0%0/2
not $count or $count < 4
not $count $count < 4
Truth table33%1/3
not(A) or B
A= not $countB= $count < 4
ABresult
1X1
011
000
10760 0 last SWITCH;
10761 }
10762 72 my ($ts,$chan,$trype,$masks) = @$args;
10763 72 ▶ if ( !$self->state_chan_exists($chan) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 72 72
10764 0 last SWITCH;
10765 }
10766 72 my $chanrec = $self->{state}{chans}{uc_irc($chan)};
10767 # Simple TS rules apply
10768 72 ▶ if ( $ts > $chanrec->{ts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ts > $chanrec->{"ts"}) 6 66 72
10769 # Drop MODE
10770 6 last SWITCH;
10771 }
10772 $self->send_output(
10773 {
10774 prefix => $prefix,
10775 command => 'BMASK',
10776 params => $args,
10777 },
10778 66 grep { $_ ne $peer_id } $self->_state_connected_peers(),
10779 );
10780 66 my $mode_u_set = ( $chanrec->{mode} =~ /u/ );
10781 66 my $sid = $self->server_sid();
10782 66 my $server = $self->server_name();
10783 72 my @local_users = map { $self->_state_uid_route( $_ ) }
10784 72 ▶ grep { !$mode_u_set || $chanrec->{users}{$_} =~ /[oh]/ }
Condition33%1/3
!$mode_u_set || $chanrec->{'users'}{$_} =~ /[oh]/
l!l&&r!l&&!r
7200
MC/DC0%0/2
!$mode_u_set || $chanrec->{'users'}{$_} =~ /[oh]/
!$mode_u_set $chanrec->{'users'}{$_} =~ /[oh]/
Truth table33%1/3
not(A) || B
A= !$mode_u_setB= $chanrec->{'users'}{$_} =~ /[oh]/
ABresult
1X1
011
000
10785 66 grep { $_ =~ m!^$sid! } keys %{ $chanrec->{users} };
10786 66 my @mask_list = split m!\s+!, $masks;
10787 66 my @marsk_list;
10788 66 foreach my $marsk ( @mask_list ) {
10789 636 my $mask = normalize_mask($marsk);
10790 636 my $umask = uc_irc($mask);
10791 636 ▶ next if $chanrec->{ $map{ $trype } }{$umask};
Branch: 1 branch
BranchTrueFalseTotal
if $$chanrec{$map{$trype}}{$umask} 327 309 636
10792 309 $chanrec->{ $map{ $trype } }{$umask} =
10793 [ $mask, $server, time() ];
10794 309 push @marsk_list, $marsk;
10795 }
10796 # Only bother with the next bit if we have local users on the channel
10797 # OR masks to announce
10798 66 ▶ if ( !@local_users || !@marsk_list ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@local_users and @marsk_list) 33 33 66
Condition66%2/3
@local_users and @marsk_list
!ll&&!rl&&r
03333
MC/DC50%1/2
@local_users and @marsk_list
@local_users @marsk_list
Truth table66%2/3
A and B
A= @local_usersB= @marsk_list
ABresult
0X0
100
111
10799 33 last SWITCH;
10800 }
10801 33 my @types;
10802 33 push @types, "+$trype" for @marsk_list;
10803 33 my @output_modes;
10804 33 my $length = length($server) + 4
10805 + length($chan) + 4;
10806 33 my @buffer = ('', '');
10807 33 for my $type (@types) {
10808 309 my $arg = shift @marsk_list;
10809 309 my $mode_line = unparse_mode_line($buffer[0].$type);
10810 309 ▶ if (length(join ' ', $mode_line, $buffer[1],
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $mode_line, $buffer[1], $arg) + $length > 510) 10 299 309
10811 $arg) + $length > 510) {
10812 push @output_modes, {
10813 prefix => $server,
10814 command => 'MODE',
10815 colonify => 0,
10816 params => [
10817 $chanrec->{name},
10818 10 $buffer[0],
10819 split /\s+/,
10820 $buffer[1],
10821 ],
10822 };
10823 10 $buffer[0] = $type;
10824 10 $buffer[1] = $arg;
10825 10 next;
10826 }
10827 299 $buffer[0] = $mode_line;
10828 299 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 266 33 299
10829 266 $buffer[1] = join ' ', $buffer[1], $arg;
10830 }
10831 else {
10832 33 $buffer[1] = $arg;
10833 }
10834 }
10835 push @output_modes, {
10836 prefix => $server,
10837 command => 'MODE',
10838 colonify => 0,
10839 params => [
10840 $chanrec->{name},
10841 33 $buffer[0],
10842 split /\s+/, $buffer[1],
10843 ],
10844 };
10845 $self->send_output($_, @local_users)
10846 33 for @output_modes;
10847 }
10848  
10849 72 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 72 72
10850 72 return $ref;
10851 }
10852  
10853 10 ▶sub _daemon_peer_tburst {
Subroutine _daemon_peer_tburst: called CC=15 SCAR=30.7
10854 10 my $self = shift;
10855 10 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
100
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10856 10 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
100
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10857 10 my $ref = [ ];
10858 10 my $args = [ @_ ];
10859 10 my $count = @$args;
10860  
10861 # :8H8 TBURST 1525787545 #dummynet 1526409011 llestr!bingos@staff.gumbynet.org.uk :this is dummynet, foo
10862  
10863 SWITCH: {
10864 10 ▶ if ( !$self->state_chan_exists( $args->[1] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($args->[1])) 0 10 10
10865 0 last SWITCH;
10866 }
10867 10 my ($chants,$chan,$topicts,$who,$what) = @$args;
10868 10 my $accept;
10869 10 my $uchan = uc_irc $chan;
10870 10 my $chanrec = $self->{state}{chans}{$uchan};
10871 10 ▶ if ( $chants < $chanrec->{ts} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($chants < $chanrec->{'ts'}) { } 0 10 10
elsif ($chants == $chanrec->{'ts'}) { } 10 0 10
10872 0 $accept = 1;
10873 }
10874 elsif ( $chants == $chanrec->{ts} ) {
10875 10 ▶ if ( !$chanrec->{topic} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $chanrec->{'topic'}) { } 6 4 10
elsif ($topicts > $chanrec->{'topic'}[2]) { } 0 4 4
10876 6 $accept = 1;
10877 }
10878 elsif ( $topicts > $chanrec->{topic}[2] ) {
10879 0 $accept = 1;
10880 }
10881 }
10882 10 ▶ if ( !$accept ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($accept) 4 6 10
10883 4 last SWITCH;
10884 }
10885 $self->send_output(
10886 {
10887 prefix => $prefix,
10888 command => 'TBURST',
10889 params => $args,
10890 },
10891 0 grep { $self->_state_peer_capab($_,'TBURST') }
10892 6 grep { $_ ne $peer_id } $self->_state_connected_peers(),
10893 );
10894 6 ▶ my $differing = ( !$chanrec->{topic} || $chanrec->{topic}[0] ne $what );
Condition33%1/3
!$chanrec->{'topic'} || $chanrec->{'topic'}[0] ne $what
l!l&&r!l&&!r
600
MC/DC0%0/2
!$chanrec->{'topic'} || $chanrec->{'topic'}[0] ne $what
!$chanrec->{'topic'} $chanrec->{'topic'}[0] ne $what
Truth table33%1/3
not(A) || B
A= !$chanrec->{'topic'}B= $chanrec->{'topic'}[0] ne $what
ABresult
1X1
011
000
10895 6 $chanrec->{topic} = [ $what, $who, $topicts ];
10896 6 ▶ if ( !$differing ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($differing) 0 6 6
10897 0 last SWITCH;
10898 }
10899 6 ▶ my $whom = ( $self->{config}{'hidden_servers'} ? $self->server_name() : $self->_state_sid_name( $prefix ) )
Branch: 1 branch
BranchTrueFalseTotal
$self->{'config'}{'hidden_servers'} ? : 1 5 6
Condition33%2/6
($self->{'config'}{'hidden_servers'} ? $self->server_name : $self->_state_sid_name($prefix)) || $self->state_user_full($prefix) || $self->server_name
l!l&&r!l&&!r
600
$self->{"config"}{"hidden_servers"} ? $self->server_name : $self->_state_sid_name($prefix) or $self->state_user_full($prefix)
l!l&&r!l&&!r
600
MC/DC0%0/3
($self->{'config'}{'hidden_servers'} ? $self->server_name : $self->_state_sid_name($prefix)) || $self->state_user_full($prefix) || $self->server_name
$self->{"config"}{"hidden_servers"} ? $self->server_name : $self->_state_sid_name($prefix) $self->state_user_full($prefix) $self->server_name
Truth table25%1/4
A or B || C
A= $self->{"config"}{"hidden_servers"} ? $self->server_name : $self->_state_sid_name($prefix)B= $self->state_user_full($prefix)C= $self->server_name
ABCresult
1XX1
01X1
0011
0000
10900 || $self->state_user_full( $prefix ) || $self->server_name();
10901 6 $self->_send_output_channel_local(
10902 $chan,
10903 {
10904 prefix => $whom,
10905 command => 'TOPIC',
10906 params => [ $chan, $what ],
10907 },
10908 );
10909 }
10910  
10911 10 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 10 10
10912 10 return $ref;
10913 }
10914  
10915 0 ▶sub _daemon_peer_umode {
Subroutine _daemon_peer_umode: not called CC=14 SCAR=53.5
10916 0 my $self = shift;
10917 0 ▶ my $peer_id = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
10918 0 ▶ my $prefix = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
10919 0 ▶ my $uid = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
10920 0 my $umode = shift;
10921 0 my $ref = [ ];
10922 0 my $record = $self->{state}{uids}{$uid};
10923 0 my $parsed_mode = parse_mode_line($umode);
10924  
10925 0 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 0 0 0
10926 0 my ($action, $char) = split //, $mode;
10927 0 ▶ if ($action eq '+' && $record->{umode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and not $record->{"umode"} =~ /$char/) 0 0 0
Condition0%0/3
$action eq "+" and not $record->{"umode"} =~ /$char/
!ll&&!rl&&r
000
MC/DC0%0/2
$action eq "+" and not $record->{"umode"} =~ /$char/
$action eq "+" not $record->{"umode"} =~ /$char/
Truth table0%0/3
A and not(B)
A= $action eq "+"B= not $record->{"umode"} =~ /$char/
ABresult
0X0
100
111
10928 0 $record->{umode} .= $char;
10929 0 ▶ $self->{state}{stats}{invisible}++ if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
10930 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
10931 0 $self->{state}{stats}{ops_online}++;
10932 }
10933 }
10934 0 ▶ if ($action eq '-' && $record->{umode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "-" and $record->{"umode"} =~ /$char/) 0 0 0
Condition0%0/3
$action eq "-" and $record->{"umode"} =~ /$char/
!ll&&!rl&&r
000
MC/DC0%0/2
$action eq "-" and $record->{"umode"} =~ /$char/
$action eq "-" $record->{"umode"} =~ /$char/
Truth table0%0/3
A and B
A= $action eq "-"B= $record->{"umode"} =~ /$char/
ABresult
0X0
100
111
10935 0 $record->{umode} =~ s/$char//g;
10936 0 ▶ $self->{state}{stats}{invisible}-- if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
10937 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
10938 0 $self->{state}{stats}{ops_online}--;
10939 }
10940 }
10941 }
10942 $self->send_output(
10943 {
10944 prefix => $prefix,
10945 command => 'MODE',
10946 params => [$uid, $umode],
10947 },
10948 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
10949 );
10950 $self->send_event(
10951 "daemon_umode",
10952 0 $record->{full}->(),
10953 $umode,
10954 );
10955  
10956 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
10957 0 return $ref;
10958 }
10959  
10960 7 ▶sub _daemon_peer_message {
Subroutine _daemon_peer_message: called CC=100 SCAR=72.3
10961 7 my $self = shift;
10962 7 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10963 7 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10964 7 ▶ my $type = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
10965 7 my $ref = [ ];
10966 7 my $args = [ @_ ];
10967 7 my $count = @$args;
10968  
10969 SWITCH: {
10970 7 my $nick = $self->state_user_nick($uid);
10971 7 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 7 7
10972 0 push @$ref, ['461', $type];
10973 0 last SWITCH;
10974 }
10975 7 ▶ if ($count < 2 || !$args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < 2 or not $args->[1]) 0 7 7
Condition33%1/3
$count < 2 or not $args->[1]
l!l&&r!l&&!r
007
MC/DC0%0/2
$count < 2 or not $args->[1]
$count < 2 not $args->[1]
Truth table33%1/3
A or not(B)
A= $count < 2B= not $args->[1]
ABresult
1X1
011
000
10976 0 push @$ref, ['412'];
10977 0 last SWITCH;
10978 }
10979 7 my $targets = 0;
10980 7 my $max_targets = $self->server_config('MAXTARGETS');
10981 7 my $full = $self->state_user_full($uid);
10982 7 my $targs = $self->_state_parse_msg_targets($args->[0]);
10983  
10984 7 LOOP: for my $target (keys %$targs) {
10985 7 my $targ_type = shift @{ $targs->{$target} };
10986 7 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)) 0 7 7
Condition66%2/3
$targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
520
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)
$targ_type =~ /(server|host)mask/ not $self->state_user_is_operator($nick)
Truth table66%2/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $self->state_user_is_operator($nick)
ABresult
0X0
100
111
10987 && !$self->state_user_is_operator($nick)) {
10988 0 push @$ref, ['481'];
10989 0 next LOOP;
10990 }
10991 7 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./) 0 7 7
Condition66%2/3
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
!ll&&!rl&&r
520
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
$targ_type =~ /(server|host)mask/ not $targs->{$target}[0] =~ /\./
Truth table66%2/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $targs->{$target}[0] =~ /\./
ABresult
0X0
100
111
10992 && $targs->{$target}[0] !~ /\./) {
10993 0 push @$ref, ['413', $target];
10994 0 next LOOP;
10995 }
10996 7 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and $targs->{$target}[0] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/) 0 7 7
Condition66%2/3
$targ_type =~ /(server|host)mask/ and $targs->{$target}[0] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
!ll&&!rl&&r
520
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and $targs->{$target}[0] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
$targ_type =~ /(server|host)mask/ $targs->{$target}[0] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
Truth table66%2/3
A and B
A= $targ_type =~ /(server|host)mask/B= $targs->{$target}[0] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/
ABresult
0X0
100
111
10997 && $targs->{$target}[0] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/) {
10998 0 push @$ref, ['414', $target];
10999 0 next LOOP;
11000 }
11001 7 ▶ if ($targ_type eq 'channel_ext'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])) 0 7 7
Condition33%1/3
$targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])
!ll&&!rl&&r
700
MC/DC0%0/2
$targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])
$targ_type eq "channel_ext" not $self->state_chan_exists($targs->{$target}[1])
Truth table33%1/3
A and not(B)
A= $targ_type eq "channel_ext"B= not $self->state_chan_exists($targs->{$target}[1])
ABresult
0X0
100
111
11002 && !$self->state_chan_exists($targs->{$target}[1])) {
11003 0 push @$ref, ['401', $targs->{$target}[1]];
11004 0 next LOOP;
11005 }
11006 7 ▶ if ($targ_type eq 'channel'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel" and not $self->state_chan_exists($target)) 0 7 7
Condition66%2/3
$targ_type eq "channel" and not $self->state_chan_exists($target)
!ll&&!rl&&r
610
MC/DC0%0/2
$targ_type eq "channel" and not $self->state_chan_exists($target)
$targ_type eq "channel" not $self->state_chan_exists($target)
Truth table66%2/3
A and not(B)
A= $targ_type eq "channel"B= not $self->state_chan_exists($target)
ABresult
0X0
100
111
11007 && !$self->state_chan_exists($target)) {
11008 0 push @$ref, ['401', $target];
11009 0 next LOOP;
11010 }
11011 7 ▶ if ($targ_type eq 'nick'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick" and not $self->state_nick_exists($target)) 0 7 7
Condition33%1/3
$targ_type eq "nick" and not $self->state_nick_exists($target)
!ll&&!rl&&r
700
MC/DC0%0/2
$targ_type eq "nick" and not $self->state_nick_exists($target)
$targ_type eq "nick" not $self->state_nick_exists($target)
Truth table33%1/3
A and not(B)
A= $targ_type eq "nick"B= not $self->state_nick_exists($target)
ABresult
0X0
100
111
11012 && !$self->state_nick_exists($target)) {
11013 0 push @$ref, ['401', $target];
11014 0 next LOOP;
11015 }
11016 7 ▶ if ($targ_type eq 'uid'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "uid" and not $self->state_uid_exists($target)) 0 7 7
Condition66%2/3
$targ_type eq "uid" and not $self->state_uid_exists($target)
!ll&&!rl&&r
340
MC/DC0%0/2
$targ_type eq "uid" and not $self->state_uid_exists($target)
$targ_type eq "uid" not $self->state_uid_exists($target)
Truth table66%2/3
A and not(B)
A= $targ_type eq "uid"B= not $self->state_uid_exists($target)
ABresult
0X0
100
111
11017 && !$self->state_uid_exists($target)) {
11018 0 push @$ref, ['401', $target];
11019 0 next LOOP;
11020 }
11021 7 ▶ if ($targ_type eq 'uid') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "uid") 4 3 7
11022 4 $target = $self->state_user_nick($target);
11023 }
11024 7 ▶ if ($targ_type eq 'nick_ext'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])) 0 7 7
Condition33%1/3
$targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])
!ll&&!rl&&r
700
MC/DC0%0/2
$targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])
$targ_type eq "nick_ext" not $self->state_peer_exists($targs->{$target}[1])
Truth table33%1/3
A and not(B)
A= $targ_type eq "nick_ext"B= not $self->state_peer_exists($targs->{$target}[1])
ABresult
0X0
100
111
11025 && !$self->state_peer_exists($targs->{$target}[1])) {
11026 0 push @$ref, ['402', $targs->{$target}[1]];
11027 0 next LOOP;
11028 }
11029 7 $targets++;
11030 7 ▶ if ($targets > $max_targets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targets > $max_targets) 0 7 7
11031 0 push @$ref, ['407', $target];
11032 0 last SWITCH;
11033 }
11034 # $$whatever
11035 7 ▶ if ($targ_type eq 'servermask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "servermask") 1 6 7
11036 1 my $us = 0;
11037 1 my %targets;
11038 1 my $ucserver = uc $self->server_name();
11039 1 for my $peer (keys %{ $self->{state}{peers} }) {
11040 4 ▶ if (matches_mask($targs->{$target}[0], $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targs->{$target}[0], $peer)) 1 3 4
11041 1 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 0 1
11042 1 $us = 1;
11043 }
11044 else {
11045 0 $targets{ $self->_state_peer_route($peer) }++;
11046 }
11047 }
11048 }
11049 1 delete $targets{$peer_id};
11050 1 $self->send_output(
11051 {
11052 prefix => $uid,
11053 command => $type,
11054 params => [$target, $args->[1]],
11055 },
11056 keys %targets,
11057 );
11058 1 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 1 0 1
11059 1 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
11060 1 my @local;
11061 1 my $spoofed = 0;
11062 1 for my $luser (values %$local) {
11063 3 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 3 3
11064 0 $spoofed = 1;
11065 }
11066 else {
11067 3 push @local, $luser->{route_id};
11068 }
11069 }
11070 $self->send_output(
11071 {
11072 1 prefix => $full,
11073 command => $type,
11074 params => [$target, $args->[1]],
11075 },
11076 @local,
11077 );
11078 1 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 1 1
11079 "daemon_" . lc $type,
11080 $full,
11081 $target,
11082 $args->[1],
11083 ) if $spoofed;
11084 }
11085 1 next LOOP;
11086 }
11087 # $#whatever
11088 6 ▶ if ($targ_type eq 'hostmask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "hostmask") 1 5 6
11089 1 my $spoofed = 0;
11090 1 my %targets;
11091 my @local;
11092 1 HOST: for my $luser (values %{ $self->{state}{users} }) {
11093 next HOST if !matches_mask(
11094 6 ▶ $targs->{$target}[0], $luser->{auth}{hostname});
Branch: 1 branch
BranchTrueFalseTotal
unless matches_mask($targs->{$target}[0], $luser->{"auth"}{"hostname"}) 3 3 6
11095 3 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 2 branches
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 3 3
elsif ($luser->{'type'} eq 'r') { } 0 3 3
11096 0 $spoofed = 1;
11097 }
11098 elsif ( $luser->{type} eq 'r') {
11099 0 $targets{$luser->{route_id}}++;
11100 }
11101 else {
11102 3 push @local, $luser->{route_id};
11103 }
11104 }
11105 1 delete $targets{$peer_id};
11106 1 $self->send_output(
11107 {
11108 prefix => $uid,
11109 command => $type,
11110 params => [$target, $args->[1]],
11111 },
11112 keys %targets,
11113 );
11114 1 $self->send_output(
11115 {
11116 prefix => $full,
11117 command => $type,
11118 params => [$target, $args->[1]],
11119 },
11120 @local,
11121 );
11122 1 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 1 1
11123 "daemon_" . lc $type,
11124 $full,
11125 $target,
11126 $args->[1],
11127 ) if $spoofed;
11128 1 next LOOP;
11129 }
11130 5 ▶ if ($targ_type eq 'nick_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext") 0 5 5
11131 $targs->{$target}[1]
11132 0 = $self->_state_peer_name($targs->{$target}[1]);
11133 0 ▶ if ($targs->{$target}[2]
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[2] and not $self->state_user_is_operator($nick)) 0 0 0
Condition0%0/3
$targs->{$target}[2] and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
000
MC/DC0%0/2
$targs->{$target}[2] and not $self->state_user_is_operator($nick)
$targs->{$target}[2] not $self->state_user_is_operator($nick)
Truth table0%0/3
A and not(B)
A= $targs->{$target}[2]B= not $self->state_user_is_operator($nick)
ABresult
0X0
100
111
11134 && !$self->state_user_is_operator($nick)) {
11135 0 push @$ref, ['481'];
11136 0 next LOOP;
11137 }
11138 0 ▶ if ($targs->{$target}[1] ne $self->server_name()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[1] ne $self->server_name) 0 0 0
11139 $self->send_output(
11140 {
11141 prefix => $uid,
11142 command => $type,
11143 params => [$target, $args->[1]],
11144 },
11145 0 $self->_state_peer_route($targs->{$target}[1]),
11146 );
11147 0 next LOOP;
11148 }
11149 0 ▶ if (uc $targs->{$target}[0] eq 'OPERS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $targs->{$target}[0] eq "OPERS") 0 0 0
11150 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
11151 0 push @$ref, ['481'];
11152 0 next LOOP;
11153 }
11154 $self->send_output(
11155 {
11156 prefix => $full,
11157 command => $type,
11158 params => [$target, $args->[1]],
11159 },
11160 0 keys %{ $self->{state}{localops} },
11161 );
11162 0 next LOOP;
11163 }
11164  
11165 my @local = $self->_state_find_user_host(
11166 $targs->{$target}[0],
11167 0 $targs->{$target}[2],
11168 );
11169  
11170 0 ▶ if (@local == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local == 1) { } 0 0 0
11171 0 my $ref = shift @local;
11172 0 ▶ if ($ref->[0] eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->[0] eq 'spoofed') { } 0 0 0
11173 0 $self->send_event(
11174 "daemon_" . lc $type,
11175 $full,
11176 $ref->[1],
11177 $args->[1],
11178 );
11179 }
11180 else {
11181 0 $self->send_output(
11182 {
11183 prefix => $full,
11184 command => $type,
11185 params => [$target, $args->[1]],
11186 },
11187 $ref->[0],
11188 );
11189 }
11190 }
11191 else {
11192 0 push @$ref, ['407', $target];
11193 0 next LOOP;
11194 }
11195 }
11196 5 my $channel;
11197 my $status_msg;
11198 5 ▶ if ($targ_type eq 'channel') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel") 1 4 5
11199 1 $channel = $self->_state_chan_name($target);
11200 }
11201 5 ▶ if ($targ_type eq 'channel_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext") 0 5 5
11202 0 $channel = $self->_state_chan_name($targs->{target}[1]);
11203 0 $status_msg = $targs->{target}[0];
11204 }
11205 5 ▶ if ($channel && $status_msg
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)) 0 5 5
Condition50%3/6
$channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
500
$channel and $status_msg
!ll&&!rl&&r
410
MC/DC0%0/3
$channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)
$channel $status_msg not $self->state_user_chan_mode($nick, $channel)
Truth table50%2/4
A and B and not(C)
A= $channelB= $status_msgC= not $self->state_user_chan_mode($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
11206 && !$self->state_user_chan_mode($nick, $channel)) {
11207 0 push @$ref, ['482', $target];
11208 0 next LOOP;
11209 }
11210 5 ▶ if ($channel && $self->state_chan_mode_set($channel, 'n')
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->state_chan_mode_set($channel, "n") and not $self->state_is_chan_member($nick, $channel)) 0 5 5
Condition66%4/6
$channel and $self->state_chan_mode_set($channel, "n") and not $self->state_is_chan_member($nick, $channel)
!ll&&!rl&&r
410
$channel and $self->state_chan_mode_set($channel, "n")
!ll&&!rl&&r
401
MC/DC0%0/3
$channel and $self->state_chan_mode_set($channel, "n") and not $self->state_is_chan_member($nick, $channel)
$channel $self->state_chan_mode_set($channel, "n") not $self->state_is_chan_member($nick, $channel)
Truth table50%2/4
A and B and not(C)
A= $channelB= $self->state_chan_mode_set($channel, "n")C= not $self->state_is_chan_member($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
11211 && !$self->state_is_chan_member($nick, $channel)) {
11212 0 push @$ref, ['404', $channel];
11213 0 next LOOP;
11214 }
11215 5 ▶ if ($channel && $self->state_chan_mode_set($channel, 'm')
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->state_chan_mode_set($channel, "m") and not $self->state_user_chan_mode($nick, $channel)) 0 5 5
Condition50%3/6
$channel and $self->state_chan_mode_set($channel, "m") and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "m")
!ll&&!rl&&r
410
MC/DC0%0/3
$channel and $self->state_chan_mode_set($channel, "m") and not $self->state_user_chan_mode($nick, $channel)
$channel $self->state_chan_mode_set($channel, "m") not $self->state_user_chan_mode($nick, $channel)
Truth table50%2/4
A and B and not(C)
A= $channelB= $self->state_chan_mode_set($channel, "m")C= not $self->state_user_chan_mode($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
11216 && !$self->state_user_chan_mode($nick, $channel)) {
11217 0 push @$ref, ['404', $channel];
11218 0 next LOOP;
11219 }
11220 5 ▶ if ($channel && $self->state_chan_mode_set($channel, 'T')
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->state_chan_mode_set($channel, "T") and $type eq "NOTICE" and not $self->state_user_chan_mode($nick, $channel)) 0 5 5
Condition44%4/9
$channel and $self->state_chan_mode_set($channel, "T") and $type eq "NOTICE" and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "T") and $type eq "NOTICE"
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "T")
!ll&&!rl&&r
410
MC/DC0%0/4
$channel and $self->state_chan_mode_set($channel, "T") and $type eq "NOTICE" and not $self->state_user_chan_mode($nick, $channel)
$channel $self->state_chan_mode_set($channel, "T") $type eq "NOTICE" not $self->state_user_chan_mode($nick, $channel)
Truth table40%2/5
A and B and C and not(D)
A= $channelB= $self->state_chan_mode_set($channel, "T")C= $type eq "NOTICE"D= not $self->state_user_chan_mode($nick, $channel)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
11221 && $type eq 'NOTICE' && !$self->state_user_chan_mode($nick, $channel)) {
11222 0 push @$ref, ['404', $channel];
11223 0 next LOOP;
11224 }
11225 5 ▶ if ($channel && $self->state_chan_mode_set($channel, 'M')
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->state_chan_mode_set($channel, "M") and not $self->state_user_umode($nick) =~ /r/) 0 5 5
Condition50%3/6
$channel and $self->state_chan_mode_set($channel, "M") and not $self->state_user_umode($nick) =~ /r/
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "M")
!ll&&!rl&&r
410
MC/DC0%0/3
$channel and $self->state_chan_mode_set($channel, "M") and not $self->state_user_umode($nick) =~ /r/
$channel $self->state_chan_mode_set($channel, "M") not $self->state_user_umode($nick) =~ /r/
Truth table50%2/4
A and B and not(C)
A= $channelB= $self->state_chan_mode_set($channel, "M")C= not $self->state_user_umode($nick) =~ /r/
ABCresult
0XX0
10X0
1100
1111
11226 && $self->state_user_umode($nick) !~ /r/) {
11227 0 push @$ref, ['477', $channel];
11228 0 next LOOP;
11229 }
11230 5 ▶ if ($channel && $self->_state_user_banned($nick, $channel)
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->_state_user_banned($nick, $channel) and not $self->state_user_chan_mode($nick, $channel)) 0 5 5
Condition50%3/6
$channel and $self->_state_user_banned($nick, $channel) and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
500
$channel and $self->_state_user_banned($nick, $channel)
!ll&&!rl&&r
410
MC/DC0%0/3
$channel and $self->_state_user_banned($nick, $channel) and not $self->state_user_chan_mode($nick, $channel)
$channel $self->_state_user_banned($nick, $channel) not $self->state_user_chan_mode($nick, $channel)
Truth table50%2/4
A and B and not(C)
A= $channelB= $self->_state_user_banned($nick, $channel)C= not $self->state_user_chan_mode($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
11231 && !$self->state_user_chan_mode($nick, $channel)) {
11232 0 push @$ref, ['404', $channel];
11233 0 next LOOP;
11234 }
11235 5 ▶ if ($channel && $self->state_chan_mode_set($channel, 'c')
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->state_chan_mode_set($channel, "c") and has_color($args->[1]) || has_formatting($args->[1])) 0 5 5
Condition33%3/9
$channel and $self->state_chan_mode_set($channel, "c") and has_color($args->[1]) || has_formatting($args->[1])
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "c")
!ll&&!rl&&r
410
has_color($args->[1]) or has_formatting($args->[1])
l!l&&r!l&&!r
000
MC/DC0%0/4
$channel and $self->state_chan_mode_set($channel, "c") and has_color($args->[1]) || has_formatting($args->[1])
$channel $self->state_chan_mode_set($channel, "c") has_color($args->[1]) has_formatting($args->[1])
Truth table40%2/5
A and B and C or D
A= $channelB= $self->state_chan_mode_set($channel, "c")C= has_color($args->[1])D= has_formatting($args->[1])
ABCDresult
0XXX0
10XX0
11000
111X1
11011
11236 && ( has_color($args->[1]) || has_formatting($args->[1]) ) ){
11237 0 push @$ref, ['408', $channel];
11238 0 next LOOP;
11239 }
11240 5 ▶ if ($channel && $self->state_chan_mode_set($channel, 'C')
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $self->state_chan_mode_set($channel, "C") and $args->[1] =~ /^\001/ and not $args->[1] =~ /^\001ACTION/) 0 5 5
Condition44%4/9
$channel and $self->state_chan_mode_set($channel, "C") and $args->[1] =~ /^\001/ and not $args->[1] =~ /^\001ACTION/
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "C") and $args->[1] =~ /^\001/
!ll&&!rl&&r
500
$channel and $self->state_chan_mode_set($channel, "C")
!ll&&!rl&&r
410
MC/DC0%0/4
$channel and $self->state_chan_mode_set($channel, "C") and $args->[1] =~ /^\001/ and not $args->[1] =~ /^\001ACTION/
$channel $self->state_chan_mode_set($channel, "C") $args->[1] =~ /^\001/ not $args->[1] =~ /^\001ACTION/
Truth table40%2/5
A and B and C and not(D)
A= $channelB= $self->state_chan_mode_set($channel, "C")C= $args->[1] =~ /^\001/D= not $args->[1] =~ /^\001ACTION/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
11241 && $args->[1] =~ m!^\001! && $args->[1] !~ m!^\001ACTION! ){
11242 0 push @$ref, ['492', $channel];
11243 0 next LOOP;
11244 }
11245 5 ▶ if ($channel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($channel) 1 4 5
11246 1 my $common = { };
11247 1 ▶ my $msg = {
Branch: 1 branch
BranchTrueFalseTotal
$status_msg ? : 0 1 1
11248 command => $type,
11249 params => [
11250 ($status_msg ? $target : $channel),
11251 $args->[1],
11252 ],
11253 };
11254 1 for my $member ($self->state_chan_list($channel, $status_msg)) {
11255 4 ▶ next if $self->_state_user_is_deaf($member);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_is_deaf($member) 0 4 4
11256 4 $common->{ $self->_state_user_route($member) }++;
11257 }
11258 1 delete $common->{$peer_id};
11259 1 for my $route_id (keys %$common) {
11260 3 $msg->{prefix} = $uid;
11261 3 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 3 0 3
11262 3 $msg->{prefix} = $full;
11263 }
11264 3 ▶ if ($route_id ne 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id ne 'spoofed') { } 3 0 3
11265 3 $self->send_output($msg, $route_id);
11266 }
11267 else {
11268 0 ▶ my $tmsg = $type eq 'PRIVMSG'
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'PRIVMSG' ? : 0 0 0
11269 ? 'public'
11270 : 'notice';
11271 0 $self->send_event(
11272 "daemon_$tmsg",
11273 $full,
11274 $channel,
11275 $args->[1],
11276 );
11277 }
11278 }
11279 1 next LOOP;
11280 }
11281 4 my $server = $self->server_name();
11282 4 ▶ if ($self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($target)) 4 0 4
11283 4 $target = $self->state_user_nick($target);
11284 4 ▶ if (my $away = $self->_state_user_away_msg($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $away = $self->_state_user_away_msg($target)) 0 4 4
11285 0 push @$ref, {
11286 prefix => $server,
11287 command => '301',
11288 params => [$nick, $target, $away],
11289 };
11290 }
11291 4 my $targ_umode = $self->state_user_umode($target);
11292 # Target user has CALLERID on
11293 4 ▶ if ($targ_umode && $targ_umode =~ /[Gg]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_umode and $targ_umode =~ /[Gg]/) 0 4 4
Condition33%1/3
$targ_umode and $targ_umode =~ /[Gg]/
!ll&&!rl&&r
040
MC/DC0%0/2
$targ_umode and $targ_umode =~ /[Gg]/
$targ_umode $targ_umode =~ /[Gg]/
Truth table33%1/3
A and B
A= $targ_umodeB= $targ_umode =~ /[Gg]/
ABresult
0X0
100
111
11294 0 my $targ_rec = $self->{state}{users}{uc_irc($target) };
11295 0 ▶ if (($targ_umode =~ /G/ && (
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)} or $targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}) 0 0 0
Condition0%0/12
$targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)} or $targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}
l!l&&r!l&&!r
000
$targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)}
!ll&&!rl&&r
000
$self->state_users_share_chan($target, $nick) && $targ_rec->{'accepts'}{uc_irc($nick)}
!ll&&!rl&&r
000
$targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}
!ll&&!rl&&r
000
MC/DC0%0/5
$targ_umode =~ /G/ and not $self->state_users_share_chan($target, $nick) && $targ_rec->{"accepts"}{uc_irc($nick)} or $targ_umode =~ /g/ and not $targ_rec->{"accepts"}{uc_irc($nick)}
$targ_umode =~ /G/ $self->state_users_share_chan($target, $nick) $targ_rec->{'accepts'}{uc_irc($nick)} $targ_umode =~ /g/ not $targ_rec->{"accepts"}{uc_irc($nick)}
Truth table0%0/8
A and not(B && C) or D and not(E)
A= $targ_umode =~ /G/B= $self->state_users_share_chan($target, $nick)C= $targ_rec->{'accepts'}{uc_irc($nick)}D= $targ_umode =~ /g/E= not $targ_rec->{"accepts"}{uc_irc($nick)}
ABCDEresult
10XXX1
110XX1
0XX111
111111
0XX0X0
0XX100
1110X0
111100
11296 !$self->state_users_share_chan($target, $nick)
11297 || !$targ_rec->{accepts}{uc_irc($nick)}))
11298 || ($targ_umode =~ /g/
11299 && !$targ_rec->{accepts}{uc_irc($nick)})) {
11300 0 push @$ref, {
11301 prefix => $server,
11302 command => '716',
11303 params => [
11304 $nick,
11305 $target,
11306 'is in +g mode (server side ignore)',
11307 ],
11308 };
11309 0 ▶ if (!$targ_rec->{last_caller}
Branch: 1 branch
BranchTrueFalseTotal
if (not $targ_rec->{"last_caller"} or time - $targ_rec->{"last_caller"} >= 60) 0 0 0
Condition0%0/3
not $targ_rec->{"last_caller"} or time - $targ_rec->{"last_caller"} >= 60
l!l&&r!l&&!r
000
MC/DC0%0/2
not $targ_rec->{"last_caller"} or time - $targ_rec->{"last_caller"} >= 60
not $targ_rec->{"last_caller"} time - $targ_rec->{"last_caller"} >= 60
Truth table0%0/3
not(A) or B
A= not $targ_rec->{"last_caller"}B= time - $targ_rec->{"last_caller"} >= 60
ABresult
1X1
011
000
11310 || (time - $targ_rec->{last_caller} ) >= 60) {
11311 0 my ($n, $uh) = split /!/,
11312 $self->state_user_full($nick);
11313 $self->send_output(
11314 {
11315 prefix => $server,
11316 command => '718',
11317 params => [
11318 $target,
11319 "$n\[$uh\]",
11320 'is messaging you, and you are umode +g.'
11321 ],
11322 },
11323 $targ_rec->{route_id},
11324 0 ▶ ) if $targ_rec->{route_id} ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $targ_rec->{"route_id"} ne "spoofed" 0 0 0
11325 0 push @$ref, {
11326 prefix => $server,
11327 command => '717',
11328 params => [
11329 $nick,
11330 $target,
11331 'has been informed that you messaged them.',
11332 ],
11333 };
11334 }
11335 0 $targ_rec->{last_caller} = time();
11336 0 next LOOP;
11337 }
11338 }
11339 4 my $msg = {
11340 prefix => $uid,
11341 command => $type,
11342 params => [$target, $args->[1]],
11343 };
11344 4 my $route_id = $self->_state_user_route($target);
11345 4 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 4 4
11346 0 $msg->{prefix} = $full;
11347 0 $self->send_event(
11348 "daemon_" . lc $type,
11349 $full,
11350 $target,
11351 $args->[1],
11352 );
11353 }
11354 else {
11355 4 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 4 0 4
11356 4 $msg->{prefix} = $full;
11357 }
11358 4 $self->send_output($msg, $route_id);
11359 }
11360 4 next LOOP;
11361 }
11362 }
11363 }
11364  
11365 7 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 7 0 7
11366 0 return $ref;
11367 }
11368  
11369 0 ▶sub _daemon_peer_topic {
Subroutine _daemon_peer_topic: not called CC=7 SCAR=40.3
11370 0 my $self = shift;
11371 0 ▶ my $peer_id = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
11372 0 ▶ my $uid = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
11373 0 my $server = $self->server_name();
11374 0 my $ref = [ ];
11375 0 my $args = [ @_ ];
11376 0 my $count = @$args;
11377  
11378 SWITCH:{
11379 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
11380 0 last SWITCH;
11381 }
11382 0 ▶ if (!$self->state_chan_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($args->[0])) 0 0 0
11383 0 last SWITCH;
11384 }
11385 0 my $record = $self->{state}{chans}{uc_irc($args->[0])};
11386 0 my $chan_name = $record->{name};
11387 0 ▶ if ( $args->[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1]) { } 0 0 0
11388 $record->{topic}
11389 0 = [$args->[1], $self->state_user_full($uid), time];
11390 }
11391 else {
11392 0 delete $record->{topic};
11393 }
11394 $self->send_output(
11395 {
11396 prefix => $uid,
11397 command => 'TOPIC',
11398 params => [$chan_name, $args->[1]],
11399 },
11400 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
11401 );
11402 0 $self->_send_output_channel_local(
11403 $chan_name,
11404 {
11405 prefix => $self->state_user_full($uid),
11406 command => 'TOPIC',
11407 params => [$chan_name, $args->[1]],
11408 },
11409 );
11410 }
11411  
11412 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
11413 0 return $ref;
11414 }
11415  
11416 1 ▶sub _daemon_peer_invite {
Subroutine _daemon_peer_invite: called CC=10 SCAR=24.7
11417 1 my $self = shift;
11418 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11419 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11420 1 my $server = $self->server_name();
11421 1 my $ref = [ ];
11422 1 my $args = [ @_ ];
11423 1 my $count = @$args;
11424  
11425 # :7UPAAAAAA INVITE 8H8AAAAAA #dummynet 1525787545
11426 SWITCH: {
11427 1 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 1 1
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
11428 0 last SWITCH;
11429 }
11430 1 my ($who, $chan) = @$args;
11431 1 $chan = $self->_state_chan_name($chan);
11432 1 my $uchan = uc_irc($chan);
11433 1 my $chanrec = $self->{state}{chans}{$uchan};
11434 1 ▶ if ($self->_state_is_local_uid($who)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_uid($who)) 1 0 1
11435 1 my $record = $self->{state}{uids}{$who};
11436 1 $record->{invites}{$uchan} = time;
11437 1 my $route_id = $self->_state_uid_route($who);
11438 1 my $output = {
11439 prefix => $self->state_user_full($uid),
11440 command => 'INVITE',
11441 params => [$self->state_user_nick($who), $chan],
11442 colonify => 0,
11443 };
11444 1 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 1 1
11445 $self->send_event(
11446 "daemon_invite",
11447 $output->{prefix},
11448 0 @{ $output->{params} },
11449 );
11450 }
11451 else {
11452 1 $self->send_output( $output, $route_id );
11453 }
11454 }
11455 1 ▶ if ( $chanrec->{mode} && $chanrec->{mode} =~ m!i! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} and $chanrec->{"mode"} =~ /i/) 1 0 1
Condition33%1/3
$chanrec->{"mode"} and $chanrec->{"mode"} =~ /i/
!ll&&!rl&&r
001
MC/DC0%0/2
$chanrec->{"mode"} and $chanrec->{"mode"} =~ /i/
$chanrec->{"mode"} $chanrec->{"mode"} =~ /i/
Truth table33%1/3
A and B
A= $chanrec->{"mode"}B= $chanrec->{"mode"} =~ /i/
ABresult
0X0
100
111
11456 1 $chanrec->{invites}{$who} = time;
11457 # Send NOTICE to +oh local channel members
11458 # ":%s NOTICE %%%s :%s is inviting %s to %s."
11459 1 my $notice = {
11460 prefix => $server,
11461 command => 'NOTICE',
11462 params => [
11463 $chan,
11464 sprintf(
11465 "%s is inviting %s to %s.",
11466 $self->state_user_nick($uid),
11467 $self->state_user_nick($who),
11468 $chan,
11469 ),
11470 ],
11471 };
11472 1 my $invite = {
11473 prefix => $self->state_user_full($uid),
11474 command => 'INVITE',
11475 params => [$self->state_user_nick($who), $chan],
11476 colonify => 0,
11477 };
11478 1 $self->_send_output_channel_local($chan,$notice,'','oh','','invite-notify');
11479 1 $self->_send_output_channel_local($chan,$invite,'','oh','invite-notify','');
11480 }
11481 # Send it on to other peers
11482 $self->send_output(
11483 {
11484 prefix => $uid,
11485 command => 'INVITE',
11486 params => $args,
11487 colonify => 0,
11488 },
11489 1 grep { $_ ne $peer_id } $self->_state_connected_peers(),
11490 );
11491 }
11492  
11493 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
11494 1 return $ref;
11495 }
11496  
11497 10 ▶sub _daemon_peer_away {
Subroutine _daemon_peer_away: called CC=5 SCAR=17.6
11498 10 my $self = shift;
11499 10 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
100
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11500 10 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
100
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11501 10 my $msg = shift;
11502 10 my $server = $self->server_name();
11503 10 my $ref = [ ];
11504  
11505 SWITCH: {
11506 10 my $rec = $self->{state}{uids}{$uid};
11507 10 ▶ if (!$msg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 0 10 10
11508 0 delete $rec->{away};
11509 $self->send_output(
11510 {
11511 prefix => $uid,
11512 command => 'AWAY',
11513 },
11514 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
11515 );
11516 0 $self->_state_do_away_notify($uid,'*',$msg);
11517 0 last SWITCH;
11518 }
11519 10 $rec->{away} = $msg;
11520  
11521 $self->send_output(
11522 {
11523 prefix => $uid,
11524 command => 'AWAY',
11525 params => [$msg],
11526 },
11527 10 grep { $_ ne $peer_id } $self->_state_connected_peers(),
11528 );
11529 10 $self->_state_do_away_notify($uid,'*',$msg);
11530 }
11531  
11532 10 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 10 10
11533 10 return $ref;
11534 }
11535  
11536 1 ▶sub _daemon_peer_links {
Subroutine _daemon_peer_links: called CC=8 SCAR=23.2
11537 1 my $self = shift;
11538 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11539 1 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11540 1 my $server = $self->server_name();
11541 1 my $sid = $self->server_sid();
11542 1 my $ref = [ ];
11543 1 my $args = [ @_ ];
11544 1 my $count = @$args;
11545  
11546 SWITCH: {
11547 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
11548 0 last SWITCH;
11549 }
11550 1 my ($target,$mask) = @$args;
11551 1 ▶ if ( $sid ne $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid ne $target) 0 1 1
11552 0 $self->send_output(
11553 {
11554 prefix => $uid,
11555 command => 'LINKS',
11556 params => $args,
11557 },
11558 $self->_state_sid_route($target),
11559 );
11560 0 last SWITCH;
11561 }
11562 1 my $urec = $self->{state}{uids}{$uid};
11563 $self->_send_to_realops(
11564 sprintf(
11565 'LINKS requested by %s (%s) [%s]',
11566 $urec->{nick}, (split /!/,$urec->{full}->())[1], $urec->{server},
11567 1 ), qw[Notice y],
11568 );
11569 1 push @$ref, $_ for
11570 1 @{ $self->_daemon_do_links($uid,$sid,$mask ) };
11571 }
11572  
11573 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
11574 0 return $ref;
11575 }
11576  
11577 6 ▶sub _daemon_peer_svsjoin {
Subroutine _daemon_peer_svsjoin: called CC=13 SCAR=32.4
11578 6 my $self = shift;
11579 6 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11580 6 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11581 6 my $sid = $self->server_sid();
11582 6 my $ref = [ ];
11583 6 my $args = [ @_ ];
11584 6 my $count = @$args;
11585  
11586 SWITCH: {
11587 6 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 6 6
Condition66%2/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
240
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table66%2/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
11588 0 last SWITCH;
11589 }
11590 6 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 6 6
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
006
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
11591 0 last SWITCH;
11592 }
11593 6 my $client = shift @$args;
11594 6 my $uid = $self->state_user_uid($client);
11595 6 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 6 6
11596 6 ▶ if ( $uid =~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uid =~ /^$sid/) 6 0 6
11597 6 my $rec = $self->{state}{uids}{$uid};
11598 $self->_send_output_to_client(
11599 $rec->{route_id},
11600 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
11601 6 ▶ ) for $self->_daemon_cmd_join($rec->{nick}, @$args);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
11602 6 last SWITCH;
11603 }
11604 0 my $route_id = $self->_state_uid_route($uid);
11605 0 ▶ if ( $route_id eq $peer_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq $peer_id) 0 0 0
11606 # The fuck
11607 0 last SWITCH;
11608 }
11609 $self->send_output(
11610 {
11611 0 prefix => $prefix,
11612 command => 'SVSJOIN',
11613 params => [
11614 $client,
11615 @$args,
11616 ],
11617 },
11618 $route_id,
11619 );
11620 }
11621  
11622 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
11623 6 return $ref;
11624 }
11625  
11626 1 ▶sub _daemon_peer_svspart {
Subroutine _daemon_peer_svspart: called CC=13 SCAR=33.1
11627 1 my $self = shift;
11628 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11629 1 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11630 1 my $sid = $self->server_sid();
11631 1 my $ref = [ ];
11632 1 my $args = [ @_ ];
11633 1 my $count = @$args;
11634  
11635 SWITCH: {
11636 1 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 1 1
Condition33%1/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
100
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table33%1/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
11637 0 last SWITCH;
11638 }
11639 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
11640 0 last SWITCH;
11641 }
11642 1 my $client = shift @$args;
11643 1 my $uid = $self->state_user_uid($client);
11644 1 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 1 1
11645 1 ▶ if ( $uid =~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uid =~ /^$sid/) 1 0 1
11646 1 my $rec = $self->{state}{uids}{$uid};
11647 $self->_send_output_to_client(
11648 $rec->{route_id},
11649 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
11650 1 ▶ ) for $self->_daemon_cmd_part($rec->{nick}, @$args);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
11651 1 last SWITCH;
11652 }
11653 0 my $route_id = $self->_state_uid_route($uid);
11654 0 ▶ if ( $route_id eq $peer_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq $peer_id) 0 0 0
11655 # The fuck
11656 0 last SWITCH;
11657 }
11658 $self->send_output(
11659 {
11660 0 prefix => $prefix,
11661 command => 'SVSPART',
11662 params => [
11663 $client,
11664 @$args,
11665 ],
11666 },
11667 $route_id,
11668 );
11669 }
11670  
11671 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
11672 1 return $ref;
11673 }
11674  
11675 2 ▶sub _daemon_peer_svshost {
Subroutine _daemon_peer_svshost: called CC=12 SCAR=28.0
11676 2 my $self = shift;
11677 2 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11678 2 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11679 2 my $sid = $self->server_sid();
11680 2 my $ref = [ ];
11681 2 my $args = [ @_ ];
11682 2 my $count = @$args;
11683  
11684 # :9T9 SVSHOST 7UPAAAABO 1529239224 fake.host.name
11685 SWITCH: {
11686 2 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 2 2
Condition33%1/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
200
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table33%1/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
11687 0 last SWITCH;
11688 }
11689 2 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 2 2
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
11690 0 last SWITCH;
11691 }
11692 2 my $client = shift @$args;
11693 2 my $uid = $self->state_user_uid($client);
11694 2 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 2 2
11695 2 ▶ last SWITCH if $args->[0] !~ m!^\d+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $args->[0] =~ /^\d+$/ 0 2 2
11696 2 ▶ last SWITCH if $args->[0] != $self->{state}{uids}{$uid}{ts};
Branch: 1 branch
BranchTrueFalseTotal
if $args->[0] != $self->{"state"}{"uids"}{$uid}{"ts"} 0 2 2
11697 2 ▶ if ($args->[1] =~ $host_re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] =~ /$host_re/) 2 0 2
11698 2 $self->_state_do_change_hostmask($uid, $args->[1]);
11699 }
11700 2 unshift @$args, $uid;
11701 $self->send_output(
11702 {
11703 prefix => $prefix,
11704 command => 'SVSHOST',
11705 params => $args,
11706 colonify => 0,
11707 },
11708 2 grep { $_ ne $peer_id } $self->_state_connected_peers(),
11709 );
11710 }
11711  
11712 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
11713 2 return $ref;
11714 }
11715  
11716 29 ▶sub _daemon_peer_svsmode {
Subroutine _daemon_peer_svsmode: called CC=42 SCAR=51.6
11717 29 my $self = shift;
11718 29 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
290
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11719 29 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
290
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11720 29 my $sid = $self->server_sid();
11721 29 my $ref = [ ];
11722 29 my $args = [ @_ ];
11723 29 my $count = @$args;
11724  
11725 # :9T9 SVSMODE 7UPAAAABO 1529239224 +<modes> extra_arg
11726 SWITCH: {
11727 29 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 29 29
Condition33%1/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
2900
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table33%1/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
11728 0 last SWITCH;
11729 }
11730 29 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 29 29
Condition33%1/3
not $count or $count < 3
l!l&&r!l&&!r
0029
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table33%1/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
11731 0 last SWITCH;
11732 }
11733 29 my $client = shift @$args;
11734 29 my $uid = $self->state_user_uid($client);
11735 29 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 29 29
11736 29 ▶ last SWITCH if $args->[0] !~ m!^\d+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $args->[0] =~ /^\d+$/ 0 29 29
11737 29 ▶ last SWITCH if $args->[0] != $self->{state}{uids}{$uid}{ts};
Branch: 1 branch
BranchTrueFalseTotal
if $args->[0] != $self->{"state"}{"uids"}{$uid}{"ts"} 0 29 29
11738 29 my $rec = $self->{state}{uids}{$uid};
11739 29 my $local = ( $uid =~ m!^$sid! );
11740 29 ▶ $local = $rec->{route_id} if $local;
Branch: 1 branch
BranchTrueFalseTotal
if $local 29 0 29
11741 29 ▶ my $extra_arg = ( $count >= 4 ? $args->[2] : '' );
Branch: 1 branch
BranchTrueFalseTotal
$count >= 4 ? : 29 0 29
11742 29 my $umode = unparse_mode_line($args->[1]);
11743 29 my $parsed_mode = parse_mode_line($umode);
11744 29 my $previous = $rec->{umode};
11745 29 ▶ MODE: while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 55 29 84
11746 55 ▶ next MODE if $mode eq '+o';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+o" 0 55 55
11747 55 my ($action, $char) = split //, $mode;
11748 55 ▶ next MODE if $char =~ m![SW]!;
Branch: 1 branch
BranchTrueFalseTotal
if $char =~ /[SW]/ 0 55 55
11749 55 ▶ if ($action eq '+' && $char eq 'x') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and $char eq "x") 3 52 55
Condition66%2/3
$action eq "+" and $char eq "x"
!ll&&!rl&&r
0523
MC/DC50%1/2
$action eq "+" and $char eq "x"
$action eq "+" $char eq "x"
Truth table66%2/3
A and B
A= $action eq "+"B= $char eq "x"
ABresult
0X0
100
111
11750 3 ▶ if ($extra_arg && $extra_arg =~ $host_re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra_arg and $extra_arg =~ /$host_re/) 3 0 3
Condition33%1/3
$extra_arg and $extra_arg =~ /$host_re/
!ll&&!rl&&r
003
MC/DC0%0/2
$extra_arg and $extra_arg =~ /$host_re/
$extra_arg $extra_arg =~ /$host_re/
Truth table33%1/3
A and B
A= $extra_argB= $extra_arg =~ /$host_re/
ABresult
0X0
100
111
11751 3 $self->_state_do_change_hostmask($uid, $extra_arg);
11752 }
11753 3 next MODE;
11754 }
11755 52 ▶ if ($action eq '+' && $char eq 'd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and $char eq "d") 26 26 52
Condition66%2/3
$action eq "+" and $char eq "d"
!ll&&!rl&&r
02626
MC/DC50%1/2
$action eq "+" and $char eq "d"
$action eq "+" $char eq "d"
Truth table66%2/3
A and B
A= $action eq "+"B= $char eq "d"
ABresult
0X0
100
111
11756 26 ▶ if ($extra_arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra_arg) 26 0 26
11757 26 $rec->{account} = $extra_arg;
11758 26 foreach my $chan ( keys %{ $rec->{chans} } ) {
11759 $self->_send_output_channel_local(
11760 $chan,
11761 {
11762 prefix => $rec->{full}->(),
11763 command => 'ACCOUNT',
11764 colonify => 0,
11765 params => [ $rec->{account} ],
11766 },
11767 $rec->{route_id},
11768 4 '',
11769 'account-notify',
11770 );
11771 }
11772 }
11773 26 next MODE;
11774 }
11775 26 ▶ if ($action eq '+' && $rec->{umode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and not $rec->{"umode"} =~ /$char/) 26 0 26
Condition33%1/3
$action eq "+" and not $rec->{"umode"} =~ /$char/
!ll&&!rl&&r
0026
MC/DC0%0/2
$action eq "+" and not $rec->{"umode"} =~ /$char/
$action eq "+" not $rec->{"umode"} =~ /$char/
Truth table33%1/3
A and not(B)
A= $action eq "+"B= not $rec->{"umode"} =~ /$char/
ABresult
0X0
100
111
11776 26 $rec->{umode} .= $char;
11777 26 ▶ if ($char eq 'i') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "i") 0 26 26
11778 0 $self->{state}{stats}{invisible}++;
11779 }
11780 26 ▶ if ($char eq 'w' && $local ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w" and $local) 0 26 26
Condition33%1/3
$char eq "w" and $local
!ll&&!rl&&r
2600
MC/DC0%0/2
$char eq "w" and $local
$char eq "w" $local
Truth table33%1/3
A and B
A= $char eq "w"B= $local
ABresult
0X0
100
111
11781 0 $self->{state}{wallops}{$local} = time;
11782 }
11783 26 ▶ if ($char eq 'l' && $local ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l" and $local) 0 26 26
Condition33%1/3
$char eq "l" and $local
!ll&&!rl&&r
2600
MC/DC0%0/2
$char eq "l" and $local
$char eq "l" $local
Truth table33%1/3
A and B
A= $char eq "l"B= $local
ABresult
0X0
100
111
11784 0 $self->{state}{locops}{$local} = time;
11785 }
11786 }
11787 26 ▶ if ($action eq '-' && $rec->{umode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "-" and $rec->{"umode"} =~ /$char/) 0 26 26
Condition33%1/3
$action eq "-" and $rec->{"umode"} =~ /$char/
!ll&&!rl&&r
2600
MC/DC0%0/2
$action eq "-" and $rec->{"umode"} =~ /$char/
$action eq "-" $rec->{"umode"} =~ /$char/
Truth table33%1/3
A and B
A= $action eq "-"B= $rec->{"umode"} =~ /$char/
ABresult
0X0
100
111
11788 0 $rec->{umode} =~ s/$char//g;
11789 0 ▶ $self->{state}{stats}{invisible}-- if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
11790  
11791 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
11792 0 $self->{state}{stats}{ops_online}--;
11793 0 delete $rec->{svstags}{313};
11794 0 ▶ if ( $local ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($local) 0 0 0
11795 0 delete $self->{state}{localops}{$local};
11796 0 $self->antiflood( $local, 1);
11797 }
11798 }
11799 0 ▶ if ($char eq 'w' && $local) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w" and $local) 0 0 0
Condition0%0/3
$char eq "w" and $local
!ll&&!rl&&r
000
MC/DC0%0/2
$char eq "w" and $local
$char eq "w" $local
Truth table0%0/3
A and B
A= $char eq "w"B= $local
ABresult
0X0
100
111
11800 0 delete $self->{state}{wallops}{$local};
11801 }
11802 0 ▶ if ($char eq 'l' && $local) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l" and $local) 0 0 0
Condition0%0/3
$char eq "l" and $local
!ll&&!rl&&r
000
MC/DC0%0/2
$char eq "l" and $local
$char eq "l" $local
Truth table0%0/3
A and B
A= $char eq "l"B= $local
ABresult
0X0
100
111
11803 0 delete $self->{state}{locops}{$local};
11804 }
11805 }
11806 }
11807 29 $rec->{umode} = join '', sort split //, $rec->{umode};
11808 29 unshift @$args, $uid;
11809 $self->send_output(
11810 {
11811 prefix => $prefix,
11812 command => 'SVSMODE',
11813 params => $args,
11814 colonify => 0,
11815 },
11816 29 grep { $_ ne $peer_id } $self->_state_connected_peers(),
11817 );
11818 29 ▶ last SWITCH if !$local;
Branch: 1 branch
BranchTrueFalseTotal
unless $local 0 29 29
11819 29 my $set = gen_mode_change($previous, $rec->{umode});
11820 29 ▶ if ($set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set) 26 3 29
11821 26 my $full = $rec->{full}->();
11822 $self->send_output(
11823 {
11824 prefix => $full,
11825 command => 'MODE',
11826 26 params => [$rec->{nick}, $set],
11827 },
11828 $local
11829 );
11830 26 $self->send_event(
11831 "daemon_umode",
11832 $full,
11833 $set,
11834 );
11835 }
11836 }
11837  
11838 29 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 29 29
11839 29 return $ref;
11840 }
11841  
11842 3 ▶sub _daemon_peer_svsnick {
Subroutine _daemon_peer_svsnick: called CC=32 SCAR=45.3
11843 3 my $self = shift;
11844 3 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11845 3 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
11846 3 my $sid = $self->server_sid();
11847 3 my $ref = [ ];
11848 3 my $args = [ @_ ];
11849 3 my $count = @$args;
11850  
11851 SWITCH: {
11852 3 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 3 3
Condition33%1/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
300
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table33%1/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
11853 0 last SWITCH;
11854 }
11855 3 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 3 3
11856 0 last SWITCH;
11857 }
11858 3 ▶ my $newnick = ( $count == 4 ? $args->[2] : $args->[1] );
Branch: 1 branch
BranchTrueFalseTotal
$count == 4 ? : 0 3 3
11859 3 ▶ last SWITCH if !is_valid_nick_name($newnick); # maybe check nicklen too
Branch: 1 branch
BranchTrueFalseTotal
unless is_valid_nick_name($newnick) 0 3 3
11860 3 my $uid = $self->state_user_uid($args->[0]);
11861 3 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 3 3
11862 3 my $rec = $self->{state}{uids}{$uid};
11863 3 my $ts = 0; my $newts = 0;
11864 3 ▶ if ( $count == 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 4) { } 0 3 3
11865 0 $ts = $args->[1];
11866 0 ▶ last SWITCH if $ts && $ts != $rec->{ts};
Branch: 1 branch
BranchTrueFalseTotal
if $ts and $ts != $rec->{"ts"} 0 0 0
Condition0%0/3
$ts and $ts != $rec->{"ts"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ts and $ts != $rec->{"ts"}
$ts $ts != $rec->{"ts"}
Truth table0%0/3
A and B
A= $tsB= $ts != $rec->{"ts"}
ABresult
0X0
100
111
11867 }
11868 else {
11869 3 $ts = $args->[2];
11870 }
11871 3 ▶ if ( $count == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 3) { } 3 0 3
11872 3 $newts = $ts;
11873 }
11874 else {
11875 0 $newts = $args->[3];
11876 }
11877 3 ▶ if ($uid !~ m!^$sid!) { # Not ours
Branch: 1 branch
BranchTrueFalseTotal
unless ($uid =~ /^$sid/) 0 3 3
11878 0 ▶ if ($rec->{route_id} eq $peer_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"route_id"} eq $peer_id) 0 0 0
11879 # eh!?
11880 0 last SWITCH;
11881 }
11882 $self->send_output(
11883 {
11884 prefix => $prefix,
11885 command => 'SVSNICK',
11886 params => [
11887 $uid,
11888 $newnick,
11889 $newts,
11890 ],
11891 },
11892 $rec->{route_id},
11893 0 );
11894 0 last SWITCH;
11895 }
11896  
11897 3 my $full = $rec->{full}->();
11898 3 my $nick = $rec->{nick};
11899 3 my $unick = uc_irc $nick;
11900 3 my $unew = uc_irc $newnick;
11901 3 my $server = uc $self->server_name();
11902  
11903 3 ▶ if ( $self->state_nick_exists($newnick) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($newnick)) 2 1 3
11904 2 ▶ if ( defined $self->{state}{users}{$unew} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"users"}{$unew}) 1 1 2
11905 1 my $exist = $self->{state}{users}{$unew};
11906 1 ▶ if ( $rec eq $exist ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec eq $exist) 0 1 1
11907 0 $rec->{nick} = $newnick;
11908 0 $rec->{ts} = $newts;
11909 0 last SWITCH;
11910 }
11911 # SVSNICK Collide methinks
11912 $self->_terminate_conn_error(
11913 $rec->{route_id},
11914 1 'SVSNICK Collide',
11915 );
11916 1 last SWITCH;
11917 }
11918 1 ▶ if ( defined $self->{state}{pending}{$unew} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"pending"}{$unew}) 1 0 1
11919 $self->_terminate_conn_error(
11920 1 $self->{state}{pending}{$unew},
11921 'SVSNICK Override',
11922 );
11923 }
11924 }
11925  
11926 2 my $common;
11927 2 for my $chan (keys %{ $rec->{chans} }) {
11928 1 for my $user ( keys %{ $self->{state}{chans}{$chan}{users} } ) {
11929 3 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 0 3 3
11930 3 $common->{$user} = $self->_state_uid_route($user);
11931 }
11932 }
11933  
11934 2 ▶ if ($unick eq $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unick eq $unew) { } 0 2 2
11935 0 $rec->{nick} = $newnick;
11936 0 $rec->{ts} = $newts;
11937 }
11938 else {
11939 2 $rec->{nick} = $newnick;
11940 2 $rec->{ts} = $newts;
11941 # WATCH ON/OFF
11942 2 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 0 2 2
11943 0 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
11944 0 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 0 0
11945 0 my $wrec = $self->{state}{uids}{$wuid};
11946 0 my $laston = time();
11947 0 $self->{state}{watches}{$unick}{laston} = $laston;
11948 $self->send_output(
11949 {
11950 prefix => $rec->{server},
11951 command => '605',
11952 params => [
11953 $wrec->{nick},
11954 $nick,
11955 $rec->{auth}{ident},
11956 $rec->{auth}{hostname},
11957 $laston,
11958 'is offline',
11959 ],
11960 },
11961 $wrec->{route_id},
11962 0 );
11963 }
11964 }
11965 2 ▶ if ( defined $self->{state}{watches}{$unew} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unew}) 0 2 2
11966 0 foreach my $wuid ( keys %{ $self->{state}{watches}{$unew}{uids} } ) {
11967 0 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 0 0
11968 0 my $wrec = $self->{state}{uids}{$wuid};
11969 $self->send_output(
11970 {
11971 prefix => $rec->{server},
11972 command => '604',
11973 params => [
11974 $wrec->{nick},
11975 $rec->{nick},
11976 $rec->{auth}{ident},
11977 $rec->{auth}{hostname},
11978 $rec->{ts},
11979 'is online',
11980 ],
11981 },
11982 $wrec->{route_id},
11983 0 );
11984 }
11985 }
11986 # Remove from peoples accept lists
11987 2 for (keys %{ $rec->{accepts} }) {
11988 0 delete $self->{state}{users}{$_}{accepts}{$unick};
11989 }
11990 2 delete $rec->{accepts};
11991 2 delete $self->{state}{users}{$unick};
11992 2 $self->{state}{users}{$unew} = $rec;
11993 2 delete $self->{state}{peers}{$server}{users}{$unick};
11994 2 $self->{state}{peers}{$server}{users}{$unew} = $rec;
11995 2 ▶ if ( $rec->{umode} =~ /r/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"umode"} =~ /r/) 1 1 2
11996 1 $rec->{umode} =~ s/r//g;
11997 $self->send_output(
11998 {
11999 prefix => $full,
12000 command => 'MODE',
12001 params => [
12002 $rec->{nick},
12003 '-r',
12004 ],
12005 },
12006 $rec->{route_id},
12007 1 );
12008 }
12009 2 unshift @{ $self->{state}{whowas}{$unick} }, {
12010 logoff => time(),
12011 account => $rec->{account},
12012 nick => $nick,
12013 user => $rec->{auth}{ident},
12014 host => $rec->{auth}{hostname},
12015 real => $rec->{auth}{realhost},
12016 sock => $rec->{socket}[0],
12017 ircname => $rec->{ircname},
12018 server => $rec->{server},
12019 2 };
12020 }
12021  
12022 2 $self->_send_to_realops(
12023 sprintf(
12024 'Nick change: From %s to %s [%s]',
12025 $nick, $newnick, (split /!/,$full)[1],
12026 ),
12027 'Notice',
12028 'n',
12029 );
12030  
12031 $self->send_output(
12032 {
12033 prefix => $rec->{uid},
12034 command => 'NICK',
12035 2 params => [$newnick, $rec->{ts}],
12036 },
12037 $self->_state_connected_peers(),
12038 );
12039  
12040 2 $self->send_event("daemon_nick", $full, $newnick);
12041  
12042 $self->send_output(
12043 {
12044 prefix => $full,
12045 command => 'NICK',
12046 params => [$newnick],
12047 },
12048 2 $rec->{route_id}, values %$common,
12049 );
12050 }
12051  
12052 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
12053 3 return $ref;
12054 }
12055  
12056 1 ▶sub _daemon_peer_svskill {
Subroutine _daemon_peer_svskill: called CC=14 SCAR=32.4
12057 1 my $self = shift;
12058 1 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12059 1 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12060 1 my $sid = $self->server_sid();
12061 1 my $ref = [ ];
12062 1 my $args = [ @_ ];
12063 1 my $count = @$args;
12064  
12065 SWITCH: {
12066 1 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 1 1
Condition33%1/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
100
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table33%1/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
12067 0 last SWITCH;
12068 }
12069 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
12070 0 last SWITCH;
12071 }
12072 1 my $client = shift @$args;
12073 1 my $uid = $self->state_user_uid($client);
12074 1 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 1 1
12075 1 ▶ last SWITCH if $args->[0] !~ m!^\d+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $args->[0] =~ /^\d+$/ 0 1 1
12076 1 ▶ last SWITCH if $args->[0] != $self->{state}{uids}{$uid}{ts};
Branch: 1 branch
BranchTrueFalseTotal
if $args->[0] != $self->{"state"}{"uids"}{$uid}{"ts"} 0 1 1
12077 1 ▶ if ( $uid =~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uid =~ /^$sid/) 1 0 1
12078 1 my $rec = $self->{state}{uids}{$uid};
12079 1 my $reason = 'SVSKilled: ';
12080 1 ▶ if ( $count == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 3) { } 1 0 1
12081 1 $reason .= pop @$args;
12082 }
12083 else {
12084 0 $reason .= '<No reason supplied>';
12085 }
12086 $self->_terminate_conn_error(
12087 $rec->{route_id},
12088 1 $reason,
12089 );
12090 1 last SWITCH;
12091 }
12092 0 my $route_id = $self->_state_uid_route($uid);
12093 0 ▶ if ( $route_id eq $peer_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq $peer_id) 0 0 0
12094 # The fuck
12095 0 last SWITCH;
12096 }
12097 $self->send_output(
12098 {
12099 0 prefix => $prefix,
12100 command => 'SVSKILL',
12101 params => [
12102 $client,
12103 @$args,
12104 ],
12105 },
12106 $route_id,
12107 );
12108 }
12109  
12110 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
12111 1 return $ref;
12112 }
12113  
12114 3 ▶sub _daemon_peer_svstag {
Subroutine _daemon_peer_svstag: called CC=15 SCAR=33.4
12115 3 my $self = shift;
12116 3 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12117 3 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12118 3 my $sid = $self->server_sid();
12119 3 my $ref = [ ];
12120 3 my $args = [ @_ ];
12121 3 my $count = @$args;
12122  
12123 # - parv[0] = nickname
12124 # - parv[1] = TS
12125 # - parv[2] = [-][raw]
12126 # - parv[3] = required user mode(s) to see the tag
12127 # - parv[4] = tag line
12128  
12129 SWITCH: {
12130 3 ▶ if (!$self->_state_sid_serv($prefix) && $prefix ne $sid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->_state_sid_serv($prefix) and $prefix ne $sid) 0 3 3
Condition33%1/3
not $self->_state_sid_serv($prefix) and $prefix ne $sid
!ll&&!rl&&r
300
MC/DC0%0/2
not $self->_state_sid_serv($prefix) and $prefix ne $sid
not $self->_state_sid_serv($prefix) $prefix ne $sid
Truth table33%1/3
not(A) and B
A= not $self->_state_sid_serv($prefix)B= $prefix ne $sid
ABresult
0X0
100
111
12131 0 last SWITCH;
12132 }
12133 3 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 3 3
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
003
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
12134 0 last SWITCH;
12135 }
12136 3 my $client = shift @$args;
12137 3 my $uid = $self->state_user_uid($client);
12138 3 ▶ last SWITCH if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 3 3
12139 3 ▶ last SWITCH if $args->[0] !~ m!^\d+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $args->[0] =~ /^\d+$/ 0 3 3
12140 3 ▶ last SWITCH if $args->[0] != $self->{state}{uids}{$uid}{ts};
Branch: 1 branch
BranchTrueFalseTotal
if $args->[0] != $self->{"state"}{"uids"}{$uid}{"ts"} 0 3 3
12141 3 my $rec = $self->{state}{uids}{$uid};
12142 3 ▶ if ( $args->[1] eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] eq "-") 0 3 3
12143 0 delete $rec->{svstags}{$_} for keys %{ $rec->{svstags} };
12144 $self->send_output(
12145 {
12146 prefix => $prefix,
12147 command => 'SVSTAG',
12148 params => [
12149 $uid,
12150 $rec->{ts},
12151 $args->[1],
12152 ],
12153 },
12154 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
12155 );
12156 0 last SWITCH;
12157 }
12158 3 ▶ last SWITCH if $count < 5 || !$args->[3];
Branch: 1 branch
BranchTrueFalseTotal
if $count < 5 or not $args->[3] 0 3 3
Condition33%1/3
$count < 5 or not $args->[3]
l!l&&r!l&&!r
003
MC/DC0%0/2
$count < 5 or not $args->[3]
$count < 5 not $args->[3]
Truth table33%1/3
A or not(B)
A= $count < 5B= not $args->[3]
ABresult
1X1
011
000
12159 3 $rec->{svstags}{$args->[1]} = {
12160 numeric => $args->[1],
12161 umodes => $args->[2],
12162 tagline => $args->[3],
12163 };
12164 $self->send_output(
12165 {
12166 prefix => $prefix,
12167 command => 'SVSTAG',
12168 params => [
12169 $uid,
12170 $rec->{ts},
12171 $args->[1],
12172 $args->[2],
12173 $args->[3],
12174 ],
12175 },
12176 3 grep { $_ ne $peer_id } $self->_state_connected_peers(),
12177 );
12178 }
12179  
12180 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
12181 3 return $ref;
12182 }
12183  
12184 183 ▶sub _state_create {
Subroutine _state_create: called CC=2 SCAR=6.9
12185 183 my $self = shift;
12186  
12187 183 $self->_state_delete();
12188  
12189 # Connection specific tables
12190 183 $self->{state}{conns} = { };
12191  
12192 # IRC State specific
12193 183 $self->{state}{users} = { };
12194 183 $self->{state}{peers} = { };
12195 183 $self->{state}{chans} = { };
12196  
12197 # Register ourselves as a peer.
12198 $self->{state}{peers}{uc $self->server_name()} = {
12199 name => $self->server_name(),
12200 hops => 0,
12201 desc => $self->{config}{SERVERDESC},
12202 183 ts => 6,
12203 };
12204  
12205 183 ▶ if ( my $sid = $self->{config}{SID} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sid = $self->{"config"}{"SID"}) 183 0 183
12206 183 my $rec = $self->{state}{peers}{uc $self->server_name()};
12207 183 $rec->{sid} = $sid;
12208 183 $rec->{ts} = 6;
12209 183 $self->{state}{sids}{uc $sid} = $rec;
12210 183 $self->{state}{uids} = { };
12211 183 $self->{genuid} = $sid . 'AAAAAA';
12212 }
12213  
12214 $self->{state}{stats} = {
12215 183 maxconns => 0,
12216 maxlocal => 0,
12217 maxglobal => 0,
12218 ops_online => 0,
12219 invisible => 0,
12220 cmds => { },
12221 };
12222  
12223 $self->{state}{caps} = {
12224 183 'account-notify' => 1,
12225 'away-notify' => 1,
12226 'chghost' => 1,
12227 'extended-join' => 1,
12228 'invite-notify' => 1,
12229 'multi-prefix' => 1,
12230 'userhost-in-names' => 1,
12231 };
12232  
12233 183 return 1;
12234 }
12235  
12236 2 ▶sub _state_rand_sid {
Subroutine _state_rand_sid: called CC=1 SCAR=0.0
12237 2 my $self = shift;
12238 2 my @components = ( 0 .. 9, 'A' .. 'Z' );
12239 2 my $total = scalar @components;
12240 2 my $prefx = 10;
12241 2 $self->{config}{SID} = join '', $components[ rand $prefx ], $components[ rand $total ], $components[ rand $total ];
12242 }
12243  
12244 10567 ▶sub _state_gen_uid {
Subroutine _state_gen_uid: called CC=2 SCAR=7.6
12245 10567 my $self = shift;
12246 10567 my $uid = $self->{genuid};
12247 10567 $self->{genuid} = _add_one_uid( $uid );
12248 10567 ▶ while ( defined $self->{state}{uids}{$uid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"uids"}{$uid}) 0 10567 10567
12249 0 $uid = $self->{genuid};
12250 0 $self->{genuid} = _add_one_uid( $uid );
12251 }
12252 10567 return $uid;
12253 }
12254  
12255 10567 ▶sub _add_one_uid {
Subroutine _add_one_uid: called CC=1 SCAR=0.2
12256 10567 my $UID = shift;
12257 10567 my @cols = unpack 'a' x length $UID, $UID;
12258 10567 my ($add,$add1);
12259 10859 ▶ $add1 = $add = sub {
Subroutine __ANON__: called CC=5 SCAR=17.8
12260 10859 my $idx = shift;
12261 10859 ▶ if ( $idx != 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx != 3) { } 10859 0 10859
12262 10859 ▶ if ( $cols[$idx] eq 'Z' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cols[$idx] eq 'Z') { } 293 10566 10859
elsif ($cols[$idx] eq '9') { } 292 10274 10566
12263 293 $cols[$idx] = '0';
12264 }
12265 elsif ( $cols[$idx] eq '9' ) {
12266 292 $cols[$idx] = 'A';
12267 292 $add->( $idx - 1 );
12268 }
12269 else {
12270 10274 $cols[$idx]++;
12271 }
12272 }
12273 else {
12274 0 ▶ if ( $cols[$idx] eq 'Z' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cols[$idx] eq 'Z') { } 0 0 0
12275 0 @cols[3..8] = qw[A A A A A A];
12276 }
12277 else {
12278 0 $cols[$idx]++;
12279 }
12280 }
12281 10567 };
12282 10567 $add->(8);
12283 10567 return pack 'a' x scalar @cols, @cols;
12284 }
12285  
12286 183 ▶sub _state_delete {
Subroutine _state_delete: called CC=1 SCAR=0.0
12287 183 my $self = shift;
12288 183 delete $self->{state};
12289 183 return 1;
12290 }
12291  
12292 812 ▶sub _state_update_stats {
Subroutine _state_update_stats: called CC=3 SCAR=11.0
12293 812 my $self = shift;
12294 812 my $server = $self->server_name();
12295 812 my $global = keys %{ $self->{state}{users} };
12296 812 my $local = keys %{ $self->{state}{peers}{uc $server}{users} };
12297  
12298 $self->{state}{stats}{maxglobal}
12299 812 ▶ = $global if $global > $self->{state}{stats}{maxglobal};
Branch: 1 branch
BranchTrueFalseTotal
if $global > $self->{"state"}{"stats"}{"maxglobal"} 806 6 812
12300 $self->{state}{stats}{maxlocal}
12301 812 ▶ = $local if $local > $self->{state}{stats}{maxlocal};
Branch: 1 branch
BranchTrueFalseTotal
if $local > $self->{"state"}{"stats"}{"maxlocal"} 265 547 812
12302 812 return 1;
12303 }
12304  
12305 522 ▶sub _state_conn_stats {
Subroutine _state_conn_stats: called CC=2 SCAR=6.9
12306 522 my $self = shift;
12307  
12308 522 $self->{state}{stats}{conns_cumlative}++;
12309 522 my $conns = keys %{ $self->{state}{conns} };
12310 $self->{state}{stats}{maxconns} = $conns
12311 522 ▶ if $conns > $self->{state}{stats}{maxconns};
Branch: 1 branch
BranchTrueFalseTotal
if $conns > $self->{"state"}{"stats"}{"maxconns"} 492 30 522
12312 522 return 1;
12313 }
12314  
12315 4101 ▶sub _state_cmd_stat {
Subroutine _state_cmd_stat: called CC=6 SCAR=17.9
12316 4101 my $self = shift;
12317 4101 ▶ my $cmd = shift || return;
Condition50%1/2
shift() || (return)
l!l
41010
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12318 4101 ▶ my $line = shift || return;
Condition100%2/2
shift() || (return)
l!l
3877224
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
12319 3877 my $remote = shift;
12320 3877 ▶ my $record = $self->{state}{stats}{cmds}{$cmd} || {
Condition100%2/2
$self->{'state'}{'stats'}{'cmds'}{$cmd} || {'remote', 0, 'local', 0, 'bytes', 0}
l!l
20541823
MC/DC100%1/1
$self->{'state'}{'stats'}{'cmds'}{$cmd} || {'remote', 0, 'local', 0, 'bytes', 0}
$self->{'state'}{'stats'}{'cmds'}{$cmd}
Truth table100%2/2
A
A= $self->{'state'}{'stats'}{'cmds'}{$cmd}
Aresult
11
00
12321 remote => 0,
12322 local => 0,
12323 bytes => 0,
12324 };
12325  
12326 3877 ▶ $record->{local}++ if !$remote;
Branch: 1 branch
BranchTrueFalseTotal
unless $remote 1984 1893 3877
12327 3877 ▶ $record->{remote}++ if $remote;
Branch: 1 branch
BranchTrueFalseTotal
if $remote 1893 1984 3877
12328 3877 $record->{bytes} += length $line;
12329 3877 $self->{state}{stats}{cmds}{$cmd} = $record;
12330 3877 return 1;
12331 }
12332  
12333 0 ▶sub _state_find_user_host {
Subroutine _state_find_user_host: not called CC=6 SCAR=37.4
12334 0 my $self = shift;
12335 0 ▶ my $luser = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
12336 0 ▶ my $host = shift || '*';
Condition0%0/2
shift() || '*'
l!l
00
MC/DC0%0/1
shift() || '*'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
12337 0 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
12338 0 my @conns;
12339 0 for my $user (values %$local) {
12340 0 ▶ if (matches_mask($host, $user->{auth}{hostname})
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($host, $user->{"auth"}{"hostname"}) and matches_mask($luser, $user->{"auth"}{"ident"})) 0 0 0
Condition0%0/3
matches_mask($host, $user->{"auth"}{"hostname"}) and matches_mask($luser, $user->{"auth"}{"ident"})
!ll&&!rl&&r
000
MC/DC0%0/2
matches_mask($host, $user->{"auth"}{"hostname"}) and matches_mask($luser, $user->{"auth"}{"ident"})
matches_mask($host, $user->{"auth"}{"hostname"}) matches_mask($luser, $user->{"auth"}{"ident"})
Truth table0%0/3
A and B
A= matches_mask($host, $user->{"auth"}{"hostname"})B= matches_mask($luser, $user->{"auth"}{"ident"})
ABresult
0X0
100
111
12341 && matches_mask($luser, $user->{auth}{ident})) {
12342 0 push @conns, [$user->{route_id}, $user->{nick}];
12343 }
12344 }
12345  
12346 0 return @conns;
12347 }
12348  
12349 26 ▶sub _state_add_drkx_line {
Subroutine _state_add_drkx_line: called CC=12 SCAR=25.5
12350 26 my $self = shift;
12351 26 ▶ my $type = shift || return;
Condition50%1/2
shift() || (return)
l!l
260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12352 26 my @args = @_;
12353 26 ▶ return if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 26 26
12354 26 ▶ return if $type !~ m!^((RK|[DKX])LINE|RESV)$!i;
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^((RK|[DKX])LINE|RESV)$/i 0 26 26
12355 26 $type = lc($type) . 's';
12356 26 my $ref = { };
12357 26 foreach my $field ( qw[setby setat target duration] ) {
12358 104 $ref->{$field} = shift @args;
12359 104 ▶ return if !defined $ref->{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref->{$field} 0 104 104
12360 }
12361 26 $ref->{reason} = pop @args;
12362 26 ▶ if ( $type =~ m!^([xd]lines|resvs)$! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^([xd]lines|resvs)$/) { } 18 8 26
12363 18 $ref->{mask} = shift @args;
12364 18 ▶ return if !$ref->{mask};
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->{"mask"} 0 18 18
12365 }
12366 else {
12367 8 $ref->{user} = shift @args;
12368 8 $ref->{host} = shift @args;
12369 8 ▶ return if !$ref->{user} || !$ref->{host};
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->{"user"} and $ref->{"host"} 0 8 8
Condition33%1/3
$ref->{"user"} and $ref->{"host"}
!ll&&!rl&&r
008
MC/DC0%0/2
$ref->{"user"} and $ref->{"host"}
$ref->{"user"} $ref->{"host"}
Truth table33%1/3
A and B
A= $ref->{"user"}B= $ref->{"host"}
ABresult
0X0
100
111
12370 }
12371 26 ▶ if ( $ref->{duration} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->{"duration"}) 17 9 26
12372 $ref->{alarm} =
12373 $poe_kernel->delay_set(
12374 '_state_drkx_line_alarm',
12375 $ref->{duration},
12376 17 $type,
12377 $ref,
12378 );
12379 }
12380 26 ▶ if ( $type eq 'resvs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'resvs') { } 8 18 26
12381 8 $self->{state}{$type}{ uc_irc $ref->{mask} } = $ref;
12382 }
12383 else {
12384 18 push @{ $self->{state}{$type} }, $ref;
12385 }
12386 26 return 1;
12387 }
12388  
12389 15 ▶sub _state_del_drkx_line {
Subroutine _state_del_drkx_line: called CC=17 SCAR=30.2
12390 15 my $self = shift;
12391 15 ▶ my $type = shift || return;
Condition50%1/2
shift() || (return)
l!l
150
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12392 15 my @args = @_;
12393 15 ▶ return if !@args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 0 15 15
12394 15 ▶ return if $type !~ m!^((RK|[DKX])LINE|RESV)$!i;
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^((RK|[DKX])LINE|RESV)$/i 0 15 15
12395 15 $type = lc($type) . 's';
12396 15 my ($mask,$user,$host);
12397 15 ▶ if ( $type =~ m!^([xd]lines|resvs)$! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^([xd]lines|resvs)$/) { } 11 4 15
12398 11 $mask = shift @args;
12399 11 ▶ return if !$mask;
Branch: 1 branch
BranchTrueFalseTotal
unless $mask 0 11 11
12400 }
12401 else {
12402 4 $user = shift @args;
12403 4 $host = shift @args;
12404 4 ▶ return if !$user || !$host;
Branch: 1 branch
BranchTrueFalseTotal
unless $user and $host 0 4 4
Condition33%1/3
$user and $host
!ll&&!rl&&r
004
MC/DC0%0/2
$user and $host
$user $host
Truth table33%1/3
A and B
A= $userB= $host
ABresult
0X0
100
111
12405 }
12406 15 my $result; my $i = 0;
12407 15 ▶ if ( $type eq 'resvs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'resvs') { } 5 10 15
12408 5 $result = delete $self->{state}{resvs}{ uc_irc $mask };
12409 }
12410 else {
12411 10 LINES: for (@{ $self->{state}{$type} }) {
12412 10 ▶ if ($mask && $_->{mask} eq $mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask and $_->{"mask"} eq $mask) 6 4 10
Condition66%2/3
$mask and $_->{"mask"} eq $mask
!ll&&!rl&&r
406
MC/DC50%1/2
$mask and $_->{"mask"} eq $mask
$mask $_->{"mask"} eq $mask
Truth table66%2/3
A and B
A= $maskB= $_->{"mask"} eq $mask
ABresult
0X0
100
111
12413 6 $result = splice @{ $self->{state}{$type} }, $i, 1;
12414 6 last LINES;
12415 }
12416 4 ▶ if ($user && ($_->{user} eq $user && $_->{host} eq $host)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user and ($_->{"user"} eq $user and $_->{"host"} eq $host)) 4 0 4
Condition33%2/6
$user and ($_->{"user"} eq $user and $_->{"host"} eq $host)
!ll&&!rl&&r
004
$_->{"user"} eq $user and $_->{"host"} eq $host
!ll&&!rl&&r
004
MC/DC0%0/3
$user and ($_->{"user"} eq $user and $_->{"host"} eq $host)
$user $_->{"user"} eq $user $_->{"host"} eq $host
Truth table25%1/4
A and B and C
A= $userB= $_->{"user"} eq $userC= $_->{"host"} eq $host
ABCresult
0XX0
10X0
1100
1111
12417 4 $result = splice @{ $self->{state}{$type} }, $i, 1;
12418 4 last LINES;
12419 }
12420 0 ++$i;
12421 }
12422 }
12423 15 ▶ return if !$result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 15 15
12424 15 ▶ if ( my $alarm = delete $result->{alarm} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $alarm = delete $result->{"alarm"}) 8 7 15
12425 8 $poe_kernel->alarm_remove( $alarm );
12426 }
12427 15 return $result;
12428 }
12429  
12430 {
12431  
12432 180 my %drkxlines = (
12433 'rklines' => 'RK-Line',
12434 'klines' => 'K-Line',
12435 'dlines' => 'D-Line',
12436 'xlines' => 'X-Line',
12437 'resvs' => 'RESV',
12438 );
12439  
12440 9 ▶ sub _state_drkx_line_alarm {
Subroutine _state_drkx_line_alarm: called CC=7 SCAR=19.6
12441 9 my ($kernel,$self,$type,$ref) = @_[KERNEL,OBJECT,ARG0,ARG1];
12442 9 my $fancy = $drkxlines{$type};
12443 9 delete $ref->{alarm};
12444 9 my $res; my $i = 0;
12445 9 ▶ if ( $type eq 'resvs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'resvs') { } 2 7 9
12446 2 $res = delete $self->{state}{resvs}{uc_irc $ref->{mask}};
12447 }
12448 else {
12449 7 LINES: foreach my $drkxline ( @{ $self->{state}{$type} } ) {
12450 7 ▶ if ( $drkxline eq $ref ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($drkxline eq $ref) 7 0 7
12451 7 $res = splice @{ $self->{state}{$type} }, $i, 1;
12452 7 last LINES;
12453 }
12454 0 ++$i;
12455 }
12456 }
12457 9 ▶ return if !$res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 0 9 9
12458 9 ▶ my $mask = $res->{mask} || join '@', $res->{user}, $res->{host};
Condition66%2/3
$res->{'mask'} || join('@', $res->{'user'}, $res->{'host'})
l!l&&r!l&&!r
630
MC/DC0%0/2
$res->{'mask'} || join('@', $res->{'user'}, $res->{'host'})
$res->{'mask'} join('@', $res->{'user'}, $res->{'host'})
Truth table66%2/3
A || B
A= $res->{'mask'}B= join('@', $res->{'user'}, $res->{'host'})
ABresult
1X1
011
000
12459 9 my $locops = sprintf 'Temporary %s for [%s] expired', $fancy, $mask;
12460 9 ▶ $self->del_denial( $res->{mask} ) if $type eq 'dlines';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "dlines" 2 7 9
12461 9 $self->send_event( "daemon_expired", lc($fancy), $mask );
12462 9 $self->_send_to_realops( $locops, 'Notice', 'X' );
12463 9 return;
12464 }
12465  
12466 }
12467  
12468 180 ▶sub _state_is_resv {
Subroutine _state_is_resv: called CC=8 SCAR=20.8
12469 383 my $self = shift;
12470 383 ▶ my $thing = shift || return;
Condition50%1/2
shift() || (return)
l!l
3830
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12471 383 my $conn_id = shift;
12472 383 ▶ if ($conn_id && !$self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn_id and not $self->_connection_exists($conn_id)) 1 382 383
Condition66%2/3
$conn_id and not $self->_connection_exists($conn_id)
!ll&&!rl&&r
03821
MC/DC50%1/2
$conn_id and not $self->_connection_exists($conn_id)
$conn_id not $self->_connection_exists($conn_id)
Truth table66%2/3
A and not(B)
A= $conn_idB= not $self->_connection_exists($conn_id)
ABresult
0X0
100
111
12473 1 $conn_id = '';
12474 }
12475 383 ▶ if ($conn_id && $self->{state}{conns}{$conn_id}{resv_exempt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn_id and $self->{"state"}{"conns"}{$conn_id}{"resv_exempt"}) 1 382 383
Condition100%3/3
$conn_id and $self->{"state"}{"conns"}{$conn_id}{"resv_exempt"}
!ll&&!rl&&r
13811
MC/DC100%2/2
$conn_id and $self->{"state"}{"conns"}{$conn_id}{"resv_exempt"}
$conn_id $self->{"state"}{"conns"}{$conn_id}{"resv_exempt"}
Truth table100%3/3
A and B
A= $conn_idB= $self->{"state"}{"conns"}{$conn_id}{"resv_exempt"}
ABresult
0X0
100
111
12476 1 return 0;
12477 }
12478 382 foreach my $mask ( keys %{ $self->{state}{resvs} } ) {
12479 10 ▶ if ( matches_mask( $mask, $thing ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($mask, $thing)) 7 3 10
12480 7 return $self->{state}{resvs}{$mask}{reason};
12481 }
12482 }
12483 375 return 0;
12484 }
12485  
12486 8 ▶sub _state_have_resv {
Subroutine _state_have_resv: called CC=3 SCAR=11.4
12487 8 my $self = shift;
12488 8 ▶ my $mask = shift || return;
Condition50%1/2
shift() || (return)
l!l
80
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12489 8 ▶ return 1 if $self->{state}{resvs}{uc_irc $mask};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"resvs"}{uc_irc($mask)} 0 8 8
12490 8 return 0;
12491 }
12492  
12493 18 ▶sub _state_do_away_notify {
Subroutine _state_do_away_notify: called CC=11 SCAR=24.0
12494 18 my $self = shift;
12495 18 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
180
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12496 18 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
180
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12497 18 my $msg = shift;
12498 18 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 18 18
12499 18 my $sid = $self->server_sid();
12500 18 my $rec = $self->{state}{uids}{$uid};
12501 18 my $common = { };
12502 18 my @chans;
12503 18 ▶ if ( $chan eq '*' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chan eq '*') { } 15 3 18
12504 15 @chans = keys %{ $rec->{chans} };
12505 }
12506 else {
12507 3 push @chans, uc_irc $chan;
12508 }
12509 18 for my $uchan (@chans) {
12510 5 for my $user ( keys %{ $self->{state}{chans}{$uchan}{users} } ) {
12511 8 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 2 6 8
12512 6 ▶ next if !$self->{state}{uids}{$user}{caps}{'away-notify'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"uids"}{$user}{"caps"}{"away-notify"} 5 1 6
12513 1 $common->{$user} = $self->_state_uid_route($user);
12514 }
12515 }
12516 my $ref = {
12517 18 prefix => $rec->{full}->(),
12518 command => 'AWAY',
12519 };
12520 18 ▶ $ref->{params} = [ $msg ] if $msg;
Branch: 1 branch
BranchTrueFalseTotal
if $msg 16 2 18
12521 18 $self->send_output( $ref, $common->{$_} ) for keys %$common;
12522 18 return 1;
12523 }
12524  
12525 5 ▶sub _state_do_local_users_match_xline {
Subroutine _state_do_local_users_match_xline: called CC=8 SCAR=28.3
12526 5 my $self = shift;
12527 5 ▶ my $mask = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12528 5 ▶ my $reason = shift || '<No reason supplied>';
Condition50%1/2
shift() || '<No reason supplied>'
l!l
50
MC/DC0%0/1
shift() || '<No reason supplied>'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12529 5 my $sid = $self->server_sid();
12530 5 my $server = $self->server_name();
12531  
12532 5 foreach my $luser ( keys %{ $self->{state}{sids}{$sid}{uids} } ) {
12533 5 my $urec = $self->{state}{uids}{$luser};
12534 5 ▶ next if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 5 0 5
12535 0 ▶ next if $urec->{umode} =~ m!o!;
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"umode"} =~ /o/ 0 0 0
12536 0 ▶ if ( $urec->{ircname} && matches_mask( $mask, $urec->{ircname} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($urec->{"ircname"} and matches_mask($mask, $urec->{"ircname"})) 0 0 0
Condition0%0/3
$urec->{"ircname"} and matches_mask($mask, $urec->{"ircname"})
!ll&&!rl&&r
000
MC/DC0%0/2
$urec->{"ircname"} and matches_mask($mask, $urec->{"ircname"})
$urec->{"ircname"} matches_mask($mask, $urec->{"ircname"})
Truth table0%0/3
A and B
A= $urec->{"ircname"}B= matches_mask($mask, $urec->{"ircname"})
ABresult
0X0
100
111
12537 $self->send_output(
12538 {
12539 prefix => $server,
12540 command => '465',
12541 params => [
12542 $urec->{nick},
12543 "You are banned from this server- $reason",
12544 ],
12545 },
12546 $urec->{route_id},
12547 0 );
12548 0 $self->_terminate_conn_error( $urec->{route_id}, $reason );
12549 }
12550 }
12551 5 return 1;
12552 }
12553  
12554 5 ▶sub _state_do_local_users_match_dline {
Subroutine _state_do_local_users_match_dline: called CC=7 SCAR=24.6
12555 5 my $self = shift;
12556 5 ▶ my $netmask = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12557 5 ▶ my $reason = shift || '<No reason supplied>';
Condition50%1/2
shift() || '<No reason supplied>'
l!l
50
MC/DC0%0/1
shift() || '<No reason supplied>'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12558 5 my $sid = $self->server_sid();
12559 5 my $server = $self->server_name();
12560  
12561 5 foreach my $luser ( keys %{ $self->{state}{sids}{$sid}{uids} } ) {
12562 5 my $urec = $self->{state}{uids}{$luser};
12563 5 ▶ next if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 5 0 5
12564 0 ▶ next if $urec->{umode} =~ m!o!;
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"umode"} =~ /o/ 0 0 0
12565 0 ▶ if ( Net::CIDR::cidrlookup($urec->{socket}[0],$netmask) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (Net::CIDR::cidrlookup($urec->{"socket"}[0], $netmask)) 0 0 0
12566 $self->send_output(
12567 {
12568 prefix => $server,
12569 command => '465',
12570 params => [
12571 $urec->{nick},
12572 "You are banned from this server- $reason",
12573 ],
12574 },
12575 $urec->{route_id},
12576 0 );
12577 0 $self->_terminate_conn_error( $urec->{route_id}, $reason );
12578 }
12579 }
12580 5 return 1;
12581 }
12582  
12583 2 ▶sub _state_do_local_users_match_rkline {
Subroutine _state_do_local_users_match_rkline: called CC=11 SCAR=36.1
12584 2 my $self = shift;
12585 2 ▶ my $luser = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12586 2 ▶ my $host = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12587 2 ▶ my $reason = shift || '<No reason supplied>';
Condition50%1/2
shift() || '<No reason supplied>'
l!l
20
MC/DC0%0/1
shift() || '<No reason supplied>'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12588 2 my $sid = $self->server_sid();
12589 2 my $server = $self->server_name();
12590 2 my $local = $self->{state}{sids}{$sid}{uids};
12591  
12592 2 for my $urec (values %$local) {
12593 2 ▶ next if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 2 0 2
12594 0 ▶ next if $urec->{umode} && $urec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"umode"} and $urec->{"umode"} =~ /o/ 0 0 0
Condition0%0/3
$urec->{"umode"} and $urec->{"umode"} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$urec->{"umode"} and $urec->{"umode"} =~ /o/
$urec->{"umode"} $urec->{"umode"} =~ /o/
Truth table0%0/3
A and B
A= $urec->{"umode"}B= $urec->{"umode"} =~ /o/
ABresult
0X0
100
111
12595 0 ▶ if (($urec->{socket}[0] =~ /$host/
Branch: 1 branch
BranchTrueFalseTotal
if ($urec->{"socket"}[0] =~ /$host/ || $urec->{"auth"}{"hostname"} =~ /$host/ and $urec->{"auth"}{"ident"} =~ /$luser/) 0 0 0
Condition0%0/6
$urec->{"socket"}[0] =~ /$host/ || $urec->{"auth"}{"hostname"} =~ /$host/ and $urec->{"auth"}{"ident"} =~ /$luser/
!ll&&!rl&&r
000
$urec->{"socket"}[0] =~ /$host/ or $urec->{"auth"}{"hostname"} =~ /$host/
l!l&&r!l&&!r
000
MC/DC0%0/3
$urec->{"socket"}[0] =~ /$host/ || $urec->{"auth"}{"hostname"} =~ /$host/ and $urec->{"auth"}{"ident"} =~ /$luser/
$urec->{"socket"}[0] =~ /$host/ $urec->{"auth"}{"hostname"} =~ /$host/ $urec->{"auth"}{"ident"} =~ /$luser/
Truth table0%0/5
A or B and C
A= $urec->{"socket"}[0] =~ /$host/B= $urec->{"auth"}{"hostname"} =~ /$host/C= $urec->{"auth"}{"ident"} =~ /$luser/
ABCresult
00X0
1X00
0100
1X11
0111
12596 || $urec->{auth}{hostname} =~ /$host/)
12597 && $urec->{auth}{ident} =~ /$luser/) {
12598 $self->send_output(
12599 {
12600 prefix => $server,
12601 command => '465',
12602 params => [
12603 $urec->{nick},
12604 "You are banned from this server- $reason",
12605 ],
12606 },
12607 $urec->{route_id},
12608 0 );
12609 0 $self->_terminate_conn_error( $urec->{route_id}, $reason );
12610 }
12611 }
12612 2 return 1;
12613 }
12614  
12615 6 ▶sub _state_do_local_users_match_kline {
Subroutine _state_do_local_users_match_kline: called CC=18 SCAR=49.6
12616 6 my $self = shift;
12617 6 ▶ my $luser = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12618 6 ▶ my $host = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12619 6 ▶ my $reason = shift || '<No reason supplied>';
Condition50%1/2
shift() || '<No reason supplied>'
l!l
60
MC/DC0%0/1
shift() || '<No reason supplied>'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12620 6 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
12621 6 my $server = $self->server_name();
12622  
12623 6 ▶ if (my $netmask = Net::CIDR::cidrvalidate($host)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $netmask = Net::CIDR::cidrvalidate($host)) { } 6 0 6
12624 6 for my $user (values %$local) {
12625 6 ▶ next if $user->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"route_id"} eq "spoofed" 6 0 6
12626 0 ▶ next if $user->{umode} && $user->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"umode"} and $user->{"umode"} =~ /o/ 0 0 0
Condition0%0/3
$user->{"umode"} and $user->{"umode"} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$user->{"umode"} and $user->{"umode"} =~ /o/
$user->{"umode"} $user->{"umode"} =~ /o/
Truth table0%0/3
A and B
A= $user->{"umode"}B= $user->{"umode"} =~ /o/
ABresult
0X0
100
111
12627 0 ▶ if (Net::CIDR::cidrlookup($user->{socket}[0],$netmask)
Branch: 1 branch
BranchTrueFalseTotal
if (Net::CIDR::cidrlookup($user->{"socket"}[0], $netmask) and matches_mask($luser, $user->{"auth"}{"ident"})) 0 0 0
Condition0%0/3
Net::CIDR::cidrlookup($user->{"socket"}[0], $netmask) and matches_mask($luser, $user->{"auth"}{"ident"})
!ll&&!rl&&r
000
MC/DC0%0/2
Net::CIDR::cidrlookup($user->{"socket"}[0], $netmask) and matches_mask($luser, $user->{"auth"}{"ident"})
Net::CIDR::cidrlookup($user->{"socket"}[0], $netmask) matches_mask($luser, $user->{"auth"}{"ident"})
Truth table0%0/3
A and B
A= Net::CIDR::cidrlookup($user->{"socket"}[0], $netmask)B= matches_mask($luser, $user->{"auth"}{"ident"})
ABresult
0X0
100
111
12628 && matches_mask($luser, $user->{auth}{ident})) {
12629 $self->send_output(
12630 {
12631 prefix => $server,
12632 command => '465',
12633 params => [
12634 $user->{nick},
12635 "You are banned from this server- $reason",
12636 ],
12637 },
12638 $user->{route_id},
12639 0 );
12640 0 $self->_terminate_conn_error( $user->{route_id}, $reason );
12641 }
12642 }
12643 }
12644 else {
12645 0 for my $user (values %$local) {
12646 0 ▶ next if $user->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"route_id"} eq "spoofed" 0 0 0
12647 0 ▶ next if $user->{umode} && $user->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"umode"} and $user->{"umode"} =~ /o/ 0 0 0
Condition0%0/3
$user->{"umode"} and $user->{"umode"} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$user->{"umode"} and $user->{"umode"} =~ /o/
$user->{"umode"} $user->{"umode"} =~ /o/
Truth table0%0/3
A and B
A= $user->{"umode"}B= $user->{"umode"} =~ /o/
ABresult
0X0
100
111
12648  
12649 0 ▶ if ((matches_mask($host, $user->{socket}[0])
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($host, $user->{"socket"}[0]) || matches_mask($host, $user->{"auth"}{"hostname"}) and matches_mask($luser, $user->{"auth"}{"ident"})) 0 0 0
Condition0%0/6
matches_mask($host, $user->{"socket"}[0]) || matches_mask($host, $user->{"auth"}{"hostname"}) and matches_mask($luser, $user->{"auth"}{"ident"})
!ll&&!rl&&r
000
matches_mask($host, $user->{"socket"}[0]) or matches_mask($host, $user->{"auth"}{"hostname"})
l!l&&r!l&&!r
000
MC/DC0%0/3
matches_mask($host, $user->{"socket"}[0]) || matches_mask($host, $user->{"auth"}{"hostname"}) and matches_mask($luser, $user->{"auth"}{"ident"})
matches_mask($host, $user->{"socket"}[0]) matches_mask($host, $user->{"auth"}{"hostname"}) matches_mask($luser, $user->{"auth"}{"ident"})
Truth table0%0/5
A or B and C
A= matches_mask($host, $user->{"socket"}[0])B= matches_mask($host, $user->{"auth"}{"hostname"})C= matches_mask($luser, $user->{"auth"}{"ident"})
ABCresult
00X0
1X00
0100
1X11
0111
12650 || matches_mask($host, $user->{auth}{hostname}))
12651 && matches_mask($luser, $user->{auth}{ident})) {
12652 $self->send_output(
12653 {
12654 prefix => $server,
12655 command => '465',
12656 params => [
12657 $user->{nick},
12658 "You are banned from this server- $reason",
12659 ],
12660 },
12661 $user->{route_id},
12662 0 );
12663 0 $self->_terminate_conn_error( $user->{route_id}, $reason );
12664 }
12665 }
12666 }
12667  
12668 6 return 1;
12669 }
12670  
12671 226 ▶sub _state_user_matches_rkline {
Subroutine _state_user_matches_rkline: called CC=9 SCAR=23.2
12672 226 my $self = shift;
12673 226 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12674 226 my $record = $self->{state}{conns}{$conn_id};
12675 226 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition66%2/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
12250
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table66%2/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
12676 226 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition100%2/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
1225
MC/DC100%1/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table100%2/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
12677 226 my $ip = $record->{socket}[0];
12678  
12679 226 ▶ return 0 if $record->{kline_exempt};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kline_exempt"} 1 225 226
12680  
12681 225 for my $kline (@{ $self->{state}{rklines} }) {
12682 2 ▶ if (($host =~ /$kline->{host}/ || $ip =~ /$kline->{host}/)
Branch: 1 branch
BranchTrueFalseTotal
if ($host =~ /$kline->{"host"}/ || $ip =~ /$kline->{"host"}/ and $user =~ /$kline->{"user"}/) 2 0 2
Condition33%2/6
$host =~ /$kline->{"host"}/ || $ip =~ /$kline->{"host"}/ and $user =~ /$kline->{"user"}/
!ll&&!rl&&r
002
$host =~ /$kline->{"host"}/ or $ip =~ /$kline->{"host"}/
l!l&&r!l&&!r
200
MC/DC0%0/3
$host =~ /$kline->{"host"}/ || $ip =~ /$kline->{"host"}/ and $user =~ /$kline->{"user"}/
$host =~ /$kline->{"host"}/ $ip =~ /$kline->{"host"}/ $user =~ /$kline->{"user"}/
Truth table20%1/5
A or B and C
A= $host =~ /$kline->{"host"}/B= $ip =~ /$kline->{"host"}/C= $user =~ /$kline->{"user"}/
ABCresult
00X0
1X00
0100
1X11
0111
12683 && $user =~ /$kline->{user}/) {
12684 2 return $kline->{reason};
12685 }
12686 }
12687 223 return 0;
12688 }
12689  
12690 231 ▶sub _state_user_matches_kline {
Subroutine _state_user_matches_kline: called CC=12 SCAR=30.4
12691 231 my $self = shift;
12692 231 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2310
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12693 231 my $record = $self->{state}{conns}{$conn_id};
12694 231 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition66%2/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
12300
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table66%2/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
12695 231 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition100%2/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
1230
MC/DC100%1/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table100%2/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
12696 231 my $ip = $record->{socket}[0];
12697  
12698 231 ▶ return 0 if $record->{kline_exempt};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kline_exempt"} 1 230 231
12699  
12700 230 for my $kline (@{ $self->{state}{klines} }) {
12701 5 ▶ if (my $netmask = Net::CIDR::cidrvalidate($kline->{host})) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $netmask = Net::CIDR::cidrvalidate($kline->{'host'})) { } 5 0 5
elsif (matches_mask($kline->{'host'}, $host) || matches_mask($kline->{'host'}, $ip) and matches_mask($kline->{'user'}, $user)) { } 0 0 0
12702 5 ▶ if (Net::CIDR::cidrlookup($ip,$netmask)
Branch: 1 branch
BranchTrueFalseTotal
if (Net::CIDR::cidrlookup($ip, $netmask) and matches_mask($kline->{"user"}, $user)) 5 0 5
Condition33%1/3
Net::CIDR::cidrlookup($ip, $netmask) and matches_mask($kline->{"user"}, $user)
!ll&&!rl&&r
005
MC/DC0%0/2
Net::CIDR::cidrlookup($ip, $netmask) and matches_mask($kline->{"user"}, $user)
Net::CIDR::cidrlookup($ip, $netmask) matches_mask($kline->{"user"}, $user)
Truth table33%1/3
A and B
A= Net::CIDR::cidrlookup($ip, $netmask)B= matches_mask($kline->{"user"}, $user)
ABresult
0X0
100
111
12703 && matches_mask($kline->{user}, $user)) {
12704 5 return $kline->{reason};
12705 }
12706 }
12707 ▶ elsif ((matches_mask($kline->{host}, $host)
Condition0%0/6
matches_mask($kline->{"host"}, $host) || matches_mask($kline->{"host"}, $ip) and matches_mask($kline->{"user"}, $user)
!ll&&!rl&&r
000
matches_mask($kline->{"host"}, $host) or matches_mask($kline->{"host"}, $ip)
l!l&&r!l&&!r
000
MC/DC0%0/3
matches_mask($kline->{"host"}, $host) || matches_mask($kline->{"host"}, $ip) and matches_mask($kline->{"user"}, $user)
matches_mask($kline->{"host"}, $host) matches_mask($kline->{"host"}, $ip) matches_mask($kline->{"user"}, $user)
Truth table0%0/5
A or B and C
A= matches_mask($kline->{"host"}, $host)B= matches_mask($kline->{"host"}, $ip)C= matches_mask($kline->{"user"}, $user)
ABCresult
00X0
1X00
0100
1X11
0111
12708 || matches_mask($kline->{host}, $ip))
12709 && matches_mask($kline->{user}, $user)) {
12710 0 return $kline->{reason};
12711 }
12712 }
12713  
12714 225 return 0;
12715 }
12716  
12717 236 ▶sub _state_user_matches_xline {
Subroutine _state_user_matches_xline: called CC=5 SCAR=16.5
12718 236 my $self = shift;
12719 236 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2360
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12720 236 my $record = $self->{state}{conns}{$conn_id};
12721 236 ▶ my $ircname = $record->{ircname} || return;
Condition50%1/2
$record->{'ircname'} || (return)
l!l
2360
MC/DC0%0/1
$record->{'ircname'} || (return)
$record->{'ircname'}
Truth table50%1/2
A
A= $record->{'ircname'}
Aresult
11
00
12722  
12723 236 for my $xline (@{ $self->{state}{xlines} }) {
12724 5 ▶ if ( matches_mask( $xline->{mask}, $ircname ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($xline->{"mask"}, $ircname)) 5 0 5
12725 5 return $xline->{reason};
12726 }
12727 }
12728  
12729 231 return 0;
12730 }
12731  
12732 242 ▶sub _state_auth_client_conn {
Subroutine _state_auth_client_conn: called CC=17 SCAR=28.4
12733 242 my $self = shift;
12734 242 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2420
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12735  
12736 242 ▶ if (!$self->{config}{auth} || !@{ $self->{config}{auth} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}) 232 10 242
Condition66%2/3
$self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}
!ll&&!rl&&r
232010
MC/DC50%1/2
$self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}
$self->{"config"}{"auth"} @{$self->{"config"}{"auth"};}
Truth table66%2/3
A and B
A= $self->{"config"}{"auth"}B= @{$self->{"config"}{"auth"};}
ABresult
0X0
100
111
12737 232 return 1;
12738 }
12739 10 my $record = $self->{state}{conns}{$conn_id};
12740 10 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition66%2/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
190
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table66%2/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
12741 10 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition50%1/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
010
MC/DC0%0/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table50%1/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
12742 10 my $uh = join '@', $user, $host;
12743 10 my $ui = join '@', $user, $record->{socket}[0];
12744  
12745 10 for my $auth (@{ $self->{config}{auth} }) {
12746 10 ▶ if (matches_mask($auth->{mask}, $uh)
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($auth->{"mask"}, $uh) or matches_mask($auth->{"mask"}, $ui)) 9 1 10
Condition100%3/3
matches_mask($auth->{"mask"}, $uh) or matches_mask($auth->{"mask"}, $ui)
l!l&&r!l&&!r
811
MC/DC100%2/2
matches_mask($auth->{"mask"}, $uh) or matches_mask($auth->{"mask"}, $ui)
matches_mask($auth->{"mask"}, $uh) matches_mask($auth->{"mask"}, $ui)
Truth table100%3/3
A or B
A= matches_mask($auth->{"mask"}, $uh)B= matches_mask($auth->{"mask"}, $ui)
ABresult
1X1
011
000
12747 || matches_mask($auth->{mask}, $ui)) {
12748 9 ▶ if ($auth->{password} && (!$record->{pass}
Branch: 1 branch
BranchTrueFalseTotal
if ($auth->{"password"} and not $record->{"pass"} && chkpasswd($record->{"pass"}, $auth->{"password"})) 4 5 9
Condition100%6/6
$auth->{"password"} and not $record->{"pass"} && chkpasswd($record->{"pass"}, $auth->{"password"})
!ll&&!rl&&r
414
$record->{'pass'} && chkpasswd($record->{'pass'}, $auth->{'password'})
!ll&&!rl&&r
311
MC/DC100%3/3
$auth->{"password"} and not $record->{"pass"} && chkpasswd($record->{"pass"}, $auth->{"password"})
$auth->{"password"} $record->{'pass'} chkpasswd($record->{'pass'}, $auth->{'password'})
Truth table100%4/4
A and not(B && C)
A= $auth->{"password"}B= $record->{'pass'}C= chkpasswd($record->{'pass'}, $auth->{'password'})
ABCresult
0XX0
1110
10X1
1101
12749 || !chkpasswd($record->{pass}, $auth->{password}) )) {
12750 4 return 0;
12751 }
12752 5 ▶ if ($auth->{spoof}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth->{"spoof"}) 1 4 5
12753 $self->_send_to_realops(
12754 sprintf(
12755 '%s spoofing: %s as %s',
12756 $record->{nick}, $record->{auth}{hostname},
12757 $auth->{spoof},
12758 1 ),
12759 'Notice',
12760 's',
12761 );
12762 1 $record->{auth}{hostname} = $auth->{spoof};
12763 }
12764 5 foreach my $feat ( qw(exceed_limit kline_exempt resv_exempt can_flood need_ident) ) {
12765 25 ▶ $record->{$feat} = 1 if $auth->{$feat};
Branch: 1 branch
BranchTrueFalseTotal
if $auth->{$feat} 5 20 25
12766 }
12767 5 ▶ if (!$record->{auth}{ident} && $auth->{no_tilde}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $record->{"auth"}{"ident"} and $auth->{"no_tilde"}) 1 4 5
Condition66%2/3
not $record->{"auth"}{"ident"} and $auth->{"no_tilde"}
!ll&&!rl&&r
041
MC/DC50%1/2
not $record->{"auth"}{"ident"} and $auth->{"no_tilde"}
not $record->{"auth"}{"ident"} $auth->{"no_tilde"}
Truth table66%2/3
not(A) and B
A= not $record->{"auth"}{"ident"}B= $auth->{"no_tilde"}
ABresult
0X0
100
111
12768 1 $record->{auth}{ident} = $record->{user};
12769 }
12770 5 return 1;
12771 }
12772 }
12773  
12774 1 return 0;
12775 }
12776  
12777 257 ▶sub _state_auth_peer_conn {
Subroutine _state_auth_peer_conn: called CC=20 SCAR=38.7
12778 257 my $self = shift;
12779 257 my ($conn_id, $name, $pass) = @_;
12780  
12781 257 ▶ if (!$conn_id || !$self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn_id and $self->_connection_exists($conn_id)) 0 257 257
Condition33%1/3
$conn_id and $self->_connection_exists($conn_id)
!ll&&!rl&&r
00257
MC/DC0%0/2
$conn_id and $self->_connection_exists($conn_id)
$conn_id $self->_connection_exists($conn_id)
Truth table33%1/3
A and B
A= $conn_idB= $self->_connection_exists($conn_id)
ABresult
0X0
100
111
12782 0 return;
12783 }
12784  
12785 257 ▶ return 0 if !$name || !$pass;
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $pass 0 257 257
Condition33%1/3
$name and $pass
!ll&&!rl&&r
00257
MC/DC0%0/2
$name and $pass
$name $pass
Truth table33%1/3
A and B
A= $nameB= $pass
ABresult
0X0
100
111
12786 257 my $peers = $self->{config}{peers};
12787 257 ▶ return 0 if !$peers->{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $$peers{uc $name} 0 257 257
12788 257 my $peer = $peers->{uc $name};
12789 257 ▶ return -1 if !chkpasswd($pass,$peer->{pass});
Branch: 1 branch
BranchTrueFalseTotal
unless chkpasswd($pass, $peer->{"pass"}) 1 256 257
12790  
12791 256 my $conn = $self->{state}{conns}{$conn_id};
12792  
12793 256 ▶ if ($peer->{certfp} && $conn->{secured}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer->{"certfp"} and $conn->{"secured"}) 4 252 256
Condition66%2/3
$peer->{"certfp"} and $conn->{"secured"}
!ll&&!rl&&r
25204
MC/DC50%1/2
$peer->{"certfp"} and $conn->{"secured"}
$peer->{"certfp"} $conn->{"secured"}
Truth table66%2/3
A and B
A= $peer->{"certfp"}B= $conn->{"secured"}
ABresult
0X0
100
111
12794 4 my $certfp = $self->connection_certfp($conn_id);
12795 4 ▶ return -2 if !$certfp || $certfp ne $peer->{certfp};
Branch: 1 branch
BranchTrueFalseTotal
if not $certfp or $certfp ne $peer->{"certfp"} 1 3 4
Condition66%2/3
not $certfp or $certfp ne $peer->{"certfp"}
l!l&&r!l&&!r
013
MC/DC50%1/2
not $certfp or $certfp ne $peer->{"certfp"}
not $certfp $certfp ne $peer->{"certfp"}
Truth table66%2/3
not(A) or B
A= not $certfpB= $certfp ne $peer->{"certfp"}
ABresult
1X1
011
000
12796 }
12797  
12798 255 ▶ if (!$peer->{ipmask} && $conn->{socket}[0] =~ /^(127\.|::1)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $peer->{"ipmask"} and $conn->{"socket"}[0] =~ /^(127\.|::1)/) 252 3 255
Condition66%2/3
not $peer->{"ipmask"} and $conn->{"socket"}[0] =~ /^(127\.|::1)/
!ll&&!rl&&r
30252
MC/DC50%1/2
not $peer->{"ipmask"} and $conn->{"socket"}[0] =~ /^(127\.|::1)/
not $peer->{"ipmask"} $conn->{"socket"}[0] =~ /^(127\.|::1)/
Truth table66%2/3
not(A) and B
A= not $peer->{"ipmask"}B= $conn->{"socket"}[0] =~ /^(127\.|::1)/
ABresult
0X0
100
111
12799 252 return 1;
12800 }
12801 3 ▶ return -3 if !$peer->{ipmask};
Branch: 1 branch
BranchTrueFalseTotal
unless $peer->{"ipmask"} 0 3 3
12802 3 my $client_ip = $conn->{socket}[0];
12803  
12804 3 ▶ if (ref $peer->{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $peer->{"ipmask"} eq "ARRAY") 0 3 3
12805 0 for my $block ( @{ $peer->{ipmask} }) {
12806 0 ▶ if ( eval { $block->isa('Net::Netmask') } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $block->isa("Net::Netmask") } }) 0 0 0
12807 0 ▶ return -3 if $block->match($client_ip);
Branch: 1 branch
BranchTrueFalseTotal
if $block->match($client_ip) 0 0 0
12808 0 next;
12809 }
12810 0 ▶ return 1 if Net::CIDR::cidrlookup( $client_ip, $block );
Branch: 1 branch
BranchTrueFalseTotal
if Net::CIDR::cidrlookup($client_ip, $block) 0 0 0
12811 }
12812 }
12813  
12814 return 1 if matches_mask(
12815 '*!*@'.$peer->{ipmask},
12816 3 ▶ "*!*\@$client_ip",
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask('*!*@' . $peer->{"ipmask"}, "*!*\@$client_ip") 3 0 3
12817 );
12818  
12819 0 return -3;
12820 }
12821  
12822 {
12823  
12824 180 my %flag_notices = (
12825 kline_exempt => '*** You are exempt from K/RK lines',
12826 resv_exempt => '*** You are exempt from resvs',
12827 exceed_limit => '*** You are exempt from user limits',
12828 can_flood => '*** You are exempt from flood protection',
12829 );
12830  
12831 224 ▶ sub _state_auth_flags_notices {
Subroutine _state_auth_flags_notices: called CC=6 SCAR=18.0
12832 224 my $self = shift;
12833 224 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2240
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12834 224 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 224 224
12835 224 my $server = $self->server_name();
12836 224 my $crec = $self->{state}{conns}{$conn_id};
12837 224 my $nick = $crec->{nick};
12838  
12839 224 foreach my $feat ( qw(kline_exempt resv_exempt exceed_limit can_flood) ) {
12840 896 ▶ next if !$crec->{$feat};
Branch: 1 branch
BranchTrueFalseTotal
unless $crec->{$feat} 892 4 896
12841 4 ▶ $self->antiflood($conn_id, 0) if $feat eq 'can_flood';
Branch: 1 branch
BranchTrueFalseTotal
if $feat eq "can_flood" 1 3 4
12842 $self->_send_output_to_client(
12843 $conn_id,
12844 {
12845 prefix => $server,
12846 command => 'NOTICE',
12847 4 params => [ $nick, $flag_notices{$feat} ],
12848 },
12849 );
12850 }
12851 224 return 1;
12852 }
12853  
12854 }
12855  
12856 180 ▶sub _state_send_credentials {
Subroutine _state_send_credentials: called CC=9 SCAR=22.4
12857 255 my $self = shift;
12858 255 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2550
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12859 255 ▶ my $name = shift || return;
Condition50%1/2
shift() || (return)
l!l
2550
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12860 255 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 255 255
12861 255 ▶ return if !$self->{config}{peers}{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"config"}{"peers"}{uc $name} 0 255 255
12862 255 ▶ return if $self->_connection_terminated($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_terminated($conn_id) 0 255 255
12863  
12864 255 my $peer = $self->{config}{peers}{uc $name};
12865 255 my $rec = $self->{state}{peers}{uc $self->server_name()};
12866 255 my $sid = $rec->{sid};
12867  
12868 $self->send_output(
12869 {
12870 command => 'PASS',
12871 255 ▶ params => [$peer->{rpass}, 'TS', ( $sid ? ( 6 => $sid ) : () )],
Branch: 1 branch
BranchTrueFalseTotal
$sid ? : 255 0 255
12872 },
12873 $conn_id,
12874 );
12875  
12876 $self->send_output(
12877 {
12878 command => 'CAPAB',
12879 params => [
12880 255 ▶ join (' ', @{ $self->{config}{capab} },
Branch: 1 branch
BranchTrueFalseTotal
$peer->{'zip'} ? : 251 4 255
12881 255 ($peer->{zip} ? 'ZIP' : ())
12882 ),
12883 ],
12884 },
12885 $conn_id,
12886 );
12887  
12888 255 my $desc = '';
12889 255 ▶ $desc = '(H) ' if $self->{config}{hidden};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"config"}{"hidden"} 2 253 255
12890 255 $desc .= $rec->{desc};
12891  
12892 $self->send_output(
12893 {
12894 command => 'SERVER',
12895 params => [
12896 $rec->{name},
12897 255 $rec->{hops} + 1,
12898 $desc,
12899 ],
12900 },
12901 $conn_id,
12902 );
12903  
12904 255 $self->send_output(
12905 {
12906 command => 'SVINFO',
12907 params => [6, 6, 0, time],
12908 },
12909 $conn_id,
12910 );
12911  
12912 255 $self->{state}{conns}{$conn_id}{zip} = $peer->{zip};
12913 255 return 1;
12914 }
12915  
12916 255 ▶sub _state_send_burst {
Subroutine _state_send_burst: called CC=32 SCAR=34.8
12917 255 my $self = shift;
12918 255 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2550
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12919 255 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 255 255
12920 255 ▶ return if $self->_connection_terminated($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_terminated($conn_id) 0 255 255
12921 255 my $server = $self->server_name();
12922 255 my $sid = $self->server_sid();
12923 255 my $conn = $self->{state}{conns}{$conn_id};
12924 255 my $burst = grep { /^EOB$/i } @{ $conn->{capab} };
12925 255 my $invex = grep { /^IE$/i } @{ $conn->{capab} };
12926 255 my $excepts = grep { /^EX$/i } @{ $conn->{capab} };
12927 255 my $tburst = grep { /^TBURST$/i } @{ $conn->{capab} };
12928 255 my $rhost = grep { /^RHOST$/i } @{ $conn->{capab} };
12929 255 ▶ $rhost = ( $self->_state_our_capab('RHOST') && $rhost );
Condition66%2/3
$self->_state_our_capab('RHOST') && $rhost
!ll&&!rl&&r
02496
MC/DC50%1/2
$self->_state_our_capab('RHOST') && $rhost
$self->_state_our_capab('RHOST') $rhost
Truth table66%2/3
A && B
A= $self->_state_our_capab('RHOST')B= $rhost
ABresult
0X0
100
111
12930 255 my %map = qw(bans b excepts e invex I);
12931 255 my @lists = qw(bans);
12932 255 ▶ push @lists, 'excepts' if $excepts;
Branch: 1 branch
BranchTrueFalseTotal
if $excepts 249 6 255
12933 255 ▶ push @lists, 'invex' if $invex;
Branch: 1 branch
BranchTrueFalseTotal
if $invex 249 6 255
12934  
12935 # Send SERVER burst
12936 255 my %eobs;
12937 255 for ($self->_state_server_burst($sid, $conn->{sid})) {
12938 195 $eobs{ $_->{prefix} }++;
12939 195 $self->send_output($_, $conn_id );
12940 }
12941  
12942 # Send NICK burst
12943 255 for my $uid (keys %{ $self->{state}{uids} }) {
12944 332 my $record = $self->{state}{uids}{$uid};
12945 332 ▶ next if $record->{route_id} eq $conn_id;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"route_id"} eq $conn_id 0 332 332
12946  
12947 332 my $umode_fixed = $record->{umode};
12948 332 $umode_fixed =~ s/[^aiow]//g;
12949 332 my $prefix = $record->{sid};
12950 my $arrayref = [
12951 $record->{nick},
12952 $record->{hops} + 1,
12953 $record->{ts},
12954 '+' . $umode_fixed,
12955 $record->{auth}{ident},
12956 $record->{auth}{hostname},
12957 332 ];
12958 332 ▶ push @$arrayref, $record->{auth}{realhost} if $rhost;
Branch: 1 branch
BranchTrueFalseTotal
if $rhost 6 326 332
12959 push @$arrayref, ( $record->{ipaddress} || 0 ),
12960 332 ▶ $record->{uid}, $record->{account}, $record->{ircname};
Condition100%2/2
$record->{'ipaddress'} || 0
l!l
28304
MC/DC100%1/1
$record->{'ipaddress'} || 0
$record->{'ipaddress'}
Truth table100%2/2
A
A= $record->{'ipaddress'}
Aresult
11
00
12961 332 my @uid_burst = (
12962 {
12963 prefix => $prefix,
12964 command => 'UID',
12965 params => $arrayref,
12966 },
12967 );
12968 332 ▶ if ( $record->{away} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"away"}) 9 323 332
12969 push @uid_burst, {
12970 prefix => $record->{uid},
12971 command => 'AWAY',
12972 9 params => [ $record->{away} ],
12973 };
12974 }
12975 332 foreach my $svstag ( keys %{ $record->{svstags} } ) {
12976 push @uid_burst, {
12977 prefix => $prefix,
12978 command => 'SVSTAG',
12979 params => [
12980 $record->{uid},
12981 $record->{ts},
12982 $svstag,
12983 $record->{svstags}{$svstag}{umodes},
12984 $record->{svstags}{$svstag}{tagline},
12985 1 ],
12986 };
12987 }
12988 332 $self->send_output( $_, $conn_id ) for @uid_burst;
12989 }
12990  
12991 # Send SJOIN+MODE burst
12992 255 for my $chan (keys %{ $self->{state}{chans} }) {
12993 58 ▶ next if $chan =~ /^\&/;
Branch: 1 branch
BranchTrueFalseTotal
if $chan =~ /^\&/ 0 58 58
12994 58 my $chanrec = $self->{state}{chans}{$chan};
12995 1020 my @uids = map { $_->[1] }
12996 4514 sort { $a->[0] cmp $b->[0] }
12997 58 map { my $w = $_; $w =~ tr/@%+/ABC/; [$w, $_] }
12998 $self->state_chan_list_multi_prefixed($chan,'UIDS');
12999  
13000 my $chanref = [
13001 $chanrec->{ts},
13002 $chanrec->{name},
13003 '+' . $chanrec->{mode},
13004 ($chanrec->{ckey} || ()),
13005 58 ▶ ($chanrec->{climit} || ()),
Condition50%3/6
$chanrec->{'ckey'} || ()
l!l&&r!l&&!r
0580
$chanrec->{'climit'} || ()
l!l&&r!l&&!r
1570
MC/DC0%0/2
$chanrec->{'ckey'} || ()
$chanrec->{'ckey'} ()
MC/DC0%0/2
$chanrec->{'climit'} || ()
$chanrec->{'climit'} ()
Truth table33%1/3
A || B
A= $chanrec->{'ckey'}B= ()
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $chanrec->{'climit'}B= ()
ABresult
1X1
011
000
13006 ];
13007  
13008 58 my $length = length( join ' ', @$chanref ) + 11;
13009 58 my $buf = '';
13010 58 UID: foreach my $uid ( @uids ) {
13011 1020 ▶ if (length(join ' ', $buf, '1', $uid)+$length+1 > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buf, 1, $uid) + $length + 1 > 510) 11 1009 1020
13012 11 $self->send_output(
13013 {
13014 prefix => $sid,
13015 command => 'SJOIN',
13016 params => [ @$chanref, $buf ],
13017 },
13018 $conn_id,
13019 );
13020 11 $buf = $uid;
13021 11 next UID;
13022 }
13023 1009 $buf = join ' ', $buf, $uid;
13024 1009 $buf =~ s!^\s+!!;
13025 }
13026 58 ▶ if ($buf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf) 58 0 58
13027 58 $self->send_output(
13028 {
13029 prefix => $sid,
13030 command => 'SJOIN',
13031 params => [ @$chanref, $buf ],
13032 },
13033 $conn_id,
13034 );
13035 }
13036  
13037 58 my @output_modes;
13038 58 OUTER: for my $type (@lists) {
13039 174 my $length = length($sid) + 5 + length($chan) + 4 + length($chanrec->{ts}) + 2;
13040 174 my @buffer = ( '', '' );
13041 174 INNER: for my $thing (keys %{ $chanrec->{$type} }) {
13042 168 $thing = $chanrec->{$type}{$thing}[0];
13043 168 ▶ if (length(join ' ', '1', $buffer[1], $thing)+$length+1 > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", 1, $buffer[1], $thing) + $length + 1 > 510) 12 156 168
13044 12 $buffer[0] = '+' . $buffer[0];
13045 push @output_modes, {
13046 prefix => $sid,
13047 command => 'BMASK',
13048 colonify => 1,
13049 params => [
13050 $chanrec->{ts},
13051 $chanrec->{name},
13052 12 $map{$type},
13053 $buffer[1],
13054 ],
13055 };
13056 12 $buffer[0] = '+' . $map{$type};
13057 12 $buffer[1] = $thing;
13058 12 next INNER;
13059 }
13060  
13061 156 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 147 9 156
13062 147 $buffer[0] .= $map{$type};
13063 147 $buffer[1] = join ' ', $buffer[1], $thing;
13064 }
13065 else {
13066 9 $buffer[0] = '+' . $map{$type};
13067 9 $buffer[1] = $thing;
13068 }
13069 }
13070  
13071 push @output_modes, {
13072 prefix => $sid,
13073 command => 'BMASK',
13074 colonify => 1,
13075 params => [
13076 $chanrec->{ts},
13077 $chanrec->{name},
13078 174 ▶ $map{$type},
Branch: 1 branch
BranchTrueFalseTotal
if $buffer[1] 9 165 174
13079 $buffer[1],
13080 ],
13081 } if $buffer[1];
13082 }
13083 58 $self->send_output($_, $conn_id) for @output_modes;
13084  
13085 58 ▶ if ( $tburst && $chanrec->{topic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tburst and $chanrec->{"topic"}) 8 50 58
Condition66%2/3
$tburst and $chanrec->{"topic"}
!ll&&!rl&&r
0508
MC/DC50%1/2
$tburst and $chanrec->{"topic"}
$tburst $chanrec->{"topic"}
Truth table66%2/3
A and B
A= $tburstB= $chanrec->{"topic"}
ABresult
0X0
100
111
13086 $self->send_output(
13087 {
13088 prefix => $sid,
13089 command => 'TBURST',
13090 params => [
13091 $chanrec->{ts},
13092 $chanrec->{name},
13093 8 @{ $chanrec->{topic} }[2,1,0],
13094 ],
13095 colonify => 1,
13096 },
13097 $conn_id,
13098 );
13099 }
13100 }
13101  
13102 # EOB for each connected peer if EOB supported
13103 # and our own EOB first
13104 255 ▶ if ( $burst ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($burst) 255 0 255
13105 255 $self->send_output(
13106 {
13107 prefix => $sid,
13108 command => 'EOB',
13109 },
13110 $conn_id,
13111 );
13112 255 delete $eobs{$sid};
13113 $self->send_output(
13114 {
13115 prefix => $_,
13116 command => 'EOB',
13117 },
13118 $conn_id,
13119 255 ) for keys %eobs;
13120 }
13121  
13122 255 return 1;
13123 }
13124  
13125 450 ▶sub _state_server_burst {
Subroutine _state_server_burst: called CC=10 SCAR=24.1
13126 450 my $self = shift;
13127 450 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
4500
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13128 450 ▶ my $targ = shift || return;
Condition50%1/2
shift() || (return)
l!l
4500
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13129 450 ▶ if (!$self->state_peer_exists( $peer )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_peer_exists($peer) and $self->state_peer_exists($targ)) 450 0 450
Condition33%1/3
$self->state_peer_exists($peer) and $self->state_peer_exists($targ)
!ll&&!rl&&r
45000
MC/DC0%0/2
$self->state_peer_exists($peer) and $self->state_peer_exists($targ)
$self->state_peer_exists($peer) $self->state_peer_exists($targ)
Truth table33%1/3
A and B
A= $self->state_peer_exists($peer)B= $self->state_peer_exists($targ)
ABresult
0X0
100
111
13130 || !$self->state_peer_exists($targ)) {
13131 }
13132  
13133 450 my $ref = [ ];
13134  
13135 450 for my $server (keys %{ $self->{state}{sids}{$peer}{sids} }) {
13136 450 ▶ next if $server eq $targ;
Branch: 1 branch
BranchTrueFalseTotal
if $server eq $targ 255 195 450
13137 195 my $rec = $self->{state}{sids}{$server};
13138 195 my $desc = '';
13139 195 ▶ $desc = '(H) ' if $rec->{hidden};
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"hidden"} 1 194 195
13140 195 $desc .= $rec->{desc};
13141 push @$ref, {
13142 prefix => $peer,
13143 command => 'SID',
13144 195 params => [$rec->{name}, $rec->{hops} + 1, $server, $desc],
13145 };
13146 195 push @$ref, $_ for $self->_state_server_burst($rec->{sid}, $targ);
13147 }
13148  
13149 450 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 450 0 450
13150 0 return $ref;
13151 }
13152  
13153 6 ▶sub _state_do_change_hostmask {
Subroutine _state_do_change_hostmask: called CC=14 SCAR=27.3
13154 6 my $self = shift;
13155 6 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13156 6 ▶ my $nhost = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13157 6 my $ref = [ ];
13158 6 my $sid = $self->server_sid();
13159 6 my $server = $self->server_name();
13160  
13161 SWITCH: {
13162 6 ▶ if ($nhost !~ $host_re ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nhost =~ /$host_re/) 0 6 6
13163 0 last SWITCH;
13164 }
13165 6 my $rec = $self->{state}{uids}{$uid};
13166 6 ▶ if ($nhost eq $rec->{auth}{hostname}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nhost eq $rec->{"auth"}{"hostname"}) 0 6 6
13167 0 last SWITCH;
13168 }
13169 6 my $local = ( $uid =~ m!^$sid! );
13170 6 ▶ my $conn_id = ($local ? $rec->{route_id} : '');
Branch: 1 branch
BranchTrueFalseTotal
$local ? : 6 0 6
13171 6 my $full = $rec->{full}->();
13172 6 foreach my $chan ( keys %{ $rec->{chans} } ) {
13173 3 $self->_send_output_channel_local(
13174 $chan,
13175 {
13176 prefix => $full,
13177 command => 'QUIT',
13178 params => [ 'Changing hostname' ],
13179 },
13180 $conn_id, '', '', 'chghost'
13181 );
13182 $self->_send_output_channel_local(
13183 $chan,
13184 {
13185 prefix => $full,
13186 command => 'CHGHOST',
13187 colonify => 0,
13188 3 params => [ $rec->{auth}{ident}, $nhost ],
13189 },
13190 $conn_id,
13191 '',
13192 'chghost'
13193 );
13194 }
13195 6 $rec->{auth}{hostname} = $nhost;
13196 6 ▶ if ($local) {
Branch: 1 branch
BranchTrueFalseTotal
if ($local) 6 0 6
13197 $self->send_output(
13198 {
13199 prefix => $server,
13200 command => '396',
13201 params => [
13202 $rec->{nick},
13203 $nhost,
13204 'is now your visible host',
13205 ],
13206 },
13207 $rec->{route_id},
13208 6 );
13209 }
13210 6 $full = $rec->{full}->();
13211 6 CHAN: foreach my $uchan ( keys %{ $rec->{chans} } ) {
13212 3 my $chan = $self->{state}{chans}{$uchan}{name};
13213 3 my $modeline;
13214 MODES: {
13215 3 my $modes = $rec->{chans}{$uchan};
13216 3 ▶ last MODES if !$modes;
Branch: 1 branch
BranchTrueFalseTotal
unless $modes 0 3 3
13217 $modes = join '',
13218 9 map { $_->[1] }
13219 9 sort { $a->[0] cmp $b->[0] }
13220 3 map { my $w = $_; $w =~ tr/ohv/ABC/; [$w, $_] }
13221 split //, $modes;
13222 3 my @args;
13223 3 push @args, $_ for
13224 9 map { $rec->{nick} } split //, $modes;
13225 3 $modeline = join ' ', "+$modes", @args;
13226 }
13227 $self->_send_output_channel_local(
13228 3 $chan,
13229 {
13230 prefix => $full,
13231 command => 'JOIN',
13232 colonify => 0,
13233 params => [ $chan ],
13234 },
13235 $conn_id, '', '', [ qw[chghost extended-join] ]
13236 );
13237 $self->_send_output_channel_local(
13238 $chan,
13239 {
13240 prefix => $full,
13241 command => 'JOIN',
13242 colonify => 0,
13243 3 params => [ $chan, $rec->{account}, $rec->{ircname} ],
13244 },
13245 $conn_id, '', 'extended-join', 'chghost'
13246 );
13247 3 ▶ if ($modeline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modeline) 3 0 3
13248 3 $self->_send_output_channel_local(
13249 $chan,
13250 {
13251 prefix => $server,
13252 command => 'MODE',
13253 colonify => 0,
13254 params => [ $chan, split m! !, $modeline ],
13255 },
13256 $conn_id, '', '', 'chghost'
13257 );
13258 }
13259 3 ▶ if ($rec->{away}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"away"}) 0 3 3
13260 $self->_send_output_channel_local(
13261 $chan,
13262 {
13263 prefix => $full,
13264 command => 'AWAY',
13265 0 params => [ $rec->{away} ],
13266 },
13267 $conn_id, '', 'away-notify', 'chghost'
13268 );
13269 }
13270 }
13271 }
13272  
13273 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
13274 6 return $ref;
13275 }
13276  
13277 18 ▶sub _state_do_map {
Subroutine _state_do_map: called CC=13 SCAR=26.2
13278 18 my $self = shift;
13279 18 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
180
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13280 18 ▶ my $psid = shift || return;
Condition50%1/2
shift() || (return)
l!l
180
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13281 18 my $isoper = shift;
13282 18 my $plen = shift;
13283 18 my $ctn = shift;
13284 18 my $ref = [ ];
13285 18 ▶ return if !$self->state_sid_exists($psid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($psid) 0 18 18
13286 18 my $rec = $self->{state}{sids}{$psid};
13287  
13288 SWITCH: {
13289 18 my $global = scalar keys %{ $self->{state}{uids} };
13290 18 my $local = scalar keys %{ $rec->{uids} };
13291 18 my $suffix = sprintf(" | Users: %5d (%1.2f%%)", $local, ( 100 * $local / $global ) );
13292  
13293 18 my $prompt = ' ' x $plen;
13294 18 ▶ substr $prompt, -2, 2, '|-' if $plen;
Branch: 1 branch
BranchTrueFalseTotal
if $plen 15 3 18
13295 18 ▶ substr $prompt, -2, 2, '`-' if !$ctn && $plen;
Branch: 1 branch
BranchTrueFalseTotal
if not $ctn and $plen 12 6 18
Condition100%3/3
not $ctn and $plen
!ll&&!rl&&r
3312
MC/DC100%2/2
not $ctn and $plen
not $ctn $plen
Truth table100%3/3
not(A) and B
A= not $ctnB= $plen
ABresult
0X0
100
111
13296 18 ▶ my $buffer = $rec->{name} . ( $isoper ? "[$psid]" : '' ) . ' ';
Branch: 1 branch
BranchTrueFalseTotal
$isoper ? : 4 14 18
13297 18 $buffer .= '-' x ( 64 - length($buffer) - length($prompt) );
13298 18 $buffer .= $suffix;
13299  
13300 18 ▶ if ( $plen && $plen > 60 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plen and $plen > 60) 0 18 18
Condition66%2/3
$plen and $plen > 60
!ll&&!rl&&r
3150
MC/DC0%0/2
$plen and $plen > 60
$plen $plen > 60
Truth table66%2/3
A and B
A= $plenB= $plen > 60
ABresult
0X0
100
111
13301 push @$ref, {
13302 prefix => $self->server_name(),
13303 command => '016',
13304 params => [
13305 $nick,
13306 join '', $prompt, $rec->{name}
13307 0 ],
13308 };
13309 0 last SWITCH;
13310 }
13311  
13312 18 push @$ref, {
13313 prefix => $self->server_name(),
13314 command => '015',
13315 params => [
13316 $nick,
13317 join '', $prompt, $buffer
13318 ],
13319 };
13320 18 my $sids = $self->{state}{sids}{$psid}{sids};
13321 18 my $cnt = keys %$sids;
13322 18 foreach my $server (sort { keys %{ $sids->{$a}{sids} } <=> keys %{ $sids->{$b}{sids} } } keys %$sids) {
13323 15 push @$ref, $_ for $self->_state_do_map( $nick, $server, $isoper, $plen + 2, --$cnt );
13324 }
13325 }
13326  
13327 18 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 18 0 18
13328 0 return $ref;
13329 }
13330  
13331 20 ▶sub _state_sid_links {
Subroutine _state_sid_links: called CC=10 SCAR=23.6
13332 20 my $self = shift;
13333 20 ▶ my $psid = shift || return;
Condition50%1/2
shift() || (return)
l!l
200
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13334 20 ▶ my $orig = shift || return;
Condition50%1/2
shift() || (return)
l!l
200
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13335 20 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
200
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13336 20 ▶ my $mask = shift || '*';
Condition100%2/2
shift() || '*'
l!l
515
MC/DC100%1/1
shift() || '*'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
13337 20 ▶ return if !$self->state_sid_exists($psid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($psid) 0 20 20
13338  
13339 20 my $ref = [ ];
13340 20 my $peer = $self->_state_sid_name($psid);
13341  
13342 20 my $sids = $self->{state}{sids}{$psid}{sids};
13343 20 for my $server (sort { keys %{ $sids->{$b}{sids} } <=> keys %{ $sids->{$a}{sids} } } keys %$sids) {
13344 15 my $rec = $self->{state}{sids}{$server};
13345 15 for ($self->_state_sid_links($server, $orig, $nick)) {
13346 5 push @$ref, $_;
13347 }
13348 push @$ref, {
13349 prefix => $orig,
13350 command => '364',
13351 params => [
13352 $nick,
13353 $rec->{name},
13354 $peer,
13355 join( ' ', $rec->{hops}, $rec->{desc}),
13356 ],
13357 15 ▶ } if matches_mask($mask, $rec->{name});
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($mask, $rec->{"name"}) 13 2 15
13358 }
13359  
13360 20 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 20 0 20
13361 0 return $ref;
13362 }
13363  
13364 0 ▶sub _state_peer_for_peer {
Subroutine _state_peer_for_peer: not called CC=3 SCAR=24.8
13365 0 my $self = shift;
13366 0 ▶ my $peer = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
13367 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
13368 0 $peer = uc $peer;
13369 0 return $self->{state}{peers}{$peer}{peer};
13370 }
13371  
13372 342 ▶sub _state_server_squit {
Subroutine _state_server_squit: called CC=8 SCAR=20.9
13373 342 my $self = shift;
13374 342 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
3420
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13375 342 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 1 341 342
13376 341 my $ref = [ ];
13377 341 push @$ref, $_ for keys %{ $self->{state}{sids}{$sid}{uids} };
13378  
13379 341 for my $psid (keys %{ $self->{state}{sids}{$sid}{sids} }) {
13380 116 push @$ref, $_ for $self->_state_server_squit($psid);
13381 }
13382  
13383 341 my $rec = delete $self->{state}{sids}{$sid};
13384 341 my $upeer = uc $rec->{name};
13385 341 my $me = uc $self->server_name();
13386 341 my $mysid = $self->server_sid();
13387  
13388 $self->_send_to_realops(
13389 sprintf(
13390 'Server %s split from %s',
13391 $rec->{name},
13392 $self->{state}{sids}{ $rec->{psid} }{name},
13393 ), qw[Notice e],
13394 341 ▶ ) if $mysid ne $rec->{psid};
Branch: 1 branch
BranchTrueFalseTotal
if $mysid ne $rec->{"psid"} 116 225 341
13395  
13396 341 delete $self->{state}{peers}{$upeer};
13397 341 delete $self->{state}{peers}{$me}{peers}{$upeer};
13398 341 delete $self->{state}{peers}{$me}{sids}{$sid};
13399 341 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 341 0 341
13400 0 return $ref;
13401 }
13402  
13403 255 ▶sub _state_register_peer {
Subroutine _state_register_peer: called CC=8 SCAR=20.8
13404 255 my $self = shift;
13405 255 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2550
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13406 255 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 255 255
13407 255 my $server = $self->server_name();
13408 255 my $mysid = $self->server_sid();
13409 255 my $record = $self->{state}{conns}{$conn_id};
13410 255 my $psid = $record->{ts_data}[1];
13411 255 ▶ return if !$psid;
Branch: 1 branch
BranchTrueFalseTotal
unless $psid 0 255 255
13412  
13413 255 ▶ if (!$record->{cntr}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"cntr"}) 252 3 255
13414 252 $self->_state_send_credentials($conn_id, $record->{name});
13415 }
13416  
13417 255 $record->{burst} = $record->{registered} = 1;
13418 255 $record->{conn_time} = time;
13419 255 $record->{type} = 'p';
13420 255 $record->{route_id} = $conn_id;
13421 255 $record->{peer} = $server;
13422 255 $record->{psid} = $mysid;
13423 255 $record->{users} = { };
13424 255 $record->{peers} = { };
13425 255 $record->{sid} = $psid;
13426 255 my $ucname = uc $record->{name};
13427 255 ▶ $record->{serv} = 1 if $self->{state}{services}{$ucname};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"services"}{$ucname} 3 252 255
13428 255 $self->{state}{peers}{uc $server}{peers}{ $ucname } = $record;
13429 255 $self->{state}{peers}{ $ucname } = $record;
13430 255 $self->{state}{sids}{ $mysid }{sids}{ $psid } = $record;
13431 255 $self->{state}{sids}{ $psid } = $record;
13432 255 $self->antiflood($conn_id, 0);
13433  
13434 255 ▶ if (my $sslinfo = $self->connection_secured($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sslinfo = $self->connection_secured($conn_id)) { } 6 249 255
13435 $self->_send_to_realops(
13436 sprintf(
13437 'Link with %s[unknown@%s] established: [TLS: %s] (Capabilities: %s)',
13438 6 $record->{name}, $record->{socket}[0], $sslinfo, join(' ', @{ $record->{capab} }),
13439 ),
13440 'Notice',
13441 's',
13442 );
13443 }
13444 else {
13445 $self->_send_to_realops(
13446 sprintf(
13447 'Link with %s[unknown@%s] established: (Capabilities: %s)',
13448 249 $record->{name}, $record->{socket}[0], join(' ', @{ $record->{capab} }),
13449 ),
13450 'Notice',
13451 's',
13452 );
13453 }
13454  
13455 $self->send_output(
13456 {
13457 prefix => $mysid,
13458 command => 'SID',
13459 params => [
13460 $record->{name},
13461 $record->{hops} + 1,
13462 $psid,
13463 ( $record->{hidden} ? '(H) ' : '' ) .
13464 $record->{desc},
13465 ],
13466 },
13467 255 ▶ grep { $_ ne $conn_id } $self->_state_connected_peers(),
Branch: 1 branch
BranchTrueFalseTotal
$record->{'hidden'} ? : 0 255 255
13468 );
13469  
13470 $self->send_event(
13471 'daemon_sid',
13472 $record->{name},
13473 $mysid,
13474 $record->{hops},
13475 $psid,
13476 $record->{desc},
13477 255 );
13478 $self->send_event(
13479 'daemon_server',
13480 $record->{name},
13481 $server,
13482 $record->{hops},
13483 $record->{desc},
13484 255 );
13485  
13486 255 return 1;
13487 }
13488  
13489 224 ▶sub _state_register_client {
Subroutine _state_register_client: called CC=20 SCAR=30.5
13490 224 my $self = shift;
13491 224 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2240
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13492 224 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 224 224
13493  
13494 224 my $record = $self->{state}{conns}{$conn_id};
13495 224 $record->{ts} = $record->{idle_time} = $record->{conn_time} = time;
13496 224 $record->{_ignore_i_umode} = 1;
13497 224 $record->{server} = $self->server_name();
13498 224 $record->{hops} = 0;
13499 224 $record->{route_id} = $conn_id;
13500 224 $record->{umode} = '';
13501  
13502  
13503 224 $record->{uid} = $self->_state_gen_uid();
13504 224 $record->{sid} = substr $record->{uid}, 0, 3;
13505  
13506 224 ▶ if (!$record->{auth}{ident}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"auth"}{"ident"}) 223 1 224
13507 223 $record->{auth}{ident} = '~' . $record->{user};
13508 }
13509  
13510 224 ▶ if ($record->{auth}{hostname} eq 'localhost' ||
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"auth"}{"hostname"} eq "localhost" or not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^(127\.|::1)/) 223 1 224
Condition66%4/6
$record->{"auth"}{"hostname"} eq "localhost" or not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^(127\.|::1)/
l!l&&r!l&&!r
02231
not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^(127\.|::1)/
!ll&&!rl&&r
10223
MC/DC33%1/3
$record->{"auth"}{"hostname"} eq "localhost" or not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^(127\.|::1)/
$record->{"auth"}{"hostname"} eq "localhost" not $record->{"auth"}{"hostname"} $record->{"socket"}[0] =~ /^(127\.|::1)/
Truth table50%2/4
A or not(B) and C
A= $record->{"auth"}{"hostname"} eq "localhost"B= not $record->{"auth"}{"hostname"}C= $record->{"socket"}[0] =~ /^(127\.|::1)/
ABCresult
1XX1
0111
00X0
0100
13511 !$record->{auth}{hostname} && $record->{socket}[0] =~ /^(127\.|::1)/) {
13512 223 $record->{auth}{hostname} = $self->server_name();
13513 }
13514  
13515 224 ▶ if (!$record->{auth}{hostname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"auth"}{"hostname"}) 0 224 224
13516 0 $record->{auth}{hostname} = $record->{socket}[0];
13517 }
13518  
13519 224 $record->{auth}{realhost} = $record->{auth}{hostname};
13520  
13521 224 $record->{account} = '*';
13522  
13523 224 $record->{ipaddress} = $record->{socket}[0]; # Needed later for UID command
13524 224 ▶ $record->{ipaddress} = '0' if $record->{ipaddress} =~ m!^:!;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"ipaddress"} =~ /^:/ 1 223 224
13525  
13526 224 my $unick = uc_irc $record->{nick};
13527 224 my $ucserver = uc $record->{server};
13528 224 $self->{state}{users}{$unick} = $record;
13529 224 ▶ $self->{state}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 224 0 224
13530 224 $self->{state}{peers}{$ucserver}{users}{$unick} = $record;
13531 224 ▶ $self->{state}{peers}{$ucserver}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 224 0 224
13532  
13533 887 ▶ $record->{full} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
13534 return sprintf('%s!%s@%s',
13535 $record->{nick},
13536 $record->{auth}{ident},
13537 887 $record->{auth}{hostname});
13538 224 };
13539  
13540 224 my $umode = '+i';
13541 224 ▶ if ( $record->{secured} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"secured"}) 5 219 224
13542 5 $umode .= 'S';
13543 5 $record->{umode} = 'S';
13544 5 ▶ if (my $certfp = $self->connection_certfp($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $certfp = $self->connection_certfp($conn_id)) 5 0 5
13545 5 $record->{certfp} = $certfp;
13546 }
13547 }
13548  
13549 my $arrayref = [
13550 $record->{nick},
13551 $record->{hops} + 1,
13552 $record->{ts}, $umode,
13553 $record->{auth}{ident},
13554 $record->{auth}{hostname},
13555 $record->{ipaddress},
13556 $record->{uid},
13557 $record->{account},
13558 $record->{ircname},
13559 224 ];
13560  
13561 my $rhostref = [
13562 $record->{nick},
13563 $record->{hops} + 1,
13564 $record->{ts}, $umode,
13565 $record->{auth}{ident},
13566 $record->{auth}{hostname},
13567 $record->{auth}{realhost},
13568 $record->{ipaddress},
13569 $record->{uid},
13570 $record->{account},
13571 $record->{ircname},
13572 224 ];
13573  
13574 224 delete $self->{state}{pending}{uc_irc($record->{nick})};
13575  
13576 224 foreach my $peer_id ( $self->_state_connected_peers() ) {
13577 326 ▶ if ( $self->_state_peer_capab( $peer_id, 'RHOST' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_peer_capab($peer_id, 'RHOST')) { } 0 326 326
13578 $self->send_output(
13579 {
13580 prefix => $record->{sid},
13581 0 command => 'UID',
13582 params => $rhostref,
13583 },
13584 $peer_id,
13585 );
13586 }
13587 else {
13588 $self->send_output(
13589 {
13590 prefix => $record->{sid},
13591 326 command => 'UID',
13592 params => $arrayref,
13593 },
13594 $peer_id,
13595 );
13596 }
13597 326 ▶ if ($record->{certfp}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"certfp"}) 8 318 326
13598 $self->send_output(
13599 {
13600 prefix => $record->{uid},
13601 command => 'CERTFP',
13602 8 params => [ $record->{certfp} ],
13603 colonify => 0,
13604 },
13605 $peer_id,
13606 );
13607 }
13608 }
13609  
13610 $self->_send_to_realops(
13611 sprintf(
13612 'Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>',
13613 224 @{ $rhostref }[0,4,6], $record->{socket}[0],
13614 'users', $record->{ircname}, $record->{uid},
13615 224 ),
13616 'Notice',
13617 'c',
13618 );
13619  
13620 224 $self->send_event('daemon_uid', @$arrayref);
13621 224 ▶ $self->send_event('daemon_nick', @{ $arrayref }[0..5], $record->{server}, ( $arrayref->[9] || '' ) );
Condition50%1/2
$arrayref->[9] || ''
l!l
2240
MC/DC0%0/1
$arrayref->[9] || ''
$arrayref->[9]
Truth table50%1/2
A
A= $arrayref->[9]
Aresult
11
00
13622 224 $self->_state_update_stats();
13623  
13624 224 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 223 224
13625 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
13626 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
13627 1 my $wrec = $self->{state}{uids}{$wuid};
13628 $self->send_output(
13629 {
13630 prefix => $record->{server},
13631 command => '600',
13632 params => [
13633 $wrec->{nick},
13634 $record->{nick},
13635 $record->{auth}{ident},
13636 $record->{auth}{hostname},
13637 $record->{ts},
13638 'logged online',
13639 ],
13640 },
13641 $wrec->{route_id},
13642 1 );
13643 }
13644 }
13645 224 return $record->{uid};
13646 }
13647  
13648 0 ▶sub state_nicks {
Subroutine state_nicks: not called CC=1 SCAR=6.9
Pod documented
13649 0 my $self = shift;
13650 0 return map { $self->{state}{users}{$_}{nick} }
13651 0 keys %{ $self->{state}{users} };
13652 }
13653  
13654 4127 ▶sub state_nick_exists {
Subroutine state_nick_exists: called CC=4 SCAR=13.9
Pod documented
13655 4127 my $self = shift;
13656 4127 ▶ my $nick = shift || return 1;
Condition50%1/2
shift() || (return 1)
l!l
41270
MC/DC0%0/1
shift() || (return 1)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13657 4127 $nick = uc_irc($nick);
13658  
13659 4127 ▶ if (!defined $self->{state}{users}{$nick}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}) 920 3207 4127
Condition100%3/3
defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}
l!l&&r!l&&!r
32061920
MC/DC100%2/2
defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}
defined $self->{"state"}{"users"}{$nick} defined $self->{"state"}{"pending"}{$nick}
Truth table100%3/3
A or B
A= defined $self->{"state"}{"users"}{$nick}B= defined $self->{"state"}{"pending"}{$nick}
ABresult
1X1
011
000
13660 && !defined $self->{state}{pending}{$nick}) {
13661 920 return 0;
13662 }
13663 3207 return 1;
13664 }
13665  
13666 6630 ▶sub state_uid_exists {
Subroutine state_uid_exists: called CC=3 SCAR=11.0
Pod undocumented
13667 6630 my $self = shift;
13668 6630 ▶ my $uid = shift || return 1;
Condition50%1/2
shift() || (return 1)
l!l
66300
MC/DC0%0/1
shift() || (return 1)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13669 6630 ▶ return 1 if defined $self->{state}{uids}{$uid};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"uids"}{$uid} 6619 11 6630
13670 11 return 0;
13671 }
13672  
13673 0 ▶sub state_chans {
Subroutine state_chans: not called CC=1 SCAR=6.9
Pod documented
13674 0 my $self = shift;
13675 0 return map { $self->{state}{chans}{$_}{name} }
13676 0 keys %{ $self->{state}{chans} };
13677 }
13678  
13679 1853 ▶sub state_chan_exists {
Subroutine state_chan_exists: called CC=3 SCAR=11.0
Pod documented
13680 1853 my $self = shift;
13681 1853 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
18530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13682 1853 ▶ return 0 if !defined $self->{state}{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"chans"}{uc_irc($chan)} 105 1748 1853
13683 1748 return 1;
13684 }
13685  
13686 0 ▶sub state_peers {
Subroutine state_peers: not called CC=1 SCAR=6.9
Pod documented
13687 0 my $self = shift;
13688 0 return map { $self->{state}{peers}{$_}{name} }
13689 0 keys %{ $self->{state}{peers} };
13690 }
13691  
13692 888 ▶sub state_peer_exists {
Subroutine state_peer_exists: called CC=3 SCAR=11.0
Pod documented
13693 888 my $self = shift;
13694 888 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
8880
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13695 888 ▶ return 0 if !defined $self->{state}{peers}{uc $peer};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"peers"}{uc $peer} 839 49 888
13696 49 return 1;
13697 }
13698  
13699 2458 ▶sub state_sid_exists {
Subroutine state_sid_exists: called CC=3 SCAR=11.0
Pod undocumented
13700 2458 my $self = shift;
13701 2458 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
24580
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13702 2458 ▶ return 0 if !defined $self->{state}{sids}{ $sid };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"sids"}{$sid} 395 2063 2458
13703 2063 return 1;
13704 }
13705  
13706 51 ▶sub state_check_joinflood_warning {
Subroutine state_check_joinflood_warning: called CC=11 SCAR=30.9
Pod undocumented
13707 51 my $self = shift;
13708 51 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
510
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13709 51 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
510
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13710 51 my $joincount = $self->{config}{joinfloodcount};
13711 51 my $jointime = $self->{config}{joinfloodtime};
13712 51 ▶ return if !$joincount || !$jointime;
Branch: 1 branch
BranchTrueFalseTotal
unless $joincount and $jointime 0 51 51
Condition33%1/3
$joincount and $jointime
!ll&&!rl&&r
0051
MC/DC0%0/2
$joincount and $jointime
$joincount $jointime
Truth table33%1/3
A and B
A= $joincountB= $jointime
ABresult
0X0
100
111
13713 51 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 51 51
13714 51 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 51 51
13715 51 my $crec = $self->{state}{chans}{uc_irc $chan};
13716 51 $crec->{_num_joined}++;
13717 51 ▶ $crec->{_num_joined} -= ( time - ( $self->{_last_joined} || time ) ) *
Condition50%1/2
$self->{'_last_joined'} || time
l!l
051
MC/DC0%0/1
$self->{'_last_joined'} || time
$self->{'_last_joined'}
Truth table50%1/2
A
A= $self->{'_last_joined'}
Aresult
11
00
13718 ( $joincount / $jointime );
13719 51 ▶ if ( $crec->{_num_joined} <= 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($crec->{'_num_joined'} <= 0) { } 0 51 51
elsif ($crec->{'_num_joined'} >= $joincount) { } 0 51 51
13720 0 $crec->{_num_joined} = 0;
13721 0 delete $crec->{_jfnotice};
13722 }
13723 elsif ( $crec->{_num_joined} >= $joincount ) {
13724 0 ▶ if ( !$crec->{_jfnotice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($crec->{"_jfnotice"}) 0 0 0
13725 0 $crec->{_jfnotice} = 1;
13726 0 my $urec = $self->{state}{users}{uc_irc $nick};
13727 $self->_send_to_realops(
13728 sprintf(
13729 'Possible Join Flooder %s[%s] on %s target: %s',
13730 $urec->{nick}, (split /!/,$urec->{full}->())[1],
13731 $urec->{server}, $crec->{name},
13732 0 ),
13733 qw[Notice b],
13734 );
13735 }
13736 }
13737 51 $crec->{_last_joined} = time();
13738 }
13739  
13740 58 ▶sub state_check_spambot_warning {
Subroutine state_check_spambot_warning: called CC=17 SCAR=42.1
Pod undocumented
13741 58 my $self = shift;
13742 58 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
580
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13743 58 ▶ my $chan = shift || return;
Condition100%2/2
shift() || (return)
l!l
517
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
13744 51 my $spamnum = $self->{config}{MAX_JOIN_LEAVE_COUNT};
13745 51 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 51 51
13746 51 my $urec = $self->{state}{users}{uc_irc $nick};
13747  
13748 51 ▶ if ( $spamnum && $urec->{_jl_cnt} && $urec->{_jl_cnt} >= $spamnum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spamnum and $urec->{'_jl_cnt'} and $urec->{'_jl_cnt'} >= $spamnum) { } 0 51 51
Condition33%2/6
$spamnum and $urec->{"_jl_cnt"} and $urec->{"_jl_cnt"} >= $spamnum
!ll&&!rl&&r
5100
$spamnum and $urec->{"_jl_cnt"}
!ll&&!rl&&r
0510
MC/DC0%0/3
$spamnum and $urec->{"_jl_cnt"} and $urec->{"_jl_cnt"} >= $spamnum
$spamnum $urec->{"_jl_cnt"} $urec->{"_jl_cnt"} >= $spamnum
Truth table25%1/4
A and B and C
A= $spamnumB= $urec->{"_jl_cnt"}C= $urec->{"_jl_cnt"} >= $spamnum
ABCresult
0XX0
10X0
1100
1111
13749 0 ▶ if ( $urec->{_owcd} && $urec->{_owcd} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($urec->{'_owcd'} and $urec->{'_owcd'} > 0) { } 0 0 0
Condition0%0/3
$urec->{"_owcd"} and $urec->{"_owcd"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$urec->{"_owcd"} and $urec->{"_owcd"} > 0
$urec->{"_owcd"} $urec->{"_owcd"} > 0
Truth table0%0/3
A and B
A= $urec->{"_owcd"}B= $urec->{"_owcd"} > 0
ABresult
0X0
100
111
13750 0 $urec->{_owcd}--;
13751 }
13752 else {
13753 0 $urec->{_owcd} = 0;
13754 }
13755 0 ▶ if ( $urec->{_owcd} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($urec->{"_owcd"} == 0) 0 0 0
13756 my $msg = $chan ?
13757 sprintf(
13758 'User %s (%s) trying to join %s is a possible spambot',
13759 $urec->{nick}, (split /!/,$urec->{full}->())[1], $chan,
13760 ) :
13761 sprintf(
13762 'User %s (%s) is a possible spambot',
13763 0 ▶ $urec->{nick}, (split /!/,$urec->{full}->())[1],
Branch: 1 branch
BranchTrueFalseTotal
$chan ? : 0 0 0
13764 );
13765 0 $self->_send_to_realops(
13766 $msg, qw[Notice b],
13767 );
13768 0 $urec->{_owcd} = $self->{config}{OPER_SPAM_COUNTDOWN};
13769 }
13770 }
13771 else {
13772 51 ▶ my $delta = time() - ( $urec->{_last_leave} || 0 );
Condition50%1/2
$urec->{'_last_leave'} || 0
l!l
051
MC/DC0%0/1
$urec->{'_last_leave'} || 0
$urec->{'_last_leave'}
Truth table50%1/2
A
A= $urec->{'_last_leave'}
Aresult
11
00
13773 51 ▶ if ( $delta > $self->{config}{JOIN_LEAVE_COUNT_EXPIRE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delta > $self->{'config'}{'JOIN_LEAVE_COUNT_EXPIRE'}) { } 51 0 51
13774 51 my $dec_cnt = $delta / $self->{config}{JOIN_LEAVE_COUNT_EXPIRE};
13775 51 ▶ if ($dec_cnt > ( $urec->{_jl_cnt} || 0 )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dec_cnt > ($urec->{'_jl_cnt'} || 0)) { } 51 0 51
Condition50%1/2
$urec->{'_jl_cnt'} || 0
l!l
051
MC/DC0%0/1
$urec->{'_jl_cnt'} || 0
$urec->{'_jl_cnt'}
Truth table50%1/2
A
A= $urec->{'_jl_cnt'}
Aresult
11
00
13776 51 $urec->{_jl_cnt} = 0;
13777 }
13778 else {
13779 0 $urec->{_jl_cnt} -= $dec_cnt;
13780 }
13781 }
13782 else {
13783 $urec->{_jl_cnt}++ if ( time() - $urec->{_last_join} )
13784 0 ▶ < $self->{config}{MIN_JOIN_LEAVE_TIME};
Branch: 1 branch
BranchTrueFalseTotal
if time - $urec->{"_last_join"} < $self->{"config"}{"MIN_JOIN_LEAVE_TIME"} 0 0 0
13785 }
13786 51 ▶ if ( $chan ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chan) { } 51 0 51
13787 51 $urec->{_last_join} = time();
13788 }
13789 else {
13790 0 $urec->{_last_leave} = time();
13791 }
13792 }
13793 }
13794  
13795 8 ▶sub state_flood_attack_channel {
Subroutine state_flood_attack_channel: called CC=19 SCAR=34.4
Pod undocumented
13796 8 my $self = shift;
13797 8 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
80
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13798 8 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
80
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13799 8 ▶ my $type = shift || 'PRIVMSG';
Condition50%1/2
shift() || 'PRIVMSG'
l!l
80
MC/DC0%0/1
shift() || 'PRIVMSG'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13800 8 ▶ return 0 if !$self->{config}{floodcount} || !$self->{config}{floodtime};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"config"}{"floodcount"} and $self->{"config"}{"floodtime"} 0 8 8
Condition33%1/3
$self->{"config"}{"floodcount"} and $self->{"config"}{"floodtime"}
!ll&&!rl&&r
008
MC/DC0%0/2
$self->{"config"}{"floodcount"} and $self->{"config"}{"floodtime"}
$self->{"config"}{"floodcount"} $self->{"config"}{"floodtime"}
Truth table33%1/3
A and B
A= $self->{"config"}{"floodcount"}B= $self->{"config"}{"floodtime"}
ABresult
0X0
100
111
13801 8 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 8 8
13802 8 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 8 8
13803 8 my $urec = $self->{state}{users}{uc_irc $nick};
13804 8 ▶ return 0 if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 0 8 8
13805 8 ▶ return 0 if $urec->{can_flood} || $urec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"can_flood"} or $urec->{"umode"} =~ /o/ 0 8 8
Condition33%1/3
$urec->{"can_flood"} or $urec->{"umode"} =~ /o/
l!l&&r!l&&!r
008
MC/DC0%0/2
$urec->{"can_flood"} or $urec->{"umode"} =~ /o/
$urec->{"can_flood"} $urec->{"umode"} =~ /o/
Truth table33%1/3
A or B
A= $urec->{"can_flood"}B= $urec->{"umode"} =~ /o/
ABresult
1X1
011
000
13806 8 my $crec = $self->{state}{chans}{uc_irc $chan};
13807 8 my $first = $crec->{_first_msg};
13808 8 ▶ if ( $first && ( $first + $self->{config}{floodtime} < time() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first and $first + $self->{"config"}{"floodtime"} < time) 0 8 8
Condition66%2/3
$first and $first + $self->{"config"}{"floodtime"} < time
!ll&&!rl&&r
350
MC/DC0%0/2
$first and $first + $self->{"config"}{"floodtime"} < time
$first $first + $self->{"config"}{"floodtime"} < time
Truth table66%2/3
A and B
A= $firstB= $first + $self->{"config"}{"floodtime"} < time
ABresult
0X0
100
111
13809 0 ▶ if ( $crec->{_recv_msgs} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{'_recv_msgs'}) { } 0 0 0
13810 0 $crec->{_recv_msgs} = 0;
13811 }
13812 else {
13813 0 $crec->{_flood_notice} = 0;
13814 }
13815 0 $crec->{_first_msg} = time();
13816 }
13817 8 my $recv = $crec->{_recv_msgs};
13818 8 ▶ if ( $recv && $recv >= $self->{config}{floodcount} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recv and $recv >= $self->{"config"}{"floodcount"}) 1 7 8
Condition100%3/3
$recv and $recv >= $self->{"config"}{"floodcount"}
!ll&&!rl&&r
341
MC/DC100%2/2
$recv and $recv >= $self->{"config"}{"floodcount"}
$recv $recv >= $self->{"config"}{"floodcount"}
Truth table100%3/3
A and B
A= $recvB= $recv >= $self->{"config"}{"floodcount"}
ABresult
0X0
100
111
13819 1 ▶ if ( !$crec->{_flood_notice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($crec->{"_flood_notice"}) 1 0 1
13820 $self->_send_to_realops(
13821 sprintf(
13822 'Possible Flooder %s[%s] on %s target: %s',
13823 $urec->{nick}, (split /!/, $urec->{full}->())[1],
13824 $urec->{server}, $crec->{name},
13825 1 ), qw[Notice b],
13826 );
13827 1 $crec->{_flood_notice} = 1;
13828 }
13829 1 ▶ if ( $type ne 'NOTICE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "NOTICE") 1 0 1
13830 $self->send_output(
13831 {
13832 prefix => $self->server_name(),
13833 command => 'NOTICE',
13834 params => [
13835 $urec->{nick},
13836 "*** Message to $crec->{name} throttled due to flooding",
13837 ],
13838 },
13839 $urec->{route_id},
13840 1 );
13841 }
13842 1 return 1;
13843 }
13844 7 ▶ $crec->{_first_msg} = time() if !$first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first 3 4 7
13845 7 $crec->{_recv_msgs}++;
13846 7 return 0;
13847 }
13848  
13849 14 ▶sub state_flood_attack_client {
Subroutine state_flood_attack_client: called CC=19 SCAR=33.4
Pod undocumented
13850 14 my $self = shift;
13851 14 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
140
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13852 14 ▶ my $targ = shift || return;
Condition50%1/2
shift() || (return)
l!l
140
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13853 14 ▶ my $type = shift || 'PRIVMSG';
Condition50%1/2
shift() || 'PRIVMSG'
l!l
140
MC/DC0%0/1
shift() || 'PRIVMSG'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13854 14 ▶ return 0 if !$self->{config}{floodcount} || !$self->{config}{floodtime};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"config"}{"floodcount"} and $self->{"config"}{"floodtime"} 0 14 14
Condition33%1/3
$self->{"config"}{"floodcount"} and $self->{"config"}{"floodtime"}
!ll&&!rl&&r
0014
MC/DC0%0/2
$self->{"config"}{"floodcount"} and $self->{"config"}{"floodtime"}
$self->{"config"}{"floodcount"} $self->{"config"}{"floodtime"}
Truth table33%1/3
A and B
A= $self->{"config"}{"floodcount"}B= $self->{"config"}{"floodtime"}
ABresult
0X0
100
111
13855 14 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 14 14
13856 14 ▶ return if !$self->state_nick_exists($targ);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($targ) 0 14 14
13857 14 my $urec = $self->{state}{users}{uc_irc $nick};
13858 14 ▶ return 0 if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 0 14 14
13859 14 ▶ return 0 if $urec->{can_flood} || $urec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"can_flood"} or $urec->{"umode"} =~ /o/ 2 12 14
Condition66%2/3
$urec->{"can_flood"} or $urec->{"umode"} =~ /o/
l!l&&r!l&&!r
0212
MC/DC50%1/2
$urec->{"can_flood"} or $urec->{"umode"} =~ /o/
$urec->{"can_flood"} $urec->{"umode"} =~ /o/
Truth table66%2/3
A or B
A= $urec->{"can_flood"}B= $urec->{"umode"} =~ /o/
ABresult
1X1
011
000
13860 12 my $trec = $self->{state}{users}{uc_irc $targ};
13861 12 my $first = $trec->{_first_msg};
13862 12 ▶ if ( $first && ( $first + $self->{config}{floodtime} < time() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first and $first + $self->{"config"}{"floodtime"} < time) 0 12 12
Condition66%2/3
$first and $first + $self->{"config"}{"floodtime"} < time
!ll&&!rl&&r
570
MC/DC0%0/2
$first and $first + $self->{"config"}{"floodtime"} < time
$first $first + $self->{"config"}{"floodtime"} < time
Truth table66%2/3
A and B
A= $firstB= $first + $self->{"config"}{"floodtime"} < time
ABresult
0X0
100
111
13863 0 ▶ if ( $trec->{_recv_msgs} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trec->{'_recv_msgs'}) { } 0 0 0
13864 0 $trec->{_recv_msgs} = 0;
13865 }
13866 else {
13867 0 $trec->{_flood_notice} = 0;
13868 }
13869 0 $trec->{_first_msg} = time();
13870 }
13871 12 my $recv = $trec->{_recv_msgs};
13872 12 ▶ if ( $recv && $recv >= $self->{config}{floodcount} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recv and $recv >= $self->{"config"}{"floodcount"}) 1 11 12
Condition100%3/3
$recv and $recv >= $self->{"config"}{"floodcount"}
!ll&&!rl&&r
561
MC/DC100%2/2
$recv and $recv >= $self->{"config"}{"floodcount"}
$recv $recv >= $self->{"config"}{"floodcount"}
Truth table100%3/3
A and B
A= $recvB= $recv >= $self->{"config"}{"floodcount"}
ABresult
0X0
100
111
13873 1 ▶ if ( !$trec->{_flood_notice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($trec->{"_flood_notice"}) 1 0 1
13874 $self->_send_to_realops(
13875 sprintf(
13876 'Possible Flooder %s[%s] on %s target: %s',
13877 $urec->{nick}, (split /!/, $urec->{full}->())[1],
13878 $urec->{server}, $trec->{nick},
13879 1 ), qw[Notice b],
13880 );
13881 1 $trec->{_flood_notice} = 1;
13882 }
13883 1 ▶ if ( $type ne 'NOTICE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "NOTICE") 1 0 1
13884 $self->send_output(
13885 {
13886 prefix => $self->server_name(),
13887 command => 'NOTICE',
13888 params => [
13889 $urec->{nick},
13890 "*** Message to $trec->{nick} throttled due to flooding",
13891 ],
13892 },
13893 $urec->{route_id},
13894 1 );
13895 }
13896 1 return 1;
13897 }
13898 11 ▶ $trec->{_first_msg} = time() if !$first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first 5 6 11
13899 11 $trec->{_recv_msgs}++;
13900 11 return 0;
13901 }
13902  
13903 23 ▶sub state_can_send_to_channel {
Subroutine state_can_send_to_channel: called CC=23 SCAR=33.7
Pod undocumented
13904 23 my $self = shift;
13905 23 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
230
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13906 23 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
230
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13907 23 ▶ my $msg = shift || return;
Condition50%1/2
shift() || (return)
l!l
230
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13908 23 ▶ my $type = shift || 'PRIVMSG';
Condition50%1/2
shift() || 'PRIVMSG'
l!l
230
MC/DC0%0/1
shift() || 'PRIVMSG'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13909 23 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 23 23
13910 23 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 23 23
13911 23 my $uid = $self->state_user_uid($nick);
13912 23 my $crec = $self->{state}{chans}{uc_irc $chan};
13913 23 my $urec = $self->{state}{uids}{$uid};
13914 23 my $member = defined $crec->{users}{$uid};
13915  
13916 23 ▶ if ( $crec->{mode} =~ /c/ && ( has_color($msg) || has_formatting($msg) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /c/ and has_color($msg) || has_formatting($msg)) 2 21 23
Condition83%5/6
$crec->{"mode"} =~ /c/ and has_color($msg) || has_formatting($msg)
!ll&&!rl&&r
2012
has_color($msg) or has_formatting($msg)
l!l&&r!l&&!r
201
MC/DC66%2/3
$crec->{"mode"} =~ /c/ and has_color($msg) || has_formatting($msg)
$crec->{"mode"} =~ /c/ has_color($msg) has_formatting($msg)
Truth table75%3/4
A and B or C
A= $crec->{"mode"} =~ /c/B= has_color($msg)C= has_formatting($msg)
ABCresult
0XX0
1000
11X1
1011
13917 2 return [ '408', $crec->{name} ];
13918 }
13919 21 ▶ if ( $crec->{mode} =~ /C/ && $msg =~ m!^\001! && $msg !~ m!^\001ACTION! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /C/ and $msg =~ /^\001/ and not $msg =~ /^\001ACTION/) 1 20 21
Condition100%6/6
$crec->{"mode"} =~ /C/ and $msg =~ /^\001/ and not $msg =~ /^\001ACTION/
!ll&&!rl&&r
1821
$crec->{"mode"} =~ /C/ and $msg =~ /^\001/
!ll&&!rl&&r
1353
MC/DC100%3/3
$crec->{"mode"} =~ /C/ and $msg =~ /^\001/ and not $msg =~ /^\001ACTION/
$crec->{"mode"} =~ /C/ $msg =~ /^\001/ not $msg =~ /^\001ACTION/
Truth table100%4/4
A and B and not(C)
A= $crec->{"mode"} =~ /C/B= $msg =~ /^\001/C= not $msg =~ /^\001ACTION/
ABCresult
0XX0
10X0
1100
1111
13920 1 return [ '492', $crec->{name} ];
13921 }
13922 20 ▶ if ( $crec->{mode} =~ /n/ && !$member ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /n/ and not $member) 0 20 20
Condition33%1/3
$crec->{"mode"} =~ /n/ and not $member
!ll&&!rl&&r
0200
MC/DC0%0/2
$crec->{"mode"} =~ /n/ and not $member
$crec->{"mode"} =~ /n/ not $member
Truth table33%1/3
A and not(B)
A= $crec->{"mode"} =~ /n/B= not $member
ABresult
0X0
100
111
13923 0 return [ '404', $crec->{name} ];
13924 }
13925 20 ▶ if ( $crec->{mode} =~ /M/ && $urec->{umode} !~ /r/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /M/ and not $urec->{"umode"} =~ /r/) 2 18 20
Condition66%2/3
$crec->{"mode"} =~ /M/ and not $urec->{"umode"} =~ /r/
!ll&&!rl&&r
1802
MC/DC50%1/2
$crec->{"mode"} =~ /M/ and not $urec->{"umode"} =~ /r/
$crec->{"mode"} =~ /M/ not $urec->{"umode"} =~ /r/
Truth table66%2/3
A and not(B)
A= $crec->{"mode"} =~ /M/B= not $urec->{"umode"} =~ /r/
ABresult
0X0
100
111
13926 2 return [ '477', $crec->{name} ];
13927 }
13928 18 ▶ if ( $member && $crec->{users}{$uid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($member and $crec->{"users"}{$uid}) 8 10 18
Condition66%2/3
$member and $crec->{"users"}{$uid}
!ll&&!rl&&r
0108
MC/DC50%1/2
$member and $crec->{"users"}{$uid}
$member $crec->{"users"}{$uid}
Truth table66%2/3
A and B
A= $memberB= $crec->{"users"}{$uid}
ABresult
0X0
100
111
13929 8 return 2;
13930 }
13931 10 ▶ if ( $crec->{mode} =~ /m/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /m/) 0 10 10
13932 0 return [ '404', $crec->{name} ];
13933 }
13934 10 ▶ if ( $crec->{mode} =~ /T/ && $type eq 'NOTICE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /T/ and $type eq "NOTICE") 2 8 10
Condition66%2/3
$crec->{"mode"} =~ /T/ and $type eq "NOTICE"
!ll&&!rl&&r
802
MC/DC50%1/2
$crec->{"mode"} =~ /T/ and $type eq "NOTICE"
$crec->{"mode"} =~ /T/ $type eq "NOTICE"
Truth table66%2/3
A and B
A= $crec->{"mode"} =~ /T/B= $type eq "NOTICE"
ABresult
0X0
100
111
13935 2 return [ '404', $crec->{name} ];
13936 }
13937 8 ▶ if ( $self->_state_user_banned($nick, $chan) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_user_banned($nick, $chan)) 0 8 8
13938 0 return [ '404', $crec->{name} ];
13939 }
13940 8 return 1;
13941 }
13942  
13943 2 ▶sub _state_peer_name {
Subroutine _state_peer_name: called CC=3 SCAR=11.0
13944 2 my $self = shift;
13945 2 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13946 2 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 1 1 2
13947 1 return $self->{state}{peers}{uc $peer}{name};
13948 }
13949  
13950 7 ▶sub _state_peer_sid {
Subroutine _state_peer_sid: called CC=5 SCAR=16.5
13951 7 my $self = shift;
13952 7 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13953 7 ▶ if ( $peer =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer =~ /^\d/) { } 4 3 7
13954 4 ▶ return if !$self->state_sid_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($peer) 0 4 4
13955 4 return $self->{state}{sids}{$peer}{sid};
13956 }
13957 else {
13958 3 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 3 3
13959 3 return $self->{state}{peers}{uc $peer}{sid};
13960 }
13961 }
13962  
13963 941 ▶sub _state_sid_name {
Subroutine _state_sid_name: called CC=3 SCAR=11.4
13964 941 my $self = shift;
13965 941 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
9410
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13966 941 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 0 941 941
13967 941 return $self->{state}{sids}{$sid}{name};
13968 }
13969  
13970 50 ▶sub _state_sid_serv {
Subroutine _state_sid_serv: called CC=4 SCAR=14.1
13971 50 my $self = shift;
13972 50 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
500
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13973 50 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 0 50 50
13974 50 ▶ return 0 if !$self->{state}{sids}{$sid}{serv};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"sids"}{$sid}{"serv"} 9 41 50
13975 41 return 1;
13976 }
13977  
13978 4 ▶sub _state_peer_desc {
Subroutine _state_peer_desc: called CC=3 SCAR=11.4
13979 4 my $self = shift;
13980 4 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13981 4 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 4 4
13982 4 return $self->{state}{peers}{uc $peer}{desc};
13983 }
13984  
13985 916 ▶sub _state_peer_capab {
Subroutine _state_peer_capab: called CC=4 SCAR=14.2
13986 916 my $self = shift;
13987 916 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
9160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13988 916 ▶ my $capab = shift || return;
Condition50%1/2
shift() || (return)
l!l
9160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13989 916 $capab = uc $capab;
13990 916 ▶ return if !$self->_connection_is_peer($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_is_peer($conn_id) 0 916 916
13991 916 my $conn = $self->{state}{conns}{$conn_id};
13992 916 return scalar grep { $_ eq $capab } @{ $conn->{capab} };
13993 }
13994  
13995 808 ▶sub _state_our_capab {
Subroutine _state_our_capab: called CC=2 SCAR=7.0
13996 808 my $self = shift;
13997 808 ▶ my $capab = shift || return;
Condition50%1/2
shift() || (return)
l!l
8080
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13998 808 $capab = uc $capab;
13999 808 my $capabs = $self->{config}{capab};
14000 808 return scalar grep { $_ eq $capab } @{ $capabs };
14001 }
14002  
14003 3134 ▶sub state_user_full {
Subroutine state_user_full: called CC=7 SCAR=19.7
Pod documented
14004 3134 my $self = shift;
14005 3134 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
31340
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14006 3134 my $oper = shift;
14007 3134 my $opuser = '';
14008 3134 my $record;
14009 3134 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 2543 591 3134
14010 2543 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 0 2543 2543
14011 2543 $record = $self->{state}{uids}{$nick};
14012 }
14013 else {
14014 591 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 591 591
14015 591 $record = $self->{state}{users}{uc_irc($nick)};
14016 }
14017 3134 ▶ if ( $oper && defined $record->{opuser} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oper and defined $record->{"opuser"}) 1 3133 3134
Condition66%2/3
$oper and defined $record->{"opuser"}
!ll&&!rl&&r
313301
MC/DC50%1/2
$oper and defined $record->{"opuser"}
$oper defined $record->{"opuser"}
Truth table66%2/3
A and B
A= $operB= defined $record->{"opuser"}
ABresult
0X0
100
111
14018 1 $opuser = '{' . $record->{opuser} . '}';
14019 }
14020 3134 return $record->{full}->() . $opuser;
14021 }
14022  
14023 184 ▶sub state_user_nick {
Subroutine state_user_nick: called CC=5 SCAR=16.1
Pod documented
14024 184 my $self = shift;
14025 184 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
1840
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14026 184 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 112 72 184
14027 112 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 2 110 112
14028 110 return $self->{state}{uids}{$nick}{nick};
14029 }
14030 else {
14031 72 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 1 71 72
14032 71 return $self->{state}{users}{uc_irc($nick)}{nick};
14033 }
14034 }
14035  
14036 579 ▶sub state_user_uid {
Subroutine state_user_uid: called CC=5 SCAR=16.1
Pod undocumented
14037 579 my $self = shift;
14038 579 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
5790
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14039 579 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 44 535 579
14040 44 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 4 40 44
14041 40 return $self->{state}{uids}{$nick}{uid};
14042 }
14043 else {
14044 535 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 4 531 535
14045 531 return $self->{state}{users}{uc_irc($nick)}{uid};
14046 }
14047 }
14048  
14049 22 ▶sub _state_user_ip {
Subroutine _state_user_ip: called CC=4 SCAR=15.2
14050 22 my $self = shift;
14051 22 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
220
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14052 22 ▶ return if !$self->state_nick_exists($nick)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) and $self->_state_is_local_user($nick) 0 22 22
Condition33%1/3
$self->state_nick_exists($nick) and $self->_state_is_local_user($nick)
!ll&&!rl&&r
0022
MC/DC0%0/2
$self->state_nick_exists($nick) and $self->_state_is_local_user($nick)
$self->state_nick_exists($nick) $self->_state_is_local_user($nick)
Truth table33%1/3
A and B
A= $self->state_nick_exists($nick)B= $self->_state_is_local_user($nick)
ABresult
0X0
100
111
14053 || !$self->_state_is_local_user($nick);
14054 22 my $record = $self->{state}{users}{uc_irc($nick)};
14055 22 return $record->{socket}[0];
14056 }
14057  
14058 0 ▶sub _state_user_away {
Subroutine _state_user_away: not called CC=4 SCAR=30.0
14059 0 my $self = shift;
14060 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14061 0 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 0 0
14062 0 ▶ return 1 if defined $self->{state}{users}{uc_irc($nick)}{away};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"users"}{uc_irc($nick)}{"away"} 0 0 0
14063 0 return 0;
14064 }
14065  
14066 17 ▶sub _state_user_away_msg {
Subroutine _state_user_away_msg: called CC=3 SCAR=11.4
14067 17 my $self = shift;
14068 17 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
170
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14069 17 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 17 17
14070 17 return $self->{state}{users}{uc_irc($nick)}{away};
14071 }
14072  
14073 75 ▶sub state_user_umode {
Subroutine state_user_umode: called CC=3 SCAR=11.4
Pod documented
14074 75 my $self = shift;
14075 75 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
750
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14076 75 ▶ return if! $self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 75 75
14077 75 return $self->{state}{users}{uc_irc($nick)}{umode};
14078 }
14079  
14080 264 ▶sub state_user_is_operator {
Subroutine state_user_is_operator: called CC=4 SCAR=14.1
Pod documented
14081 264 my $self = shift;
14082 264 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
2640
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14083 264 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 264 264
14084 264 ▶ return 0 if $self->{state}{users}{uc_irc($nick)}{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"users"}{uc_irc($nick)}{"umode"} =~ /o/ 203 61 264
14085 61 return 1;
14086 }
14087  
14088 31 ▶sub _state_user_is_deaf {
Subroutine _state_user_is_deaf: called CC=4 SCAR=15.6
14089 31 my $self = shift;
14090 31 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
310
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14091 31 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 31 31
14092 31 ▶ return 0 if $self->{state}{users}{uc_irc($nick)}{umode} !~ /D/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"users"}{uc_irc($nick)}{"umode"} =~ /D/ 31 0 31
14093 0 return 1;
14094 }
14095  
14096 114 ▶sub state_user_chans {
Subroutine state_user_chans: called CC=3 SCAR=11.2
Pod documented
14097 114 my $self = shift;
14098 114 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
1140
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14099 114 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 114 114
14100 114 my $record = $self->{state}{users}{uc_irc($nick)};
14101 2 return map { $self->{state}{chans}{$_}{name} }
14102 114 keys %{ $record->{chans} };
14103 }
14104  
14105 442 ▶sub _state_user_route {
Subroutine _state_user_route: called CC=3 SCAR=11.3
14106 442 my $self = shift;
14107 442 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
4420
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14108 442 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 442 442
14109 442 my $record = $self->{state}{users}{uc_irc($nick)};
14110 442 return $record->{route_id};
14111 }
14112  
14113 615 ▶sub _state_uid_route {
Subroutine _state_uid_route: called CC=3 SCAR=11.3
14114 615 my $self = shift;
14115 615 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
6150
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14116 615 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 615 615
14117 615 my $record = $self->{state}{uids}{ $uid };
14118 615 return $record->{route_id};
14119 }
14120  
14121 1 ▶sub state_user_server {
Subroutine state_user_server: called CC=3 SCAR=11.3
Pod documented
14122 1 my $self = shift;
14123 1 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14124 1 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 1 1
14125 1 my $record = $self->{state}{users}{uc_irc($nick)};
14126 1 return $record->{server};
14127 }
14128  
14129 0 ▶sub state_uid_sid {
Subroutine state_uid_sid: not called CC=3 SCAR=24.8
Pod undocumented
14130 0 my $self = shift;
14131 0 ▶ my $uid = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14132 0 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 0 0
14133 0 return substr( $uid, 0, 3 );
14134 }
14135  
14136 37 ▶sub _state_peer_route {
Subroutine _state_peer_route: called CC=3 SCAR=11.3
14137 37 my $self = shift;
14138 37 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
370
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14139 37 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 37 37
14140 37 my $record = $self->{state}{peers}{uc $peer};
14141 37 return $record->{route_id};
14142 }
14143  
14144 459 ▶sub _state_sid_route {
Subroutine _state_sid_route: called CC=3 SCAR=11.3
14145 459 my $self = shift;
14146 459 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
4590
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14147 459 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 0 459 459
14148 459 my $record = $self->{state}{sids}{$sid};
14149 459 return $record->{route_id};
14150 }
14151  
14152 2114 ▶sub _state_connected_peers {
Subroutine _state_connected_peers: called CC=2 SCAR=6.9
14153 2114 my $self = shift;
14154 2114 my $server = uc $self->server_name();
14155 2114 ▶ return if !(keys %{ $self->{state}{peers} } > 1);
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"peers"};} > 1 196 1918 2114
14156 1918 my $record = $self->{state}{peers}{$server};
14157 3119 return map { $record->{peers}{$_}{route_id} }
14158 1918 keys %{ $record->{peers} };
14159 }
14160  
14161 10 ▶sub state_chan_list {
Subroutine state_chan_list: called CC=6 SCAR=24.9
Pod documented
14162 10 my $self = shift;
14163 10 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
100
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14164 10 ▶ my $status_msg = shift || '';
Condition50%1/2
shift() || ''
l!l
010
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14165 10 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 10 10
14166  
14167 10 $status_msg =~ s/[^@%+]//g;
14168 10 my $record = $self->{state}{chans}{uc_irc($chan)};
14169 31 return map { $self->{state}{uids}{$_}{nick} }
14170 10 ▶ keys %{ $record->{users} } if !$status_msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $status_msg 10 0 10
14171  
14172 0 my %map = qw(o 3 h 2 v 1);
14173 0 my %sym = qw(@ 3 % 2 + 1);
14174 0 my $lowest = (sort map { $sym{$_} } split //, $status_msg)[0];
14175  
14176 0 return map { $self->{state}{uids}{$_}{nick} }
14177 grep {
14178 0 $record->{users}{ $_ } and (reverse sort map { $map{$_} }
14179 0 ▶ split //, $record->{users}{$_})[0] >= $lowest
Condition0%0/3
$record->{'users'}{$_} && (reverse sort map({$map{$_};} split(//, $record->{'users'}{$_}, 0)))[0] >= $lowest
!ll&&!rl&&r
000
MC/DC0%0/2
$record->{'users'}{$_} && (reverse sort map({$map{$_};} split(//, $record->{'users'}{$_}, 0)))[0] >= $lowest
$record->{'users'}{$_} (reverse sort map({$map{$_};} split(//, $record->{'users'}{$_}, 0)))[0] >= $lowest
Truth table0%0/3
A && B
A= $record->{'users'}{$_}B= (reverse sort map({$map{$_};} split(//, $record->{'users'}{$_}, 0)))[0] >= $lowest
ABresult
0X0
100
111
14180 0 } keys %{ $record->{users} };
14181 }
14182  
14183 94 ▶sub state_chan_list_prefixed {
Subroutine state_chan_list_prefixed: called CC=10 SCAR=23.3
Pod documented
14184 94 my $self = shift;
14185 94 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
940
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14186 94 my $flag = shift;
14187 94 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 94 94
14188 94 my $record = $self->{state}{chans}{uc_irc($chan)};
14189  
14190 return map {
14191 168 my $n = $self->{state}{uids}{$_}{nick};
14192 168 ▶ $n = (($flag && $flag eq 'FULL') ? $self->state_user_full($_) : $n );
Branch: 1 branch
BranchTrueFalseTotal
$flag && $flag eq 'FULL' ? : 6 162 168
Condition66%2/3
$flag and $flag eq "FULL"
!ll&&!rl&&r
16206
MC/DC50%1/2
$flag and $flag eq "FULL"
$flag $flag eq "FULL"
Truth table66%2/3
A and B
A= $flagB= $flag eq "FULL"
ABresult
0X0
100
111
14193 168 my $m = $record->{users}{$_};
14194 168 my $p = '';
14195 168 ▶ $p = '@' if $m =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /o/ 94 74 168
14196 168 ▶ $p = '%' if $m =~ /h/ && !$p;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /h/ and not $p 11 157 168
Condition100%3/3
$m =~ /h/ and not $p
!ll&&!rl&&r
1411611
MC/DC100%2/2
$m =~ /h/ and not $p
$m =~ /h/ not $p
Truth table100%3/3
A and not(B)
A= $m =~ /h/B= not $p
ABresult
0X0
100
111
14197 168 ▶ $p = '+' if $m =~ /v/ && !$p;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /v/ and not $p 0 168 168
Condition66%2/3
$m =~ /v/ and not $p
!ll&&!rl&&r
152160
MC/DC0%0/2
$m =~ /v/ and not $p
$m =~ /v/ not $p
Truth table66%2/3
A and not(B)
A= $m =~ /v/B= not $p
ABresult
0X0
100
111
14198 168 $p . $n;
14199 94 } keys %{ $record->{users} };
14200 }
14201  
14202 72 ▶sub state_chan_list_multi_prefixed {
Subroutine state_chan_list_multi_prefixed: called CC=10 SCAR=23.0
Pod undocumented
14203 72 my $self = shift;
14204 72 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
720
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14205 72 my $flag = shift;
14206 72 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 72 72
14207 72 my $record = $self->{state}{chans}{uc_irc($chan)};
14208  
14209 return map {
14210 1042 my $rec = $self->{state}{uids}{$_};
14211 1042 ▶ my $n = ( ($flag && $flag eq 'UIDS') ? $_ : $rec->{nick} );
Branch: 1 branch
BranchTrueFalseTotal
$flag && $flag eq 'UIDS' ? : 1020 22 1042
Condition100%3/3
$flag and $flag eq "UIDS"
!ll&&!rl&&r
1661020
MC/DC100%2/2
$flag and $flag eq "UIDS"
$flag $flag eq "UIDS"
Truth table100%3/3
A and B
A= $flagB= $flag eq "UIDS"
ABresult
0X0
100
111
14212 1042 ▶ $n = (($flag && $flag eq 'FULL') ? $self->state_user_full($_) : $n );
Branch: 1 branch
BranchTrueFalseTotal
$flag && $flag eq 'FULL' ? : 6 1036 1042
Condition100%3/3
$flag and $flag eq "FULL"
!ll&&!rl&&r
1610206
MC/DC100%2/2
$flag and $flag eq "FULL"
$flag $flag eq "FULL"
Truth table100%3/3
A and B
A= $flagB= $flag eq "FULL"
ABresult
0X0
100
111
14213 1042 my $m = $record->{users}{$_};
14214 1042 my $p = '';
14215 1042 ▶ $p .= '@' if $m =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /o/ 47 995 1042
14216 1042 ▶ $p .= '%' if $m =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /h/ 4 1038 1042
14217 1042 ▶ $p .= '+' if $m =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /v/ 4 1038 1042
14218 1042 $p . $n;
14219 72 } keys %{ $record->{users} };
14220 }
14221  
14222 1 ▶sub _state_chan_timestamp {
Subroutine _state_chan_timestamp: called CC=3 SCAR=11.4
14223 1 my $self = shift;
14224 1 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14225 1 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 1 1
14226 1 return $self->{state}{chans}{uc_irc($chan)}{ts};
14227 }
14228  
14229 56 ▶sub state_chan_topic {
Subroutine state_chan_topic: called CC=4 SCAR=15.9
Pod documented
14230 56 my $self = shift;
14231 56 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
560
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14232 56 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 56 56
14233 56 my $record = $self->{state}{chans}{uc_irc($chan)};
14234 56 ▶ return if !$record->{topic};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"topic"} 56 0 56
14235 0 return [@{ $record->{topic} }];
14236 }
14237  
14238 29 ▶sub _state_is_local_user {
Subroutine _state_is_local_user: called CC=7 SCAR=23.8
14239 29 my $self = shift;
14240 29 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
290
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14241 29 my $record = $self->{state}{sids}{uc $self->server_sid()};
14242 29 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 0 29 29
14243 0 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 0 0 0
14244 0 ▶ return 1 if defined $record->{uids}{$nick};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"uids"}{$nick} 0 0 0
14245 }
14246 else {
14247 29 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 29 29
14248 29 ▶ return 1 if defined $record->{users}{uc_irc($nick)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"users"}{uc_irc($nick)} 28 1 29
14249 }
14250 1 return 0;
14251 }
14252  
14253 3274 ▶sub _state_is_local_uid {
Subroutine _state_is_local_uid: called CC=4 SCAR=14.1
14254 3274 my $self = shift;
14255 3274 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
32740
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14256 3274 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 3274 3274
14257 3274 ▶ return 1 if $self->server_sid() eq substr( $uid, 0, 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $self->server_sid eq substr($uid, 0, 3) 29 3245 3274
14258 3245 return 0;
14259 }
14260  
14261 208 ▶sub _state_chan_name {
Subroutine _state_chan_name: called CC=3 SCAR=11.4
14262 208 my $self = shift;
14263 208 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
2080
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14264 208 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 208 208
14265 208 return $self->{state}{chans}{uc_irc($chan)}{name};
14266 }
14267  
14268 68 ▶sub state_chan_mode_set {
Subroutine state_chan_mode_set: called CC=6 SCAR=18.5
Pod documented
14269 68 my $self = shift;
14270 68 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
680
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14271 68 ▶ my $mode = shift || return;
Condition50%1/2
shift() || (return)
l!l
680
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14272 68 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 68 68
14273  
14274 68 $mode =~ s/[^a-zA-Z]+//g;
14275 68 ▶ $mode = (split //, $mode )[0] if length $mode > 1;
Branch: 1 branch
BranchTrueFalseTotal
if length $mode > 1 0 68 68
14276 68 my $record = $self->{state}{chans}{uc_irc($chan)};
14277 68 ▶ return 1 if $record->{mode} =~ /$mode/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /$mode/ 4 64 68
14278 64 return 0;
14279 }
14280  
14281 4 ▶sub _state_user_invited {
Subroutine _state_user_invited: called CC=7 SCAR=20.4
14282 4 my $self = shift;
14283 4 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14284 4 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14285 4 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 4 4
14286 4 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 4 4
14287 4 my $nickrec = $self->{state}{users}{uc_irc($nick)};
14288 4 ▶ return 1 if $nickrec->{invites}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if $nickrec->{"invites"}{uc_irc($chan)} 1 3 4
14289 # Check if user matches INVEX
14290 3 ▶ return 1 if $self->_state_user_matches_list($nick, $chan, 'invex');
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_matches_list($nick, $chan, "invex") 0 3 3
14291 3 return 0;
14292 }
14293  
14294 68 ▶sub _state_user_banned {
Subroutine _state_user_banned: called CC=5 SCAR=20.9
14295 68 my $self = shift;
14296 68 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
680
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14297 68 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
680
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14298 68 ▶ return 0 if !$self->_state_user_matches_list($nick, $chan, 'bans');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_user_matches_list($nick, $chan, "bans") 68 0 68
14299 0 ▶ return 1 if !$self->_state_user_matches_list($nick, $chan, 'excepts');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_user_matches_list($nick, $chan, "excepts") 0 0 0
14300 0 return 0;
14301 }
14302  
14303 71 ▶sub _state_user_matches_list {
Subroutine _state_user_matches_list: called CC=8 SCAR=22.0
14304 71 my $self = shift;
14305 71 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
710
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14306 71 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
710
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14307 71 ▶ my $list = shift || 'bans';
Condition50%1/2
shift() || 'bans'
l!l
710
MC/DC0%0/1
shift() || 'bans'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14308 71 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 71 71
14309 71 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 71 71
14310 71 my $full = $self->state_user_full($nick);
14311 71 my $record = $self->{state}{chans}{uc_irc($chan)};
14312  
14313 71 for my $mask (keys %{ $record->{$list} }) {
14314 3 ▶ return 1 if matches_mask($mask, $full);
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($mask, $full) 0 3 3
14315 }
14316 71 return 0;
14317 }
14318  
14319 377 ▶sub state_is_chan_member {
Subroutine state_is_chan_member: called CC=6 SCAR=18.6
Pod documented
14320 377 my $self = shift;
14321 377 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
3770
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14322 377 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
3770
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14323 377 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 377 377
14324 377 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 377 377
14325 377 my $record = $self->{state}{users}{uc_irc($nick)};
14326 377 ▶ return 1 if defined $record->{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"chans"}{uc_irc($chan)} 307 70 377
14327 70 return 0;
14328 }
14329  
14330 2 ▶sub state_uid_chan_member {
Subroutine state_uid_chan_member: called CC=6 SCAR=19.9
Pod undocumented
14331 2 my $self = shift;
14332 2 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14333 2 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14334 2 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 2 2
14335 2 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 2 2
14336 2 my $record = $self->{state}{uids}{$uid};
14337 2 ▶ return 1 if defined $record->{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"chans"}{uc_irc($chan)} 2 0 2
14338 0 return 0;
14339 }
14340 0 ▶sub state_user_chan_mode {
Subroutine state_user_chan_mode: not called CC=4 SCAR=30.0
Pod documented
14341 0 my $self = shift;
14342 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14343 0 ▶ my $chan = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14344 0 ▶ return if !$self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($nick, $chan) 0 0 0
14345 0 return $self->{state}{users}{uc_irc($nick)}{chans}{uc_irc($chan)};
14346 }
14347  
14348 63 ▶sub state_is_chan_op {
Subroutine state_is_chan_op: called CC=7 SCAR=21.0
Pod documented
14349 63 my $self = shift;
14350 63 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
630
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14351 63 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
630
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14352 63 ▶ return if !$self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($nick, $chan) 0 63 63
14353 63 my $record = $self->{state}{users}{uc_irc($nick)};
14354 63 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /o/ 49 14 63
14355 14 ▶ return 1 if $self->{config}{OPHACKS} && $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"config"}{"OPHACKS"} and $record->{"umode"} =~ /o/ 0 14 14
Condition33%1/3
$self->{"config"}{"OPHACKS"} and $record->{"umode"} =~ /o/
!ll&&!rl&&r
1400
MC/DC0%0/2
$self->{"config"}{"OPHACKS"} and $record->{"umode"} =~ /o/
$self->{"config"}{"OPHACKS"} $record->{"umode"} =~ /o/
Truth table33%1/3
A and B
A= $self->{"config"}{"OPHACKS"}B= $record->{"umode"} =~ /o/
ABresult
0X0
100
111
14356 14 return 0;
14357 }
14358  
14359 54 ▶sub state_is_chan_hop {
Subroutine state_is_chan_hop: called CC=5 SCAR=16.5
Pod documented
14360 54 my $self = shift;
14361 54 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
540
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14362 54 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
540
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14363 54 ▶ return if !$self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($nick, $chan) 0 54 54
14364 54 my $record = $self->{state}{users}{uc_irc($nick)};
14365 54 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /h/ 21 33 54
14366 33 return 0;
14367 }
14368  
14369 0 ▶sub state_has_chan_voice {
Subroutine state_has_chan_voice: not called CC=5 SCAR=34.0
Pod documented
14370 0 my $self = shift;
14371 0 ▶ my $nick = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14372 0 ▶ my $chan = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14373 0 ▶ return if !$self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($nick, $chan) 0 0 0
14374 0 my $record = $self->{state}{users}{uc_irc($nick)};
14375 0 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /v/ 0 0 0
14376 0 return 0;
14377 }
14378  
14379 25 ▶sub _state_o_line {
Subroutine _state_o_line: called CC=23 SCAR=44.0
14380 25 my $self = shift;
14381 25 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14382 25 my ($user, $pass) = @_;
14383 25 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 25 25
14384 25 ▶ return if !$user || !$pass;
Branch: 1 branch
BranchTrueFalseTotal
unless $user and $pass 0 25 25
Condition33%1/3
$user and $pass
!ll&&!rl&&r
0025
MC/DC0%0/2
$user and $pass
$user $pass
Truth table33%1/3
A and B
A= $userB= $pass
ABresult
0X0
100
111
14385  
14386 25 my $ops = $self->{config}{ops};
14387 25 ▶ return if !$ops->{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless $ops->{$user} 1 24 25
14388 24 ▶ return -1 if !chkpasswd ($pass, $ops->{$user}{password});
Branch: 1 branch
BranchTrueFalseTotal
unless chkpasswd($pass, $ops->{$user}{"password"}) 0 24 24
14389  
14390 24 ▶ if ($ops->{$user}{ssl_required}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops->{$user}{"ssl_required"}) 5 19 24
14391 5 ▶ return -2 if $self->{state}{users}{uc_irc $nick}{umode} !~ /S/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"users"}{uc_irc($nick)}{"umode"} =~ /S/ 1 4 5
14392 }
14393  
14394 23 ▶ if ($ops->{$user}{certfp}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops->{$user}{"certfp"}) 4 19 23
14395 4 my $certfp = $self->{state}{users}{uc_irc $nick}{certfp};
14396 4 ▶ if (!$certfp || uc($certfp) ne uc($ops->{$user}{certfp})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $certfp or uc $certfp ne uc $ops->{$user}{"certfp"}) 1 3 4
Condition66%2/3
not $certfp or uc $certfp ne uc $ops->{$user}{"certfp"}
l!l&&r!l&&!r
013
MC/DC50%1/2
not $certfp or uc $certfp ne uc $ops->{$user}{"certfp"}
not $certfp uc $certfp ne uc $ops->{$user}{"certfp"}
Truth table66%2/3
not(A) or B
A= not $certfpB= uc $certfp ne uc $ops->{$user}{"certfp"}
ABresult
1X1
011
000
14397 1 return -3;
14398 }
14399 }
14400  
14401 22 my $client_ip = $self->_state_user_ip($nick);
14402 22 ▶ return if !$client_ip;
Branch: 1 branch
BranchTrueFalseTotal
unless $client_ip 0 22 22
14403 22 ▶ if (!$ops->{$user}{ipmask} && ($client_ip && $client_ip =~ /^(127\.|::1)/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^(127\.|::1)/)) 22 0 22
Condition33%2/6
not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^(127\.|::1)/)
!ll&&!rl&&r
0022
$client_ip and $client_ip =~ /^(127\.|::1)/
!ll&&!rl&&r
0022
MC/DC0%0/3
not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^(127\.|::1)/)
not $ops->{$user}{"ipmask"} $client_ip $client_ip =~ /^(127\.|::1)/
Truth table25%1/4
not(A) and B and C
A= not $ops->{$user}{"ipmask"}B= $client_ipC= $client_ip =~ /^(127\.|::1)/
ABCresult
0XX0
10X0
1100
1111
14404 22 return 1;
14405 }
14406 0 ▶ return 0 if !$ops->{$user}{ipmask};
Branch: 1 branch
BranchTrueFalseTotal
unless $ops->{$user}{"ipmask"} 0 0 0
14407  
14408 0 ▶ if (ref $ops->{$user}{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ops->{$user}{"ipmask"} eq "ARRAY") 0 0 0
14409 0 for my $block (@{ $ops->{$user}{ipmask} }) {
14410 0 ▶ if ( eval { $block->isa('Net::Netmask') } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $block->isa("Net::Netmask") } }) 0 0 0
14411 0 ▶ return 1 if $block->match($client_ip);
Branch: 1 branch
BranchTrueFalseTotal
if $block->match($client_ip) 0 0 0
14412 0 next;
14413 }
14414 0 ▶ return 1 if Net::CIDR::cidrlookup( $client_ip, $block );
Branch: 1 branch
BranchTrueFalseTotal
if Net::CIDR::cidrlookup($client_ip, $block) 0 0 0
14415 }
14416 }
14417 0 ▶ return 1 if matches_mask($ops->{$user}{ipmask}, $client_ip);
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($ops->{$user}{"ipmask"}, $client_ip) 0 0 0
14418 0 return 0;
14419 }
14420  
14421 0 ▶sub _state_users_share_chan {
Subroutine _state_users_share_chan: not called CC=7 SCAR=40.3
14422 0 my $self = shift;
14423 0 ▶ my $nick1 = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14424 0 ▶ my $nick2 = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14425 0 ▶ return if !$self->state_nick_exists($nick1)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick1) and $self->state_nick_exists($nick2) 0 0 0
Condition0%0/3
$self->state_nick_exists($nick1) and $self->state_nick_exists($nick2)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->state_nick_exists($nick1) and $self->state_nick_exists($nick2)
$self->state_nick_exists($nick1) $self->state_nick_exists($nick2)
Truth table0%0/3
A and B
A= $self->state_nick_exists($nick1)B= $self->state_nick_exists($nick2)
ABresult
0X0
100
111
14426 || !$self->state_nick_exists($nick2);
14427 0 my $rec1 = $self->{state}{users}{uc_irc($nick1)};
14428 0 my $rec2 = $self->{state}{users}{uc_irc($nick2)};
14429 0 for my $chan (keys %{ $rec1->{chans} }) {
14430 0 ▶ return 1 if $rec2->{chans}{$chan};
Branch: 1 branch
BranchTrueFalseTotal
if $rec2->{"chans"}{$chan} 0 0 0
14431 }
14432 0 return 0;
14433 }
14434  
14435 38 ▶sub _state_parse_msg_targets {
Subroutine _state_parse_msg_targets: called CC=10 SCAR=25.0
14436 38 my $self = shift;
14437 38 ▶ my $targets = shift || return;
Condition50%1/2
shift() || (return)
l!l
380
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14438 38 my %results;
14439  
14440 38 for my $target (split /,/, $targets) {
14441 38 ▶ if ($target =~ /^[#&]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^[#&]/) 18 20 38
14442 18 $results{$target} = ['channel'];
14443 18 next;
14444 }
14445 20 ▶ if ($target =~ /^([@%+]+)([#&].+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^([\@%+]+)([#&].+)$/) 0 20 20
14446 0 $results{$target} = ['channel_ext', $1, $2];
14447 0 next;
14448 }
14449 20 ▶ if ( $target =~ /^\$([^#].+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^\$([^#].+)$/) 1 19 20
14450 1 $results{$target} = ['servermask', $1];
14451 1 next;
14452 }
14453 19 ▶ if ( $target =~ /^\$#(.+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^\$#(.+)$/) 1 18 19
14454 1 $results{$target} = ['hostmask', $1];
14455 1 next;
14456 }
14457 18 ▶ if ($target =~ /@/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /@/) 0 18 18
14458 0 my ($nick, $server) = split /@/, $target, 2;
14459 0 my $host;
14460 0 ▶ ($nick, $host) = split ( /%/, $nick, 2 ) if $nick =~ /%/;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ /%/ 0 0 0
14461 0 $results{$target} = ['nick_ext', $nick, $server, $host];
14462 0 next;
14463 }
14464 18 ▶ if ($target =~ $uid_re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /$uid_re/) 4 14 18
14465 4 $results{$target} = ['uid'];
14466 4 next;
14467 }
14468 14 $results{$target} = ['nick'];
14469 }
14470  
14471 38 return \%results;
14472 }
14473  
14474 13877 ▶sub server_name {
Subroutine server_name: called CC=1 SCAR=0.0
Pod documented
14475 13877 return $_[0]->{config}{'SERVERNAME'};
14476 }
14477  
14478 230 ▶sub server_version {
Subroutine server_version: called CC=1 SCAR=0.0
Pod documented
14479 230 return $_[0]->{config}{'VERSION'};
14480 }
14481  
14482 9234 ▶sub server_sid {
Subroutine server_sid: called CC=1 SCAR=0.0
Pod undocumented
14483 9234 return $_[0]->{config}{'SID'};
14484 }
14485  
14486 224 ▶sub server_created {
Subroutine server_created: called CC=1 SCAR=0.0
Pod documented
14487 224 return strftime("This server was created %a %h %d %Y at %H:%M:%S %Z",
14488 localtime($_[0]->server_config('created')));
14489 }
14490  
14491 3793 ▶sub _client_nickname {
Subroutine _client_nickname: called CC=3 SCAR=11.0
14492 3793 my $self = shift;
14493 3793 ▶ my $wheel_id = $_[0] || return;
Condition50%1/2
$_[0] || (return)
l!l
37930
MC/DC0%0/1
$_[0] || (return)
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
14494 3793 ▶ return '*' if !$self->{state}{conns}{$wheel_id}{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$wheel_id}{"nick"} 218 3575 3793
14495 3575 return $self->{state}{conns}{$wheel_id}{nick};
14496 }
14497  
14498 791 ▶sub _client_uid {
Subroutine _client_uid: called CC=3 SCAR=11.4
14499 791 my $self = shift;
14500 791 ▶ my $wheel_id = $_[0] || return;
Condition50%1/2
$_[0] || (return)
l!l
7910
MC/DC0%0/1
$_[0] || (return)
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
14501 791 ▶ return '*' if !$self->{state}{conns}{$wheel_id}{uid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$wheel_id}{"uid"} 0 791 791
14502 791 return $self->{state}{conns}{$wheel_id}{uid};
14503 }
14504  
14505 237 ▶sub _client_ip {
Subroutine _client_ip: called CC=2 SCAR=7.1
14506 237 my $self = shift;
14507 237 ▶ my $wheel_id = shift || return '';
Condition50%1/2
shift() || (return '')
l!l
2370
MC/DC0%0/1
shift() || (return '')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14508 237 return $self->{state}{conns}{$wheel_id}{socket}[0];
14509 }
14510  
14511 1288 ▶sub server_config {
Subroutine server_config: called CC=2 SCAR=7.1
Pod documented
14512 1288 my $self = shift;
14513 1288 ▶ my $value = shift || return;
Condition50%1/2
shift() || (return)
l!l
12880
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14514 1288 return $self->{config}{uc $value};
14515 }
14516  
14517 183 ▶sub configure {
Subroutine configure: called CC=26 SCAR=36.9
Pod documented
14518 183 my $self = shift;
14519 183 ▶ my $opts = ref $_[0] eq 'HASH' ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 181 2 183
14520 183 $opts->{uc $_} = delete $opts->{$_} for keys %$opts;
14521  
14522 my %defaults = (
14523 CREATED => time(),
14524 CASEMAPPING => 'rfc1459',
14525 SERVERNAME => 'poco.server.irc',
14526 SERVERDESC => 'Poco? POCO? POCO!',
14527 183 VERSION => do {
14528 180 ▶ no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
14529 183 ▶ ref($self) . '-' . (defined $VERSION ? $VERSION : 'dev-git');
Branch: 1 branch
BranchTrueFalseTotal
defined $VERSION ? : 183 0 183
14530 },
14531 NETWORK => 'poconet',
14532 NETWORKDESC => 'poco mcpoconet',
14533 HOSTLEN => 63,
14534 NICKLEN => 9,
14535 USERLEN => 10,
14536 REALLEN => 50,
14537 KICKLEN => 120,
14538 TOPICLEN => 80,
14539 AWAYLEN => 160,
14540 CHANNELLEN => 50,
14541 PASSWDLEN => 20,
14542 KEYLEN => 23,
14543 MAXCHANNELS => 15, # Think this is called CHANLIMIT now
14544 MAXACCEPT => 20,
14545 MODES => 4,
14546 MAXTARGETS => 4,
14547 MAXCLIENTS => 512,
14548 MAXBANS => 50,
14549 MAXBANLENGTH => 1024,
14550 AUTH => 1,
14551 ANTIFLOOD => 1,
14552 OPHACKS => 0,
14553 JOIN_LEAVE_COUNT_EXPIRE => 120,
14554 OPER_SPAM_COUNTDOWN => 5,
14555 MAX_JOIN_LEAVE_COUNT => 25,
14556 MIN_JOIN_LEAVE_TIME => 60,
14557 knock_client_count => 1,
14558 knock_client_time => 5 * 60,
14559 knock_delay_channel => 60,
14560 pace_wait => 10,
14561 max_watch => 50,
14562 max_bans_large => 500,
14563 oper_umode => 'aceklnswy',
14564 anti_spam_exit_message_time => 5 * 60,
14565 anti_nick_flood => 1,
14566 max_nick_time => 20,
14567 max_nick_changes => 5,
14568 floodcount => 10,
14569 floodtime => 1,
14570 joinfloodcount => 18,
14571 joinfloodtime => 6,
14572 hidden_servers => '',
14573 hidden => '',
14574 );
14575 183 $self->{config}{$_} = $defaults{$_} for keys %defaults;
14576  
14577 183 for my $opt (qw(HOSTLEN NICKLEN USERLEN REALLEN TOPICLEN CHANNELLEN
14578 PASSWDLEN KEYLEN MAXCHANNELS MAXACCEPT MODES MAXTARGETS MAXBANS)) {
14579 2379 my $new = delete $opts->{$opt};
14580 2379 ▶ if (defined $new && $new > $self->{config}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new and $new > $self->{"config"}{$opt}) 0 2379 2379
Condition33%1/3
defined $new and $new > $self->{"config"}{$opt}
!ll&&!rl&&r
237900
MC/DC0%0/2
defined $new and $new > $self->{"config"}{$opt}
defined $new $new > $self->{"config"}{$opt}
Truth table33%1/3
A and B
A= defined $newB= $new > $self->{"config"}{$opt}
ABresult
0X0
100
111
14581 0 $self->{config}{$opt} = $new;
14582 }
14583 }
14584  
14585 183 for my $opt (qw(KICKLEN AWAYLEN)) {
14586 366 my $new = delete $opts->{$opt};
14587 366 ▶ if (defined $new && $new < $self->{config}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new and $new < $self->{"config"}{$opt}) 0 366 366
Condition33%1/3
defined $new and $new < $self->{"config"}{$opt}
!ll&&!rl&&r
36600
MC/DC0%0/2
defined $new and $new < $self->{"config"}{$opt}
defined $new $new < $self->{"config"}{$opt}
Truth table33%1/3
A and B
A= defined $newB= $new < $self->{"config"}{$opt}
ABresult
0X0
100
111
14588 0 $self->{config}{$opt} = $new;
14589 }
14590 }
14591  
14592 183 for my $opt (keys %$opts) {
14593 468 ▶ next if $opt !~ m!^(knock_|pace_|max_watch|max_bans_|oper_umode|max_nick|anti_|flood|hidden)!i;
Branch: 1 branch
BranchTrueFalseTotal
unless $opt =~ /^(knock_|pace_|max_watch|max_bans_|oper_umode|max_nick|anti_|flood|hidden)/i 342 126 468
14594 $self->{config}{lc $opt} = delete $opts->{$opt}
14595 126 ▶ if defined $opts->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$opt} 126 0 126
14596 }
14597  
14598 183 $self->{config}{oper_umode} =~ s/[^DFGHRSWXabcdefgijklnopqrsuwy]+//g;
14599 183 $self->{config}{oper_umode} =~ s/[SWori]+//g;
14600  
14601 183 for my $opt (keys %$opts) {
14602 342 ▶ $self->{config}{$opt} = $opts->{$opt} if defined $opts->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$opt} 342 0 342
14603 }
14604  
14605 {
14606 183 my $sid = delete $self->{config}{SID};
14607 183 ▶ if (!$sid || $sid !~ $sid_re) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $sid && $sid =~ /$sid_re/) { } 2 181 183
Condition66%2/3
$sid && $sid =~ /$sid_re/
!ll&&!rl&&r
20181
MC/DC50%1/2
$sid && $sid =~ /$sid_re/
$sid $sid =~ /$sid_re/
Truth table66%2/3
A && B
A= $sidB= $sid =~ /$sid_re/
ABresult
0X0
100
111
14608 2 warn "No SID or SID is invalid, generating a random one\n";
14609 2 $self->_state_rand_sid();
14610 }
14611 else {
14612 181 $self->{config}{SID} = uc $sid;
14613 }
14614 }
14615  
14616 $self->{config}{BANLEN}
14617 183 = sum(@{ $self->{config} }{qw(NICKLEN USERLEN HOSTLEN)}, 3);
14618 $self->{config}{USERHOST_REPLYLEN}
14619 183 = sum(@{ $self->{config} }{qw(NICKLEN USERLEN HOSTLEN)}, 5);
14620  
14621 183 $self->{config}{SERVERNAME} =~ s/[^a-zA-Z0-9\-.]//g;
14622 183 ▶ if ($self->{config}{SERVERNAME} !~ /\./) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"}{"SERVERNAME"} =~ /\./) 0 183 183
14623 0 $self->{config}{SERVERNAME} .= '.';
14624 }
14625  
14626 183 ▶ if (!defined $self->{config}{ADMIN}
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"config"}{"ADMIN"} or ref $self->{"config"}{"ADMIN"} ne "ARRAY" or @{$self->{"config"}{"ADMIN"};} != 3) 183 0 183
Condition33%2/6
not defined $self->{"config"}{"ADMIN"} or ref $self->{"config"}{"ADMIN"} ne "ARRAY" or @{$self->{"config"}{"ADMIN"};} != 3
l!l&&r!l&&!r
18300
not defined $self->{"config"}{"ADMIN"} or ref $self->{"config"}{"ADMIN"} ne "ARRAY"
l!l&&r!l&&!r
18300
MC/DC0%0/3
not defined $self->{"config"}{"ADMIN"} or ref $self->{"config"}{"ADMIN"} ne "ARRAY" or @{$self->{"config"}{"ADMIN"};} != 3
not defined $self->{"config"}{"ADMIN"} ref $self->{"config"}{"ADMIN"} ne "ARRAY" @{$self->{"config"}{"ADMIN"};} != 3
Truth table25%1/4
not(A) or B or C
A= not defined $self->{"config"}{"ADMIN"}B= ref $self->{"config"}{"ADMIN"} ne "ARRAY"C= @{$self->{"config"}{"ADMIN"};} != 3
ABCresult
1XX1
01X1
0011
0000
14627 || ref $self->{config}{ADMIN} ne 'ARRAY'
14628 0 || @{ $self->{config}{ADMIN} } != 3) {
14629 183 $self->{config}{ADMIN} = [];
14630 183 $self->{config}{ADMIN}[0] = 'Somewhere, Somewhere, Somewhere';
14631 183 $self->{config}{ADMIN}[1] = 'Some Institution';
14632 183 $self->{config}{ADMIN}[2] = 'someone@somewhere';
14633 }
14634  
14635 183 ▶ if (!defined $self->{config}{INFO}
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY" or not @{$self->{"config"}{"INFO"};} == 1) 183 0 183
Condition33%2/6
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY" or not @{$self->{"config"}{"INFO"};} == 1
l!l&&r!l&&!r
18300
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY"
l!l&&r!l&&!r
18300
MC/DC0%0/3
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY" or not @{$self->{"config"}{"INFO"};} == 1
not defined $self->{"config"}{"INFO"} ref $self->{"config"}{"INFO"} ne "ARRAY" not @{$self->{"config"}{"INFO"};} == 1
Truth table25%1/4
not(A) or B or not(C)
A= not defined $self->{"config"}{"INFO"}B= ref $self->{"config"}{"INFO"} ne "ARRAY"C= not @{$self->{"config"}{"INFO"};} == 1
ABCresult
1XX1
01X1
0011
0000
14636 || ref $self->{config}{INFO} ne 'ARRAY'
14637 0 || !(@{ $self->{config}{INFO} } == 1)) {
14638 183 $self->{config}{INFO} = [split /\n/, <<'EOF'];
14639 # POE::Component::Server::IRC
14640 #
14641 # Author: Chris "BinGOs" Williams
14642 #
14643 # Filter-IRCD Written by Hachi
14644 #
14645 # This module may be used, modified, and distributed under the same
14646 # terms as Perl itself. Please see the license that came with your Perl
14647 # distribution for details.
14648 #
14649 EOF
14650 }
14651  
14652 $self->{Error_Codes} = {
14653 183 263 => [1, "Server load is temporarily too heavy. Please wait a while and try again."],
14654 401 => [1, "No such nick/channel"],
14655 402 => [1, "No such server"],
14656 403 => [1, "No such channel"],
14657 404 => [1, "Cannot send to channel"],
14658 405 => [1, "You have joined too many channels"],
14659 406 => [1, "There was no such nickname"],
14660 407 => [1, "Too many targets"],
14661 408 => [1, "You cannot use control codes on this channel"],
14662 409 => [0, "No origin specified"],
14663 410 => [1, "Invalid CAP subcommand"],
14664 411 => [0, "No recipient given (%s)"],
14665 412 => [0, "No text to send"],
14666 413 => [1, "No toplevel domain specified"],
14667 414 => [1, "Wildcard in toplevel domain"],
14668 415 => [1, "Bad server/host mask"],
14669 421 => [1, "Unknown command"],
14670 422 => [0, "MOTD File is missing"],
14671 423 => [1, "No administrative info available"],
14672 424 => [1, "File error doing % on %"],
14673 431 => [1, "No nickname given"],
14674 432 => [1, "Erroneous nickname"],
14675 433 => [1, "Nickname is already in use"],
14676 436 => [1, "Nickname collision KILL from %s\@%s"],
14677 437 => [1, "Nick/channel is temporarily unavailable"],
14678 438 => [1, "Nick change too fast. Please wait %s seconds."],
14679 440 => [1, "Services are currently unavailable."],
14680 441 => [1, "They aren\'t on that channel"],
14681 442 => [1, "You\'re not on that channel"],
14682 443 => [2, "is already on channel"],
14683 444 => [1, "User not logged in"],
14684 445 => [0, "SUMMON has been disabled"],
14685 446 => [0, "USERS has been disabled"],
14686 447 => [0, "Cannot change nickname while on %s (+N)"],
14687 451 => [0, "You have not registered"],
14688 461 => [1, "Not enough parameters"],
14689 462 => [0, "Unauthorised command (already registered)"],
14690 463 => [0, "Your host isn\'t among the privileged"],
14691 464 => [0, "Password incorrect"],
14692 465 => [0, "You are banned from this server"],
14693 466 => [0, "You will be banned from this server"],
14694 467 => [1, "Channel key already set"],
14695 471 => [1, "Cannot join channel (+l)"],
14696 472 => [1, "is unknown mode char to me for %s"],
14697 473 => [1, "Cannot join channel (+i)"],
14698 474 => [1, "Cannot join channel (+b)"],
14699 475 => [1, "Cannot join channel (+k)"],
14700 476 => [1, "Bad Channel Mask"],
14701 477 => [1, "You need to identify to a registered nick to join or speak in that channel."],
14702 478 => [2, "Channel list is full"],
14703 481 => [0, "Permission Denied- You\'re not an IRC operator"],
14704 482 => [1, "You\'re not channel operator"],
14705 483 => [0, "You can\'t kill a server!"],
14706 484 => [0, "Your connection is restricted!"],
14707 485 => [1, "Cannot join channel (%s)"],
14708 489 => [1, "Cannot join channel (+S) - SSL/TLS required"],
14709 491 => [0, "Only few of mere mortals may try to enter the twilight zone"],
14710 492 => [1, "You cannot send CTCPs to this channel."],
14711 501 => [0, "Unknown MODE flag"],
14712 502 => [0, "Cannot change mode for other users"],
14713 512 => [0, "Maximum size for WATCH-list is %s entries"],
14714 520 => [1, "Cannot join channel (+O)"],
14715 521 => [0, "Bad list syntax"],
14716 524 => [1, "Help not found"],
14717 710 => [2, "has asked for an invite."],
14718 711 => [1, "Your KNOCK has been delivered."],
14719 712 => [1, "Too many KNOCKs (%s)."],
14720 713 => [1, "Channel is open."],
14721 714 => [1, "You are already on that channel."],
14722 723 => [1, "Insufficient oper privileges."],
14723 };
14724  
14725 $self->{config}{isupport} = {
14726 INVEX => 'I',
14727 EXCEPTS => 'e',
14728 CALLERID => undef,
14729 CHANTYPES => '#&',
14730 KNOCK => undef,
14731 PREFIX => '(ohv)@%+',
14732 CHANMODES => 'beI,k,l,cimnprstuCLMNORST',
14733 STATUSMSG => '@%+',
14734 DEAF => 'D',
14735 MAXLIST => 'beI:' . $self->{config}{MAXBANS},
14736 SAFELIST => undef,
14737 ELIST => 'CMNTU',
14738 183 map { ($_, $self->{config}{$_}) }
14739 qw(MAXCHANNELS MAXTARGETS NICKLEN TOPICLEN KICKLEN CASEMAPPING
14740 NETWORK MODES AWAYLEN),
14741 };
14742  
14743 183 $self->{config}{capab} = [qw(KNOCK DLN TBURST UNDLN ENCAP UNKLN KLN RHOST SVS CLUSTER EOB QS)];
14744  
14745 183 $self->{config}{cmds}{uc $_}++ for
14746 qw[accept admin away bmask cap close connect die dline encap eob etrace globops info invite ison isupport join kick kill],
14747 qw[kline knock links list locops lusers map message mode motd names nick oper part pass ping pong quit rehash remove],
14748 qw[resv rkline set sid sjoin squit stats summon svinfo svshost svsjoin svskill svsmode svsnick svspart svstag tburst time],
14749 qw[tmode topic trace uid umode undline unkline unresv unrkline unxline user userhost users version wallops watch who whois whowas xline];
14750  
14751 183 return 1;
14752 }
14753  
14754 2143 ▶sub _send_to_realops {
Subroutine _send_to_realops: called CC=6 SCAR=17.9
14755 2143 my $self = shift;
14756 2143 ▶ my $msg = shift || return;
Condition50%1/2
shift() || (return)
l!l
21430
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14757 2143 ▶ my $type = shift || 'Notice';
Condition100%2/2
shift() || 'Notice'
l!l
208756
MC/DC100%1/1
shift() || 'Notice'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
14758 2143 my $flags = shift; # Future use
14759 2143 my $server = $self->server_name();
14760 2143 ▶ $flags =~ s/[^a-zA-Z]+//g if $flags;
Branch: 1 branch
BranchTrueFalseTotal
if $flags 2087 56 2143
14761  
14762 2143 my %types = (
14763 NOTICE => 'Notice',
14764 LOCOPS => 'LocOps',
14765 GLOBOPS => 'Global',
14766 );
14767  
14768 my $notice =
14769 2143 ▶ sprintf('*** %s -- %s', ( $types{uc $type} || 'Notice' ), $msg );
Condition50%1/2
$types{uc $type} || 'Notice'
l!l
21430
MC/DC0%0/1
$types{uc $type} || 'Notice'
$types{uc $type}
Truth table50%1/2
A
A= $types{uc $type}
Aresult
11
00
14770  
14771 2143 my @locops;
14772  
14773 2143 ▶ if ( $flags ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags) { } 2087 56 2143
14774 37 @locops = grep { $self->{state}{conns}{$_}{umode} =~ m![$flags]! }
14775 2087 keys %{ $self->{state}{localops} };
14776 }
14777 else {
14778 56 @locops = keys %{ $self->{state}{localops} };
14779 }
14780  
14781 2143 $self->send_event( 'daemon_snotice', $notice );
14782  
14783 2143 $self->send_output(
14784 {
14785 prefix => $server,
14786 command => 'NOTICE',
14787 params => [
14788 '*',
14789 $notice,
14790 ],
14791 },
14792 @locops,
14793 );
14794 2143 return 1;
14795 }
14796  
14797 2466 ▶sub _send_output_to_client {
Subroutine _send_output_to_client: called CC=10 SCAR=23.1
14798 2466 my $self = shift;
14799 2466 ▶ my $wheel_id = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
24660
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14800 2466 my $nick = $self->_client_nickname($wheel_id);
14801 2466 my $prefix = $self->server_name();
14802 2466 ▶ if ( $self->_connection_is_peer($wheel_id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_peer($wheel_id)) 34 2432 2466
14803 34 $nick = shift;
14804 34 $prefix = $self->server_sid();
14805 }
14806 2466 ▶ my $err = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
24660
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14807 2466 ▶ return if !$self->_connection_exists($wheel_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($wheel_id) 0 2466 2466
14808  
14809 SWITCH: {
14810 2466 ▶ if (ref $err eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $err eq "HASH") 2404 62 2466
14811 2404 $self->send_output($err, $wheel_id);
14812 2404 last SWITCH;
14813 }
14814 62 ▶ if (defined $self->{Error_Codes}{$err}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"Error_Codes"}{$err}) 62 0 62
14815 62 my $input = {
14816 command => $err,
14817 prefix => $self->server_name(),
14818 params => [$nick],
14819 };
14820 62 ▶ if ($self->{Error_Codes}{$err}[0] > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Error_Codes"}{$err}[0] > 0) 40 22 62
14821 40 ▶ for (my $i = 1; $i <= $self->{Error_Codes}{$err}[0]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $self->{"Error_Codes"}{$err}[0]) 40 40 80
14822 40 push @{ $input->{params} }, shift;
14823 }
14824 }
14825 62 ▶ if ($self->{Error_Codes}{$err}[1] =~ /%/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Error_Codes'}{$err}[1] =~ /%/) { } 6 56 62
14826 6 push @{ $input->{params} },
14827 6 sprintf($self->{Error_Codes}{$err}[1], @_);
14828 }
14829 else {
14830 56 push @{ $input->{params} }, $self->{Error_Codes}{$err}[1];
14831 }
14832 62 $self->send_output($input, $wheel_id);
14833 }
14834 }
14835  
14836 2466 return 1;
14837 }
14838  
14839 199 ▶sub _send_output_channel_local {
Subroutine _send_output_channel_local: called CC=29 SCAR=33.9
14840 199 my $self = shift;
14841 199 ▶ my $channel = shift || return;
Condition50%1/2
shift() || (return)
l!l
1990
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14842 199 ▶ return if !$self->state_chan_exists($channel);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($channel) 0 199 199
14843 199 my ($output,$conn_id,$status,$poscap,$negcap) = @_;
14844 199 ▶ return if !$output;
Branch: 1 branch
BranchTrueFalseTotal
unless $output 0 199 199
14845 199 my $sid = $self->server_sid();
14846  
14847 199 ▶ my $is_msg = ( $output->{command} =~ m!^(PRIVMSG|NOTICE)$! ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$output->{'command'} =~ /^(PRIVMSG|NOTICE)$/ ? : 6 193 199
14848 199 my $chanrec = $self->{state}{chans}{uc_irc($channel)};
14849 199 my @targs;
14850 199 ▶ my $negative = ( $status ? $status =~ s!^\-!! : '' );
Branch: 1 branch
BranchTrueFalseTotal
$status ? : 13 186 199
14851 199 UID: foreach my $uid ( keys %{ $chanrec->{users} } ) {
14852 771 ▶ next if $uid !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid =~ /^$sid/ 339 432 771
14853 432 my $route_id = $self->_state_uid_route( $uid );
14854 432 ▶ if ( $conn_id && $conn_id eq $route_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn_id and $conn_id eq $route_id) 125 307 432
Condition100%3/3
$conn_id and $conn_id eq $route_id
!ll&&!rl&&r
130177125
MC/DC100%2/2
$conn_id and $conn_id eq $route_id
$conn_id $conn_id eq $route_id
Truth table100%3/3
A and B
A= $conn_idB= $conn_id eq $route_id
ABresult
0X0
100
111
14855 125 next UID;
14856 }
14857 307 ▶ if ( $status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) 21 286 307
14858 21 my $matched;
14859 21 STATUS: foreach my $stat ( split //, $status ) {
14860 42 ▶ $matched++ if $chanrec->{users}{$uid} =~ m!$stat!;
Branch: 1 branch
BranchTrueFalseTotal
if $chanrec->{"users"}{$uid} =~ /$stat/ 15 27 42
14861 }
14862 21 ▶ next UID if ( $negative && $matched ) || ( !$negative && !$matched );
Branch: 1 branch
BranchTrueFalseTotal
if $negative and $matched or not $negative || $matched 9 12 21
Condition100%9/9
$negative and $matched or not $negative || $matched
l!l&&r!l&&!r
4512
$negative and $matched
!ll&&!rl&&r
1524
$negative || $matched
l!l&&r!l&&!r
2105
MC/DC100%4/4
$negative and $matched or not $negative || $matched
$negative $matched $negative $matched
Truth table57%4/7
A and B or not(C || D)
A= $negativeB= $matchedC= $negativeD= $matched
ABCDresult
11XX1
0X001
10001
0X1X0
0X010
101X0
10010
14863 }
14864 298 ▶ if ( $poscap ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($poscap) 88 210 298
14865 88 ▶ foreach my $cap ( @{ ref $poscap eq 'ARRAY' ? $poscap : [ $poscap ] } ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $poscap eq 'ARRAY' ? : 0 88 88
14866 88 ▶ next UID if !$self->{state}{uids}{$uid}{caps}{$cap};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"uids"}{$uid}{"caps"}{$cap} 75 13 88
14867 }
14868 }
14869 223 ▶ if ( $negcap ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($negcap) 90 133 223
14870 90 ▶ foreach my $cap ( @{ ref $negcap eq 'ARRAY' ? $negcap : [ $negcap ] } ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $negcap eq 'ARRAY' ? : 6 84 90
14871 93 ▶ next UID if $self->{state}{uids}{$uid}{caps}{$cap};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"uids"}{$uid}{"caps"}{$cap} 15 78 93
14872 }
14873 }
14874 208 ▶ if ( $is_msg && $self->{state}{uids}{$uid}{umode} =~ m!D! ) { # +D 'deaf'
Branch: 1 branch
BranchTrueFalseTotal
if ($is_msg and $self->{"state"}{"uids"}{$uid}{"umode"} =~ /D/) 0 208 208
Condition66%2/3
$is_msg and $self->{"state"}{"uids"}{$uid}{"umode"} =~ /D/
!ll&&!rl&&r
20620
MC/DC0%0/2
$is_msg and $self->{"state"}{"uids"}{$uid}{"umode"} =~ /D/
$is_msg $self->{"state"}{"uids"}{$uid}{"umode"} =~ /D/
Truth table66%2/3
A and B
A= $is_msgB= $self->{"state"}{"uids"}{$uid}{"umode"} =~ /D/
ABresult
0X0
100
111
14875 0 next UID;
14876 }
14877 # Default
14878 208 push @targs, $route_id;
14879 }
14880  
14881 199 $self->send_output($output,@targs);
14882  
14883 199 my $spoofs = grep { $_ eq 'spoofed' } @targs;
14884  
14885 $self->send_event(
14886 "daemon_" . lc $output->{command},
14887 $output->{prefix},
14888 199 ▶ @{ $output->{params} },
Branch: 1 branch
BranchTrueFalseTotal
if not $is_msg or $spoofs 193 6 199
Condition66%2/3
not $is_msg or $spoofs
l!l&&r!l&&!r
19306
MC/DC50%1/2
not $is_msg or $spoofs
not $is_msg $spoofs
Truth table66%2/3
not(A) or B
A= not $is_msgB= $spoofs
ABresult
1X1
011
000
14889 ) if !$is_msg || $spoofs;
14890  
14891 199 return 1;
14892 }
14893  
14894 225 ▶sub _duration {
Subroutine _duration: called CC=7 SCAR=24.8
14895 225 my $duration = shift;
14896 225 ▶ $duration = 0 if !defined $duration || $duration !~ m!^\d+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $duration and $duration =~ /^\d+$/ 0 225 225
Condition33%1/3
defined $duration and $duration =~ /^\d+$/
!ll&&!rl&&r
00225
MC/DC0%0/2
defined $duration and $duration =~ /^\d+$/
defined $duration $duration =~ /^\d+$/
Truth table33%1/3
A and B
A= defined $durationB= $duration =~ /^\d+$/
ABresult
0X0
100
111
14897 225 my $timestr;
14898 225 my $days = my $hours = my $mins = my $secs = 0;
14899 225 ▶ while ($duration >= 60 * 60 * 24) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration >= 86400) 0 225 225
14900 0 $duration -= 60 * 60 * 24;
14901 0 ++$days;
14902 }
14903 225 ▶ while ($duration >= 60 * 60) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration >= 3600) 0 225 225
14904 0 $duration -= 60 * 60;
14905 0 ++$hours;
14906 }
14907 225 ▶ while ($duration >= 60) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration >= 60) 0 225 225
14908 0 $duration -= 60;
14909 0 ++$mins;
14910 }
14911 225 $secs = $duration;
14912 225 ▶ return sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$days == 1 ? : 0 225 225
14913 '%u day%s, %02u:%02u:%02u',
14914 $days, ($days == 1 ? '' : 's'), $hours, $mins, $secs,
14915 );
14916 }
14917  
14918 30 ▶sub add_operator {
Subroutine add_operator: called CC=14 SCAR=37.5
Pod documented
14919 30 my $self = shift;
14920 30 my $ref;
14921 30 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 30 0 30
14922 30 $ref = $_[0];
14923 }
14924 else {
14925 0 $ref = { @_ };
14926 }
14927 30 $ref->{lc $_} = delete $ref->{$_} for keys %$ref;
14928  
14929 30 ▶ if (!defined $ref->{username} || !defined $ref->{password}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ref->{"username"} and defined $ref->{"password"}) 0 30 30
Condition33%1/3
defined $ref->{"username"} and defined $ref->{"password"}
!ll&&!rl&&r
0030
MC/DC0%0/2
defined $ref->{"username"} and defined $ref->{"password"}
defined $ref->{"username"} defined $ref->{"password"}
Truth table33%1/3
A and B
A= defined $ref->{"username"}B= defined $ref->{"password"}
ABresult
0X0
100
111
14930 0 warn "Not enough parameters\n";
14931 0 return;
14932 }
14933  
14934 30 ▶ if (($ref->{ssl_required} || $ref->{certfp}) && !$self->{got_ssl}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->{"ssl_required"} || $ref->{"certfp"} and not $self->{"got_ssl"}) 0 30 30
Condition66%4/6
$ref->{"ssl_required"} || $ref->{"certfp"} and not $self->{"got_ssl"}
!ll&&!rl&&r
2550
$ref->{"ssl_required"} or $ref->{"certfp"}
l!l&&r!l&&!r
5025
MC/DC0%0/3
$ref->{"ssl_required"} || $ref->{"certfp"} and not $self->{"got_ssl"}
$ref->{"ssl_required"} $ref->{"certfp"} not $self->{"got_ssl"}
Truth table40%2/5
A or B and not(C)
A= $ref->{"ssl_required"}B= $ref->{"certfp"}C= not $self->{"got_ssl"}
ABCresult
00X0
1X00
0100
1X11
0111
14935 0 warn "SSL required, but it is not supported, ignoring\n";
14936 0 delete $ref->{ssl_required};
14937 0 delete $ref->{certfp};
14938 }
14939  
14940 30 ▶ if ( $ref->{ipmask} && $ref->{ipmask} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->{"ipmask"} and $ref->{"ipmask"} eq "ARRAY") 0 30 30
Condition33%1/3
$ref->{"ipmask"} and $ref->{"ipmask"} eq "ARRAY"
!ll&&!rl&&r
3000
MC/DC0%0/2
$ref->{"ipmask"} and $ref->{"ipmask"} eq "ARRAY"
$ref->{"ipmask"} $ref->{"ipmask"} eq "ARRAY"
Truth table33%1/3
A and B
A= $ref->{"ipmask"}B= $ref->{"ipmask"} eq "ARRAY"
ABresult
0X0
100
111
14941 0 my @validated;
14942 0 foreach my $mask ( @{ $ref->{ipmask} } ) {
14943 0 ▶ if ( eval { $mask->isa('Net::Netmask' ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $mask->isa("Net::Netmask") } }) 0 0 0
14944 0 push @validated, $mask;
14945 0 next;
14946 }
14947 0 my $valid = Net::CIDR::cidrvalidate($mask);
14948 0 ▶ push @validated, $valid if $valid;
Branch: 1 branch
BranchTrueFalseTotal
if $valid 0 0 0
14949 }
14950 0 $ref->{ipmask} = \@validated;
14951 }
14952  
14953 30 ▶ if ( $ref->{umode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->{"umode"}) 28 2 30
14954 28 $ref->{umode} =~ s/[^DFGHRSWXabcdefgijklnopqrsuwy]+//g;
14955 28 $ref->{umode} =~ s/[SWori]+//g;
14956 }
14957  
14958 30 my $record = $self->{state}{peers}{uc $self->server_name()};
14959 30 my $user = delete $ref->{username};
14960 30 $self->{config}{ops}{$user} = $ref;
14961 30 return 1;
14962 }
14963  
14964 0 ▶sub del_operator {
Subroutine del_operator: not called CC=3 SCAR=24.8
Pod documented
14965 0 my $self = shift;
14966 0 ▶ my $user = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14967 0 ▶ return if !defined $self->{config}{ops}{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{"ops"}{$user} 0 0 0
14968 0 delete $self->{config}{ops}{$user};
14969 0 return;
14970 }
14971  
14972 45 ▶sub add_service {
Subroutine add_service: called CC=2 SCAR=7.0
Pod documented
14973 45 my $self = shift;
14974 45 ▶ my $host = shift || return;
Condition50%1/2
shift() || (return)
l!l
450
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14975 45 $self->{state}{services}{uc $host} = $host;
14976 45 return 1;
14977 }
14978  
14979 0 ▶sub del_service {
Subroutine del_service: not called CC=2 SCAR=17.9
Pod documented
14980 0 my $self = shift;
14981 0 ▶ my $host = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
14982 0 delete $self->{state}{services}{uc $host};
14983 0 return 1;
14984 }
14985  
14986 6 ▶sub add_auth {
Subroutine add_auth: called CC=4 SCAR=15.0
Pod documented
14987 6 my $self = shift;
14988 6 my $parms;
14989 6 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 6 6
14990 0 $parms = $_[0];
14991 }
14992 else {
14993 6 $parms = { @_ };
14994 }
14995 6 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
14996  
14997 6 ▶ if (!$parms->{mask}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parms->{"mask"}) 0 6 6
14998 0 warn "Not enough parameters specified\n";
14999 0 return;
15000 }
15001 6 push @{ $self->{config}{auth} }, $parms;
15002 6 return 1;
15003 }
15004  
15005 0 ▶sub del_auth {
Subroutine del_auth: not called CC=4 SCAR=30.0
Pod documented
15006 0 my $self = shift;
15007 0 ▶ my $mask = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
15008 0 my $i = 0;
15009  
15010 0 for (@{ $self->{config}{auth} }) {
15011 0 ▶ if ($_->{mask} eq $mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"mask"} eq $mask) 0 0 0
15012 0 splice( @{ $self->{config}{auth} }, $i, 1 );
15013 0 last;
15014 }
15015 0 ++$i;
15016 }
15017 0 return;
15018 }
15019  
15020 288 ▶sub add_peer {
Subroutine add_peer: called CC=23 SCAR=40.5
Pod documented
15021 288 my $self = shift;
15022 288 my $parms;
15023 288 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 288 288
15024 0 $parms = $_[0];
15025 }
15026 else {
15027 288 $parms = { @_ };
15028 }
15029 288 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
15030  
15031 288 ▶ if (!defined $parms->{name} || !defined $parms->{pass}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}) 0 288 288
Condition33%2/6
defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}
!ll&&!rl&&r
00288
defined $parms->{"name"} and defined $parms->{"pass"}
!ll&&!rl&&r
00288
MC/DC0%0/3
defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}
defined $parms->{"name"} defined $parms->{"pass"} defined $parms->{"rpass"}
Truth table25%1/4
A and B and C
A= defined $parms->{"name"}B= defined $parms->{"pass"}C= defined $parms->{"rpass"}
ABCresult
0XX0
10X0
1100
1111
15032 || !defined $parms->{rpass}) {
15033 0 croak((caller(0))[3].": Not enough parameters specified\n");
15034 0 return;
15035 }
15036  
15037 288 ▶ $parms->{type} = 'c' if !$parms->{type} || lc $parms->{type} ne 'r';
Branch: 1 branch
BranchTrueFalseTotal
if not $parms->{"type"} or lc $parms->{"type"} ne "r" 285 3 288
Condition66%2/3
not $parms->{"type"} or lc $parms->{"type"} ne "r"
l!l&&r!l&&!r
02853
MC/DC50%1/2
not $parms->{"type"} or lc $parms->{"type"} ne "r"
not $parms->{"type"} lc $parms->{"type"} ne "r"
Truth table66%2/3
not(A) or B
A= not $parms->{"type"}B= lc $parms->{"type"} ne "r"
ABresult
1X1
011
000
15038 288 $parms->{type} = lc $parms->{type};
15039 288 ▶ $parms->{rport} = 6667 if $parms->{type} eq 'r' && !$parms->{rport};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"type"} eq "r" and not $parms->{"rport"} 0 288 288
Condition66%2/3
$parms->{"type"} eq "r" and not $parms->{"rport"}
!ll&&!rl&&r
28530
MC/DC0%0/2
$parms->{"type"} eq "r" and not $parms->{"rport"}
$parms->{"type"} eq "r" not $parms->{"rport"}
Truth table66%2/3
A and not(B)
A= $parms->{"type"} eq "r"B= not $parms->{"rport"}
ABresult
0X0
100
111
15040  
15041 288 for (qw(sockport sockaddr)) {
15042 576 ▶ $parms->{ $_ } = '*' if !$parms->{ $_ };
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{$_} 576 0 576
15043 }
15044  
15045 288 ▶ $parms->{ipmask} = $parms->{raddress} if $parms->{raddress};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"raddress"} 3 285 288
15046 288 ▶ $parms->{zip} = 0 if !$parms->{zip};
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{"zip"} 4 284 288
15047 288 ▶ $parms->{ssl} = 0 if !$parms->{ssl};
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{"ssl"} 287 1 288
15048  
15049 288 ▶ if ( $parms->{ipmask} && $parms->{ipmask} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parms->{"ipmask"} and $parms->{"ipmask"} eq "ARRAY") 0 288 288
Condition66%2/3
$parms->{"ipmask"} and $parms->{"ipmask"} eq "ARRAY"
!ll&&!rl&&r
28530
MC/DC0%0/2
$parms->{"ipmask"} and $parms->{"ipmask"} eq "ARRAY"
$parms->{"ipmask"} $parms->{"ipmask"} eq "ARRAY"
Truth table66%2/3
A and B
A= $parms->{"ipmask"}B= $parms->{"ipmask"} eq "ARRAY"
ABresult
0X0
100
111
15050 0 my @validated;
15051 0 foreach my $mask ( @{ $parms->{ipmask} } ) {
15052 0 ▶ if ( eval { $mask->isa('Net::Netmask' ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $mask->isa("Net::Netmask") } }) 0 0 0
15053 0 push @validated, $mask;
15054 0 next;
15055 }
15056 0 my $valid = Net::CIDR::cidrvalidate($mask);
15057 0 ▶ push @validated, $valid if $valid;
Branch: 1 branch
BranchTrueFalseTotal
if $valid 0 0 0
15058 }
15059 0 $parms->{ipmask} = \@validated;
15060 }
15061  
15062 288 my $name = $parms->{name};
15063 288 $self->{config}{peers}{uc $name} = $parms;
15064 288 ▶ $self->add_service( $name ) if $parms->{service};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"service"} 0 288 288
15065 $self->add_connector(
15066 remoteaddress => $parms->{raddress},
15067 remoteport => $parms->{rport},
15068 name => $name,
15069 usessl => $parms->{ssl},
15070 288 ▶ ) if $parms->{type} eq 'r' && $parms->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"type"} eq "r" and $parms->{"auto"} 3 285 288
Condition66%2/3
$parms->{"type"} eq "r" and $parms->{"auto"}
!ll&&!rl&&r
28503
MC/DC50%1/2
$parms->{"type"} eq "r" and $parms->{"auto"}
$parms->{"type"} eq "r" $parms->{"auto"}
Truth table66%2/3
A and B
A= $parms->{"type"} eq "r"B= $parms->{"auto"}
ABresult
0X0
100
111
15071  
15072 288 return 1;
15073 }
15074  
15075 0 ▶sub del_peer {
Subroutine del_peer: not called CC=4 SCAR=30.0
Pod documented
15076 0 my $self = shift;
15077 0 ▶ my $name = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
15078 0 ▶ return if !defined $self->{config}{peers}{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{"peers"}{uc $name} 0 0 0
15079 0 my $rec = delete $self->{config}{peers}{uc $name};
15080 0 ▶ $self->del_service( $rec->{name} ) if $rec->{service};
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"service"} 0 0 0
15081 0 return;
15082 }
15083  
15084 2 ▶sub add_pseudo {
Subroutine add_pseudo: called CC=11 SCAR=31.1
Pod documented
15085 2 my $self = shift;
15086 2 my $parms;
15087 2 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 2 0 2
15088 2 $parms = $_[0];
15089 }
15090 else {
15091 0 $parms = { @_ };
15092 }
15093 2 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
15094  
15095 2 ▶ if (!defined $parms->{cmd} || !defined $parms->{name}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms->{"cmd"} and defined $parms->{"name"} and defined $parms->{"target"}) 0 2 2
Condition33%2/6
defined $parms->{"cmd"} and defined $parms->{"name"} and defined $parms->{"target"}
!ll&&!rl&&r
002
defined $parms->{"cmd"} and defined $parms->{"name"}
!ll&&!rl&&r
002
MC/DC0%0/3
defined $parms->{"cmd"} and defined $parms->{"name"} and defined $parms->{"target"}
defined $parms->{"cmd"} defined $parms->{"name"} defined $parms->{"target"}
Truth table25%1/4
A and B and C
A= defined $parms->{"cmd"}B= defined $parms->{"name"}C= defined $parms->{"target"}
ABCresult
0XX0
10X0
1100
1111
15096 || !defined $parms->{target}) {
15097 0 croak((caller(0))[3].": Not enough parameters specified\n");
15098 0 return;
15099 }
15100  
15101 2 my ($nick,$user,$host) = parse_user( $parms->{target} );
15102  
15103 2 ▶ if (!$nick || !$user || !$host) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nick and $user and $host) 0 2 2
Condition33%2/6
$nick and $user and $host
!ll&&!rl&&r
002
$nick and $user
!ll&&!rl&&r
002
MC/DC0%0/3
$nick and $user and $host
$nick $user $host
Truth table25%1/4
A and B and C
A= $nickB= $userC= $host
ABCresult
0XX0
10X0
1100
1111
15104 0 croak((caller(0))[3].": target is invalid\n");
15105 0 return;
15106 }
15107  
15108 2 $parms->{nick} = $nick;
15109 2 $parms->{user} = $user;
15110 2 $parms->{host} = $host;
15111  
15112 2 my $cmd = delete $parms->{cmd};
15113 2 $cmd = uc $cmd;
15114  
15115 2 ▶ if (defined $self->{config}{cmds}{$cmd} || defined $self->{config}{pseudo}{$cmd}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"config"}{"cmds"}{$cmd} or defined $self->{"config"}{"pseudo"}{$cmd}) 0 2 2
Condition33%1/3
defined $self->{"config"}{"cmds"}{$cmd} or defined $self->{"config"}{"pseudo"}{$cmd}
l!l&&r!l&&!r
002
MC/DC0%0/2
defined $self->{"config"}{"cmds"}{$cmd} or defined $self->{"config"}{"pseudo"}{$cmd}
defined $self->{"config"}{"cmds"}{$cmd} defined $self->{"config"}{"pseudo"}{$cmd}
Truth table33%1/3
A or B
A= defined $self->{"config"}{"cmds"}{$cmd}B= defined $self->{"config"}{"pseudo"}{$cmd}
ABresult
1X1
011
000
15116 0 croak((caller(0))[3].": That command already exists\n");
15117 0 return;
15118 }
15119  
15120 2 $self->{config}{pseudo}{$cmd} = $parms;
15121 2 return 1;
15122 }
15123  
15124 0 ▶sub del_pseudo {
Subroutine del_pseudo: not called CC=2 SCAR=17.9
Pod documented
15125 0 my $self = shift;
15126 0 ▶ my $cmd = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
15127 0 delete $self->{config}{pseudo}{uc $cmd};
15128 0 return 1;
15129 }
15130  
15131 237 ▶sub _terminate_conn_error {
Subroutine _terminate_conn_error: called CC=6 SCAR=18.0
15132 237 my $self = shift;
15133 237 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2370
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
15134 237 my $msg = shift;
15135 237 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 237 237
15136  
15137 237 $self->disconnect($conn_id, $msg);
15138 237 $self->{state}{conns}{$conn_id}{terminated} = 1;
15139 237 ▶ if ( $self->{state}{conns}{$conn_id}{type} eq 'c' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"conns"}{$conn_id}{"type"} eq "c") 202 35 237
15140 202 my $conn = $self->{state}{conns}{$conn_id};
15141 $self->_send_to_realops(
15142 sprintf(
15143 'Client exiting: %s (%s@%s) [%s] [%s]',
15144 $conn->{nick},
15145 $conn->{auth}{ident},
15146 $conn->{auth}{realhost},
15147 202 $conn->{socket}[0],
15148 $msg,
15149 ),
15150 'Notice',
15151 'c',
15152 );
15153 }
15154 $self->send_output(
15155 {
15156 237 command => 'ERROR',
15157 params => [
15158 'Closing Link: ' . $self->_client_ip($conn_id)
15159 . ' (' . $msg . ')',
15160 ],
15161 },
15162 $conn_id,
15163 );
15164  
15165 237 foreach my $nick ( keys %{ $self->{state}{pending} }) {
15166 19 my $id = $self->{state}{pending}{$nick};
15167 19 ▶ if ($id == $conn_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id == $conn_id) 19 0 19
15168 19 delete $self->{state}{pending}{$nick};
15169 19 last;
15170 }
15171 }
15172  
15173 237 return 1;
15174 }
15175  
15176 4 ▶sub daemon_server_join {
Subroutine daemon_server_join: called CC=9 SCAR=27.0
Pod documented
15177 4 my $self = shift;
15178 4 my $server = $self->server_name();
15179 4 my $mysid = $self->server_sid();
15180 4 my $ref = [ ];
15181 4 my $args = [ @_ ];
15182 4 my $count = @$args;
15183  
15184 SWITCH: {
15185 4 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 4 4
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
004
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
15186 0 last SWITCH;
15187 }
15188 4 ▶ if ( $args->[0] =~ m!^\d! && !$self->state_uid_exists($args->[0]) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])) { } 0 4 4
elsif (not $args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])) { } 0 4 4
Condition33%1/3
$args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])
!ll&&!rl&&r
400
MC/DC0%0/2
$args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])
$args->[0] =~ /^\d/ not $self->state_uid_exists($args->[0])
Truth table33%1/3
A and not(B)
A= $args->[0] =~ /^\d/B= not $self->state_uid_exists($args->[0])
ABresult
0X0
100
111
15189 0 last SWITCH;
15190 }
15191 ▶ elsif ( $args->[0] !~ m!^\d! && !$self->state_nick_exists($args->[0])) {
Condition33%1/3
$args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])
l!l&&r!l&&!r
040
MC/DC0%0/2
$args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])
$args->[0] =~ /^\d/ $self->state_nick_exists($args->[0])
Truth table33%1/3
A || B
A= $args->[0] =~ /^\d/B= $self->state_nick_exists($args->[0])
ABresult
1X1
011
000
15192 0 last SWITCH;
15193 }
15194 4 ▶ if ( $args->[1] !~ m!^[#&]! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[1] =~ /^[#&]/) 0 4 4
15195 0 last SWITCH;
15196 }
15197 4 $ref = $self->_daemon_peer_svsjoin( 'spoofed', $mysid, @$args );
15198 }
15199  
15200 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
15201 4 return $ref;
15202 }
15203  
15204 7 ▶sub daemon_server_kill {
Subroutine daemon_server_kill: called CC=14 SCAR=28.1
Pod documented
15205 7 my $self = shift;
15206 7 my $server = $self->server_name();
15207 7 my $mysid = $self->server_sid();
15208 7 my $ref = [ ];
15209 7 my $args = [ @_ ];
15210 7 my $count = @$args;
15211  
15212 SWITCH: {
15213 7 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 7 7
15214 0 last SWITCH;
15215 }
15216 7 ▶ if ( $args->[0] =~ m!^\d! && !$self->state_uid_exists($args->[0]) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])) { } 0 7 7
elsif (not $args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])) { } 0 7 7
Condition33%1/3
$args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])
!ll&&!rl&&r
070
MC/DC0%0/2
$args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])
$args->[0] =~ /^\d/ not $self->state_uid_exists($args->[0])
Truth table33%1/3
A and not(B)
A= $args->[0] =~ /^\d/B= not $self->state_uid_exists($args->[0])
ABresult
0X0
100
111
15217 0 last SWITCH;
15218 }
15219 ▶ elsif ( $args->[0] !~ m!^\d! && !$self->state_nick_exists($args->[0])) {
Condition33%1/3
$args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])
l!l&&r!l&&!r
700
MC/DC0%0/2
$args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])
$args->[0] =~ /^\d/ $self->state_nick_exists($args->[0])
Truth table33%1/3
A || B
A= $args->[0] =~ /^\d/B= $self->state_nick_exists($args->[0])
ABresult
1X1
011
000
15220 0 last SWITCH;
15221 }
15222  
15223  
15224 7 my $target = $self->state_user_nick($args->[0]);
15225 7 ▶ my $comment = $args->[1] || '<No reason given>';
Condition50%1/2
$args->[1] || '<No reason given>'
l!l
70
MC/DC0%0/1
$args->[1] || '<No reason given>'
$args->[1]
Truth table50%1/2
A
A= $args->[1]
Aresult
11
00
15226 7 ▶ my $conn_id = ($args->[2] && $self->_connection_exists($args->[2])
Branch: 1 branch
BranchTrueFalseTotal
$args->[2] && $self->_connection_exists($args->[2]) ? : 1 6 7
Condition66%2/3
$args->[2] and $self->_connection_exists($args->[2])
!ll&&!rl&&r
601
MC/DC50%1/2
$args->[2] and $self->_connection_exists($args->[2])
$args->[2] $self->_connection_exists($args->[2])
Truth table66%2/3
A and B
A= $args->[2]B= $self->_connection_exists($args->[2])
ABresult
0X0
100
111
15227 ? $args->[2]
15228 : '');
15229  
15230 7 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 6 1 7
15231 6 my $route_id = $self->_state_user_route($target);
15232 6 $self->send_output(
15233 {
15234 prefix => $server,
15235 command => 'KILL',
15236 params => [$target, $comment],
15237 },
15238 $route_id,
15239 );
15240 $self->send_output(
15241 {
15242 prefix => $mysid,
15243 command => 'KILL',
15244 params => [
15245 $self->state_user_uid($target),
15246 join('!', $server, $target )." ($comment)",
15247 ],
15248 },
15249 6 ▶ grep { !$conn_id || $_ ne $conn_id }
Condition100%3/3
!$conn_id || $_ ne $conn_id
l!l&&r!l&&!r
711
MC/DC100%2/2
!$conn_id || $_ ne $conn_id
!$conn_id $_ ne $conn_id
Truth table100%3/3
not(A) || B
A= !$conn_idB= $_ ne $conn_id
ABresult
1X1
011
000
15250 $self->_state_connected_peers(),
15251 );
15252 6 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 3 3 6
15253 3 $self->call(
15254 'del_spoofed_nick',
15255 $target,
15256 "Killed ($server ($comment))",
15257 );
15258 }
15259 else {
15260 3 $self->{state}{conns}{$route_id}{killed} = 1;
15261 3 $self->_terminate_conn_error(
15262 $route_id,
15263 "Killed ($server ($comment))",
15264 );
15265 }
15266 }
15267 else {
15268 1 my $tuid = $self->state_user_uid( $target );
15269 1 $self->{state}{uids}{$tuid}{killed} = 1;
15270 $self->send_output(
15271 {
15272 prefix => $mysid,
15273 command => 'KILL',
15274 params => [$tuid, "$server ($comment)"],
15275 },
15276 1 ▶ grep { !$conn_id || $_ ne $conn_id }
Condition33%1/3
!$conn_id || $_ ne $conn_id
l!l&&r!l&&!r
200
MC/DC0%0/2
!$conn_id || $_ ne $conn_id
!$conn_id $_ ne $conn_id
Truth table33%1/3
not(A) || B
A= !$conn_idB= $_ ne $conn_id
ABresult
1X1
011
000
15277 $self->_state_connected_peers(),
15278 );
15279 $self->send_output(
15280 1 @{ $self->_daemon_peer_quit(
15281 $tuid,
15282 "Killed ($server ($comment))"
15283 ) });
15284 }
15285 }
15286  
15287 7 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 7 7
15288 7 return $ref;
15289 }
15290  
15291 10 ▶sub daemon_server_mode {
Subroutine daemon_server_mode: called CC=53 SCAR=59.0
Pod documented
15292 10 my $self = shift;
15293 10 my $chan = shift;
15294 10 my $server = $self->server_name();
15295 10 my $sid = $self->server_sid();
15296 10 my $ref = [ ];
15297 10 my $args = [ @_ ];
15298 10 my $count = @$args;
15299  
15300 SWITCH: {
15301 10 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 10 10
15302 0 last SWITCH;
15303 }
15304 10 my $record = $self->{state}{chans}{uc_irc($chan)};
15305 10 $chan = $record->{name};
15306 10 my $mode_u_set = ( $record->{mode} =~ /u/ );
15307 10 my $full = $server;
15308 10 my %subs; my @reply_args; my $reply;
15309 10 my $parsed_mode = parse_mode_line(@$args);
15310  
15311 10 ▶ while(my $mode = shift (@{ $parsed_mode->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 13 10 23
15312 13 ▶ next if $mode !~ /^[+-][CceIbkMNRSTLOlimnpstohuv]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $mode =~ /^[+-][CceIbkMNRSTLOlimnpstohuv]$/ 0 13 13
15313 13 my $arg;
15314 13 ▶ if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) 3 10 13
15315 3 $arg = shift @{ $parsed_mode->{args} };
15316 }
15317 13 ▶ if (my ($flag, $char) = $mode =~ /^([-+])([ohv])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^([-+])([ohv])/) 2 11 13
15318  
15319 2 ▶ if ($flag eq '+'
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/) 2 0 2
Condition33%1/3
$flag eq "+" and not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
!ll&&!rl&&r
002
MC/DC0%0/2
$flag eq "+" and not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
$flag eq "+" not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
Truth table33%1/3
A and not(B)
A= $flag eq "+"B= not $record->{"users"}{$self->state_user_uid($arg)} =~ /$char/
ABresult
0X0
100
111
15320 && $record->{users}{$self->state_user_uid($arg)} !~ /$char/) {
15321 # Update user and chan record
15322 2 $arg = $self->state_user_uid($arg);
15323 $record->{users}{$arg} = join('', sort
15324 2 split //, $record->{users}{$arg} . $char);
15325 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
15326 2 = $record->{users}{$arg};
15327 2 $reply .= $mode;
15328 2 my $anick = $self->state_user_nick($arg);
15329 2 $subs{$anick} = $arg;
15330 2 push @reply_args, $anick;
15331 }
15332  
15333 2 ▶ if ($flag eq '-' && $record->{users}{uc_irc($arg)}
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/) 0 2 2
Condition33%1/3
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
!ll&&!rl&&r
200
MC/DC0%0/2
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
$flag eq "-" $record->{"users"}{uc_irc($arg)} =~ /$char/
Truth table33%1/3
A and B
A= $flag eq "-"B= $record->{"users"}{uc_irc($arg)} =~ /$char/
ABresult
0X0
100
111
15334 =~ /$char/) {
15335 # Update user and chan record
15336 0 $arg = $self->state_user_uid($arg);
15337 0 $record->{users}{$arg} =~ s/$char//g;
15338 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
15339 0 = $record->{users}{$arg};
15340 0 $reply .= $mode;
15341 0 my $anick = $self->state_user_nick($arg);
15342 0 $subs{$anick} = $arg;
15343 0 push @reply_args, $anick;
15344 }
15345 2 next;
15346 }
15347 11 ▶ if ($mode eq '+l' && $arg =~ /^\d+$/ && $arg > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0) 0 11 11
Condition33%2/6
$mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0
!ll&&!rl&&r
1100
$mode eq "+l" and $arg =~ /^\d+$/
!ll&&!rl&&r
1100
MC/DC0%0/3
$mode eq "+l" and $arg =~ /^\d+$/ and $arg > 0
$mode eq "+l" $arg =~ /^\d+$/ $arg > 0
Truth table25%1/4
A and B and C
A= $mode eq "+l"B= $arg =~ /^\d+$/C= $arg > 0
ABCresult
0XX0
10X0
1100
1111
15348 0 $reply .= $mode;
15349 0 push @reply_args, $arg;
15350 0 ▶ if ($record->{mode} !~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /l/) 0 0 0
15351 $record->{mode} = join('', sort split //,
15352 0 $record->{mode} . 'l');
15353 }
15354 0 $record->{climit} = $arg;
15355 0 next;
15356 }
15357 11 ▶ if ($mode eq '-l' && $record->{mode} =~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "-l" and $record->{"mode"} =~ /l/) 0 11 11
Condition33%1/3
$mode eq "-l" and $record->{"mode"} =~ /l/
!ll&&!rl&&r
1100
MC/DC0%0/2
$mode eq "-l" and $record->{"mode"} =~ /l/
$mode eq "-l" $record->{"mode"} =~ /l/
Truth table33%1/3
A and B
A= $mode eq "-l"B= $record->{"mode"} =~ /l/
ABresult
0X0
100
111
15358 0 $reply .= $mode;
15359 0 $record->{mode} =~ s/l//g;
15360 0 delete $record->{climit};
15361 0 next;
15362 }
15363 11 ▶ if ($mode eq '+k' && $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+k" and $arg) 0 11 11
Condition33%1/3
$mode eq "+k" and $arg
!ll&&!rl&&r
1100
MC/DC0%0/2
$mode eq "+k" and $arg
$mode eq "+k" $arg
Truth table33%1/3
A and B
A= $mode eq "+k"B= $arg
ABresult
0X0
100
111
15364 0 $reply .= $mode;
15365 0 push @reply_args, $arg;
15366 0 ▶ if ($record->{mode} !~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /k/) 0 0 0
15367 $record->{mode} = join('', sort split //,
15368 0 $record->{mode} . 'k');
15369 }
15370 0 $record->{ckey} = $arg;
15371 0 next;
15372 }
15373 11 ▶ if ($mode eq '-k' && $record->{mode} =~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "-k" and $record->{"mode"} =~ /k/) 0 11 11
Condition33%1/3
$mode eq "-k" and $record->{"mode"} =~ /k/
!ll&&!rl&&r
1100
MC/DC0%0/2
$mode eq "-k" and $record->{"mode"} =~ /k/
$mode eq "-k" $record->{"mode"} =~ /k/
Truth table33%1/3
A and B
A= $mode eq "-k"B= $record->{"mode"} =~ /k/
ABresult
0X0
100
111
15374 0 $reply .= $mode;
15375 0 push @reply_args, '*';
15376 0 $record->{mode} =~ s/k//g;
15377 0 delete $record->{ckey};
15378 0 next;
15379 }
15380 # Bans
15381 11 ▶ if (my ($flag) = $mode =~ /(\+|-)b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)b/) 1 10 11
15382 1 my $mask = normalize_mask($arg);
15383 1 my $umask = uc_irc($mask);
15384 1 ▶ if ($flag eq '+' && !$record->{bans}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"bans"}{$umask}) 1 0 1
Condition33%1/3
$flag eq "+" and not $record->{"bans"}{$umask}
!ll&&!rl&&r
001
MC/DC0%0/2
$flag eq "+" and not $record->{"bans"}{$umask}
$flag eq "+" not $record->{"bans"}{$umask}
Truth table33%1/3
A and not(B)
A= $flag eq "+"B= not $record->{"bans"}{$umask}
ABresult
0X0
100
111
15385 1 ▶ $record->{bans}{$umask}
Condition33%1/3
$full || $server
l!l&&r!l&&!r
100
MC/DC0%0/2
$full || $server
$full $server
Truth table33%1/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
15386 = [$mask, ($full || $server), time];
15387 1 $reply .= $mode;
15388 1 push @reply_args, $mask;
15389 }
15390 1 ▶ if ($flag eq '-' and $record->{bans}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"bans"}{$umask}) 0 1 1
Condition33%1/3
$flag eq "-" and $record->{"bans"}{$umask}
!ll&&!rl&&r
100
MC/DC0%0/2
$flag eq "-" and $record->{"bans"}{$umask}
$flag eq "-" $record->{"bans"}{$umask}
Truth table33%1/3
A and B
A= $flag eq "-"B= $record->{"bans"}{$umask}
ABresult
0X0
100
111
15391 0 delete $record->{bans}{$umask};
15392 0 $reply .= $mode;
15393 0 push @reply_args, $mask;
15394 }
15395 1 next;
15396 }
15397 # Invex
15398 10 ▶ if (my ($flag) = $mode =~ /(\+|-)I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)I/) 0 10 10
15399 0 my $mask = normalize_mask($arg);
15400 0 my $umask = uc_irc($mask);
15401 0 ▶ if ($flag eq '+' && !$record->{invex}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"invex"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"invex"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"invex"}{$umask}
$flag eq "+" not $record->{"invex"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"invex"}{$umask}
ABresult
0X0
100
111
15402 0 ▶ $record->{invex}{$umask}
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
15403 = [$mask, ($full || $server), time];
15404 0 $reply .= $mode;
15405 0 push @reply_args, $mask;
15406 }
15407 0 ▶ if ($flag eq '-' && $record->{invex}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"invex"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"invex"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"invex"}{$umask}
$flag eq "-" $record->{"invex"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"invex"}{$umask}
ABresult
0X0
100
111
15408 0 delete $record->{invex}{$umask};
15409 0 $reply .= $mode;
15410 0 push @reply_args, $mask;
15411 }
15412 0 next;
15413 }
15414 # Exceptions
15415 10 ▶ if (my ($flag) = $mode =~ /(\+|-)e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)e/) 0 10 10
15416 0 my $mask = normalize_mask($arg);
15417 0 my $umask = uc_irc($mask);
15418 0 ▶ if ($flag eq '+' && !$record->{excepts}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"excepts"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "+" and not $record->{"excepts"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "+" and not $record->{"excepts"}{$umask}
$flag eq "+" not $record->{"excepts"}{$umask}
Truth table0%0/3
A and not(B)
A= $flag eq "+"B= not $record->{"excepts"}{$umask}
ABresult
0X0
100
111
15419 0 ▶ $record->{excepts}{$umask}
Condition0%0/3
$full || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$full || $server
$full $server
Truth table0%0/3
A || B
A= $fullB= $server
ABresult
1X1
011
000
15420 = [$mask, ($full || $server), time];
15421 0 $reply .= $mode;
15422 0 push @reply_args, $mask;
15423 }
15424 0 ▶ if ($flag eq '-' && $record->{excepts}{$umask}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"excepts"}{$umask}) 0 0 0
Condition0%0/3
$flag eq "-" and $record->{"excepts"}{$umask}
!ll&&!rl&&r
000
MC/DC0%0/2
$flag eq "-" and $record->{"excepts"}{$umask}
$flag eq "-" $record->{"excepts"}{$umask}
Truth table0%0/3
A and B
A= $flag eq "-"B= $record->{"excepts"}{$umask}
ABresult
0X0
100
111
15425 0 delete $record->{excepts}{$umask};
15426 0 $reply .= $mode;
15427 0 push @reply_args, $mask;
15428 }
15429 0 next;
15430 }
15431 # The rest should be argumentless.
15432 10 my ($flag, $char) = split //, $mode;
15433 10 ▶ if ($flag eq '+' && $record->{mode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"mode"} =~ /$char/) 7 3 10
Condition66%2/3
$flag eq "+" and not $record->{"mode"} =~ /$char/
!ll&&!rl&&r
307
MC/DC50%1/2
$flag eq "+" and not $record->{"mode"} =~ /$char/
$flag eq "+" not $record->{"mode"} =~ /$char/
Truth table66%2/3
A and not(B)
A= $flag eq "+"B= not $record->{"mode"} =~ /$char/
ABresult
0X0
100
111
15434 $record->{mode} = join('', sort split //,
15435 7 $record->{mode} . $char);
15436 7 $reply .= $mode;
15437 7 next;
15438 }
15439 3 ▶ if ($flag eq '-' && $record->{mode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"mode"} =~ /$char/) 3 0 3
Condition33%1/3
$flag eq "-" and $record->{"mode"} =~ /$char/
!ll&&!rl&&r
003
MC/DC0%0/2
$flag eq "-" and $record->{"mode"} =~ /$char/
$flag eq "-" $record->{"mode"} =~ /$char/
Truth table33%1/3
A and B
A= $flag eq "-"B= $record->{"mode"} =~ /$char/
ABresult
0X0
100
111
15440 3 $record->{mode} =~ s/$char//g;
15441 3 $reply .= $mode;
15442 3 next;
15443 }
15444 } # while
15445  
15446 10 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 10 0 10
15447 10 $reply = unparse_mode_line($reply);
15448 my @reply_args_peer = map {
15449 10 ▶ ( defined $subs{$_} ? $subs{$_} : $_ )
Branch: 1 branch
BranchTrueFalseTotal
defined $subs{$_} ? : 2 1 3
15450 } @reply_args;
15451 $self->send_output(
15452 {
15453 prefix => $sid,
15454 command => 'TMODE',
15455 10 params => [$record->{ts}, $chan, $reply, @reply_args_peer],
15456 colonify => 0,
15457 },
15458 $self->_state_connected_peers(),
15459 );
15460 $self->_send_output_channel_local(
15461 $record->{name},
15462 {
15463 prefix => $server,
15464 command => 'MODE',
15465 colonify => 0,
15466 params => [
15467 $record->{name},
15468 10 ▶ $reply,
Branch: 1 branch
BranchTrueFalseTotal
$mode_u_set ? : 2 8 10
15469 @reply_args,
15470 ],
15471 },
15472 '', ( $mode_u_set ? 'oh' : '' ),
15473 );
15474 10 ▶ if ($mode_u_set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode_u_set) 2 8 10
15475 2 my $bparse = parse_mode_line( $reply, @reply_args );
15476 2 my $breply; my @breply_args;
15477 2 ▶ while (my $bmode = shift (@{ $bparse->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bmode = shift @{$$bparse{"modes"};}) 2 2 4
15478 2 my $arg;
15479 2 ▶ $arg = shift @{ $bparse->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 1 1 2
15480 if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
15481 2 ▶ next if $bmode =~ m!^[+-][beI]$!;
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^[+-][beI]$/ 1 1 2
15482 1 $breply .= $bmode;
15483 1 ▶ push @breply_args, $arg if $arg;
Branch: 1 branch
BranchTrueFalseTotal
if $arg 0 1 1
15484 }
15485 2 ▶ if ($breply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breply) 1 1 2
15486 1 my $parsed_line = unparse_mode_line($breply);
15487 $self->_send_output_channel_local(
15488 $record->{name},
15489 {
15490 prefix => $server,
15491 command => 'MODE',
15492 colonify => 0,
15493 params => [
15494 $record->{name},
15495 1 $parsed_line,
15496 @breply_args,
15497 ],
15498 },
15499 '','-oh',
15500 );
15501 }
15502 }
15503 }
15504 } # SWITCH
15505  
15506 10 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 10 10
15507 10 return $ref;
15508 }
15509  
15510 2 ▶sub daemon_server_kick {
Subroutine daemon_server_kick: called CC=9 SCAR=24.3
Pod documented
15511 2 my $self = shift;
15512 2 my $server = $self->server_name();
15513 2 my $sid = $self->server_sid();
15514 2 my $ref = [ ];
15515 2 my $args = [ @_ ];
15516 2 my $count = @$args;
15517  
15518 SWITCH: {
15519 2 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 2 2
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
002
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
15520 0 last SWITCH;
15521 }
15522 2 my $chan = (split /,/, $args->[0])[0];
15523 2 my $who = (split /,/, $args->[1])[0];
15524 2 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 2 2
15525 0 last SWITCH;
15526 }
15527 2 $chan = $self->_state_chan_name($chan);
15528 2 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 2 2
15529 0 last SWITCH;
15530 }
15531 2 $who = $self->state_user_nick($who);
15532 2 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 2 2
15533 0 last SWITCH;
15534 }
15535 2 my $wuid = $self->state_user_uid($who);
15536 2 ▶ my $comment = $args->[2] || $who;
Condition33%1/3
$args->[2] || $who
l!l&&r!l&&!r
200
MC/DC0%0/2
$args->[2] || $who
$args->[2] $who
Truth table33%1/3
A || B
A= $args->[2]B= $who
ABresult
1X1
011
000
15537 2 $self->send_output(
15538 {
15539 prefix => $sid,
15540 command => 'KICK',
15541 params => [$chan, $wuid, $comment],
15542 },
15543 $self->_state_connected_peers(),
15544 );
15545 2 $self->_send_output_channel_local(
15546 $chan,
15547 {
15548 prefix => $server,
15549 command => 'KICK',
15550 params => [$chan, $who, $comment],
15551 },
15552 );
15553 2 $chan = uc_irc($chan);
15554 2 delete $self->{state}{chans}{$chan}{users}{$wuid};
15555 2 delete $self->{state}{uids}{$wuid}{chans}{$chan};
15556 2 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 2 2
15557 0 delete $self->{state}{chans}{$chan};
15558 }
15559 }
15560  
15561 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
15562 2 return $ref;
15563 }
15564  
15565 1 ▶sub daemon_server_remove {
Subroutine daemon_server_remove: called CC=9 SCAR=23.5
Pod documented
15566 1 my $self = shift;
15567 1 my $server = $self->server_name();
15568 1 my $ref = [ ];
15569 1 my $args = [ @_ ];
15570 1 my $count = @$args;
15571  
15572 SWITCH: {
15573 1 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 1 1
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
not $count or $count < 2
not $count $count < 2
Truth table33%1/3
not(A) or B
A= not $countB= $count < 2
ABresult
1X1
011
000
15574 0 last SWITCH;
15575 }
15576 1 my $chan = (split /,/, $args->[0])[0];
15577 1 my $who = (split /,/, $args->[1])[0];
15578 1 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 1 1
15579 0 last SWITCH;
15580 }
15581 1 $chan = $self->_state_chan_name($chan);
15582 1 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 1 1
15583 0 last SWITCH;
15584 }
15585 1 my $fullwho = $self->state_user_full($who);
15586 1 $who = (split /!/, $who)[0];
15587 1 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 1 1
15588 0 last SWITCH;
15589 }
15590 1 my $wuid = $self->state_user_uid($who);
15591 1 my $comment = 'Enforced PART';
15592 1 ▶ $comment .= " \"$args->[2]\"" if $args->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[2] 1 0 1
15593 1 $self->send_output(
15594 {
15595 prefix => $wuid,
15596 command => 'PART',
15597 params => [$chan, $comment],
15598 },
15599 $self->_state_connected_peers(),
15600 );
15601 1 $self->_send_output_channel_local(
15602 $chan,
15603 {
15604 prefix => $fullwho,
15605 command => 'PART',
15606 params => [$chan, $comment],
15607 },
15608 );
15609 1 $chan = uc_irc($chan);
15610 1 delete $self->{state}{chans}{$chan}{users}{$wuid};
15611 1 delete $self->{state}{uids}{$wuid}{chans}{$chan};
15612 1 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 1 0 1
15613 1 delete $self->{state}{chans}{$chan};
15614 }
15615 }
15616  
15617 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
15618 1 return $ref;
15619 }
15620  
15621 0 ▶sub daemon_server_wallops {
Subroutine daemon_server_wallops: not called CC=3 SCAR=24.8
Pod documented
15622 0 my $self = shift;
15623 0 my $server = $self->server_name();
15624 0 my $sid = $self->server_sid();
15625 0 my $ref = [ ];
15626 0 my $args = [ @_ ];
15627 0 my $count = @$args;
15628  
15629 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
15630 0 $self->send_output(
15631 {
15632 prefix => $sid,
15633 command => 'WALLOPS',
15634 params => [$args->[0]],
15635 },
15636 $self->_state_connected_peers(),
15637 );
15638 $self->send_output(
15639 {
15640 prefix => $server,
15641 command => 'WALLOPS',
15642 params => [$args->[0]],
15643 },
15644 0 keys %{ $self->{state}{wallops} },
15645 );
15646 0 $self->send_event("daemon_wallops", $server, $args->[0]);
15647 }
15648  
15649 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
15650 0 return $ref;
15651 }
15652  
15653 0 ▶sub daemon_server_realops {
Subroutine daemon_server_realops: not called CC=3 SCAR=24.8
Pod documented
15654 0 my $self = shift;
15655 0 my $ref = [ ];
15656 0 my $args = [ @_ ];
15657 0 my $count = @$args;
15658  
15659 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
15660 0 $self->_send_to_realops( @$args );
15661 }
15662  
15663 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
15664 0 return $ref;
15665 }
15666  
15667 41 ▶sub add_spoofed_nick {
Subroutine add_spoofed_nick: called CC=21 SCAR=33.6
Pod documented
15668 41 my ($kernel, $self) = @_[KERNEL, OBJECT];
15669 41 my $ref;
15670 41 ▶ if (ref $_[ARG0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[10] eq 'HASH') { } 41 0 41
15671 41 $ref = $_[ARG0];
15672 }
15673 else {
15674 0 $ref = { @_[ARG0..$#_] };
15675 }
15676  
15677 41 $ref->{ lc $_ } = delete $ref->{$_} for keys %$ref;
15678 41 ▶ return if !$ref->{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->{"nick"} 0 41 41
15679 41 ▶ return if $self->state_nick_exists($ref->{nick});
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_nick_exists($ref->{"nick"}) 0 41 41
15680 41 my $record = $ref;
15681 41 $record->{uid} = $self->_state_gen_uid();
15682 41 $record->{sid} = substr $record->{uid}, 0, 3;
15683 41 ▶ $record->{ts} = time if !$record->{ts};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"ts"} 35 6 41
15684 41 $record->{type} = 's';
15685 41 $record->{server} = $self->server_name();
15686 41 $record->{hops} = 0;
15687 41 $record->{route_id} = 'spoofed';
15688 41 ▶ $record->{umode} = 'i' if !$record->{umode};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"umode"} 0 41 41
15689 41 ▶ if (!defined $record->{ircname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record->{"ircname"}) 31 10 41
15690 31 $record->{ircname} = "* I'm too lame to read the documentation *";
15691 }
15692 41 ▶ $self->{state}{stats}{invisible}++ if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 8 33 41
15693 41 ▶ $self->{state}{stats}{ops_online}++ if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 34 7 41
15694 41 $record->{idle_time} = $record->{conn_time} = $record->{ts};
15695 41 ▶ $record->{auth}{ident} = delete $record->{user} || $record->{nick};
Condition33%1/3
delete $record->{'user'} || $record->{'nick'}
l!l&&r!l&&!r
0410
MC/DC0%0/2
delete $record->{'user'} || $record->{'nick'}
delete $record->{'user'} $record->{'nick'}
Truth table33%1/3
A || B
A= delete $record->{'user'}B= $record->{'nick'}
ABresult
1X1
011
000
15696 $record->{auth}{hostname} = delete $record->{hostname}
15697 41 ▶ || $self->server_name();
Condition33%1/3
delete $record->{'hostname'} || $self->server_name
l!l&&r!l&&!r
0410
MC/DC0%0/2
delete $record->{'hostname'} || $self->server_name
delete $record->{'hostname'} $self->server_name
Truth table33%1/3
A || B
A= delete $record->{'hostname'}B= $self->server_name
ABresult
1X1
011
000
15698 41 $record->{auth}{realhost} = $record->{auth}{hostname};
15699 41 ▶ $record->{account} = '*' if !$record->{account};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"account"} 41 0 41
15700 41 $record->{ipaddress} = 0;
15701 41 $self->{state}{users}{uc_irc($record->{nick})} = $record;
15702 41 ▶ $self->{state}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 41 0 41
15703 41 $self->{state}{peers}{uc $record->{server}}{users}{uc_irc($record->{nick})} = $record;
15704 41 ▶ $self->{state}{peers}{uc $record->{server}}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 41 0 41
15705  
15706 82 ▶ $record->{full} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
15707 return sprintf('%s!%s@%s',
15708 $record->{nick},
15709 $record->{auth}{ident},
15710 82 $record->{auth}{hostname});
15711 41 };
15712  
15713 my $arrayref = [
15714 $record->{nick},
15715 $record->{hops} + 1,
15716 $record->{ts},
15717 '+' . $record->{umode},
15718 $record->{auth}{ident},
15719 $record->{auth}{hostname},
15720 $record->{ipaddress},
15721 $record->{uid},
15722 $record->{account},
15723 $record->{ircname},
15724 41 ];
15725  
15726 my $rhostref = [
15727 $record->{nick},
15728 $record->{hops} + 1,
15729 $record->{ts},
15730 '+' . $record->{umode},
15731 $record->{auth}{ident},
15732 $record->{auth}{hostname},
15733 $record->{auth}{realhost},
15734 $record->{ipaddress},
15735 $record->{uid},
15736 $record->{account},
15737 $record->{ircname},
15738 41 ];
15739  
15740 41 ▶ if (my $whois = $record->{whois}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $whois = $record->{"whois"}) 0 41 41
15741 0 $record->{svstags}{313} = {
15742 numeric => '313',
15743 umodes => '+',
15744 tagline => $whois,
15745 };
15746 }
15747  
15748 41 foreach my $peer_id ( $self->_state_connected_peers() ) {
15749 0 ▶ if ( $self->_state_peer_capab( $peer_id, 'RHOST' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_peer_capab($peer_id, 'RHOST')) { } 0 0 0
15750 $self->send_output(
15751 {
15752 prefix => $record->{sid},
15753 0 command => 'UID',
15754 params => $rhostref,
15755 },
15756 $peer_id,
15757 );
15758 }
15759 else {
15760 $self->send_output(
15761 {
15762 prefix => $record->{sid},
15763 0 command => 'UID',
15764 params => $arrayref,
15765 },
15766 $peer_id,
15767 );
15768 }
15769 $self->send_output(
15770 {
15771 prefix => $record->{sid},
15772 command => 'SVSTAG',
15773 params => [
15774 $record->{uid},
15775 $record->{ts},
15776 '313', '+', $record->{whois},
15777 ],
15778 },
15779 $peer_id,
15780 0 ▶ ) if $record->{whois};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"whois"} 0 0 0
15781 }
15782  
15783  
15784 41 $self->send_event('daemon_uid', @$arrayref);
15785 41 ▶ $self->send_event('daemon_nick', @{ $arrayref }[0..5], $record->{server}, ( $arrayref->[9] || '' ) );
Condition50%1/2
$arrayref->[9] || ''
l!l
410
MC/DC0%0/1
$arrayref->[9] || ''
$arrayref->[9]
Truth table50%1/2
A
A= $arrayref->[9]
Aresult
11
00
15786 41 ▶ if ( $record->{umode} =~ /o/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /o/) 34 7 41
15787 34 my $notice = sprintf("%s{%s} is now an operator",$record->{full}->(),$record->{nick});
15788 34 $self->_send_to_realops($notice);
15789 }
15790 41 $self->_state_update_stats();
15791 41 return;
15792 }
15793  
15794 9 ▶sub del_spoofed_nick {
Subroutine del_spoofed_nick: called CC=7 SCAR=23.0
Pod documented
15795 9 my ($kernel, $self, $nick) = @_[KERNEL, OBJECT, ARG0];
15796 9 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 0 9 9
15797 0 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 0 0 0
15798 0 ▶ return if $self->_state_uid_route($nick) ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_uid_route($nick) ne "spoofed" 0 0 0
15799 }
15800 else {
15801 9 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 9 9
15802 9 ▶ return if $self->_state_user_route($nick) ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_route($nick) ne "spoofed" 0 9 9
15803 }
15804 9 $nick = $self->state_user_nick($nick);
15805  
15806 9 ▶ my $message = $_[ARG1] || 'Client Quit';
Condition100%2/2
$_[11] || 'Client Quit'
l!l
36
MC/DC100%1/1
$_[11] || 'Client Quit'
$_[11]
Truth table100%2/2
A
A= $_[11]
Aresult
11
00
15807 $self->send_output(
15808 9 @{ $self->_daemon_cmd_quit($nick, qq{"$message"}) },
15809 qq{"$message"},
15810 );
15811 9 return;
15812 }
15813  
15814 31 ▶sub _spoofed_command {
Subroutine _spoofed_command: called CC=9 SCAR=24.1
15815 31 my ($kernel, $self, $state, $nick) = @_[KERNEL, OBJECT, STATE, ARG0];
15816 31 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 31 31
15817 31 ▶ return if $self->_state_user_route($nick) ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_route($nick) ne "spoofed" 0 31 31
15818  
15819 31 $nick = $self->state_user_nick($nick);
15820 31 my $uid = $self->state_user_uid($nick);
15821 31 $state =~ s/daemon_cmd_//;
15822 31 my $command = "_daemon_cmd_" . $state;
15823  
15824 31 ▶ if ($state =~ /^(privmsg|notice)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state =~ /^(privmsg|notice)$/) { } 0 31 31
elsif ($state eq 'sjoin') { } 1 30 31
15825 0 my $type = uc $1;
15826 0 $self->_daemon_cmd_message($nick, $type, @_[ARG1 .. $#_]);
15827 0 return;
15828 }
15829 elsif ($state eq 'sjoin') {
15830 1 my $chan = $_[ARG1];
15831 1 ▶ return if !$chan || !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $chan and $self->state_chan_exists($chan) 0 1 1
Condition33%1/3
$chan and $self->state_chan_exists($chan)
!ll&&!rl&&r
001
MC/DC0%0/2
$chan and $self->state_chan_exists($chan)
$chan $self->state_chan_exists($chan)
Truth table33%1/3
A and B
A= $chanB= $self->state_chan_exists($chan)
ABresult
0X0
100
111
15832 1 ▶ return if $self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_is_chan_member($nick, $chan) 0 1 1
15833 1 $chan = $self->_state_chan_name($chan);
15834 1 my $ts = $self->_state_chan_timestamp($chan) - 10;
15835 1 $self->_daemon_peer_sjoin(
15836 'spoofed',
15837 $self->server_sid(),
15838 $ts,
15839 $chan,
15840 '+nt',
15841 '@' . $uid,
15842 );
15843 1 return;
15844 }
15845  
15846 30 ▶ $self->$command($nick, @_[ARG1 .. $#_]) if $self->can($command);
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($command) 30 0 30
15847 30 return;
15848 }
15849  
15850 180 1;
15851  
15852 =encoding utf8
15853  
15854 =head1 NAME
15855  
15856 POE::Component::Server::IRC - A fully event-driven networkable IRC server daemon module.
15857  
15858 =head1 SYNOPSIS
15859  
15860 # A fairly simple example:
15861 use strict;
15862 use warnings;
15863 use POE qw(Component::Server::IRC);
15864  
15865 my %config = (
15866 servername => 'simple.poco.server.irc',
15867 nicklen => 15,
15868 network => 'SimpleNET'
15869 );
15870  
15871 my $pocosi = POE::Component::Server::IRC->spawn( config => \%config );
15872  
15873 POE::Session->create(
15874 package_states => [
15875 'main' => [qw(_start _default)],
15876 ],
15877 heap => { ircd => $pocosi },
15878 );
15879  
15880 $poe_kernel->run();
15881  
15882 sub _start {
15883 my ($kernel, $heap) = @_[KERNEL, HEAP];
15884  
15885 $heap->{ircd}->yield('register', 'all');
15886  
15887 # Anyone connecting from the loopback gets spoofed hostname
15888 $heap->{ircd}->add_auth(
15889 mask => '*@localhost',
15890 spoof => 'm33p.com',
15891 no_tilde => 1,
15892 );
15893  
15894 # We have to add an auth as we have specified one above.
15895 $heap->{ircd}->add_auth(mask => '*@*');
15896  
15897 # Start a listener on the 'standard' IRC port.
15898 $heap->{ircd}->add_listener(port => 6667);
15899  
15900 # Add an operator who can connect from localhost
15901 $heap->{ircd}->add_operator(
15902 {
15903 username => 'moo',
15904 password => 'fishdont',
15905 }
15906 );
15907 }
15908  
15909 sub _default {
15910 my ($event, $args) = @_[ARG0 .. $#_];
15911  
15912 print "$event: ";
15913 for my $arg (@$args) {
15914 if (ref($arg) eq 'ARRAY') {
15915 print "[", join ( ", ", @$arg ), "] ";
15916 }
15917 elsif (ref($arg) eq 'HASH') {
15918 print "{", join ( ", ", %$arg ), "} ";
15919 }
15920 else {
15921 print "'$arg' ";
15922 }
15923 }
15924  
15925 print "\n";
15926 }
15927  
15928 =head1 DESCRIPTION
15929  
15930 POE::Component::Server::IRC is a POE component which implements an IRC
15931 server (also referred to as an IRC daemon or IRCd). It should be compliant
15932 with the pertient IRC RFCs and is based on reverse engineering Hybrid IRCd
15933 behaviour with regards to interactions with IRC clients and other IRC
15934 servers.
15935  
15936 Yes, that's right. POE::Component::Server::IRC is capable of linking to
15937 foreign IRC networks. It supports the TS6 server to server protocol and
15938 has been tested with linking to Hybrid-8 based networks. It should in
15939 theory work with any TS6-based IRC network.
15940  
15941 POE::Component::Server::IRC also has a services API, which enables one to
15942 extend the IRCd to create IRC Services. This is fully event-driven (of
15943 course =]). There is also a Plugin system, similar to that sported by
15944 L<POE::Component::IRC|POE::Component::IRC>.
15945  
15946 B<Note:> This is a subclass of
15947 L<POE::Component::Server::IRC::Backend|POE::Component::Server::IRC::Backend>.
15948 You should read its documentation too.
15949  
15950 =head1 CONSTRUCTOR
15951  
15952 =head2 C<spawn>
15953  
15954 Returns a new instance of the component. Takes the following parameters:
15955  
15956 =over 4
15957  
15958 =item * B<'config'>, a hashref of configuration options, see the
15959 L<C<configure>|/configure> method for details.
15960  
15961 =back
15962  
15963 Any other parameters will be passed along to
15964 L<POE::Component::Server::IRC::Backend|POE::Component::Server::IRC::Backend>'s
15965 L<C<create>|POE::Component::Server::IRC::Backend/create> method.
15966  
15967 If the component is spawned from within another session then that session
15968 will automagically be registered with the component to receive events and
15969 be sent an L<C<ircd_registered>|POE::Component::IRC::Server::Backend/ircd_registered>
15970 event.
15971  
15972 =head1 METHODS
15973  
15974 =head2 Information
15975  
15976 =head3 C<server_name>
15977  
15978 No arguments, returns the name of the ircd.
15979  
15980 =head3 C<server_version>
15981  
15982 No arguments, returns the software version of the ircd.
15983  
15984 =head3 C<server_created>
15985  
15986 No arguments, returns a string signifying when the ircd was created.
15987  
15988 =head3 C<server_config>
15989  
15990 Takes one argument, the server configuration value to query.
15991  
15992 =head2 Configuration
15993  
15994 These methods provide mechanisms for configuring and controlling the IRCd
15995 component.
15996  
15997 =head3 C<configure>
15998  
15999 Configures your new shiny IRCd.
16000  
16001 Takes a number of parameters:
16002  
16003 =over 4
16004  
16005 =item * B<'servername'>, a name to bless your shiny new IRCd with,
16006 defaults to 'poco.server.irc';
16007  
16008 =item * B<'serverdesc'>, a description for your IRCd, defaults to
16009 'Poco? POCO? POCO!';
16010  
16011 =item * B<'network'>, the name of the IRC network you will be creating,
16012 defaults to 'poconet';
16013  
16014 =item * B<'nicklen'>, the max length of nicknames to support, defaults
16015 to 9. B<Note>: the nicklen must be the same on all servers on your IRC
16016 network;
16017  
16018 =item * B<'maxtargets'>, max number of targets a user can send
16019 PRIVMSG/NOTICE's to, defaults to 4;
16020  
16021 =item * B<'maxchannels'>, max number of channels users may join, defaults
16022 to 15;
16023  
16024 =item * B<'version'>, change the server version that is reported;
16025  
16026 =item * B<'admin'>, an arrayref consisting of the 3 lines that will be
16027 returned by ADMIN;
16028  
16029 =item * B<'info'>, an arrayref consisting of lines to be returned by INFO;
16030  
16031 =item * B<'ophacks'>, set to true to enable oper hacks. Default is false;
16032  
16033 =item * B<'whoisactually'>, setting this to a false value means that only
16034 opers can see 338. Defaults to true;
16035  
16036 =item * B<'sid'>, servers unique ID. This is three characters long and must be in
16037 the form [0-9][A-Z0-9][A-Z0-9]. Specifying this enables C<TS6>.
16038  
16039 =back
16040  
16041 =head3 C<add_auth>
16042  
16043 By default the IRCd allows any user to connect to the server without a
16044 password. Configuring auths enables you to control who can connect and
16045 set passwords required to connect.
16046  
16047 Takes the following parameters:
16048  
16049 =over 4
16050  
16051 =item * B<'mask'>, a user@host or user@ipaddress mask to match against,
16052 mandatory;
16053  
16054 =item * B<'password'>, if specified, any client matching the mask must
16055 provide this to connect;
16056  
16057 =item * B<'spoof'>, if specified, any client matching the mask will have
16058 their hostname changed to this;
16059  
16060 =item * B<'no_tilde'>, if specified, the '~' prefix is removed from their
16061 username;
16062  
16063 =item * B<'exceed_limit'>, if specified, any client matching the mask will not
16064 have their connection limited, if the server is full;
16065  
16066 =item * B<'kline_exempt'>, if true, any client matching the mask will be exempt
16067 from KLINEs and RKLINEs;
16068  
16069 =item * B<'resv_exempt'>, if true, any client matching the mask will be exempt
16070 from RESVs;
16071  
16072 =item * B<'can_flood'>, if true, any client matching the mask will be exempt
16073 from flood protection;
16074  
16075 =item * B<'need_ident'>, if true, any client matching the mask will be
16076 required to have a valid response to C<Ident> queries;
16077  
16078 =back
16079  
16080 Auth masks are processed in order of addition.
16081  
16082 If auth masks have been defined, then a connecting user *must* match one
16083 of the masks in order to be authorised to connect. This is a feature >;)
16084  
16085 =head3 C<del_auth>
16086  
16087 Takes a single argument, the mask to remove.
16088  
16089 =head3 C<add_operator>
16090  
16091 This adds an O line to the IRCd. Takes a number of parameters:
16092  
16093 =over 4
16094  
16095 =item * B<'username'>, the username of the IRC oper, mandatory;
16096  
16097 =item * B<'password'>, the password, mandatory;
16098  
16099 =item * B<'ipmask'>, either a scalar ipmask or an arrayref of addresses or CIDRs
16100 as understood by L<Net::CIDR>::cidrvalidate;
16101  
16102 =item * B<'ssl_required'>, set to true to require that the oper is connected
16103 securely using SSL/TLS;
16104  
16105 =item * B<'certfp'>, specify the fingerprint of the oper's client certificate
16106 to verify;
16107  
16108 =back
16109  
16110 A scalar ipmask can contain '*' to match any number of characters or '?' to
16111 match one character. If no 'ipmask' is provided, operators are only allowed
16112 to OPER from the loopback interface.
16113  
16114 B<'password'> can be either plain-text, L<C<crypt>|crypt>'d or unix/apache
16115 md5. See the C<mkpasswd> function in
16116 L<POE::Component::Server::IRC::Common|POE::Component::Server::IRC::Common>
16117 for how to generate passwords.
16118  
16119 B<'ssl_required'> and B<'certfp'> obviously both require that the server
16120 supports SSL/TLS connections. B<'certfp'> is the SHA256 digest fingerprint
16121 of the client certificate. This can be obtained from the PEM formated cert
16122 using one of the following methods:
16123  
16124 OpenSSL/LibreSSL:
16125 openssl x509 -sha256 -noout -fingerprint -in cert.pem | sed -e 's/^.*=//;s/://g'
16126  
16127 GnuTLS:
16128 certtool -i < cert.pem | egrep -A 1 'SHA256 fingerprint'
16129  
16130 =head3 C<del_operator>
16131  
16132 Takes a single argument, the username to remove.
16133  
16134 =head3 C<add_peer>
16135  
16136 Adds peer servers that we will allow to connect to us and who we will
16137 connect to. Takes the following parameters:
16138  
16139 =over 4
16140  
16141 =item * B<'name'>, the name of the server. This is the IRC name, not
16142 hostname, mandatory;
16143  
16144 =item * B<'pass'>, the password they must supply to us, mandatory;
16145  
16146 =item * B<'rpass'>, the password we need to supply to them, mandatory;
16147  
16148 =item * B<'type'>, the type of server, 'c' for a connecting server, 'r'
16149 for one that we will connect to;
16150  
16151 =item * B<'raddress'>, the remote address to connect to, implies 'type'
16152 eq 'r';
16153  
16154 =item * B<'rport'>, the remote port to connect to, default is 6667;
16155  
16156 =item * B<'ipmask'>, either a scalar ipmask or an arrayref of addresses or CIDRs
16157 as understood by L<Net::CIDR>::cidrvalidate;
16158  
16159 =item * B<'auto'>, if set to true value will automatically connect to
16160 remote server if type is 'r';
16161  
16162 =item * B<'zip'>, set to a true value to enable ziplink support. This must
16163 be done on both ends of the connection. Requires
16164 L<POE::Filter::Zlib::Stream|POE::Filter::Zlib::Stream>;
16165  
16166 =item * B<'service'>, set to a true value to enable the peer to be
16167 accepted as a services peer.
16168  
16169 =item * B<'ssl'>, set to a true value to enable SSL/TLS support. This must
16170 be done on both ends of the connection. Requires L<POE::Component::SSLify>.
16171  
16172 =item * B<'certfp'>, specify the fingerprint of the peer's client certificate
16173 to verify;
16174  
16175 =back
16176  
16177 B<'certfp'> is the SHA256 digest fingerprint of the client certificate.
16178 This can be obtained from the PEM formated cert using one of the following
16179 methods:
16180  
16181 OpenSSL/LibreSSL:
16182 openssl x509 -sha256 -noout -fingerprint -in cert.pem | sed -e 's/^.*=//;s/://g'
16183  
16184 GnuTLS:
16185 certtool -i < cert.pem | egrep -A 1 'SHA256 fingerprint'
16186  
16187 =head3 C<del_peer>
16188  
16189 Takes a single argument, the peer to remove. This does not disconnect the
16190 said peer if it is currently connected.
16191  
16192 =head3 C<add_service>
16193  
16194 Adds a service peer. A service peer is a peer that is accepted to send
16195 service commands C<SVS*>. Takes a single argument the service peer to add.
16196 This does not have to be a directly connected peer as defined with C<add_peer>.
16197  
16198 =head3 C<del_service>
16199  
16200 Takes a single argument, the service peer to remove. This does not disconnect
16201 the said service peer, but it will deny the peer access to service commands.
16202  
16203 =head3 C<add_pseudo>
16204  
16205 Adds a pseudo command, also known as a service alias. The command is transformed
16206 by the server into a C<PRIVMSG> and sent to the given target.
16207  
16208 Takes several arguments:
16209  
16210 =over 4
16211  
16212 =item * B<'cmd'>, (mandatory) command/alias to be added.
16213  
16214 =item * B<'name'>, (mandatory) the service name, eg. NickServ, this is
16215 used in error messages reported to users.
16216  
16217 =item * B<'target'>, (mandatory) the target for the command in nick!user@host
16218 format.
16219  
16220 =item * B<'prepend'>, (optional) text that will prepended to the user's
16221 message.
16222  
16223 =back
16224  
16225 =head3 C<del_pseudo>
16226  
16227 Removes a previously defined pseudo command/alias.
16228  
16229 =head2 State queries
16230  
16231 The following methods allow you to query state information regarding
16232 nicknames, channels, and peers.
16233  
16234 =head3 C<state_nicks>
16235  
16236 Takes no arguments, returns a list of all nicknames in the state.
16237  
16238 =head3 C<state_chans>
16239  
16240 Takes no arguments, returns a list of all channels in the state.
16241  
16242 =head3 C<state_peers>
16243  
16244 Takes no arguments, returns a list of all irc servers in the state.
16245  
16246 =head3 C<state_nick_exists>
16247  
16248 Takes one argument, a nickname, returns true or false dependent on whether
16249 the given nickname exists or not.
16250  
16251 =head3 C<state_chan_exists>
16252  
16253 Takes one argument, a channel name, returns true or false dependent on
16254 whether the given channel exists or not.
16255  
16256 =head3 C<state_peer_exists>
16257  
16258 Takes one argument, a peer server name, returns true or false dependent
16259 on whether the given peer exists or not.
16260  
16261 =head3 C<state_user_full>
16262  
16263 Takes one argument, a nickname, returns that users full nick!user@host
16264 if they exist, undef if they don't.
16265  
16266 If a second argument is provided and the nickname provided is an oper,
16267 then the returned value will be nick!user@host{opuser}
16268  
16269 =head3 C<state_user_nick>
16270  
16271 Takes one argument, a nickname, returns the proper nickname for that user.
16272 Returns undef if the nick doesn't exist.
16273  
16274 =head3 C<state_user_umode>
16275  
16276 Takes one argument, a nickname, returns that users mode setting.
16277  
16278 =head3 C<state_user_is_operator>
16279  
16280 Takes one argument, a nickname, returns true or false dependent on whether
16281 the given nickname is an IRC operator or not.
16282  
16283 =head3 C<state_user_chans>
16284  
16285 Takes one argument, a nickname, returns a list of channels that that nick
16286 is a member of.
16287  
16288 =head3 C<state_user_server>
16289  
16290 Takes one argument, a nickname, returns the name of the peer server that
16291 that user is connected from.
16292  
16293 =head3 C<state_chan_list>
16294  
16295 Takes one argument, a channel name, returns a list of the member nicks on
16296 that channel.
16297  
16298 =head3 C<state_chan_list_prefixed>
16299  
16300 Takes one argument, a channel name, returns a list of the member nicks on
16301 that channel, nicknames will be prefixed with @%+ if they are +o +h or +v,
16302 respectively.
16303  
16304 =head3 C<state_chan_topic>
16305  
16306 Takes one argument, a channel name, returns undef if no topic is set on
16307 that channel, or an arrayref consisting of the topic, who set it and the
16308 time they set it.
16309  
16310 =head3 C<state_chan_mode_set>
16311  
16312 Takes two arguments, a channel name and a channel mode character. Returns
16313 true if that channel mode is set, false otherwise.
16314  
16315 =head3 C<state_is_chan_member>
16316  
16317 Takes two arguments, a nick and a channel name. Returns true if that nick
16318 is on channel, false otherwise.
16319  
16320 =head3 C<state_user_chan_mode>
16321  
16322 Takes two arguments, a nick and a channel name. Returns that nicks status
16323 (+ohv or '') on that channel.
16324  
16325 =head3 C<state_is_chan_op>
16326  
16327 Takes two arguments, a nick and a channel name. Returns true if that nick
16328 is an channel operator, false otherwise.
16329  
16330 =head3 C<state_is_chan_hop>
16331  
16332 Takes two arguments, a nick and a channel name. Returns true if that nick
16333 is an channel half-operator, false otherwise.
16334  
16335 =head3 C<state_has_chan_voice>
16336  
16337 Takes two arguments, a nick and a channel name. Returns true if that nick
16338 has channel voice, false otherwise.
16339  
16340 =head2 Server actions
16341  
16342 =head3 C<daemon_server_kill>
16343  
16344 Takes two arguments, a nickname and a comment (which is optional); Issues
16345 a SERVER KILL of the given nick;
16346  
16347 =head3 C<daemon_server_mode>
16348  
16349 First argument is a channel name, remaining arguments are channel modes
16350 and their parameters to apply.
16351  
16352 =head3 C<daemon_server_join>
16353  
16354 Takes two arguments that are mandatory: a nickname of a user and a channel
16355 name. The user will join the channel.
16356  
16357 =head3 C<daemon_server_kick>
16358  
16359 Takes two arguments that are mandatory and an optional one: channel name,
16360 nickname of the user to kick and a pithy comment.
16361  
16362 =head3 C<daemon_server_remove>
16363  
16364 Takes two arguments that are mandatory and an optional one: channel name,
16365 nickname of the user to remove and a pithy comment.
16366  
16367 =head3 C<daemon_server_wallops>
16368  
16369 Takes one argument, the message text to send.
16370  
16371 =head3 C<daemon_server_realops>
16372  
16373 Sends server notices.
16374  
16375 Takes one mandatory argument, the message text to send.
16376  
16377 Second argument is the notice type, this can be C<Notice>, C<locops>
16378 or C<Globops>. Defaults to C<Notice>.
16379  
16380 Third argument is a umode flag. The notice will be sent to OPERs who
16381 have this umode set. Default is none and the notice will be sent to
16382 all OPERs.
16383  
16384 =head1 INPUT EVENTS
16385  
16386 These are POE events that can be sent to the component.
16387  
16388 =head2 C<add_spoofed_nick>
16389  
16390 Takes a single argument a hashref which should have the following keys:
16391  
16392 =over 4
16393  
16394 =item * B<'nick'>, the nickname to add, mandatory;
16395  
16396 =item * B<'user'>, the ident you want the nick to have, defaults to the
16397 same as the nick;
16398  
16399 =item * B<'hostname'>, the hostname, defaults to the server name;
16400  
16401 =item * B<'umode'>, specify whether this is to be an IRCop etc, defaults
16402 to 'i';
16403  
16404 =item * B<'ts'>, unixtime, default is time(), best not to meddle;
16405  
16406 =back
16407  
16408 B<Note:> spoofed nicks are currently only really functional for use as IRC
16409 services.
16410  
16411 =head2 C<del_spoofed_nick>
16412  
16413 Takes a single mandatory argument, the spoofed nickname to remove.
16414 Optionally, you may specify a quit message for the spoofed nick.
16415  
16416 =head2 Spoofed nick commands
16417  
16418 The following input events are for the benefit of spoofed nicks. All
16419 require a nickname of a spoofed nick as the first argument.
16420  
16421 =head3 C<daemon_cmd_join>
16422  
16423 Takes two arguments, a spoofed nick and a channel name to join.
16424  
16425 =head3 C<daemon_cmd_part>
16426  
16427 Takes two arguments, a spoofed nick and a channel name to part from.
16428  
16429 =head3 C<daemon_cmd_mode>
16430  
16431 Takes at least three arguments, a spoofed nick, a channel and a channel
16432 mode to apply. Additional arguments are parameters for the channel modes.
16433  
16434 =head3 C<daemon_cmd_kick>
16435  
16436 Takes at least three arguments, a spoofed nick, a channel name and the
16437 nickname of a user to kick from that channel. You may supply a fourth
16438 argument which will be the kick comment.
16439  
16440 =head3 C<daemon_cmd_topic>
16441  
16442 Takes three arguments, a spoofed nick, a channel name and the topic to
16443 set on that channel. If the third argument is an empty string then the
16444 channel topic will be unset.
16445  
16446 =head3 C<daemon_cmd_nick>
16447  
16448 Takes two arguments, a spoofed nick and a new nickname to change to.
16449  
16450 =head3 C<daemon_cmd_kline>
16451  
16452 Takes a number of arguments depending on where the KLINE is to be applied
16453 and for how long:
16454  
16455 To set a permanent KLINE:
16456  
16457 $ircd->yield(
16458 'daemon_cmd_kline',
16459 $spoofed_nick,
16460 $nick || $user_host_mask,
16461 $reason,
16462 );
16463  
16464 To set a temporary 10 minute KLINE:
16465  
16466 $ircd->yield(
16467 'daemon_cmd_kline',
16468 $spoofed_nick,
16469 10,
16470 $nick || $user_host_mask,
16471 $reason,
16472 );
16473  
16474 To set a temporary 10 minute KLINE on all servers:
16475  
16476 $ircd->yield(
16477 'daemon_cmd_kline',
16478 $spoofed_nick,
16479 10,
16480 $nick || $user_host_mask,
16481 'on',
16482 '*',
16483 $reason,
16484 );
16485  
16486 =head3 C<daemon_cmd_unkline>
16487  
16488 Removes a KLINE as indicated by the user@host mask supplied.
16489  
16490 To remove a KLINE:
16491  
16492 $ircd->yield(
16493 'daemon_cmd_unkline',
16494 $spoofed_nick,
16495 $user_host_mask,
16496 );
16497  
16498 To remove a KLINE from all servers:
16499  
16500 $ircd->yield(
16501 'daemon_cmd_unkline',
16502 $spoofed_nick,
16503 $user_host_mask,
16504 'on',
16505 '*',
16506 );
16507  
16508 =head3 C<daemon_cmd_rkline>
16509  
16510 Used to set a regex based KLINE. The regex given must be based on a
16511 user@host mask.
16512  
16513 To set a permanent RKLINE:
16514  
16515 $ircd->yield(
16516 'daemon_cmd_rkline',
16517 $spoofed_nick,
16518 '^.*$@^(yahoo|google|microsoft)\.com$',
16519 $reason,
16520 );
16521  
16522 To set a temporary 10 minute RKLINE:
16523  
16524 $ircd->yield(
16525 'daemon_cmd_rkline',
16526 $spoofed_nick,
16527 10,
16528 '^.*$@^(yahoo|google|microsoft)\.com$',
16529 $reason,
16530 );
16531  
16532 =head3 C<daemon_cmd_unrkline>
16533  
16534 Removes an RKLINE as indicated by the user@host mask supplied.
16535  
16536 To remove a RKLINE:
16537  
16538 $ircd->yield(
16539 'daemon_cmd_unrkline',
16540 $spoofed_nick,
16541 $user_host_mask,
16542 );
16543  
16544 =head3 C<daemon_cmd_sjoin>
16545  
16546 Takes two arguments a spoofed nickname and an existing channel name. This
16547 command will then manipulate the channel timestamp to clear all modes on
16548 that channel, including existing channel operators, reset the channel mode
16549 to '+nt', the spoofed nick will then join the channel and gain channel ops.
16550  
16551 =head3 C<daemon_cmd_privmsg>
16552  
16553 Takes three arguments, a spoofed nickname, a target (which can be a
16554 nickname or a channel name) and whatever text you wish to send.
16555  
16556 =head3 C<daemon_cmd_notice>
16557  
16558 Takes three arguments, a spoofed nickname, a target (which can be a
16559 nickname or a channel name) and whatever text you wish to send.
16560  
16561 =head3 C<daemon_cmd_locops>
16562  
16563 Takes two arguments, a spoofed nickname and the text message to send to
16564 local operators.
16565  
16566 =head3 C<daemon_cmd_wallops>
16567  
16568 Takes two arguments, a spoofed nickname and the text message to send to
16569 all operators.
16570  
16571 =head3 C<daemon_cmd_globops>
16572  
16573 Takes two arguments, a spoofed nickname and the text message to send to
16574 all operators.
16575  
16576 =head1 OUTPUT EVENTS
16577  
16578 =head2 C<ircd_daemon_error>
16579  
16580 =over
16581  
16582 =item Emitted: when we fail to register with a peer;
16583  
16584 =item Target: all plugins and registered sessions;
16585  
16586 =item Args:
16587  
16588 =over 4
16589  
16590 =item * C<ARG0>, the connection id;
16591  
16592 =item * C<ARG1>, the server name;
16593  
16594 =item * C<ARG2>, the reason;
16595  
16596 =back
16597  
16598 =back
16599  
16600 =head2 C<ircd_daemon_server>
16601  
16602 =over
16603  
16604 =item Emitted: when a server is introduced onto the network;
16605  
16606 =item Target: all plugins and registered sessions;
16607  
16608 =item Args:
16609  
16610 =over 4
16611  
16612 =item * C<ARG0>, the server name;
16613  
16614 =item * C<ARG1>, the name of the server that is introducing them;
16615  
16616 =item * C<ARG2>, the hop count;
16617  
16618 =item * C<ARG3>, the server description;
16619  
16620 =back
16621  
16622 =back
16623  
16624 =head2 C<ircd_daemon_squit>
16625  
16626 =over
16627  
16628 =item Emitted: when a server quits the network;
16629  
16630 =item Target: all plugins and registered sessions;
16631  
16632 =item Args:
16633  
16634 =over 4
16635  
16636 =item * C<ARG0>, the server name;
16637  
16638 =back
16639  
16640 =back
16641  
16642 =head2 C<ircd_daemon_nick>
16643  
16644 =over
16645  
16646 =item Emitted: when a user is introduced onto the network or changes their
16647 nickname
16648  
16649 =item Target: all plugins and registered sessions;
16650  
16651 =item Args (new user):
16652  
16653 =over 4
16654  
16655 =item * C<ARG0>, the nickname;
16656  
16657 =item * C<ARG1>, the hop count;
16658  
16659 =item * C<ARG2>, the time stamp (TS);
16660  
16661 =item * C<ARG3>, the user mode;
16662  
16663 =item * C<ARG4>, the ident;
16664  
16665 =item * C<ARG5>, the hostname;
16666  
16667 =item * C<ARG6>, the server name;
16668  
16669 =item * C<ARG7>, the real name;
16670  
16671 =back
16672  
16673 =item Args (nick change):
16674  
16675 =over 4
16676  
16677 =item * C<ARG0>, the full nick!user@host;
16678  
16679 =item * C<ARG1>, the new nickname;
16680  
16681 =back
16682  
16683 =back
16684  
16685 =head2 C<ircd_daemon_umode>
16686  
16687 =over
16688  
16689 =item Emitted: when a user changes their user mode;
16690  
16691 =item Target: all plugins and registered sessions;
16692  
16693 =item Args:
16694  
16695 =over 4
16696  
16697 =item * C<ARG0>, the full nick!user@host;
16698  
16699 =item * C<ARG1>, the user mode change;
16700  
16701 =back
16702  
16703 =back
16704  
16705 =head2 C<ircd_daemon_quit>
16706  
16707 =over
16708  
16709 =item Emitted: when a user quits or the server they are on squits;
16710  
16711 =item Target: all plugins and registered sessions;
16712  
16713 =item Args:
16714  
16715 =over 4
16716  
16717 =item * C<ARG0>, the full nick!user@host;
16718  
16719 =item * C<ARG1>, the quit message;
16720  
16721 =back
16722  
16723 =back
16724  
16725 =head2 C<ircd_daemon_join>
16726  
16727 =over
16728  
16729 =item Emitted: when a user joins a channel
16730  
16731 =item Target: all plugins and registered sessions;
16732  
16733 =item Args:
16734  
16735 =over 4
16736  
16737 =item * C<ARG0>, the full nick!user@host;
16738  
16739 =item * C<ARG1>, the channel name;
16740  
16741 =back
16742  
16743 =back
16744  
16745 =head2 C<ircd_daemon_part>
16746  
16747 =over
16748  
16749 =item Emitted: when a user parts a channel;
16750  
16751 =item Target: all plugins and registered sessions;
16752  
16753 =item Args:
16754  
16755 =over 4
16756  
16757 =item * C<ARG0>, the full nick!user@host;
16758  
16759 =item * C<ARG1>, the channel name;
16760  
16761 =item * C<ARG2>, the part message;
16762  
16763 =back
16764  
16765 =back
16766  
16767 =head2 C<ircd_daemon_kick>
16768  
16769 =over
16770  
16771 =item Emitted: when a user is kicked from a channel;
16772  
16773 =item Target: all plugins and registered sessions;
16774  
16775 =item Args:
16776  
16777 =over 4
16778  
16779 =item * C<ARG0>, the full nick!user@host of the kicker;
16780  
16781 =item * C<ARG1>, the channel name;
16782  
16783 =item * C<ARG2>, the nick of the kicked user;
16784  
16785 =item * C<ARG3>, the kick message;
16786  
16787 =back
16788  
16789 =back
16790  
16791 =head2 C<ircd_daemon_mode>
16792  
16793 =over
16794  
16795 =item Emitted: when a channel mode is changed;
16796  
16797 =item Target: all plugins and registered sessions;
16798  
16799 =item Args:
16800  
16801 =over 4
16802  
16803 =item * C<ARG0>, the full nick!user@host or server name;
16804  
16805 =item * C<ARG1>, the channel name;
16806  
16807 =item * C<ARG2..$#_>, the modes and their arguments;
16808  
16809 =back
16810  
16811 =back
16812  
16813 =head2 C<ircd_daemon_topic>
16814  
16815 =over
16816  
16817 =item Emitted: when a channel topic is changed
16818  
16819 =item Target: all plugins and registered sessions;
16820  
16821 =item Args:
16822  
16823 =over 4
16824  
16825 =item * C<ARG0>, the full nick!user@host of the changer;
16826  
16827 =item * C<ARG1>, the channel name;
16828  
16829 =item * C<ARG2>, the new topic;
16830  
16831 =back
16832  
16833 =back
16834  
16835 =head2 C<ircd_daemon_public>
16836  
16837 =over
16838  
16839 =item Emitted: when a channel message is sent (a spoofed nick must be in
16840 the channel)
16841  
16842 =item Target: all plugins and registered sessions;
16843  
16844 =item Args:
16845  
16846 =over 4
16847  
16848 =item * C<ARG0>, the full nick!user@host of the sender;
16849  
16850 =item * C<ARG1>, the channel name;
16851  
16852 =item * C<ARG2>, the message;
16853  
16854 =back
16855  
16856 =back
16857  
16858 =head2 C<ircd_daemon_privmsg>
16859  
16860 =over
16861  
16862 =item Emitted: when someone sends a private message to a spoofed nick
16863  
16864 =item Target: all plugins and registered sessions;
16865  
16866 =item Args:
16867  
16868 =over 4
16869  
16870 =item * C<ARG0>, the full nick!user@host of the sender;
16871  
16872 =item * C<ARG1>, the spoofed nick targeted;
16873  
16874 =item * C<ARG2>, the message;
16875  
16876 =back
16877  
16878 =back
16879  
16880 =head2 C<ircd_daemon_notice>
16881  
16882 =over
16883  
16884 =item Emitted: when someone sends a notice to a spoofed nick or channel
16885  
16886 =item Target: all plugins and registered sessions;
16887  
16888 =item Args:
16889  
16890 =over 4
16891  
16892 =item * C<ARG0>, the full nick!user@host of the sender;
16893  
16894 =item * C<ARG1>, the spoofed nick targeted or channel spoofed nick is in;
16895  
16896 =item * C<ARG2>, the message;
16897  
16898 =back
16899  
16900 =back
16901  
16902 =head2 C<ircd_daemon_snotice>
16903  
16904 =over
16905  
16906 =item Emitted: when the server issues a notice for various reasons
16907  
16908 =item Target: all plugins and registered sessions;
16909  
16910 =item Args:
16911  
16912 =over 4
16913  
16914 =item * C<ARG0>, the message;
16915  
16916 =back
16917  
16918 =back
16919  
16920 =head2 C<ircd_daemon_invite>
16921  
16922 =over
16923  
16924 =item Emitted: when someone invites a spoofed nick to a channel;
16925  
16926 =item Target: all plugins and registered sessions;
16927  
16928 =item Args:
16929  
16930 =over 4
16931  
16932 =item * C<ARG0>, the full nick!user@host of the inviter;
16933  
16934 =item * C<ARG1>, the spoofed nick being invited;
16935  
16936 =item * C<ARG2>, the channel being invited to;
16937  
16938 =back
16939  
16940 =back
16941  
16942 =head2 C<ircd_daemon_rehash>
16943  
16944 =over
16945  
16946 =item Emitted: when an oper issues a REHASH command;
16947  
16948 =item Target: all plugins and registered sessions;
16949  
16950 =item Args:
16951  
16952 =over 4
16953  
16954 =item * C<ARG0>, the full nick!user@host of the oper;
16955  
16956 =back
16957  
16958 =back
16959  
16960 =head2 C<ircd_daemon_die>
16961  
16962 =over
16963  
16964 =item Emitted: when an oper issues a DIE command;
16965  
16966 =item Target: all plugins and registered sessions;
16967  
16968 =item Args:
16969  
16970 =over 4
16971  
16972 =item * C<ARG0>, the full nick!user@host of the oper;
16973  
16974 =back
16975  
16976 =back
16977  
16978 B<Note:> the component will shutdown, this is a feature;
16979  
16980 =head2 C<ircd_daemon_dline>
16981  
16982 =over
16983  
16984 =item Emitted: when an oper issues a DLINE command;
16985  
16986 =item Target: all plugins and registered sessions;
16987  
16988 =item Args:
16989  
16990 =over 4
16991  
16992 =item * C<ARG0>, the full nick!user@host;
16993  
16994 =item * C<ARG1>, the duration;
16995  
16996 =item * C<ARG2>, the network mask;
16997  
16998 =item * C<ARG3>, the reason;
16999  
17000 =back
17001  
17002 =back
17003  
17004 =head2 C<ircd_daemon_kline>
17005  
17006 =over
17007  
17008 =item Emitted: when an oper issues a KLINE command;
17009  
17010 =item Target: all plugins and registered sessions;
17011  
17012 =item Args:
17013  
17014 =over 4
17015  
17016 =item * C<ARG0>, the full nick!user@host;
17017  
17018 =item * C<ARG1>, the target for the KLINE;
17019  
17020 =item * C<ARG2>, the duration in seconds;
17021  
17022 =item * C<ARG3>, the user mask;
17023  
17024 =item * C<ARG4>, the host mask;
17025  
17026 =item * C<ARG5>, the reason;
17027  
17028 =back
17029  
17030 =back
17031  
17032 =head2 C<ircd_daemon_rkline>
17033  
17034 =over
17035  
17036 =item Emitted: when an oper issues an RKLINE command;
17037  
17038 =item Target: all plugins and registered sessions;
17039  
17040 =item Args:
17041  
17042 =over 4
17043  
17044 =item * C<ARG0>, the full nick!user@host;
17045  
17046 =item * C<ARG1>, the target for the RKLINE;
17047  
17048 =item * C<ARG2>, the duration in seconds;
17049  
17050 =item * C<ARG3>, the user mask;
17051  
17052 =item * C<ARG4>, the host mask;
17053  
17054 =item * C<ARG5>, the reason;
17055  
17056 =back
17057  
17058 =back
17059  
17060 =head2 C<ircd_daemon_unkline>
17061  
17062 =over
17063  
17064 =item Emitted: when an oper issues an UNKLINE command;
17065  
17066 =item Target: all plugins and registered sessions;
17067  
17068 =item Args:
17069  
17070 =over 4
17071  
17072 =item * C<ARG0>, the full nick!user@host;
17073  
17074 =item * C<ARG1>, the target for the UNKLINE;
17075  
17076 =item * C<ARG2>, the user mask;
17077  
17078 =item * C<ARG3>, the host mask;
17079  
17080 =back
17081  
17082 =back
17083  
17084 =head2 C<ircd_daemon_expired>
17085  
17086 =over
17087  
17088 =item Emitted: when a temporary D-Line, X-Line, K-Line or RK-Line expires
17089  
17090 =item Target: all plugins and registered sessions;
17091  
17092 =item Args:
17093  
17094 =over 4
17095  
17096 =item * C<ARG0>, What expired, can be C<d-line>, C<x-line>, C<k-line> or C<rk-line>;
17097  
17098 =item * C<ARG1>, the mask (D-Line and X-Line) or user@host (K-Line and RK-Line);
17099  
17100 =back
17101  
17102 =back
17103  
17104 =head2 C<ircd_daemon_encap>
17105  
17106 =over
17107  
17108 =item Emitted: when the server receives an C<ENCAP> message;
17109  
17110 =item Target: all plugins and registered sessions;
17111  
17112 =item Args:
17113  
17114 =over 4
17115  
17116 =item * C<ARG0>, the server name or full nick!user@host;
17117  
17118 =item * C<ARG1>, peermask of targets for the C<ENCAP>;
17119  
17120 =item * C<ARG2>, the sub command being propagated;
17121  
17122 =item * Subsequent ARGs are dependent on the sub command;
17123  
17124 =back
17125  
17126 =back
17127  
17128 =head2 C<ircd_daemon_locops>
17129  
17130 =over
17131  
17132 =item Emitted: when an oper issues a LOCOPS command;
17133  
17134 =item Target: all plugins and registered sessions;
17135  
17136 =item Args:
17137  
17138 =over 4
17139  
17140 =item * C<ARG0>, the full nick!user@host;
17141  
17142 =item * C<ARG1>, the locops message;
17143  
17144 =back
17145  
17146 =back
17147  
17148 =head2 C<ircd_daemon_globops>
17149  
17150 =over
17151  
17152 =item Emitted: when an oper or server issues a GLOBOPS;
17153  
17154 =item Target: all plugins and registered sessions;
17155  
17156 =item Args:
17157  
17158 =over 4
17159  
17160 =item * C<ARG0>, the full nick!user@host or server name;
17161  
17162 =item * C<ARG1>, the globops message;
17163  
17164 =back
17165  
17166 =back
17167  
17168 =head2 C<ircd_daemon_wallops>
17169  
17170 =over
17171  
17172 =item Emitted: when a server issues a WALLOPS;
17173  
17174 =item Target: all plugins and registered sessions;
17175  
17176 =item Args:
17177  
17178 =over 4
17179  
17180 =item * C<ARG0>, the server name;
17181  
17182 =item * C<ARG1>, the wallops message;
17183  
17184 =back
17185  
17186 =back
17187  
17188 =head1 BUGS
17189  
17190 A few have turned up in the past and they are sure to again. Please use
17191 L<http://rt.cpan.org/> to report any. Alternatively, email the current
17192 maintainer.
17193  
17194 =head1 DEVELOPMENT
17195  
17196 You can find the latest source on github:
17197 L<http://github.com/bingos/poe-component-server-irc>
17198  
17199 The project's developers usually hang out in the C<#poe> IRC channel on
17200 irc.perl.org. Do drop us a line.
17201  
17202 =head1 MAINTAINER
17203  
17204 Hinrik E<Ouml>rn SigurE<eth>sson <hinrik.sig@gmail.com>
17205  
17206 =head1 AUTHOR
17207  
17208 Chris 'BinGOs' Williams
17209  
17210 =head1 LICENSE
17211  
17212 Copyright C<(c)> Chris Williams
17213  
17214 This module may be used, modified, and distributed under the same terms as
17215 Perl itself. Please see the license that came with your Perl distribution
17216 for details.
17217  
17218 =head1 KUDOS
17219  
17220 Rocco Caputo for creating POE.
17221  
17222 Buu for pestering me when I started to procrastinate =]
17223  
17224 =head1 SEE ALSO
17225  
17226 L<POE|POE> L<http://poe.perl.org/>
17227  
17228 L<POE::Component::Server::IRC::Backend|POE::Component::IRC::Server::Backend>
17229  
17230 L<Net::CIDR|Net::CIDR>
17231  
17232 Hybrid IRCD L<http://ircd-hybrid.com/>
17233  
17234 RFC 2810 L<http://www.faqs.org/rfcs/rfc2810.html>
17235  
17236 RFC 2811 L<http://www.faqs.org/rfcs/rfc2811.html>
17237  
17238 RFC 2812 L<http://www.faqs.org/rfcs/rfc2812.html>
17239  
17240 RFC 2813 L<http://www.faqs.org/rfcs/rfc2813.html>
17241  
17242 =cut
↑ Summary blib/lib/POE/Component/Server/IRC/Plugin/Auth.pm »