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

filter: Statementstmt 71.0% 5497 / 7742 Branchbran 54.1% 2004 / 3704 Conditioncond 42.3% 1028 / 2430 MC/DCmcdc 11.4% 160 / 1397 Subroutinesub 84.0% 248 / 295 Podpod 68.6% 46 / 67 totaltotal 57.4% 8983 / 15635 CC 3029 SCAR 59.0
CC
3029
Cov
61%
_daemon_do_stats
4563.8
_daemon_peer_tmode
3422.0
_daemon_cmd_mode
1473.3
CRAP 366.7
↑ Summary blib/lib/POE/Component/Server/IRC/Plugin/Auth.pm »
1 package POE::Component::Server::IRC;
2 179 our $AUTHORITY = 'cpan:BINGOS';
3 179 $POE::Component::Server::IRC::VERSION = '1.62';
4 179 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 179 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 179 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 179 use IRC::Utils qw(uc_irc parse_mode_line unparse_mode_line normalize_mask
8 matches_mask matches_mask_array gen_mode_change is_valid_nick_name
9 179 ▶ is_valid_chan_name has_color has_formatting parse_user);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 179 ▶use List::Util qw(sum);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 179 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 179 ▶use POE::Component::Server::IRC::Common qw(chkpasswd);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 179 ▶use POE::Component::Server::IRC::Plugin qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 179 ▶use POSIX 'strftime';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 179 ▶use Net::CIDR ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 179 ▶use base qw(POE::Component::Server::IRC::Backend);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 179 my $sid_re = qr/^[0-9][A-Z0-9][A-Z0-9]$/;
19 179 my $id_re = qr/^[A-Z][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]$/;
20 179 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]$/;
21 179 my $host_re = qr/^[^.:][A-Za-z0-9.:-]+$/;
22 179 my $user_re = qr/^[^\x2D][\x24\x2D-\x39\x41-\x7E]+$/;
23  
24 sub spawn {
25 179 ▶ my ($package, %args) = @_;
Subroutine spawn: called CC=4 SCAR=13.9
Pod documented
26 179 $args{lc $_} = delete $args{$_} for keys %args;
27 179 my $config = delete $args{config};
28 179 my $debug = delete $args{debug};
29 my $self = $package->create(
30 ($debug ? (raw_events => 1) : ()),
31 %args,
32 states => [
33 [qw(add_spoofed_nick del_spoofed_nick _state_drkx_line_alarm _daemon_do_safelist)],
34 {
35 179 ▶ map { +"daemon_cmd_$_" => '_spoofed_command' }
Branch: 1 branch
BranchTrueFalseTotal
$debug ? : 0 179 179
36 qw(join part mode kick topic nick privmsg notice xline unxline resv unresv
37 rkline unrkline kline unkline sjoin locops wallops globops dline undline)
38 },
39 ],
40 );
41  
42 179 ▶ $self->configure($config ? $config : ());
Branch: 1 branch
BranchTrueFalseTotal
$config ? : 178 1 179
43 179 $self->{debug} = $debug;
44 179 $self->_state_create();
45 179 return $self;
46 }
47  
48 sub IRCD_connection {
49 516 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connection: called CC=3 SCAR=11.0
Pod undocumented
50 516 pop @_;
51 my ($conn_id, $peeraddr, $peerport, $sockaddr, $sockport, $needs_auth, $secured, $filter)
52 516 = map { ${ $_ } } @_;
53  
54 516 ▶ if ($self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_exists($conn_id)) 0 516 516
55 0 delete $self->{state}{conns}{$conn_id};
56 }
57  
58 516 $self->{state}{conns}{$conn_id}{registered} = 0;
59 516 $self->{state}{conns}{$conn_id}{type} = 'u';
60 516 $self->{state}{conns}{$conn_id}{seen} = time();
61 516 $self->{state}{conns}{$conn_id}{conn_time} = time();
62 516 $self->{state}{conns}{$conn_id}{secured} = $secured;
63 516 $self->{state}{conns}{$conn_id}{stats} = $filter;
64 $self->{state}{conns}{$conn_id}{socket}
65 516 = [$peeraddr, $peerport, $sockaddr, $sockport];
66  
67 516 $self->_state_conn_stats();
68  
69 516 ▶ if (!$needs_auth) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($needs_auth) 515 1 516
70 $self->{state}{conns}{$conn_id}{auth} = {
71 515 hostname => '',
72 ident => '',
73 };
74 515 $self->_client_register($conn_id);
75 }
76  
77 516 return PCSI_EAT_CLIENT;
78 }
79  
80 sub IRCD_connected {
81 3 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connected: called CC=2 SCAR=7.0
Pod undocumented
82 3 pop @_;
83 my ($conn_id, $peeraddr, $peerport, $sockaddr, $sockport, $name, $filter)
84 3 = map { ${ $_ } } @_;
85  
86 3 ▶ if ($self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_exists($conn_id)) 0 3 3
87 0 delete $self->{state}{conns}{$conn_id};
88 }
89  
90 3 $self->{state}{conns}{$conn_id}{peer} = $name;
91 3 $self->{state}{conns}{$conn_id}{registered} = 0;
92 3 $self->{state}{conns}{$conn_id}{cntr} = 1;
93 3 $self->{state}{conns}{$conn_id}{type} = 'u';
94 3 $self->{state}{conns}{$conn_id}{seen} = time();
95 3 $self->{state}{conns}{$conn_id}{conn_time} = time();
96 3 $self->{state}{conns}{$conn_id}{stats} = $filter;
97 $self->{state}{conns}{$conn_id}{socket}
98 3 = [$peeraddr, $peerport, $sockaddr, $sockport];
99  
100 3 $self->_state_conn_stats();
101 3 $self->_state_send_credentials($conn_id, $name);
102 3 return PCSI_EAT_CLIENT;
103 }
104  
105 sub IRCD_connection_flood {
106 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connection_flood: not called CC=1 SCAR=6.9
Pod undocumented
107 0 pop @_;
108 0 my ($conn_id) = map { ${ $_ } } @_;
109 0 $self->_terminate_conn_error($conn_id, 'Excess Flood');
110 0 return PCSI_EAT_CLIENT;
111 }
112  
113 sub IRCD_connection_idle {
114 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connection_idle: not called CC=4 SCAR=30.0
Pod undocumented
115 0 pop @_;
116 0 my ($conn_id, $interval) = map { ${ $_ } } @_;
117 0 ▶ return PCSI_EAT_NONE if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 0 0
118  
119 0 my $conn = $self->{state}{conns}{$conn_id};
120 0 ▶ if ($conn->{type} eq 'u') {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"type"} eq "u") 0 0 0
121 0 $self->_terminate_conn_error($conn_id, 'Connection Timeout');
122 0 return PCSI_EAT_CLIENT;
123 }
124  
125 0 ▶ if ($conn->{pinged}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"pinged"}) 0 0 0
126 0 my $msg = 'Ping timeout: '.(time - $conn->{seen}).' seconds';
127 0 $self->_terminate_conn_error($conn_id, $msg);
128 0 return PCSI_EAT_CLIENT;
129 }
130  
131 0 $conn->{pinged} = 1;
132 0 $self->send_output(
133 {
134 command => 'PING',
135 params => [$self->server_name()],
136 },
137 $conn_id,
138 );
139 0 return PCSI_EAT_CLIENT;
140 }
141  
142 sub IRCD_auth_done {
143 1 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_auth_done: called CC=2 SCAR=6.9
Pod undocumented
144 1 pop @_;
145 1 my ($conn_id, $ref) = map { ${ $_ } } @_;
146 1 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 1 1
147  
148 1 $self->{state}{conns}{$conn_id}{auth} = $ref;
149 1 $self->_client_register($conn_id);
150 1 return PCSI_EAT_CLIENT;
151 }
152  
153 sub IRCD_disconnected {
154 479 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_disconnected: called CC=4 SCAR=13.9
Pod undocumented
155 479 pop @_;
156 479 my ($conn_id, $errstr) = map { ${ $_ } } @_;
157 479 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 479 479
158  
159 479 ▶ if ($self->_connection_is_peer($conn_id)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_connection_is_peer($conn_id)) { } 223 256 479
elsif ($self->_connection_is_client($conn_id)) { } 213 43 256
160 223 my $peer = $self->{state}{conns}{$conn_id}{sid};
161 $self->send_output(
162 223 @{ $self->_daemon_peer_squit($conn_id, $peer, $errstr) }
163 );
164 }
165 elsif ($self->_connection_is_client($conn_id)) {
166 $self->send_output(
167 213 @{ $self->_daemon_cmd_quit(
168 $self->_client_nickname($conn_id,$errstr ),
169 $errstr,
170 )}
171 );
172 }
173  
174 479 delete $self->{state}{conns}{$conn_id};
175 479 return PCSI_EAT_CLIENT;
176 }
177  
178 sub IRCD_compressed_conn {
179 2 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_compressed_conn: called CC=1 SCAR=0.0
Pod undocumented
180 2 pop @_;
181 2 my ($conn_id) = map { ${ $_ } } @_;
182 2 $self->_state_send_burst($conn_id);
183 2 return PCSI_EAT_CLIENT;
184 }
185  
186 sub IRCD_raw_input {
187 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_raw_input: not called CC=2 SCAR=17.9
Pod undocumented
188 0 ▶ return PCSI_EAT_CLIENT if !$self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"debug"} 0 0 0
189 0 my $conn_id = ${ $_[0] };
190 0 my $input = ${ $_[1] };
191 0 warn "<<< $conn_id: $input\n";
192 0 return PCSI_EAT_CLIENT;
193 }
194  
195 sub IRCD_raw_output {
196 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_raw_output: not called CC=2 SCAR=17.9
Pod undocumented
197 0 ▶ return PCSI_EAT_CLIENT if !$self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"debug"} 0 0 0
198 0 my $conn_id = ${ $_[0] };
199 0 my $output = ${ $_[1] };
200 0 warn ">>> $conn_id: $output\n";
201 0 return PCSI_EAT_CLIENT;
202 }
203  
204 sub _default {
205 13252 ▶ my ($self, $ircd, $event) = splice @_, 0, 3;
Subroutine _default: called CC=7 SCAR=19.5
206 13252 ▶ return PCSI_EAT_NONE if $event !~ /^IRCD_cmd_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $event =~ /^IRCD_cmd_/ 9146 4106 13252
207 4106 pop @_;
208 4106 my ($conn_id, $input) = map { $$_ } @_;
209  
210 4106 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4106 4106
211 4106 ▶ return PCSI_EAT_CLIENT if $self->_connection_terminated($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_terminated($conn_id) 21 4085 4106
212 4085 $self->{state}{conns}{$conn_id}{seen} = time;
213  
214 4085 ▶ if (!$self->_connection_registered($conn_id)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $self->_connection_registered($conn_id)) { } 1413 2672 4085
elsif ($self->_connection_is_peer($conn_id)) { } 1885 787 2672
elsif ($self->_connection_is_client($conn_id)) { } 787 0 787
215 1413 $self->_cmd_from_unknown($conn_id, $input);
216 }
217 elsif ($self->_connection_is_peer($conn_id)) {
218 1885 $self->_cmd_from_peer($conn_id, $input);
219 }
220 elsif ($self->_connection_is_client($conn_id)) {
221 787 delete $input->{prefix};
222 787 $self->_cmd_from_client($conn_id, $input);
223 }
224  
225 4085 return PCSI_EAT_CLIENT;
226 }
227  
228 sub _auth_finished {
229 241 ▶ my $self = shift;
Subroutine _auth_finished: called CC=3 SCAR=11.4
230 241 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2410
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
231 241 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 241 241
232 241 return $self->{state}{conns}{$conn_id}{auth};
233 }
234  
235 sub _connection_exists {
236 22746 ▶ my $self = shift;
Subroutine _connection_exists: called CC=3 SCAR=11.0
237 22746 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
227460
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
238 22746 ▶ return if !defined $self->{state}{conns}{$conn_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"conns"}{$conn_id} 520 22226 22746
239 22226 return 1;
240 }
241  
242 sub _connection_terminated {
243 4612 ▶ my $self = shift;
Subroutine _connection_terminated: called CC=4 SCAR=14.2
244 4612 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
46120
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
245 4612 ▶ return if !defined $self->{state}{conns}{$conn_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"conns"}{$conn_id} 0 4612 4612
246 4612 ▶ return 1 if defined $self->{state}{conns}{$conn_id}{terminated};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"conns"}{$conn_id}{"terminated"} 21 4591 4612
247 }
248  
249 sub _client_register {
250 1048 ▶ my $self = shift;
Subroutine _client_register: called CC=25 SCAR=33.8
251 1048 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10480
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
252 1048 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 1048 1048
253 1048 ▶ return if !$self->{state}{conns}{$conn_id}{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"nick"} 555 493 1048
254 493 ▶ return if !$self->{state}{conns}{$conn_id}{user};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"user"} 242 251 493
255 251 ▶ return if $self->{state}{conns}{$conn_id}{capneg};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"capneg"} 10 241 251
256 241 my $server = $self->server_name();
257  
258 241 my $auth = $self->_auth_finished($conn_id);
259 241 ▶ return if !$auth;
Branch: 1 branch
BranchTrueFalseTotal
unless $auth 0 241 241
260 # pass required for link
261 241 ▶ if (!$self->_state_auth_client_conn($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_state_auth_client_conn($conn_id)) 5 236 241
262 5 my $crec = $self->{state}{conns}{$conn_id};
263 $self->_send_to_realops(
264 sprintf(
265 'Unauthorized client connection from %s!%s@%s on [%s/%u].',
266 $crec->{nick}, $crec->{user}, $crec->{socket}[0],
267 5 $crec->{socket}[2], $crec->{socket}[3],
268 ),
269 'Notice', 'u',
270 );
271 5 $self->_terminate_conn_error(
272 $conn_id,
273 'You are not authorized to use this server',
274 );
275 5 return;
276 }
277 236 ▶ if ($self->{auth}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"auth"}) 1 235 236
278 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
279 !$self->{state}{conns}{$conn_id}{auth}{ident} ) {
280 1 $self->_send_output_to_client(
281 $conn_id,
282 {
283 prefix => $server,
284 command => 'NOTICE',
285 params => [
286 '*',
287 '*** Notice -- You need to install identd to use this server',
288 ],
289 },
290 );
291 1 $self->_terminate_conn_error(
292 $conn_id,
293 'Install identd',
294 );
295 1 return;
296 }
297 }
298 235 ▶ 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 230 235
299 5 my $crec = $self->{state}{conns}{$conn_id};
300 $self->_send_to_realops(
301 sprintf(
302 'X-line Rejecting [%s] [%s], user %s!%s@%s [%s]',
303 $crec->{ircname}, $reason,
304 $crec->{nick}, $crec->{user},
305 ( $crec->{auth}{hostname} || $crec->{socket}[0] ),
306 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
307 ),
308 'Notice',
309 'j',
310 );
311 5 $self->_send_output_to_client( $conn_id, '465' );
312 5 $self->_terminate_conn_error($conn_id, "X-Lined: [$reason]");
313 5 return;
314 }
315 230 ▶ 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 225 230
316 5 $self->_send_output_to_client( $conn_id, '465' );
317 5 $self->_terminate_conn_error($conn_id, "K-Lined: [$reason]");
318 5 return;
319 }
320 225 ▶ 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 223 225
321 2 $self->_send_output_to_client( $conn_id, '465' );
322 2 $self->_terminate_conn_error($conn_id, "K-Lined: [$reason]");
323 2 return;
324 }
325  
326 223 ▶ 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 223 223
Condition66%2/3
$self->{"state"}{"conns"}{$conn_id}{"auth"}{"ident"} or $self->{"state"}{"conns"}{$conn_id}{"user"} =~ /$user_re/
l!l&&r!l&&!r
12220
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
327 $self->{state}{conns}{$conn_id}{user} !~ $user_re ) {
328 0 my $crec = $self->{state}{conns}{$conn_id};
329 $self->_send_to_realops(
330 sprintf(
331 'Invalid username: %s (%s@%s)',
332 $crec->{nick}, $crec->{user},
333 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
334 ),
335 'Notice',
336 'j',
337 );
338 $self->_terminate_conn_error(
339 $conn_id,
340 sprintf(
341 'Invalid username [%s]', $crec->{user},
342 0 ),
343 );
344 0 return;
345 }
346  
347 223 my $clients = keys %{ $self->{state}{sids}{$self->server_sid()}{uids} };
348 223 ▶ if ( $self->{config}{MAXCLIENTS} < $clients + 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"config"}{"MAXCLIENTS"} < $clients + 1) 0 223 223
349 0 my $crec = $self->{state}{conns}{$conn_id};
350 0 ▶ if (!$crec->{exceed_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($crec->{"exceed_limit"}) 0 0 0
351 0 $self->_terminate_conn_error($conn_id,
352 'Sorry, server is full - try later');
353 0 return;
354 }
355 }
356  
357 # Add new nick
358 223 my $uid = $self->_state_register_client($conn_id);
359 223 my $umode = $self->{state}{conns}{$conn_id}{umode};
360 223 my $nick = $self->_client_nickname($conn_id);
361 223 my $port = $self->{state}{conns}{$conn_id}{socket}[3];
362 223 my $version = $self->server_version();
363 223 my $network = $self->server_config('NETWORK');
364 223 my $server_is = "$server\[$server/$port]";
365  
366 223 ▶ if (my $sslinfo = $self->connection_secured($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sslinfo = $self->connection_secured($conn_id)) 5 218 223
367 5 $self->_send_output_to_client(
368 $conn_id,
369 {
370 prefix => $server,
371 command => 'NOTICE',
372 params => [
373 $nick,
374 "*** Connected securely via $sslinfo",
375 ],
376 },
377 );
378 }
379  
380 223 $self->_state_auth_flags_notices($conn_id);
381  
382 223 $self->_send_output_to_client(
383 $conn_id,
384 {
385 prefix => $server,
386 command => '001',
387 params => [
388 $nick,
389 "Welcome to the $network Internet Relay Chat network $nick"
390 ],
391 }
392 );
393 223 $self->_send_output_to_client(
394 $conn_id,
395 {
396 prefix => $server,
397 command => '002',
398 params => [
399 $nick,
400 "Your host is $server_is, running version $version",
401 ],
402 },
403 );
404 223 $self->_send_output_to_client(
405 $conn_id,
406 {
407 prefix => $server,
408 command => '003',
409 params => [$nick, $self->server_created()],
410 },
411 );
412 223 $self->_send_output_to_client(
413 $conn_id,
414 {
415 prefix => $server,
416 command => '004',
417 colonify => 0,
418 params => [
419 $nick,
420 $server,
421 $version,
422 'DFGHRSWXabcdefgijklnopqrsuwy',
423 'biklmnopstveIh',
424 'bkloveIh',
425 ],
426 }
427 );
428  
429 223 for my $output (@{ $self->_daemon_do_isupport($uid) }) {
430 446 $output->{prefix} = $server;
431 446 $output->{params}[0] = $nick;
432 446 $self->_send_output_to_client($conn_id, $output);
433 }
434  
435 223 $self->{state}{conns}{$conn_id}{registered} = 1;
436 223 $self->{state}{conns}{$conn_id}{type} = 'c';
437  
438 223 $self->send_output( $_, $conn_id ) for
439 1327 map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
440 223 @{ $self->_daemon_do_lusers($uid) };
441  
442  
443 223 $self->send_output( $_, $conn_id ) for
444 223 map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
445 223 @{ $self->_daemon_do_motd($uid) };
446  
447 223 ▶ if ( $umode ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umode) 5 218 223
448 $self->send_output(
449 {
450 5 prefix => $self->{state}{uids}{$uid}{full}->(),
451 command => 'MODE',
452 params => [ $nick, "+$umode" ],
453 },
454 $conn_id,
455 );
456 }
457  
458 $self->send_event(
459 223 'cmd_mode',
460 $conn_id,
461 {
462 command => 'MODE',
463 params => [$nick, "+i"],
464 },
465 );
466  
467 223 return 1;
468 }
469  
470 sub _connection_registered {
471 4226 ▶ my $self = shift;
Subroutine _connection_registered: called CC=3 SCAR=11.4
472 4226 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
42260
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
473 4226 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4226 4226
474 4226 return $self->{state}{conns}{$conn_id}{registered};
475 }
476  
477 sub _connection_is_peer {
478 6516 ▶ my $self = shift;
Subroutine _connection_is_peer: called CC=5 SCAR=16.2
479 6516 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
65160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
480  
481 6516 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 6516 6516
482 6516 ▶ return if !$self->{state}{conns}{$conn_id}{registered};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"registered"} 1511 5005 6516
483 5005 ▶ return 1 if $self->{state}{conns}{$conn_id}{type} eq 'p';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} eq "p" 3054 1951 5005
484 1951 return;
485 }
486  
487 sub _connection_is_client {
488 1078 ▶ my $self = shift;
Subroutine _connection_is_client: called CC=5 SCAR=16.2
489 1078 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
10780
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
490  
491 1078 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 1078 1078
492 1078 ▶ return if !$self->{state}{conns}{$conn_id}{registered};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"registered"} 43 1035 1078
493 1035 ▶ return 1 if $self->{state}{conns}{$conn_id}{type} eq 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} eq "c" 1029 6 1035
494 6 return;
495 }
496  
497 sub _cmd_from_unknown {
498 1413 ▶ my ($self, $wheel_id, $input) = @_;
Subroutine _cmd_from_unknown: called CC=49 SCAR=45.5
499  
500 1413 my $cmd = uc $input->{command};
501 1413 ▶ my $params = $input->{params} || [ ];
Condition100%2/2
$input->{'params'} || []
l!l
14121
MC/DC100%1/1
$input->{'params'} || []
$input->{'params'}
Truth table100%2/2
A
A= $input->{'params'}
Aresult
11
00
502 1413 my $pcount = @$params;
503 1413 my $invalid = 0;
504  
505 SWITCH: {
506 1413 ▶ if ($cmd eq 'ERROR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "ERROR") 0 1413 1413
507 0 my $peer = $self->{state}{conns}{$wheel_id}{peer};
508 0 ▶ if (defined $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $peer) 0 0 0
509 0 $self->send_event_next(
510 'daemon_error',
511 $wheel_id,
512 $peer,
513 $params->[0],
514 );
515 }
516 }
517 1413 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 7 1406 1413
518 7 $self->_terminate_conn_error($wheel_id, 'Client Quit');
519 7 last SWITCH;
520 }
521  
522 1406 ▶ if ($cmd eq 'CAP' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAP") 141 1265 1406
523 141 $self->_daemon_cmd_cap($wheel_id, @$params);
524 141 last SWITCH;
525 }
526  
527 # PASS or NICK cmd but no parameters.
528 1265 ▶ if ($cmd =~ /^(PASS|NICK|SERVER)$/ && !$pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount) 0 1265 1265
Condition66%2/3
$cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount
!ll&&!rl&&r
5027630
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
529 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
530 0 last SWITCH;
531 }
532  
533 # PASS or NICK cmd with one parameter, connection from client
534 1265 ▶ if ($cmd eq 'PASS' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "PASS" and $pcount) 260 1005 1265
Condition66%2/3
$cmd eq "PASS" and $pcount
!ll&&!rl&&r
10050260
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
535 260 $self->{state}{conns}{$wheel_id}{lc $cmd} = $params->[0];
536  
537 260 ▶ if ($params->[1] && $params->[1] =~ /TS$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->[1] and $params->[1] =~ /TS$/) 258 2 260
Condition66%2/3
$params->[1] and $params->[1] =~ /TS$/
!ll&&!rl&&r
20258
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
538 258 $self->{state}{conns}{$wheel_id}{ts_server} = 1;
539 258 $self->antiflood($wheel_id, 0);
540  
541 # TS6 server
542 # PASS password TS 6 6FU
543 258 ▶ if ($params->[2] && $params->[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->[2] and $params->[3]) { } 257 1 258
Condition66%2/3
$params->[2] and $params->[3]
!ll&&!rl&&r
10257
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
544 257 $self->{state}{conns}{$wheel_id}{ts_data} = [ @{$params}[2,3] ];
545 257 my $ts = $params->[2];
546 257 my $sid = $params->[3];
547 257 my $errstr;
548 257 ▶ if ($sid !~ $sid_re || $ts ne '6') {
Branch: 2 branches
BranchTrueFalseTotal
if (not $sid =~ /$sid_re/ or $ts ne '6') { } 1 256 257
elsif ($self->state_sid_exists($sid)) { } 1 255 256
Condition66%2/3
not $sid =~ /$sid_re/ or $ts ne 6
l!l&&r!l&&!r
10256
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
549 1 my $crec = $self->{state}{conns}{$wheel_id};
550 $self->_send_to_realops(
551 sprintf(
552 'Link [unknown@%s] introduced server with bogus server ID %s',
553 1 $crec->{socket}[0], $sid,
554 ), qw[Notice s],
555 );
556 1 $errstr = 'Bogus server ID introduced';
557 }
558 elsif ($self->state_sid_exists( $sid )) {
559 1 my $crec = $self->{state}{conns}{$wheel_id};
560 $self->_send_to_realops(
561 sprintf(
562 'Attempt to re-introduce server %s SID %s from [unknown@%s]',
563 1 $self->_state_sid_name($sid), $sid, $crec->{socket}[0],
564 ), qw[Notice s],
565 );
566 1 $errstr = 'Server ID already exists';
567 }
568 257 ▶ if ($errstr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errstr) 2 255 257
569 2 $self->_terminate_conn_error($wheel_id, $errstr);
570 2 last SWITCH;
571 }
572 }
573 else {
574 1 $self->_terminate_conn_error($wheel_id, 'Incompatible TS version' );
575 1 last SWITCH;
576 }
577 }
578 257 last SWITCH;
579 }
580  
581 # SERVER stuff.
582 1005 ▶ if ($cmd eq 'CAPAB' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAPAB" and $pcount) 255 750 1005
Condition66%2/3
$cmd eq "CAPAB" and $pcount
!ll&&!rl&&r
7500255
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
583 $self->{state}{conns}{$wheel_id}{capab}
584 255 = [split /\s+/, $params->[0]];
585 255 last SWITCH;
586 }
587 750 ▶ if ($cmd eq 'SERVER' && $pcount < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SERVER" and $pcount < 2) 0 750 750
Condition66%2/3
$cmd eq "SERVER" and $pcount < 2
!ll&&!rl&&r
4952550
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
588 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
589 0 last SWITCH;
590 }
591 750 ▶ if ($cmd eq 'SERVER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SERVER") 255 495 750
592 255 my $conn = $self->{state}{conns}{$wheel_id};
593 255 $conn->{name} = $params->[0];
594 255 ▶ $conn->{hops} = $params->[1] || 1;
Condition50%1/2
$params->[1] || 1
l!l
2550
MC/DC0%0/1
$params->[1] || 1
$params->[1]
Truth table50%1/2
A
A= $params->[1]
Aresult
11
00
595 255 ▶ $conn->{desc} = $params->[2] || '(unknown location)';
Condition50%1/2
$params->[2] || '(unknown location)'
l!l
2550
MC/DC0%0/1
$params->[2] || '(unknown location)'
$params->[2]
Truth table50%1/2
A
A= $params->[2]
Aresult
11
00
596  
597 255 ▶ if ( $conn->{desc} && $conn->{desc} =~ m!^\(H\) ! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"desc"} and $conn->{"desc"} =~ /^\(H\) /) 0 255 255
Condition33%1/3
$conn->{"desc"} and $conn->{"desc"} =~ /^\(H\) /
!ll&&!rl&&r
02550
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
598 0 $conn->{hidden} = 1;
599 0 $conn->{desc} =~ s!^\(H\) !!;
600 }
601  
602 255 ▶ if (!$conn->{ts_server}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn->{"ts_server"}) 0 255 255
603 0 $self->_terminate_conn_error($wheel_id, 'Non-TS server.');
604 0 last SWITCH;
605 }
606 my $result = $self->_state_auth_peer_conn($wheel_id,
607 255 $conn->{name}, $conn->{pass});
608 255 ▶ if (!$result || $result <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result or $result <= 0) 2 253 255
Condition66%2/3
not $result or $result <= 0
l!l&&r!l&&!r
02253
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
609 2 my $errstr; my $snotice;
610 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
611 0 $snotice = 'No entry for';
612 0 $errstr = 'No connect {} block.';
613 }
614 elsif ($result == -1) {
615 1 $snotice = 'Bad password';
616 1 $errstr = 'Invalid password.';
617 }
618 elsif ($result == -2) {
619 1 $snotice = 'Invalid certificate fingerprint';
620 1 $errstr = 'Invalid certificate fingerprint.';
621 }
622 else {
623 0 $snotice = 'Invalid host';
624 0 $errstr = 'Invalid host.';
625 }
626 $self->_send_to_realops(
627 sprintf(
628 'Unauthorized server connection attempt from [unknown@%s]: %s for server %s',
629 $conn->{socket}[0], $snotice, $conn->{name},
630 2 ),
631 'Notice', 's',
632 );
633 2 $self->_terminate_conn_error(
634 $wheel_id,
635 $errstr,
636 );
637 2 last SWITCH;
638 }
639 253 ▶ if ($self->state_peer_exists($conn->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($conn->{"name"})) 0 253 253
640 $self->_send_to_realops(
641 sprintf(
642 'Attempt to re-introduce server %s from [unknown@%s]',
643 0 $conn->{name}, $conn->{socket}[0],
644 ), qw[Notice s],
645 );
646 0 $self->_terminate_conn_error($wheel_id, 'Server exists.');
647 0 last SWITCH;
648 }
649 253 $self->_state_register_peer($wheel_id);
650  
651 253 ▶ if ($conn->{zip} && grep { $_ eq 'ZIP' } @{ $conn->{capab} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{'zip'} and grep {$_ eq 'ZIP';} @{$$conn{'capab'};}) { } 2 251 253
Condition100%3/3
$conn->{"zip"} and grep {$_ eq "ZIP";} @{$$conn{"capab"};}
!ll&&!rl&&r
42472
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
652 2 $self->compressed_link($wheel_id, 1, $conn->{cntr});
653 }
654 else {
655 251 $self->_state_send_burst($wheel_id);
656 }
657  
658 $self->send_event(
659 "daemon_capab",
660 $conn->{name},
661 253 @{ $conn->{capab} },
662 );
663 253 last SWITCH;
664 }
665  
666 495 ▶ if ($cmd eq 'NICK' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "NICK" and $pcount) 248 247 495
Condition66%2/3
$cmd eq "NICK" and $pcount
!ll&&!rl&&r
2470248
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
667 248 my $nicklen = $self->server_config('NICKLEN');
668 248 ▶ if (length($params->[0]) > $nicklen) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $params->[0] > $nicklen) 0 248 248
669 0 $params->[0] = substr($params->[0], 0, $nicklen);
670 }
671  
672 248 ▶ if (!is_valid_nick_name($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_nick_name($params->[0])) 0 248 248
673 0 $self->_send_output_to_client(
674 $wheel_id,
675 '432',
676 $params->[0],
677 );
678 0 last SWITCH;
679 }
680  
681 248 ▶ if ($self->state_nick_exists($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($params->[0])) 1 247 248
682 1 $self->_send_output_to_client(
683 $wheel_id,
684 '433',
685 $params->[0],
686 );
687 1 last SWITCH;
688 }
689  
690 247 ▶ 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 242 247
691 5 $self->_send_output_to_client(
692 $wheel_id, {
693 prefix => $self->server_name(),
694 command => '432',
695 params => [
696 '*',
697 $params->[0],
698 $reason,
699 ],
700 }
701 );
702 5 last SWITCH;
703 }
704  
705 242 $self->{state}{conns}{$wheel_id}{lc $cmd} = $params->[0];
706 242 $self->{state}{pending}{uc_irc($params->[0])} = $wheel_id;
707 242 $self->_client_register($wheel_id);
708 242 last SWITCH;
709 }
710 247 ▶ if ($cmd eq 'USER' && $pcount < 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "USER" and $pcount < 4) 0 247 247
Condition33%1/3
$cmd eq "USER" and $pcount < 4
!ll&&!rl&&r
02470
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
711 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
712 0 last SWITCH;
713 }
714 247 ▶ if ($cmd eq 'USER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "USER") 247 0 247
715 247 $self->{state}{conns}{$wheel_id}{user} = $params->[0];
716 247 ▶ $self->{state}{conns}{$wheel_id}{ircname} = $params->[3] || '';
Condition50%1/2
$params->[3] || ''
l!l
2470
MC/DC0%0/1
$params->[3] || ''
$params->[3]
Truth table50%1/2
A
A= $params->[3]
Aresult
11
00
717 247 $self->_client_register($wheel_id);
718 247 last SWITCH;
719 }
720  
721 0 ▶ last SWITCH if $self->{state}{conns}{$wheel_id}{cntr};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$wheel_id}{"cntr"} 0 0 0
722 0 $invalid = 1;
723 0 $self->_send_output_to_client($wheel_id, '451');
724 }
725  
726 1413 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 1413 1413
727 1413 $self->_state_cmd_stat($cmd, $input->{raw_line});
728 1413 return 1;
729 }
730  
731 sub _cmd_from_peer {
732 1885 ▶ my ($self, $conn_id, $input) = @_;
Subroutine _cmd_from_peer: called CC=28 SCAR=34.5
733  
734 1885 my $cmd = uc $input->{command};
735 1885 my $params = $input->{params};
736 1885 my $prefix = $input->{prefix};
737 1885 my $sid = $self->server_sid();
738 1885 my $invalid = 0;
739  
740 SWITCH: {
741 1885 my $method = '_daemon_peer_' . lc $cmd;
742 1885 ▶ if ($cmd eq 'SQUIT' && !$prefix ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SQUIT" and not $prefix) 1 1884 1885
Condition66%2/3
$cmd eq "SQUIT" and not $prefix
!ll&&!rl&&r
188401
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
743 1 $self->_daemon_peer_squit($conn_id, @$params);
744 #$self->_send_output_to_client(
745 # $conn_id,
746 # $prefix,
747 # (ref $_ eq 'ARRAY' ? @{ $_ } : $_)
748 #) for $self->_daemon_cmd_squit($prefix, @$params);
749 1 last SWITCH;
750 }
751  
752 1884 ▶ if ($cmd =~ /\d{3}/ && $params->[0] !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\d{3}/ and not $params->[0] =~ /^$sid/) 0 1884 1884
Condition66%2/3
$cmd =~ /\d{3}/ and not $params->[0] =~ /^$sid/
!ll&&!rl&&r
1873110
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
753 0 $self->send_output(
754 $input,
755 $self->_state_uid_route($params->[0]),
756 );
757 0 last SWITCH;
758 }
759 1884 ▶ if ($cmd =~ /\d{3}/ && $params->[0] =~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\d{3}/ and $params->[0] =~ /^$sid/) 11 1873 1884
Condition66%2/3
$cmd =~ /\d{3}/ and $params->[0] =~ /^$sid/
!ll&&!rl&&r
1873011
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
760 11 $input->{prefix} = $self->_state_sid_name($prefix);
761 11 my $uid = $params->[0];
762 11 $input->{params}[0] = $self->state_user_nick($uid);
763 11 $self->send_output(
764 $input,
765 $self->_state_uid_route($uid),
766 );
767 11 last SWITCH;
768 }
769 1873 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 5 1868 1873
770 $self->send_output(
771 5 @{ $self->_daemon_peer_quit(
772 $prefix, @$params, $conn_id
773 )}
774 );
775 5 last SWITCH;
776 }
777  
778 1868 ▶ if ($cmd =~ /^(PRIVMSG|NOTICE)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PRIVMSG|NOTICE)$/) 7 1861 1868
779 $self->_send_output_to_client(
780 $conn_id,
781 $prefix,
782 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_)
783 7 ▶ ) for $self->_daemon_peer_message(
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
784 $conn_id,
785 $prefix,
786 $cmd,
787 @$params
788 );
789 7 last SWITCH;
790 }
791  
792 1861 ▶ 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 1855 1861
793 6 my $client_method = '_daemon_peer_miscell';
794 6 ▶ $client_method = '_daemon_peer_links' if $cmd eq 'LINKS';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "LINKS" 1 5 6
795 $self->_send_output_to_client(
796 $conn_id,
797 $prefix,
798 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_ )
799 6 ▶ ) for $self->$client_method($cmd, $prefix, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 34 34
800 6 last SWITCH;
801 }
802  
803 1855 ▶ if ($cmd =~ /^(PING|PONG)$/i && $self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PING|PONG)$/i and $self->can($method)) 251 1604 1855
Condition66%2/3
$cmd =~ /^(PING|PONG)$/i and $self->can($method)
!ll&&!rl&&r
16040251
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
804 251 $self->$method($conn_id, $prefix, @{ $params });
805 251 last SWITCH;
806 }
807  
808 1604 ▶ if ($cmd =~ /^SVINFO$/i && $self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^SVINFO$/i and $self->can($method)) 253 1351 1604
Condition66%2/3
$cmd =~ /^SVINFO$/i and $self->can($method)
!ll&&!rl&&r
13510253
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
809 253 $self->$method($conn_id, @$params);
810 253 my $conn = $self->{state}{conns}{$conn_id};
811 $self->send_event(
812 "daemon_svinfo",
813 $conn->{name},
814 253 @$params,
815 );
816 253 last SWITCH;
817 }
818  
819 1351 ▶ if ( $cmd =~ m!^E?TRACE$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^E?TRACE$/i) 4 1347 1351
820 4 $self->send_output( $_, $conn_id ) for
821 $self->_daemon_peer_tracing($cmd, $conn_id, $prefix, @$params);
822 4 last SWITCH;
823 }
824  
825 # Chanmode and umode have distinct commands now
826 # No need for check, MODE is always umode
827 1347 ▶ if ($cmd eq 'MODE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "MODE") 0 1347 1347
828 0 $method = '_daemon_peer_umode';
829 }
830  
831 1347 ▶ if ($cmd =~ m!^(UN)?([DKX]LINE|RESV)$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(UN)?([DKX]LINE|RESV)$/i) 12 1335 1347
832 12 $self->send_output( $_, $conn_id ) for
833 $self->$method($conn_id, $prefix, @$params);
834 12 last SWITCH;
835 }
836  
837 1335 ▶ if ($cmd =~ m!^WHO(IS|WAS)$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^WHO(IS|WAS)$/i) 4 1331 1335
838 4 $self->send_output( $_, $conn_id ) for
839 $self->$method($conn_id, $prefix, @$params);
840 4 last SWITCH;
841 }
842  
843 1331 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 1331 0 1331
844 1331 $self->$method($conn_id, $prefix, @$params);
845 1331 last SWITCH;
846 }
847 0 $invalid = 1;
848 }
849  
850 1885 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 1885 1885
851 1885 $self->_state_cmd_stat($cmd, $input->{raw_line}, 1);
852 1885 return 1;
853 }
854  
855 sub _cmd_from_client {
856 787 ▶ my ($self, $wheel_id, $input) = @_;
Subroutine _cmd_from_client: called CC=40 SCAR=38.1
857  
858 787 my $cmd = uc $input->{command};
859 787 ▶ my $params = $input->{params} || [ ];
Condition100%2/2
$input->{'params'} || []
l!l
73255
MC/DC100%1/1
$input->{'params'} || []
$input->{'params'}
Truth table100%2/2
A
A= $input->{'params'}
Aresult
11
00
860 787 my $pcount = @$params;
861 787 my $server = $self->server_name();
862 787 my $nick = $self->_client_nickname($wheel_id);
863 787 my $uid = $self->_client_uid($wheel_id);
864 787 my $invalid = 0;
865 787 my $pseudo = 0;
866  
867 SWITCH: {
868 787 my $method = '_daemon_cmd_' . lc $cmd;
869 787 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 196 591 787
870 196 my $qmsg = $params->[0];
871 196 delete $self->{state}{localops}{ $wheel_id };
872 196 ▶ 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 189 196
Condition100%3/3
$qmsg and my $msgtime = $self->{"config"}{"anti_spam_exit_message_time"}
!ll&&!rl&&r
261637
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
873 $qmsg = '' if
874 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
875 }
876 $self->_terminate_conn_error(
877 196 ▶ $wheel_id,
Branch: 1 branch
BranchTrueFalseTotal
$qmsg ? : 163 33 196
878 ($qmsg ? qq{Quit: "$qmsg"} : 'Client Quit'),
879 );
880 196 last SWITCH;
881 }
882  
883 591 ▶ if ($cmd =~ /^(USERHOST|MODE)$/ && !$pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(USERHOST|MODE)$/ and not $pcount) 0 591 591
Condition66%2/3
$cmd =~ /^(USERHOST|MODE)$/ and not $pcount
!ll&&!rl&&r
3102810
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
884 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
885 0 last SWITCH;
886 }
887 591 ▶ if ($cmd =~ /^(USERHOST)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(USERHOST)$/) 1 590 591
888 $self->_send_output_to_client($wheel_id, $_)
889 1 ▶ for $self->$method(
Branch: 1 branch
BranchTrueFalseTotal
$pcount <= 5 ? : 1 0 1
890 $nick,
891 ($pcount <= 5
892 ? @$params
893 0 : @{ $params }[0..5]
894 )
895 );
896 1 last SWITCH;
897 }
898  
899 590 ▶ if ($cmd =~ /^(PRIVMSG|NOTICE)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PRIVMSG|NOTICE)$/) 30 560 590
900 30 $self->{state}{conns}{$wheel_id}{idle_time} = time;
901 $self->_send_output_to_client(
902 $wheel_id,
903 7 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
904 30 ▶ ) for $self->_daemon_cmd_message($nick, $cmd, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 7 2 9
905 30 last SWITCH;
906 }
907  
908 560 ▶ 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])) 227 333 560
Condition100%3/3
$cmd eq "MODE" and $self->state_nick_exists($params->[0])
!ll&&!rl&&r
28053227
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
909 227 ▶ if (uc_irc($nick) ne uc_irc($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc_irc($nick) ne uc_irc($params->[0])) 0 227 227
910 0 $self->_send_output_to_client($wheel_id => '502');
911 0 last SWITCH;
912 }
913  
914 1 $self->_send_output_to_client($wheel_id, (ref $_ eq 'ARRAY' ? @{ $_ } : $_) )
915 227 ▶ for $self->_daemon_cmd_umode($nick, @{ $params }[1..$#{ $params }]);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 226 227
916 227 last SWITCH;
917 }
918  
919 333 ▶ if ($cmd eq 'CAP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAP") 0 333 333
920 0 $self->_daemon_cmd_cap($wheel_id, @$params);
921 0 last SWITCH;
922 }
923  
924 333 ▶ if ( $cmd =~ m!^(ADMIN|INFO|VERSION|TIME|MOTD)$! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(ADMIN|INFO|VERSION|TIME|MOTD)$/) 6 327 333
925 $self->_send_output_to_client(
926 $wheel_id,
927 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
928 6 ▶ ) for $self->_daemon_client_miscell($cmd, $nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 30 30
929 6 last SWITCH;
930 }
931  
932 327 ▶ if ( $cmd =~ m!^E?TRACE$!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^E?TRACE$/i) 6 321 327
933 $self->_send_output_to_client(
934 $wheel_id,
935 1 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
936 6 ▶ ) for $self->_daemon_client_tracing($cmd, $nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 17 18
937 6 last SWITCH;
938 }
939  
940 321 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 317 4 321
941 $self->_send_output_to_client(
942 $wheel_id,
943 33 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
944 317 ▶ ) for $self->$method($nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 33 308 341
945 317 last SWITCH;
946 }
947  
948 4 ▶ if (defined $self->{config}{pseudo}{$cmd}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"config"}{"pseudo"}{$cmd}) 3 1 4
949 3 $pseudo = 1;
950 3 my $pseudo = $self->{config}{pseudo}{$cmd};
951 3 ▶ if (!$params->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params->[0]) 1 2 3
952 1 $self->_send_output_to_client($wheel_id, '412');
953 1 last SWITCH;
954 }
955 2 my $targ = $self->state_user_nick($pseudo->{nick});
956 2 my $serv = $self->_state_peer_name($pseudo->{host});
957 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
958 1 $self->_send_output_to_client($wheel_id, '440', $pseudo->{name});
959 1 last SWITCH;
960 }
961 1 my $msg;
962 1 ▶ if ($pseudo->{prepend}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pseudo->{'prepend'}) { } 1 0 1
963 1 ▶ my $join = ($pseudo->{prepend} =~ m! $! ? '' : ' ');
Branch: 1 branch
BranchTrueFalseTotal
$pseudo->{'prepend'} =~ / $/ ? : 0 1 1
964 1 $msg = join $join, $pseudo->{prepend}, $params->[0];
965 }
966 else {
967 0 $msg = $params->[0];
968 }
969 $self->_send_output_to_client(
970 $wheel_id,
971 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
972 1 ▶ ) for $self->_daemon_cmd_message($nick, 'PRIVMSG', $pseudo->{nick}, $msg);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
973 1 last SWITCH;
974 }
975  
976 1 $invalid = 1;
977 1 $self->_send_output_to_client($wheel_id, '421', $cmd);
978 }
979  
980 787 ▶ return 1 if $invalid || $pseudo;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid or $pseudo 4 783 787
Condition100%3/3
$invalid or $pseudo
l!l&&r!l&&!r
13783
MC/DC100%2/2
$invalid or $pseudo
$invalid $pseudo
Truth table100%3/3
A or B
A= $invalidB= $pseudo
ABresult
1X1
011
000
981 783 $self->_state_cmd_stat($cmd, $input->{raw_line});
982 783 return 1;
983 }
984  
985 sub _daemon_cmd_help {
986 5 ▶ my $self = shift;
Subroutine _daemon_cmd_help: called CC=11 SCAR=24.1
987 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
988 5 my $server = $self->server_name();
989 5 my $ref = [ ];
990 5 my $args = [@_];
991 5 my $count = @$args;
992  
993 SWITCH: {
994 5 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 2 3 5
995 2 my $lastuse = $self->{state}{lastuse}{help};
996 2 my $pacewait = $self->{config}{pace_wait};
997 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
998 1 push @$ref, ['263', 'HELP'];
999 1 last SWITCH;
1000 }
1001 1 $self->{state}{lastuse}{help} = time();
1002 }
1003 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
1004 4 ▶ if (!$self->{_help}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_help"}) 2 2 4
1005 2 require POE::Component::Server::IRC::Help;
1006 2 $self->{_help} = POE::Component::Server::IRC::Help->new();
1007 }
1008 4 $item = lc $item;
1009 4 my @lines = $self->{_help}->topic($item);
1010 4 ▶ if (!scalar @lines) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @lines) 1 3 4
1011 1 push @$ref, [ '524', $item ];
1012 1 last SWITCH;
1013 }
1014 3 my $reply = '704';
1015 3 foreach my $line (@lines) {
1016 43 push @$ref, {
1017 prefix => $server,
1018 command => $reply,
1019 params => [
1020 $nick,
1021 $item,
1022 $line,
1023 ],
1024 };
1025 43 $reply = '705';
1026 }
1027 3 push @$ref, {
1028 prefix => $server,
1029 command => '706',
1030 params => [
1031 $nick,
1032 $item,
1033 'End of /HELP.',
1034 ],
1035 };
1036 }
1037  
1038 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
1039 0 return $ref;
1040 }
1041  
1042 sub _daemon_cmd_watch {
1043 4 ▶ my $self = shift;
Subroutine _daemon_cmd_watch: called CC=31 SCAR=51.9
1044 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
1045 4 my $server = $self->server_name();
1046 4 my $ref = [ ];
1047 4 my $args = [@_];
1048 4 my $count = @$args;
1049  
1050 SWITCH: {
1051 4 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 4 4
1052 0 $args->[0] = 'l';
1053 }
1054 4 my $uid = $self->state_user_uid($nick);
1055 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
1056 4 my $list = 0;
1057 4 ITEM: foreach my $item ( split m!,!, $args->[0] ) {
1058 6 ▶ if ( $item =~ m!^\+! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^\+/) 4 2 6
1059 4 $item =~ s!^\+!!;
1060 4 ▶ if ( keys %$watches >= $self->{config}{max_watch} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$watches >= $self->{"config"}{"max_watch"}) 0 4 4
1061 0 push @$ref, ['512', $self->{config}{max_watch}];
1062 0 next ITEM;
1063 }
1064 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
1065 # Add_to_watch_list
1066 4 $watches->{uc_irc $item} = $item;
1067 4 $self->{state}{watches}{uc_irc $item}{uids}{$uid} = 1;
1068 # Show_watch possible refactor here
1069 4 ▶ if ( my $tuid = $self->state_user_uid($item) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tuid = $self->state_user_uid($item)) { } 0 4 4
1070 0 my $rec = $self->{state}{uids}{$tuid};
1071 push @$ref, {
1072 prefix => $server,
1073 command => '604',
1074 params => [
1075 $nick,
1076 $rec->{nick},
1077 $rec->{auth}{ident},
1078 $rec->{auth}{hostname},
1079 $rec->{ts},
1080 0 'is online',
1081 ],
1082 };
1083 }
1084 else {
1085 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
1086 4 push @$ref, {
1087 prefix => $server,
1088 command => '605',
1089 params => [
1090 $nick, $item, '*', '*', $laston, 'is offline'
1091 ],
1092 };
1093 }
1094 4 next ITEM;
1095 }
1096 2 ▶ if ( $item =~ m!^\-! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^\-/) 0 2 2
1097 0 $item =~ s!^\-!!;
1098 0 ▶ next ITEM if !$item;
Branch: 1 branch
BranchTrueFalseTotal
unless $item 0 0 0
1099 0 $item = uc_irc $item;
1100 0 my $pitem = delete $watches->{$item};
1101 0 delete $self->{state}{watches}{$item}{uids}{$uid};
1102 0 ▶ if ( my $tuid = $self->state_user_uid($item) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tuid = $self->state_user_uid($item)) { } 0 0 0
1103 0 my $rec = $self->{state}{uids}{$tuid};
1104 push @$ref, {
1105 prefix => $server,
1106 command => '602',
1107 params => [
1108 $nick,
1109 $rec->{nick},
1110 $rec->{auth}{ident},
1111 $rec->{auth}{hostname},
1112 $rec->{ts},
1113 0 'stopped watching',
1114 ],
1115 };
1116 }
1117 else {
1118 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
1119 0 push @$ref, {
1120 prefix => $server,
1121 command => '602',
1122 params => [
1123 $nick, $pitem, '*', '*', $laston, 'stopped watching'
1124 ],
1125 };
1126 }
1127 delete $self->{state}{watches}{$item}
1128 0 ▶ if !keys %{ $self->{state}{watches}{$item}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"watches"}{$item}{"uids"};} 0 0 0
1129 0 next ITEM;
1130 }
1131 2 ▶ if ( $item =~ m!^C!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^C/i) 0 2 2
1132 0 foreach my $watched ( keys %$watches ) {
1133 0 delete $self->{state}{watches}{$watched}{uids}{$uid};
1134 delete $self->{state}{watches}{$watched}
1135 0 ▶ if !keys %{ $self->{state}{watches}{$watched}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"watches"}{$watched}{"uids"};} 0 0 0
1136 }
1137 0 $watches = { };
1138 0 next ITEM;
1139 }
1140 2 ▶ if ( $item =~ m!^S!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^S/i) 2 0 2
1141 2 ▶ next ITEM if $list & 0x1;
Branch: 1 branch
BranchTrueFalseTotal
if $list & 1 0 2 2
1142 2 $item = substr $item, 0, 1;
1143 2 $list |= 0x1;
1144 2 my @watching = sort keys %$watches;
1145 2 my $wcount = 0;
1146 2 my $mcount = @watching;
1147 2 ▶ if ( defined $self->{state}{watches}{uc_irc $nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{uc_irc($nick)}) 0 2 2
1148 0 $wcount = keys %{ $self->{state}{watches}{uc_irc $nick}{uids} };
1149 }
1150 2 push @$ref, {
1151 prefix => $server,
1152 command => '603',
1153 params => [
1154 $nick,
1155 "You have $mcount and are on $wcount WATCH entries",
1156 ],
1157 };
1158 2 my $len = length($server) + length($nick) + 8;
1159 2 my $buf = '';
1160 2 WATCHED: foreach my $watched ( @watching ) {
1161 4 $watched = $watches->{$watched};
1162 4 ▶ if (length(join ' ', $buf, $watched)+$len+1 > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buf, $watched) + $len + 1 > 510) 0 4 4
1163 0 push @$ref, {
1164 prefix => $server,
1165 command => '606',
1166 params => [ $nick, $buf ],
1167 };
1168 0 $buf = $watched;
1169 0 next WATCHED;
1170 }
1171 4 $buf = join ' ', $buf, $watched;
1172 4 $buf =~ s!^\s+!!;
1173 }
1174 2 ▶ if ($buf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf) 2 0 2
1175 2 push @$ref, {
1176 prefix => $server,
1177 command => '606',
1178 params => [ $nick, $buf ],
1179 };
1180 }
1181 2 push @$ref, {
1182 prefix => $server,
1183 command => '607',
1184 params => [
1185 $nick,
1186 "End of WATCH $item",
1187 ],
1188 };
1189 2 next ITEM;
1190 }
1191 0 ▶ if ( $item =~ m!^L!i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^L/i) 0 0 0
1192 0 ▶ next ITEM if $list & 0x2;
Branch: 1 branch
BranchTrueFalseTotal
if $list & 2 0 0 0
1193 0 $item = substr $item, 0, 1;
1194 0 $list |= 0x2;
1195 0 foreach my $watched ( keys %$watches ) {
1196 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
1197 0 my $rec = $self->{state}{uids}{$tuid};
1198 push @$ref, {
1199 prefix => $server,
1200 command => '604',
1201 params => [
1202 $nick,
1203 $rec->{nick},
1204 $rec->{auth}{ident},
1205 $rec->{auth}{hostname},
1206 $rec->{ts},
1207 0 'is online',
1208 ],
1209 };
1210 }
1211 elsif ( $item eq 'L' ) {
1212 push @$ref, {
1213 prefix => $server,
1214 command => '605',
1215 params => [
1216 0 $nick, $watches->{$watched}, '*', '*', 0, 'is offline'
1217 ],
1218 };
1219 }
1220 }
1221 0 push @$ref, {
1222 prefix => $server,
1223 command => '607',
1224 params => [
1225 $nick,
1226 "End of WATCH $item",
1227 ],
1228 };
1229 0 next ITEM;
1230 }
1231 }
1232 4 $self->{state}{uids}{$uid}{watches} = $watches;
1233 }
1234  
1235 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4 0 4
1236 0 return $ref;
1237 }
1238  
1239 sub _daemon_cmd_cap {
1240 141 ▶ my $self = shift;
Subroutine _daemon_cmd_cap: called CC=17 SCAR=32.0
1241 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
1242 141 my $subcmd = shift;
1243 141 my $args = [@_];
1244 141 my $server = $self->server_name();
1245  
1246 141 my $registered = $self->_connection_registered($wheel_id);
1247  
1248 SWITCH: {
1249 141 ▶ if (!$subcmd) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subcmd) 0 141 141
1250 0 $self->_send_output_to_client($wheel_id, '461', 'CAP');
1251 0 last SWITCH;
1252 }
1253 141 $subcmd = uc $subcmd;
1254 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
1255 0 $self->_send_output_to_client($wheel_id, '410', $subcmd);
1256 0 last SWITCH;
1257 }
1258 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
1259 0 last SWITCH;
1260 }
1261 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
1262 43 my $capneg = delete $self->{state}{conns}{$wheel_id}{capneg};
1263 43 ▶ $self->_client_register($wheel_id) if $capneg;
Branch: 1 branch
BranchTrueFalseTotal
if $capneg 43 0 43
1264 43 last SWITCH;
1265 }
1266 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
1267 98 ▶ if ( $subcmd eq 'LS' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "LS") 32 66 98
1268 32 my $output = {
1269 prefix => $server,
1270 command => 'CAP',
1271 params => [ $self->_client_nickname($wheel_id), $subcmd, ],
1272 };
1273 32 push @{ $output->{params} }, join ' ', sort keys %{ $self->{state}{caps} };
1274 32 $self->_send_output_to_client($wheel_id, $output);
1275 32 last SWITCH;
1276 }
1277 66 ▶ if ( $subcmd eq 'LIST' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "LIST") 0 66 66
1278 0 my $output = {
1279 prefix => $server,
1280 command => 'CAP',
1281 params => [ $self->_client_nickname($wheel_id), $subcmd, ],
1282 };
1283 0 push @{ $output->{params} }, join ' ', sort keys %{ $self->{state}{conns}{$wheel_id}{caps} };
1284 0 $self->_send_output_to_client($wheel_id, $output);
1285 0 last SWITCH;
1286 }
1287 66 ▶ if ( $subcmd eq 'REQ' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcmd eq "REQ") 66 0 66
1288 66 foreach my $cap ( split ' ', $args->[0] ) {
1289 73 my $ocap = $cap;
1290 73 my $neg = $cap =~ s!^\-!!;
1291 73 $cap = lc $cap;
1292 73 ▶ if ( !$self->{state}{caps}{$cap} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"state"}{"caps"}{$cap}) 23 50 73
1293 23 my $output = {
1294 prefix => $server,
1295 command => 'CAP',
1296 params => [ $self->_client_nickname($wheel_id), 'NAK', $args->[0] ],
1297 };
1298 23 $self->_send_output_to_client($wheel_id, $output);
1299 23 last SWITCH;
1300 }
1301 50 ▶ if ( $neg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($neg) { } 0 50 50
1302 0 delete $self->{state}{conns}{$wheel_id}{caps}{$cap};
1303 }
1304 else {
1305 50 $self->{state}{conns}{$wheel_id}{caps}{$cap} = 1;
1306 }
1307 }
1308 43 my $output = {
1309 prefix => $server,
1310 command => 'CAP',
1311 params => [ $self->_client_nickname($wheel_id), 'ACK', $args->[0] ],
1312 };
1313 43 $self->_send_output_to_client($wheel_id, $output);
1314 43 last SWITCH;
1315 }
1316 }
1317  
1318 141 return 1;
1319 }
1320  
1321 sub _daemon_cmd_message {
1322 31 ▶ my $self = shift;
Subroutine _daemon_cmd_message: called CC=79 SCAR=69.9
1323 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
1324 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
1325 31 my $ref = [ ];
1326 31 my $args = [@_];
1327 31 my $count = @$args;
1328  
1329 SWITCH: {
1330 31 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 31 31
1331 0 push @$ref, ['461', $type];
1332 0 last SWITCH;
1333 }
1334 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
1335 0 push @$ref, ['412'];
1336 0 last SWITCH;
1337 }
1338  
1339 31 my $targets = 0;
1340 31 my $max_targets = $self->server_config('MAXTARGETS');
1341 31 my $uid = $self->state_user_uid($nick);
1342 31 my $sid = $self->server_sid();
1343 31 my $full = $self->state_user_full($nick);
1344 31 my $targs = $self->_state_parse_msg_targets($args->[0]);
1345  
1346 31 LOOP: for my $target (keys %$targs) {
1347 31 my $targ_type = shift @{ $targs->{$target} };
1348  
1349 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
1350 && !$self->state_user_is_operator($nick)) {
1351 0 push @$ref, ['481'];
1352 0 next LOOP;
1353 }
1354  
1355 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
1356 && $targs->{$target}[0] !~ /\./) {
1357 0 push @$ref, ['413', $target];
1358 0 next LOOP;
1359 }
1360  
1361 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
1362 && $targs->{$target}[1] =~ /\x2E[^.]*[\x2A\x3F]+[^.]*$/) {
1363 0 push @$ref, ['414', $target];
1364 0 next LOOP;
1365 }
1366  
1367 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
1368 && !$self->state_chan_exists($targs->{$target}[1])) {
1369 0 push @$ref, ['401', $targs->{$target}[1]];
1370 0 next LOOP;
1371 }
1372  
1373 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
1374 && !$self->state_chan_exists($target)) {
1375 0 push @$ref, ['401', $target];
1376 0 next LOOP;
1377 }
1378  
1379 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
1380 && !$self->state_nick_exists($target)) {
1381 0 push @$ref, ['401', $target];
1382 0 next LOOP;
1383 }
1384  
1385 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
1386 && !$self->state_peer_exists($targs->{$target}[1])) {
1387 0 push @$ref, ['402', $targs->{$target}[1]];
1388 0 next LOOP;
1389 }
1390  
1391 31 $targets++;
1392 31 ▶ if ($targets > $max_targets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targets > $max_targets) 0 31 31
1393 0 push @$ref, ['407', $target];
1394 0 last SWITCH;
1395 }
1396  
1397 # $$whatever
1398 31 ▶ if ($targ_type eq 'servermask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "servermask") 0 31 31
1399 0 my $us = 0;
1400 0 my %targets;
1401 0 my $ucserver = uc $self->server_name();
1402  
1403 0 for my $peer (keys %{ $self->{state}{peers} }) {
1404 0 ▶ if (matches_mask( $targs->{$target}[0], $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targs->{$target}[0], $peer)) 0 0 0
1405 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
1406 0 $us = 1;
1407 }
1408 else {
1409 0 $targets{ $self->_state_peer_route($peer) }++;
1410 }
1411 }
1412 }
1413  
1414 $self->send_output(
1415 {
1416 0 prefix => $uid,
1417 command => $type,
1418 params => [$target, $args->[1]],
1419 },
1420 keys %targets,
1421 );
1422  
1423 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
1424 my $local
1425 0 = $self->{state}{peers}{uc $self->server_name()}{users};
1426 0 my @local;
1427 0 my $spoofed = 0;
1428  
1429 0 for my $luser (values %$local) {
1430 0 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 0 0
1431 0 $spoofed = 1;
1432 }
1433 else {
1434 0 push @local, $luser->{route_id};
1435 }
1436 }
1437  
1438 $self->send_output(
1439 {
1440 0 prefix => $full,
1441 command => $type,
1442 params => [$target, $args->[1]],
1443 },
1444 @local,
1445 );
1446  
1447 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
1448 "daemon_" . lc $type,
1449 $full,
1450 $target,
1451 $args->[1],
1452 ) if $spoofed;
1453 }
1454 0 next LOOP;
1455 }
1456  
1457 # $#whatever
1458 31 ▶ if ($targ_type eq 'hostmask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "hostmask") 0 31 31
1459 0 my $spoofed = 0;
1460 0 my %targets; my @local;
1461  
1462 0 HOST: for my $luser (values %{ $self->{state}{users} }) {
1463 0 ▶ if (!matches_mask($targs->{$target}[0],
Branch: 1 branch
BranchTrueFalseTotal
unless (matches_mask($targs->{$target}[0], $luser->{"auth"}{"hostname"})) 0 0 0
1464 $luser->{auth}{hostname})) {;
1465 0 next HOST;
1466 }
1467  
1468 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
1469 0 $spoofed = 1;
1470 }
1471 elsif ($luser->{type} eq 'r') {
1472 0 $targets{ $luser->{route_id} }++;
1473 }
1474 else {
1475 0 push @local, $luser->{route_id};
1476 }
1477 }
1478  
1479 $self->send_output(
1480 {
1481 0 prefix => $uid,
1482 command => $type,
1483 params => [$target, $args->[1]],
1484 },
1485 keys %targets,
1486 );
1487  
1488 0 $self->send_output(
1489 {
1490 prefix => $full,
1491 command => $type,
1492 params => [$target, $args->[1]],
1493 },
1494 @local,
1495 );
1496  
1497 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
1498 "daemon_" . lc $type,
1499 $full,
1500 $target,
1501 $args->[1],
1502 ) if $spoofed;
1503  
1504 0 next LOOP;
1505 }
1506  
1507 31 ▶ if ($targ_type eq 'nick_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext") 0 31 31
1508 $targs->{$target}[1] = $self->_state_peer_name(
1509 0 $targs->{$target}[1]);
1510  
1511 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
1512 && !$self->state_user_is_operator($nick)) {
1513 0 push @$ref, ['481'];
1514 0 next LOOP;
1515 }
1516  
1517 0 ▶ if ($targs->{$target}[1] ne $self->server_name()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[1] ne $self->server_name) 0 0 0
1518 $self->send_output(
1519 {
1520 prefix => $uid,
1521 command => $type,
1522 params => [$target, $args->[1]],
1523 },
1524 0 $self->_state_peer_route($targs->{$target}[1]),
1525 );
1526 0 next LOOP;
1527 }
1528  
1529 0 ▶ if (uc $targs->{$target}[0] eq 'OPERS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $targs->{$target}[0] eq "OPERS") 0 0 0
1530 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1531 0 push @$ref, ['481'];
1532 0 next LOOP;
1533 }
1534  
1535 $self->send_output(
1536 {
1537 prefix => $full,
1538 command => $type,
1539 params => [$target, $args->[1]],
1540 },
1541 0 keys %{ $self->{state}{localops} },
1542 );
1543 0 next LOOP;
1544 }
1545  
1546 my @local = $self->_state_find_user_host(
1547 $targs->{$target}[0],
1548 0 $targs->{$target}[2],
1549 );
1550  
1551 0 ▶ if (@local == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local == 1) { } 0 0 0
1552 0 my $ref = shift @local;
1553 0 ▶ if ($ref->[0] eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->[0] eq 'spoofed') { } 0 0 0
1554 0 $self->send_event(
1555 "daemon_" . lc $type,
1556 $full,
1557 $ref->[1],
1558 $args->[1],
1559 );
1560 }
1561 else {
1562 0 $self->send_output(
1563 {
1564 prefix => $full,
1565 command => $type,
1566 params => [$target, $args->[1]],
1567 },
1568 $ref->[0],
1569 );
1570 }
1571 }
1572 else {
1573 0 push @$ref, ['407', $target];
1574 0 next LOOP;
1575 }
1576 }
1577  
1578 31 my ($channel, $status_msg);
1579 31 ▶ if ($targ_type eq 'channel') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel") 17 14 31
1580 17 $channel = $self->_state_chan_name($target);
1581 }
1582 31 ▶ if ($targ_type eq 'channel_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext") 0 31 31
1583 0 $channel = $self->_state_chan_name($targs->{target}[1]);
1584 0 $status_msg = $targs->{target}[0];
1585 }
1586 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
1587 && !$self->state_user_chan_mode($nick, $channel)) {
1588 0 push @$ref, ['482', $target];
1589 0 next LOOP;
1590 }
1591 31 ▶ if ($channel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($channel) 17 14 31
1592 17 my $res = $self->state_can_send_to_channel($nick,$channel,$args->[1],$type);
1593 17 ▶ if ( !$res ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $res) { } 0 17 17
elsif (ref $res eq 'ARRAY') { } 7 10 17
1594 0 next LOOP;
1595 }
1596 elsif ( ref $res eq 'ARRAY' ) {
1597 7 push @$ref, $res;
1598 7 next LOOP;
1599 }
1600 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
1601 1 next LOOP;
1602 }
1603 9 my $common = { };
1604 9 ▶ my $msg = {
Branch: 1 branch
BranchTrueFalseTotal
$status_msg ? : 0 9 9
1605 command => $type,
1606 params => [
1607 ($status_msg ? $target : $channel), $args->[1]
1608 ],
1609 };
1610 9 for my $member ($self->state_chan_list($channel, $status_msg)) {
1611 27 ▶ next if $self->_state_user_is_deaf($member);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_is_deaf($member) 0 27 27
1612 27 $common->{ $self->_state_user_route($member) }++;
1613 }
1614 9 delete $common->{ $self->_state_user_route($nick) };
1615 9 for my $route_id (keys %$common) {
1616 18 $msg->{prefix} = $uid;
1617 18 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 17 1 18
1618 17 $msg->{prefix} = $full;
1619 }
1620 18 ▶ if ($route_id ne 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id ne 'spoofed') { } 18 0 18
1621 18 $self->send_output($msg, $route_id);
1622 }
1623 else {
1624 0 ▶ my $tmsg = $type eq 'PRIVMSG' ? 'public' : 'notice';
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'PRIVMSG' ? : 0 0 0
1625 0 $self->send_event(
1626 "daemon_$tmsg",
1627 $full,
1628 $channel,
1629 $args->[1],
1630 );
1631 }
1632 }
1633 9 next LOOP;
1634 }
1635  
1636 14 my $server = $self->server_name();
1637 14 ▶ if ($self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($target)) 14 0 14
1638 14 $target = $self->state_user_nick($target);
1639  
1640 # Flood check
1641 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
1642  
1643 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
1644 0 push @$ref, {
1645 prefix => $server,
1646 command => '301',
1647 params => [$nick, $target, $away],
1648 };
1649 }
1650  
1651 13 my $targ_umode = $self->state_user_umode($target);
1652  
1653 # Target user has CALLERID on
1654 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
1655 1 my $targ_rec = $self->{state}{users}{uc_irc($target)};
1656 1 my $targ_uid = $targ_rec->{uid};
1657 1 my $local = $targ_uid =~ m!^sid!;
1658 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
1659 && (!$self->state_users_share_chan($target, $nick)
1660 || !$targ_rec->{accepts}{uc_irc($nick)}))
1661 || ($targ_umode =~ /g/
1662 && !$targ_rec->{accepts}{uc_irc($nick)})) {
1663  
1664 1 push @$ref, {
1665 prefix => $server,
1666 command => '716',
1667 params => [
1668 $nick,
1669 $target,
1670 'is in +g mode (server side ignore)',
1671 ],
1672 };
1673  
1674 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
1675 || time() - $targ_rec->{last_caller} >= 60) {
1676  
1677 1 my ($n, $uh) = split /!/,
1678 $self->state_user_full($nick);
1679 $self->send_output(
1680 {
1681 prefix => ( $local ? $server : $sid ),
1682 command => '718',
1683 params => [
1684 ( $local ? $target : $targ_uid ),
1685 "$n\[$uh\]",
1686 'is messaging you, and you are umode +g.',
1687 ]
1688 },
1689 $targ_rec->{route_id},
1690 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
1691 1 push @$ref, {
1692 prefix => $server,
1693 command => '717',
1694 params => [
1695 $nick,
1696 $target,
1697 'has been informed that you messaged them.',
1698 ],
1699 };
1700 }
1701 1 $targ_rec->{last_caller} = time();
1702 1 next LOOP;
1703 }
1704 }
1705  
1706 12 my $targ_uid = $self->state_user_uid($target);
1707 12 my $msg = {
1708 prefix => $uid,
1709 command => $type,
1710 params => [$targ_uid, $args->[1]],
1711 };
1712 12 my $route_id = $self->_state_user_route($target);
1713  
1714 12 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 2 10 12
1715 2 $msg->{prefix} = $full;
1716 2 $self->send_event(
1717 "daemon_" . lc $type,
1718 $full,
1719 $target,
1720 $args->[1],
1721 );
1722 }
1723 else {
1724 10 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 5 5 10
1725 5 $msg->{prefix} = $full;
1726 5 $msg->{params}[0] = $target;
1727 }
1728 10 $self->send_output($msg, $route_id);
1729 }
1730 12 next LOOP;
1731 }
1732 }
1733 }
1734  
1735 31 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 31 0 31
1736 0 return $ref;
1737 }
1738  
1739 sub _daemon_cmd_accept {
1740 0 ▶ my $self = shift;
Subroutine _daemon_cmd_accept: not called CC=21 SCAR=61.4
1741 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
1742 0 my $server = $self->server_name();
1743 0 my $ref = [ ];
1744 0 my $args = [ @_ ];
1745 0 my $count = @$args;
1746  
1747 SWITCH: {
1748 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
1749 0 my $record = $self->{state}{users}{uc_irc($nick)};
1750 0 my @list;
1751 0 for my $accept (keys %{ $record->{accepts} }) {
1752 0 ▶ if (!$self->state_nick_exists($accept)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($accept)) 0 0 0
1753 0 delete $record->{accepts}{$accept};
1754 0 next;
1755 }
1756 0 push @list, $self->state_user_nick($accept);
1757 }
1758 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if @list 0 0 0
1759 prefix => $server,
1760 command => '281',
1761 params => [$nick, join( ' ', @list)],
1762 } if @list;
1763  
1764 0 push @$ref, {
1765 prefix => $server,
1766 command => '282',
1767 params => [$nick, 'End of /ACCEPT list'],
1768 };
1769 0 last SWITCH;
1770 }
1771 }
1772  
1773 0 my $record = $self->{state}{users}{uc_irc($nick)};
1774  
1775 0 for (keys %{ $record->{accepts} }) {
1776 0 ▶ delete $record->{accepts}{$_} if !$self->state_nick_exists($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($_) 0 0 0
1777 }
1778  
1779 0 OUTER: for my $target (split /,/, $args->[0]) {
1780 0 ▶ if (my ($foo) = $target =~ /^\-(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($foo) = $target =~ /^\-(.+)$/) 0 0 0
1781 0 my $dfoo = delete $record->{accepts}{uc_irc($foo)};
1782 0 ▶ if (!$dfoo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dfoo) 0 0 0
1783 0 push @$ref, {
1784 prefix => $server,
1785 command => '458',
1786 params => [$nick, $foo, "doesn\'t exist"],
1787 };
1788 }
1789 0 delete $self->{state}{accepts}{uc_irc($foo)}{uc_irc($nick)};
1790 0 ▶ if (!keys %{ $self->{state}{accepts}{uc_irc($foo)} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$self->{"state"}{"accepts"}{uc_irc($foo)};}) 0 0 0
1791 0 delete $self->{state}{accepts}{uc_irc($foo)};
1792 }
1793 0 next OUTER;
1794 }
1795  
1796 0 ▶ if (!$self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($target)) 0 0 0
1797 0 push @$ref, ['401', $target];
1798 0 next OUTER;
1799 }
1800 # 457 ERR_ACCEPTEXIST
1801 0 ▶ if ($record->{accepts}{uc_irc($target)}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"accepts"}{uc_irc($target)}) 0 0 0
1802 0 push @$ref, {
1803 prefix => $server,
1804 command => '457',
1805 params => [
1806 $nick,
1807 $self->state_user_nick($target),
1808 'already exists',
1809 ],
1810 };
1811 0 next OUTER;
1812 }
1813  
1814 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
1815 && $self->_state_users_share_chan($nick, $target) ) {
1816 0 push @$ref, {
1817 prefix => $server,
1818 command => '457',
1819 params => [
1820 $nick,
1821 $self->state_user_nick($target),
1822 'already exists',
1823 ],
1824 };
1825 0 next OUTER;
1826 }
1827  
1828 $self->{state}{accepts}{uc_irc($target)}{uc_irc($nick)}
1829 0 = $record->{accepts}{uc_irc($target)} = time;
1830 0 my @list = map { $self->state_user_nick($_) } keys %{ $record->{accepts} };
1831  
1832 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if @list 0 0 0
1833 prefix => $server,
1834 command => '281',
1835 params => [
1836 $nick,
1837 join(' ', @list),
1838 ],
1839 } if @list;
1840  
1841 0 push @$ref, {
1842 prefix => $server,
1843 command => '282',
1844 params => [$nick, 'End of /ACCEPT list'],
1845 };
1846 }
1847  
1848 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1849 0 return $ref;
1850 }
1851  
1852 sub _daemon_cmd_quit {
1853 222 ▶ my $self = shift;
Subroutine _daemon_cmd_quit: called CC=19 SCAR=29.5
1854 222 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
2220
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1855 222 my $qmsg = shift;
1856 222 my $ref = [ ];
1857 222 my $name = uc $self->server_name();
1858 222 my $sid = $self->server_sid();
1859  
1860 222 $nick = uc_irc($nick);
1861 222 my $record = delete $self->{state}{peers}{$name}{users}{$nick};
1862 222 ▶ $qmsg = 'Client Quit' if !$qmsg;
Branch: 1 branch
BranchTrueFalseTotal
unless $qmsg 0 222 222
1863 222 my $full = $record->{full}->();
1864 222 delete $self->{state}{peers}{$name}{uids}{ $record->{uid} };
1865 222 my $uid = $record->{uid};
1866 $self->send_output(
1867 {
1868 prefix => $uid,
1869 command => 'QUIT',
1870 params => [$qmsg],
1871 },
1872 $self->_state_connected_peers(),
1873 222 ▶ ) if !$record->{killed};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"killed"} 219 3 222
1874  
1875 222 push @$ref, {
1876 prefix => $full,
1877 command => 'QUIT',
1878 params => [$qmsg],
1879 };
1880 222 $self->send_event("daemon_quit", $full, $qmsg);
1881  
1882 # Remove from peoples accept lists
1883 222 for my $user (keys %{ $record->{accepts} }) {
1884 0 delete $self->{state}{users}{$user}{accepts}{uc_irc($nick)};
1885 }
1886  
1887 222 ▶ if ( defined $self->{state}{watches}{$nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$nick}) 1 221 222
1888 1 my $laston = time();
1889 1 $self->{state}{watches}{$nick}{laston} = $laston;
1890 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$nick}{uids} } ) {
1891 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
1892 1 my $wrec = $self->{state}{uids}{$wuid};
1893 $self->send_output(
1894 {
1895 prefix => $record->{server},
1896 command => '601',
1897 params => [
1898 $wrec->{nick},
1899 $record->{nick},
1900 $record->{auth}{ident},
1901 $record->{auth}{hostname},
1902 $laston,
1903 'logged offline',
1904 ],
1905 },
1906 $wrec->{route_id},
1907 1 );
1908 }
1909 }
1910 # clear WATCH list
1911 222 foreach my $watched ( keys %{ $record->{watches} } ) {
1912 4 delete $self->{state}{watches}{$watched}{uids}{$uid};
1913 delete $self->{state}{watches}{$watched}
1914 4 ▶ if !keys %{ $self->{state}{watches}{$watched}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$self{"state"}{"watches"}{$watched}{"uids"};} 4 0 4
1915 }
1916  
1917 # Okay, all 'local' users who share a common channel with user.
1918 222 my $common = { };
1919 222 for my $uchan (keys %{ $record->{chans} }) {
1920 90 delete $self->{state}{chans}{$uchan}{users}{$uid};
1921 90 for my $user ( keys %{ $self->{state}{chans}{$uchan}{users} } ) {
1922 80 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 25 55 80
1923 55 $common->{$user} = $self->_state_uid_route($user);
1924 }
1925  
1926 90 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 38 52 90
1927 38 delete $self->{state}{chans}{$uchan};
1928 }
1929 }
1930  
1931 222 push @$ref, $common->{$_} for keys %$common;
1932 222 ▶ $self->{state}{stats}{ops_online}-- if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 25 197 222
1933 222 ▶ $self->{state}{stats}{invisible}-- if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 217 5 222
1934 222 ▶ delete $self->{state}{users}{$nick} if !$record->{nick_collision};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"nick_collision"} 216 6 222
1935 222 delete $self->{state}{uids}{ $record->{uid} };
1936 222 delete $self->{state}{localops}{$record->{route_id}};
1937 222 unshift @{ $self->{state}{whowas}{$nick} }, {
1938 logoff => time(),
1939 account => $record->{account},
1940 nick => $record->{nick},
1941 user => $record->{auth}{ident},
1942 host => $record->{auth}{hostname},
1943 real => $record->{auth}{realhost},
1944 sock => $record->{socket}[0],
1945 ircname => $record->{ircname},
1946 222 server => $name,
1947 };
1948 222 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 222 222
1949 222 return $ref;
1950 }
1951  
1952 sub _daemon_cmd_ping {
1953 3 ▶ my $self = shift;
Subroutine _daemon_cmd_ping: called CC=8 SCAR=21.6
1954 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
1955 3 my $server = $self->server_name();
1956 3 my $sid = $self->server_sid();
1957 3 my $args = [ @_ ];
1958 3 my $count = @$args;
1959 3 my $ref = [ ];
1960  
1961 SWITCH: {
1962 3 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 1 2 3
1963 1 push @$ref, [ '409' ];
1964 1 last SWITCH;
1965 }
1966  
1967 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
1968 1 push @$ref, ['402', $args->[1]];
1969 1 last SWITCH;
1970 }
1971 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
1972 1 my $target = $self->_state_peer_sid($args->[1]);
1973 1 $self->send_output(
1974 {
1975 prefix => $self->state_user_uid($nick),
1976 command => 'PING',
1977 params => [$nick, $target],
1978 },
1979 $self->_state_sid_route($target),
1980 );
1981 1 last SWITCH;
1982 }
1983 0 push @$ref, {
1984 prefix => $sid,
1985 command => 'PONG',
1986 params => [$server, $args->[0]],
1987 };
1988 }
1989 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
1990 0 return $ref;
1991 }
1992  
1993 sub _daemon_cmd_pong {
1994 0 ▶ my $self = shift;
Subroutine _daemon_cmd_pong: not called CC=8 SCAR=42.8
1995 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
1996 0 my $server = uc $self->server_name();
1997 0 my $args = [ @_ ];
1998 0 my $count = @$args;
1999 0 my $ref = [ ];
2000  
2001 SWITCH: {
2002 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2003 0 push @$ref, ['409'];
2004 0 last SWITCH;
2005 }
2006 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
2007 0 push @$ref, ['402', $args->[1]];
2008 0 last SWITCH;
2009 }
2010 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
2011 0 my $target = $self->_state_peer_sid($args->[1]);
2012 0 $self->send_output(
2013 {
2014 prefix => $self->state_user_uid($nick),
2015 command => 'PONG',
2016 params => [$nick, $target],
2017 },
2018 $self->_state_sid_route($target),
2019 );
2020 0 last SWITCH;
2021 }
2022 0 delete $self->{state}{users}{uc_irc($nick)}{pinged};
2023 }
2024  
2025 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2026 0 return $ref;
2027 }
2028  
2029 sub _daemon_cmd_pass {
2030 0 ▶ my $self = shift;
Subroutine _daemon_cmd_pass: not called CC=3 SCAR=24.8
2031 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
2032 0 my $server = uc $self->server_name();
2033 0 my $ref = [['462']];
2034 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2035 0 return $ref;
2036 }
2037  
2038 sub _daemon_cmd_user {
2039 0 ▶ my $self = shift;
Subroutine _daemon_cmd_user: not called CC=3 SCAR=24.8
2040 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
2041 0 my $server = uc $self->server_name();
2042 0 my $ref = [['462']];
2043 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2044 0 return $ref;
2045 }
2046  
2047 sub _daemon_cmd_oper {
2048 24 ▶ my $self = shift;
Subroutine _daemon_cmd_oper: called CC=14 SCAR=27.6
2049 24 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
240
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2050 24 my $server = $self->server_name();
2051 24 my $sid = $self->server_sid();
2052 24 my $ref = [ ];
2053 24 my $args = [@_];
2054 24 my $count = @$args;
2055  
2056 SWITCH: {
2057 24 ▶ last SWITCH if $self->state_user_is_operator($nick);
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_user_is_operator($nick) 0 24 24
2058 24 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 24 24
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
0024
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
2059 0 push @$ref, ['461', 'OPER'];
2060 0 last SWITCH;
2061 }
2062  
2063 24 my $record = $self->{state}{users}{uc_irc($nick)};
2064 24 my $result = $self->_state_o_line($nick, @$args);
2065 24 ▶ if (!$result || $result <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result or $result <= 0) 3 21 24
Condition100%3/3
not $result or $result <= 0
l!l&&r!l&&!r
1221
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
2066 3 my $omsg; my $errcode = '491';
2067 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
2068 1 $omsg = 'no operator {} block';
2069 }
2070 elsif ($result == -1) {
2071 0 $omsg = 'password mismatch';
2072 0 $errcode = '464';
2073 }
2074 elsif ($result == -2) {
2075 1 $omsg = 'requires SSL/TLS';
2076 }
2077 elsif ($result == -3) {
2078 1 $omsg = 'client certificate fingerprint mismatch';
2079 }
2080 else {
2081 0 $omsg = 'host mismatch';
2082 }
2083 $self->_send_to_realops(
2084 sprintf(
2085 'Failed OPER attempt as %s by %s (%s) - %s',
2086 3 $args->[0], $nick, (split /!/, $record->{full}->())[1], $omsg),
2087 'Notice',
2088 's',
2089 );
2090 3 push @$ref, [$errcode];
2091 3 last SWITCH;
2092 }
2093 21 my $opuser = $args->[0];
2094 21 $self->{stats}{ops}++;
2095 21 $record->{umode} .= 'o';
2096 21 $record->{opuser} = $opuser;
2097 21 $self->{state}{stats}{ops_online}++;
2098 21 push @$ref, {
2099 prefix => $server,
2100 command => '381',
2101 params => [$nick, 'You are now an IRC operator'],
2102 };
2103  
2104 21 my @peers = $self->_state_connected_peers();
2105  
2106 21 ▶ if (my $whois = $self->{config}{ops}{$opuser}{whois}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $whois = $self->{"config"}{"ops"}{$opuser}{"whois"}) 0 21 21
2107 0 $record->{svstags}{313} = {
2108 numeric => '313',
2109 umodes => '+',
2110 tagline => $whois,
2111 };
2112 $self->send_output(
2113 {
2114 prefix => $sid,
2115 command => 'SVSTAG',
2116 params => [
2117 $record->{uid},
2118 $record->{ts},
2119 0 '313', '+', $whois,
2120 ],
2121 },
2122 @peers,
2123 );
2124 }
2125  
2126 21 ▶ 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
1920
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
2127 21 $record->{umode} .= $umode;
2128 21 $umode .= 'o';
2129 21 $umode = join '', sort split //, $umode;
2130  
2131 21 my $uid = $record->{uid};
2132 21 my $full = $record->{full}->();
2133  
2134 21 my $notice = sprintf("%s{%s} is now an operator",$full,$opuser);
2135  
2136 21 $self->send_output(
2137 {
2138 prefix => $sid,
2139 command => 'GLOBOPS',
2140 params => [ $notice ],
2141 },
2142 @peers,
2143 );
2144  
2145 21 $self->_send_to_realops( $notice );
2146  
2147 21 my $reply = {
2148 prefix => $uid,
2149 command => 'MODE',
2150 params => [$uid, "+$umode"],
2151 };
2152  
2153 21 $self->send_output(
2154 $reply,
2155 @peers,
2156 );
2157 21 $self->send_event(
2158 "daemon_umode",
2159 $full,
2160 "+$umode",
2161 );
2162  
2163  
2164 21 my $route_id = $record->{route_id};
2165 21 $self->{state}{localops}{$route_id} = time;
2166 21 $self->antiflood($route_id, 0);
2167 21 $reply->{prefix} = $full;
2168 21 $reply->{params}[0] = $record->{nick};
2169 21 push @$ref, $reply;
2170 }
2171  
2172 24 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 24 0 24
2173 0 return $ref;
2174 }
2175  
2176 sub _daemon_cmd_die {
2177 1 ▶ my $self = shift;
Subroutine _daemon_cmd_die: called CC=4 SCAR=15.2
2178 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
2179 1 my $server = $self->server_name();
2180 1 my $ref = [ ];
2181  
2182 SWITCH: {
2183 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2184 0 push @$ref, ['481'];
2185 0 last SWITCH;
2186 }
2187 1 $self->send_event("daemon_die", $nick);
2188 1 $self->shutdown();
2189 }
2190 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2191 0 return $ref;
2192 }
2193  
2194 sub _daemon_cmd_close {
2195 1 ▶ my $self = shift;
Subroutine _daemon_cmd_close: called CC=9 SCAR=23.9
2196 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
2197 1 my $server = $self->server_name();
2198 1 my $ref = [ ];
2199  
2200 SWITCH: {
2201 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2202 0 push @$ref, ['723','close'];
2203 0 last SWITCH;
2204 }
2205 1 $self->send_event("daemon_close", $nick);
2206 1 my $count = 0;
2207 1 foreach my $conn_id ( keys %{ $self->{state}{conns} } ) {
2208 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
2209 1 my $crec = $self->{state}{conns}{$conn_id};
2210 push @$ref, {
2211 prefix => $server,
2212 command => '362',
2213 params => [
2214 $nick,
2215 sprintf(
2216 '%s[%s@%s]',
2217 ( $crec->{name} || $crec->{nick} || '' ),
2218 ( $crec->{user} || 'unknown' ),
2219 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
2220 ),
2221 'Closed: status = unknown',
2222 ],
2223 };
2224 1 $count++;
2225 1 $self->_terminate_conn_error($conn_id,'Oper Closing');
2226 }
2227 1 push @$ref, {
2228 prefix => $server,
2229 command => '363',
2230 params => [
2231 $nick,
2232 $count,
2233 'Connections closed',
2234 ],
2235 };
2236 }
2237 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2238 0 return $ref;
2239 }
2240  
2241 sub _daemon_cmd_set {
2242 5 ▶ my $self = shift;
Subroutine _daemon_cmd_set: called CC=9 SCAR=33.3
2243 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
2244 5 my $server = $self->server_name();
2245 5 my $ref = [ ];
2246 5 my $args = [@_];
2247 5 my $count = @$args;
2248  
2249 my %vars = (
2250 FLOODCOUNT => sub {
2251 0 ▶ my $val = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
2252 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
2253 0 $self->{config}{floodcount} = $val;
2254 0 $self->_send_to_realops(
2255 sprintf(
2256 '%s has changed FLOODCOUNT to %s',
2257 $self->state_user_full($nick,1), $val,
2258 ), qw[Notice s],
2259 );
2260 }
2261 else {
2262 push @$ref, {
2263 prefix => $server,
2264 command => 'NOTICE',
2265 params => [
2266 $nick,
2267 sprintf(
2268 'FLOODCOUNT is currently %s',
2269 $self->{config}{floodcount},
2270 0 ),
2271 ],
2272 };
2273 }
2274 },
2275 FLOODTIME => sub {
2276 0 ▶ my $val = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
2277 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
2278 0 $self->{config}{floodtime} = $val;
2279 0 $self->_send_to_realops(
2280 sprintf(
2281 '%s has changed FLOODTIME to %s',
2282 $self->state_user_full($nick,1), $val,
2283 ), qw[Notice s],
2284 );
2285 }
2286 else {
2287 push @$ref, {
2288 prefix => $server,
2289 command => 'NOTICE',
2290 params => [
2291 $nick,
2292 sprintf(
2293 'FLOODTIME is currently %s',
2294 $self->{config}{floodtime},
2295 0 ),
2296 ],
2297 };
2298 }
2299 },
2300 IDENTTIMEOUT => sub {
2301 0 ▶ my $val = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
2302 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
2303 0 $self->{config}{ident_timeout} = $val;
2304 0 $self->_send_to_realops(
2305 sprintf(
2306 '%s has changed IDENTTIMEOUT to %s',
2307 $self->state_user_full($nick,1), $val,
2308 ), qw[Notice s],
2309 );
2310 }
2311 else {
2312 push @$ref, {
2313 prefix => $server,
2314 command => 'NOTICE',
2315 params => [
2316 $nick,
2317 sprintf(
2318 'IDENTTIMEOUT is currently %s',
2319 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
2320 ),
2321 ],
2322 };
2323 }
2324 },
2325 MAX => sub {
2326 2 ▶ my $val = shift;
Subroutine __ANON__: called CC=5 SCAR=18.0
2327 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
2328 1 ▶ if ( $val > 7000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val > 7000) 0 1 1
2329 push @$ref, {
2330 prefix => $server,
2331 command => 'NOTICE',
2332 params => [
2333 $nick,
2334 sprintf(
2335 'You cannot set MAXCLIENTS to > 7000, restoring to %u',
2336 $self->{config}{MAXCLIENTS},
2337 0 ),
2338 ],
2339 };
2340 0 return;
2341 }
2342 1 ▶ if ( $val < 32 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val < 32) 1 0 1
2343 push @$ref, {
2344 prefix => $server,
2345 command => 'NOTICE',
2346 params => [
2347 $nick,
2348 sprintf(
2349 'You cannot set MAXCLIENTS to < 32, restoring to %u',
2350 $self->{config}{MAXCLIENTS},
2351 1 ),
2352 ],
2353 };
2354 1 return;
2355 }
2356 0 $self->{config}{MAXCLIENTS} = $val;
2357 0 $self->_send_to_realops(
2358 sprintf(
2359 '%s has changed MAXCLIENTS to %s',
2360 $self->state_user_full($nick,1), $val,
2361 ), qw[Notice s],
2362 );
2363 }
2364 else {
2365 push @$ref, {
2366 prefix => $server,
2367 command => 'NOTICE',
2368 params => [
2369 $nick,
2370 sprintf(
2371 'MAXCLIENTS is currently %s',
2372 $self->{config}{MAXCLIENTS},
2373 1 ),
2374 ],
2375 };
2376 }
2377 },
2378 SPAMNUM => sub {
2379 0 ▶ my $val = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
2380 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
2381 0 $self->{config}{MAX_JOIN_LEAVE_COUNT} = $val;
2382 0 ▶ if ( $val == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val == 0) { } 0 0 0
2383 0 $self->_send_to_realops(
2384 sprintf(
2385 '%s has disabled ANTI_SPAMBOT',
2386 $self->state_user_full($nick,1),
2387 ), qw[Notice s],
2388 );
2389 }
2390 else {
2391 0 $self->_send_to_realops(
2392 sprintf(
2393 '%s has changed SPAMNUM to %s',
2394 $self->state_user_full($nick,1), $val,
2395 ), qw[Notice s],
2396 );
2397 }
2398 }
2399 else {
2400 push @$ref, {
2401 prefix => $server,
2402 command => 'NOTICE',
2403 params => [
2404 $nick,
2405 sprintf(
2406 'SPAMNUM is currently %s',
2407 $self->{config}{MAX_JOIN_LEAVE_COUNT},
2408 0 ),
2409 ],
2410 };
2411 }
2412 },
2413 SPAMTIME => sub {
2414 0 ▶ my $val = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
2415 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
2416 0 $self->{config}{MIN_JOIN_LEAVE_TIME} = $val;
2417 0 $self->_send_to_realops(
2418 sprintf(
2419 '%s has changed SPAMTIME to %s',
2420 $self->state_user_full($nick,1), $val,
2421 ), qw[Notice s],
2422 );
2423 }
2424 else {
2425 push @$ref, {
2426 prefix => $server,
2427 command => 'NOTICE',
2428 params => [
2429 $nick,
2430 sprintf(
2431 'SPAMTIME is currently %s',
2432 $self->{config}{MIN_JOIN_LEAVE_TIME},
2433 0 ),
2434 ],
2435 };
2436 }
2437 },
2438 JFLOODTIME => sub {
2439 2 ▶ my $val = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
2440 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
2441 1 $self->{config}{joinfloodtime} = $val;
2442 1 $self->_send_to_realops(
2443 sprintf(
2444 '%s has changed JFLOODTIME to %s',
2445 $self->state_user_full($nick,1), $val,
2446 ), qw[Notice s],
2447 );
2448 }
2449 else {
2450 push @$ref, {
2451 prefix => $server,
2452 command => 'NOTICE',
2453 params => [
2454 $nick,
2455 sprintf(
2456 'JFLOODTIME is currently %s',
2457 $self->{config}{joinfloodtime},
2458 1 ),
2459 ],
2460 };
2461 }
2462 },
2463 JFLOODCOUNT => sub {
2464 0 ▶ my $val = shift;
Subroutine __ANON__: not called CC=3 SCAR=24.8
2465 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
2466 0 $self->{config}{joinfloodcount} = $val;
2467 0 $self->_send_to_realops(
2468 sprintf(
2469 '%s has changed JFLOODCOUNT to %s',
2470 $self->state_user_full($nick,1), $val,
2471 ), qw[Notice s],
2472 );
2473 }
2474 else {
2475 push @$ref, {
2476 prefix => $server,
2477 command => 'NOTICE',
2478 params => [
2479 $nick,
2480 sprintf(
2481 'JFLOODCOUNT is currently %s',
2482 $self->{config}{joinfloodcount},
2483 0 ),
2484 ],
2485 };
2486 }
2487 },
2488 5 );
2489  
2490 SWITCH: {
2491 5 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 5 5
2492 0 push @$ref, ['481'];
2493 0 last SWITCH;
2494 }
2495 5 ▶ if ($count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 0) 4 1 5
2496 4 ▶ if ( defined $vars{ uc $args->[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vars{uc $args->[0]}) 4 0 4
2497 4 $vars{ uc $args->[0] }->( $args->[1] );
2498 4 last SWITCH;
2499 }
2500 0 push @$ref, {
2501 prefix => $server,
2502 command => 'NOTICE',
2503 params => [
2504 $nick,
2505 'Variable not found.',
2506 ],
2507 };
2508 0 last SWITCH;
2509 }
2510 1 push @$ref, {
2511 prefix => $server,
2512 command => 'NOTICE',
2513 params => [
2514 $nick,
2515 'Available QUOTE SET commands:',
2516 ],
2517 };
2518 1 my @names;
2519 1 foreach my $var ( sort keys %vars ) {
2520 8 push @names, $var;
2521 8 ▶ if ( scalar @names == 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @names == 4) 2 6 8
2522 2 push @$ref, {
2523 prefix => $server,
2524 command => 'NOTICE',
2525 params => [
2526 $nick,
2527 join(' ',@names),
2528 ],
2529 };
2530 2 @names = ();
2531 }
2532 }
2533 1 ▶ if (@names) {
Branch: 1 branch
BranchTrueFalseTotal
if (@names) 0 1 1
2534 0 push @$ref, {
2535 prefix => $server,
2536 command => 'NOTICE',
2537 params => [
2538 $nick,
2539 join(' ',@names),
2540 ],
2541 };
2542 }
2543 }
2544 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
2545 0 return $ref;
2546 }
2547  
2548 sub _daemon_cmd_rehash {
2549 1 ▶ my $self = shift;
Subroutine _daemon_cmd_rehash: called CC=4 SCAR=15.2
2550 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
2551 1 my $server = $self->server_name();
2552 1 my $ref = [ ];
2553  
2554 SWITCH: {
2555 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2556 0 push @$ref, ['481'];
2557 0 last SWITCH;
2558 }
2559 1 $self->send_event("daemon_rehash", $nick);
2560 1 push @$ref, {
2561 prefix => $server,
2562 command => '383',
2563 params => [$nick, 'ircd.conf', 'Rehashing'],
2564 };
2565 }
2566 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2567 0 return $ref;
2568 }
2569  
2570 sub _daemon_cmd_locops {
2571 0 ▶ my $self = shift;
Subroutine _daemon_cmd_locops: not called CC=5 SCAR=34.0
2572 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
2573 0 my $server = $self->server_name();
2574 0 my $ref = [ ];
2575 0 my $args = [@_];
2576 0 my $count = @$args;
2577  
2578 SWITCH: {
2579 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2580 0 push @$ref, ['723', 'locops'];
2581 0 last SWITCH;
2582 }
2583 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2584 0 push @$ref, ['461', 'LOCOPS'];
2585 0 last SWITCH;
2586 }
2587 0 my $full = $self->state_user_full($nick,1);
2588 0 $self->_send_to_realops( "from $nick: " . $args->[0], 'locops', 'l' );
2589 0 $self->send_event("daemon_locops", $full, $args->[0]);
2590 }
2591  
2592 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2593 0 return $ref;
2594 }
2595  
2596 sub _daemon_cmd_wallops {
2597 0 ▶ my $self = shift;
Subroutine _daemon_cmd_wallops: not called CC=5 SCAR=34.0
2598 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
2599 0 my $server = $self->server_name();
2600 0 my $ref = [ ];
2601 0 my $args = [@_];
2602 0 my $count = @$args;
2603  
2604 SWITCH: {
2605 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2606 0 push @$ref, ['723', 'wallops'];
2607 0 last SWITCH;
2608 }
2609 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2610 0 push @$ref, ['461', 'WALLOPS'];
2611 0 last SWITCH;
2612 }
2613  
2614 0 my $full = $self->state_user_full($nick);
2615 0 my $uid = $self->state_user_uid($nick);
2616  
2617 0 $self->send_output(
2618 {
2619 prefix => $uid,
2620 command => 'WALLOPS',
2621 params => [$args->[0]],
2622 },
2623 $self->_state_connected_peers(),
2624 );
2625  
2626 $self->send_output(
2627 {
2628 prefix => $full,
2629 command => 'WALLOPS',
2630 params => [$args->[0]],
2631 },
2632 0 keys %{ $self->{state}{wallops} },
2633 );
2634  
2635 0 $self->send_event("daemon_wallops", $full, $args->[0]);
2636 }
2637  
2638 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2639 0 return $ref;
2640 }
2641  
2642 sub _daemon_cmd_globops {
2643 0 ▶ my $self = shift;
Subroutine _daemon_cmd_globops: not called CC=5 SCAR=34.0
2644 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
2645 0 my $server = $self->server_name();
2646 0 my $sid = $self->server_sid();
2647 0 my $ref = [ ];
2648 0 my $args = [@_];
2649 0 my $count = @$args;
2650  
2651 SWITCH: {
2652 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2653 0 push @$ref, ['723', 'globops'];
2654 0 last SWITCH;
2655 }
2656 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2657 0 push @$ref, ['461', 'GLOBOPS'];
2658 0 last SWITCH;
2659 }
2660  
2661 $self->send_output(
2662 {
2663 0 prefix => $self->state_user_uid($nick),
2664 command => 'GLOBOPS',
2665 params => [ $args->[0] ],
2666 },
2667 $self->_state_connected_peers(),
2668 );
2669  
2670 0 my $msg = "from $nick: " . $args->[0];
2671  
2672 0 $self->_send_to_realops(
2673 $msg,
2674 'Globops',
2675 's',
2676 );
2677  
2678 0 $self->send_event("daemon_globops", $nick, $args->[0]);
2679 }
2680 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2681 0 return $ref;
2682 }
2683  
2684 sub _daemon_cmd_connect {
2685 0 ▶ my $self = shift;
Subroutine _daemon_cmd_connect: not called CC=13 SCAR=52.0
2686 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
2687 0 my $server = $self->server_name();
2688 0 my $ref = [ ];
2689 0 my $args = [@_];
2690 0 my $count = @$args;
2691  
2692 SWITCH: {
2693 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2694 0 push @$ref, ['481'];
2695 0 last SWITCH;
2696 }
2697 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2698 0 push @$ref, ['461', 'CONNECT'];
2699 0 last SWITCH;
2700 }
2701 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
2702 0 push @$ref, ['402', $args->[2]];
2703 0 last SWITCH;
2704 }
2705 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
2706 0 $args->[2] = $self->_state_peer_name($args->[2]);
2707 0 $self->send_output(
2708 {
2709 prefix => $nick,
2710 command => 'CONNECT',
2711 params => $args,
2712 },
2713 $self->_state_peer_route($args->[2]),
2714 );
2715 0 last SWITCH;
2716 }
2717 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
2718 || $self->{config}{peers}{uc $args->[0]}{type} ne 'r') {
2719 0 push @$ref, {
2720 command => 'NOTICE',
2721 params => [
2722 $nick,
2723 "Connect: Host $args->[0] is not listed in ircd.conf",
2724 ],
2725 };
2726 0 last SWITCH;
2727 }
2728 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
2729 0 push @$ref, {
2730 command => 'NOTICE',
2731 params => [
2732 $nick,
2733 "Connect: Server $args->[0] already exists from $peer_name.",
2734 ],
2735 };
2736 0 last SWITCH;
2737 }
2738  
2739 0 my $connector = $self->{config}{peers}{uc $args->[0]};
2740 0 my $name = $connector->{name};
2741 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
2742 0 my $raddr = $connector->{raddress};
2743 0 $self->add_connector(
2744 remoteaddress => $raddr,
2745 remoteport => $rport,
2746 name => $name,
2747 );
2748 }
2749  
2750 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2751 0 return $ref;
2752 }
2753  
2754 sub _daemon_cmd_squit {
2755 0 ▶ my $self = shift;
Subroutine _daemon_cmd_squit: not called CC=9 SCAR=45.0
2756 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
2757 0 my $server = $self->server_name();
2758 0 my $ref = [ ];
2759 0 my $args = [@_];
2760 0 my $count = @$args;
2761  
2762 SWITCH: {
2763 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2764 0 push @$ref, ['481'];
2765 0 last SWITCH;
2766 }
2767 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2768 0 push @$ref, ['461', 'SQUIT'];
2769 0 last SWITCH;
2770 }
2771 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
2772 || uc $server eq uc $args->[0]) {
2773 0 push @$ref, ['402', $args->[0]];
2774 0 last SWITCH;
2775 }
2776  
2777 0 my $peer = uc $args->[0];
2778 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
2779 0 $args->[0] = $self->_state_peer_name($peer);
2780 0 $args->[1] = $reason;
2781  
2782 0 my $conn_id = $self->_state_peer_route($peer);
2783  
2784 0 ▶ if ( !grep { $_ eq $peer }
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $peer;} keys %{$self->{"state"}{"peers"}{uc $server}{"peers"};}) 0 0 0
2785 0 keys %{ $self->{state}{peers}{uc $server}{peers} }) {
2786 0 $self->send_output(
2787 {
2788 prefix => $self->state_user_uid($nick),
2789 command => 'SQUIT',
2790 params => [ $self->_state_peer_sid($peer), $reason ],
2791 },
2792 $conn_id,
2793 );
2794 0 last SWITCH;
2795 }
2796  
2797 0 $self->disconnect($conn_id, $reason);
2798 0 $self->send_output(
2799 {
2800 command => 'ERROR',
2801 params => [
2802 join ' ', 'Closing Link:',
2803 $self->_client_ip($conn_id), $args->[0], "($nick)"
2804 ],
2805 },
2806 $conn_id,
2807 );
2808 }
2809  
2810 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2811 0 return $ref;
2812 }
2813  
2814 sub _daemon_cmd_rkline {
2815 2 ▶ my $self = shift;
Subroutine _daemon_cmd_rkline: called CC=15 SCAR=30.6
2816 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
2817 2 my $server = $self->server_name();
2818 2 my $ref = [ ];
2819 2 my $args = [@_];
2820 2 my $count = @$args;
2821  
2822 SWITCH: {
2823 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
2824 0 push @$ref, ['481'];
2825 0 last SWITCH;
2826 }
2827 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
2828 0 push @$ref, ['461', 'RKLINE'];
2829 0 last SWITCH;
2830 }
2831 2 my $duration = 0;
2832 2 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 1 1 2
2833 1 $duration = shift @$args;
2834 1 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 1 1
2835 }
2836 2 my $mask = shift @$args;
2837 2 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 2 2
2838 0 push @$ref, ['461', 'RKLINE'];
2839 0 last SWITCH;
2840 }
2841 2 my ($user, $host) = split /\@/, $mask;
2842 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
2843 0 last SWITCH;
2844 }
2845 2 my $full = $self->state_user_full($nick);
2846 2 my $reason;
2847  
2848 {
2849 2 ▶ if (!$reason) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 2 0 2
2850 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
2851 }
2852 $self->send_event(
2853 2 "daemon_rkline",
2854 $full,
2855 $server,
2856 $duration,
2857 $user,
2858 $host,
2859 $reason,
2860 );
2861  
2862 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
2863 $server, $duration * 60,
2864 $user, $host, $reason );
2865  
2866 2 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 1 1 2
2867  
2868 2 my $reply_notice = "Added ${temp}RK-Line [$user\@host]";
2869 2 my $locop_notice = "$full added ${temp}RK-Line for [$user\@$host] [$reason]";
2870  
2871 2 push @$ref, {
2872 prefix => $server,
2873 command => 'NOTICE',
2874 params => [ $nick, $reply_notice ],
2875 };
2876  
2877 2 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
2878  
2879 2 $self->_state_do_local_users_match_rkline($user, $host, $reason);
2880 }
2881 }
2882  
2883 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
2884 2 return $ref;
2885 }
2886  
2887 sub _daemon_cmd_unrkline {
2888 1 ▶ my $self = shift;
Subroutine _daemon_cmd_unrkline: called CC=9 SCAR=26.2
2889 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
2890 1 my $server = $self->server_name();
2891 1 my $ref = [ ];
2892 1 my $args = [@_];
2893 1 my $count = @$args;
2894  
2895 SWITCH: {
2896 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
2897 0 push @$ref, ['481'];
2898 0 last SWITCH;
2899 }
2900 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
2901 0 push @$ref, ['461', 'UNRKLINE'];
2902 0 last SWITCH;
2903 }
2904 1 my ($user, $host) = split /\@/, $args->[0];
2905 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
2906 0 last SWITCH;
2907 }
2908  
2909 1 my $result = $self->_state_del_drkx_line( 'rkline', $user, $host );
2910  
2911 1 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 1 1
2912 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No RK-Line for [$user\@$host] found" ] };
2913 0 last SWITCH;
2914 }
2915  
2916 1 my $full = $self->state_user_full($nick);
2917  
2918 1 $self->send_event(
2919 "daemon_unrkline", $full, $server, $user, $host,
2920 );
2921  
2922 1 push @$ref, {
2923 prefix => $server,
2924 command => 'NOTICE',
2925 params => [ $nick, "RK-Line for [$user\@$host] is removed" ],
2926 };
2927  
2928 1 $self->_send_to_realops( "$full has removed the RK-Line for: [$user\@$host]", 'Notice', 's' );
2929 }
2930  
2931 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
2932 1 return $ref;
2933 }
2934  
2935 sub _daemon_cmd_kline {
2936 4 ▶ my $self = shift;
Subroutine _daemon_cmd_kline: called CC=26 SCAR=37.0
2937 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
2938 4 my $server = $self->server_name();
2939 4 my $ref = [ ];
2940 4 my $args = [@_];
2941 4 my $count = @$args;
2942 # KLINE [time] <nick|user@host> [ ON <server> ] :[reason]
2943  
2944 SWITCH: {
2945 4 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 4 4
2946 0 push @$ref, ['481'];
2947 0 last SWITCH;
2948 }
2949 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
2950 0 push @$ref, ['461', 'KLINE'];
2951 0 last SWITCH;
2952 }
2953 4 my $duration = 0;
2954 4 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 2 4
2955 2 $duration = shift @$args;
2956 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
2957 }
2958 4 my $mask = shift @$args;
2959 4 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 4 4
2960 0 push @$ref, ['461', 'KLINE'];
2961 0 last SWITCH;
2962 }
2963 4 my ($user, $host);
2964 4 ▶ if ($mask !~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $mask =~ /\@/) { } 0 4 4
2965 0 ▶ if (my $rogue = $self->_state_user_full($mask)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rogue = $self->_state_user_full($mask)) { } 0 0 0
2966 0 ($user, $host) = (split /[!\@]/, $rogue )[1..2];
2967 }
2968 else {
2969 0 push @$ref, ['401', $mask];
2970 0 last SWITCH;
2971 }
2972 }
2973 else {
2974 4 ($user, $host) = split /\@/, $mask;
2975 }
2976  
2977 4 my $full = $self->state_user_full($nick);
2978 4 my $us = 0;
2979 4 my $ucserver = uc $server;
2980 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
2981 && scalar @$args < 2) {
2982 0 push @$ref, ['461', 'KLINE'];
2983 0 last SWITCH;
2984 }
2985 4 my ($target, $reason);
2986 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
2987 1 my $on = shift @$args;
2988 1 $target = shift @$args;
2989 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
2990 1 my %targets;
2991  
2992 1 for my $peer (keys %{ $self->{state}{peers} }) {
2993 4 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 4 0 4
2994 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
2995 1 $us = 1;
2996 }
2997 else {
2998 3 $targets{ $self->_state_peer_route($peer) }++;
2999 }
3000 }
3001 }
3002  
3003 $self->send_output(
3004 {
3005 prefix => $self->state_user_uid($nick),
3006 command => 'KLINE',
3007 params => [
3008 $target,
3009 $duration * 60,
3010 $user,
3011 $host,
3012 $reason,
3013 ],
3014 },
3015 1 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
3016 );
3017 }
3018 else {
3019 3 $us = 1;
3020 }
3021  
3022 4 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 4 0 4
3023 4 ▶ $target = $server if !$target;
Branch: 1 branch
BranchTrueFalseTotal
unless $target 3 1 4
3024 4 ▶ if (!$reason) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 3 1 4
3025 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
3026 }
3027  
3028 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
3029 $duration * 60, $user, $host, $reason );
3030 4 $self->send_event(
3031 "daemon_kline",
3032 $full,
3033 $target,
3034 $duration,
3035 $user,
3036 $host,
3037 $reason,
3038 );
3039  
3040 4 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 2 4
3041  
3042 4 my $reply_notice = "Added ${temp}K-Line [$user\@host]";
3043 4 my $locop_notice = "$full added ${temp}K-Line for [$user\@$host] [$reason]";
3044  
3045 4 push @$ref, {
3046 prefix => $server,
3047 command => 'NOTICE',
3048 params => [ $nick, $reply_notice ],
3049 };
3050  
3051 4 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3052  
3053 4 $self->_state_do_local_users_match_kline($user, $host, $reason);
3054 }
3055 }
3056  
3057 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
3058 4 return $ref;
3059 }
3060  
3061 sub _daemon_cmd_unkline {
3062 2 ▶ my $self = shift;
Subroutine _daemon_cmd_unkline: called CC=20 SCAR=42.7
3063 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
3064 2 my $server = $self->server_name();
3065 2 my $ref = [ ];
3066 2 my $args = [@_];
3067 2 my $count = @$args;
3068 # UNKLINE <user@host> [ ON <target_mask> ]
3069  
3070 SWITCH: {
3071 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
3072 0 push @$ref, ['481'];
3073 0 last SWITCH;
3074 }
3075 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
3076 0 push @$ref, ['461', 'UNKLINE'];
3077 0 last SWITCH;
3078 }
3079 2 my ($user, $host);
3080 2 ▶ if ($args->[0] !~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $args->[0] =~ /\@/) { } 0 2 2
3081 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
3082 0 ($user, $host) = (split /[!\@]/, $rogue)[1..2]
3083 }
3084 else {
3085 0 push @$ref, ['401', $args->[0]];
3086 0 last SWITCH;
3087 }
3088 }
3089 else {
3090 2 ($user, $host) = split /\@/, $args->[0];
3091 }
3092  
3093 2 my $full = $self->state_user_full($nick);
3094 2 my $us = 0;
3095 2 my $ucserver = uc $server;
3096 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
3097 0 push @$ref, ['461', 'UNKLINE'];
3098 0 last SWITCH;
3099 }
3100 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
3101 0 my $target = $args->[3];
3102 0 my %targets;
3103 0 for my $peer (keys %{ $self->{state}{peers} }) {
3104 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
3105 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
3106 0 $us = 1;
3107 }
3108 else {
3109 0 $targets{ $self->_state_peer_route( $peer ) }++;
3110 }
3111 }
3112 }
3113  
3114 $self->send_output(
3115 {
3116 prefix => $self->state_user_uid($nick),
3117 command => 'UNKLINE',
3118 params => [$target, $user, $host],
3119 colonify => 0,
3120 },
3121 0 grep { $self->_state_peer_capab($_, 'UNKLN') } keys %targets,
3122 );
3123 }
3124 else {
3125 2 $us = 1;
3126 }
3127  
3128 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
3129  
3130 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
3131  
3132 2 my $result = $self->_state_del_drkx_line( 'kline', $user, $host );
3133  
3134 2 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 2 2
3135 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No K-Line for [$user\@$host] found" ] };
3136 0 last SWITCH;
3137 }
3138  
3139 $self->send_event(
3140 2 "daemon_unkline", $full, $target, $user, $host,
3141 );
3142  
3143 2 push @$ref, {
3144 prefix => $server,
3145 command => 'NOTICE',
3146 params => [ $nick, "K-Line for [$user\@$host] is removed" ],
3147 };
3148  
3149 2 $self->_send_to_realops( "$full has removed the K-Line for: [$user\@$host]", 'Notice', 's' );
3150 }
3151  
3152 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
3153 2 return $ref;
3154 }
3155  
3156 sub _daemon_cmd_resv {
3157 6 ▶ my $self = shift;
Subroutine _daemon_cmd_resv: called CC=24 SCAR=35.4
3158 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
3159 6 my $server = $self->server_name();
3160 6 my $sid = $self->server_sid();
3161 6 my $ref = [ ];
3162 6 my $args = [ @_ ];
3163 6 my $count = @$args;
3164  
3165 SWITCH: {
3166 6 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 6 6
3167 0 push @$ref, ['481'];
3168 0 last SWITCH;
3169 }
3170 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
3171 0 push @$ref, ['461', 'RESV'];
3172 0 last SWITCH;
3173 }
3174 6 my $duration = 0;
3175 6 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 4 6
3176 2 $duration = shift @$args;
3177 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
3178 }
3179 6 my $mask = shift @$args;
3180 6 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 6 6
3181 0 push @$ref, ['461', 'RESV'];
3182 0 last SWITCH;
3183 }
3184 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
3185 && scalar @$args < 2) {
3186 0 push @$ref, ['461', 'RESV'];
3187 0 last SWITCH;
3188 }
3189 6 my ($peermask,$reason);
3190 6 my $us = 0;
3191 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
3192 1 my $on = shift @$args;
3193 1 $peermask = shift @$args;
3194 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
3195 1 my %targpeers; my $ucserver = uc $server;
3196 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3197 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3198 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3199 1 $us = 1;
3200 }
3201 else {
3202 3 $targpeers{ $self->_state_peer_route($peer) }++;
3203 }
3204 }
3205 }
3206 $self->send_output(
3207 {
3208 prefix => $self->state_user_uid($nick),
3209 command => 'RESV',
3210 params => [
3211 $peermask,
3212 ( $duration * 60 ),
3213 $mask,
3214 $reason,
3215 ],
3216 },
3217 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3218 );
3219 }
3220 else {
3221 5 $us = 1;
3222 }
3223  
3224 6 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 6 6
3225  
3226 6 ▶ if ( $self->_state_have_resv($mask) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_have_resv($mask)) 0 6 6
3227 0 push @$ref, {
3228 prefix => $server,
3229 command => 'NOTICE',
3230 params => [ $nick, "A RESV has already been placed on: $mask" ],
3231 };
3232 0 last SWITCH;
3233 }
3234  
3235 6 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 5 1 6
3236 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
3237 }
3238  
3239 6 my $full = $self->state_user_full($nick);
3240  
3241 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
3242 $duration * 60, $mask, $reason );
3243 6 $self->send_event(
3244 "daemon_resv",
3245 $full,
3246 $mask,
3247 $duration,
3248 $reason,
3249 );
3250  
3251 6 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 4 6
3252  
3253 6 my $reply_notice = "Added ${temp}RESV [$mask]";
3254 6 my $locop_notice = "$full added ${temp}RESV for [$mask] [$reason]";
3255  
3256 6 push @$ref, {
3257 prefix => $server,
3258 command => 'NOTICE',
3259 params => [ $nick, $reply_notice ],
3260 };
3261  
3262 6 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3263  
3264 }
3265  
3266 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
3267 6 return $ref;
3268 }
3269  
3270 sub _daemon_cmd_unresv {
3271 4 ▶ my $self = shift;
Subroutine _daemon_cmd_unresv: called CC=15 SCAR=29.4
3272 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
3273 4 my $server = $self->server_name();
3274 4 my $sid = $self->server_sid();
3275 4 my $ref = [ ];
3276 4 my $args = [ @_ ];
3277 4 my $count = @$args;
3278  
3279 SWITCH: {
3280 4 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 4 4
3281 0 push @$ref, ['481'];
3282 0 last SWITCH;
3283 }
3284 4 ▶ if (!$count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 4 4
3285 0 push @$ref, ['461', 'UNRESV'];
3286 0 last SWITCH;
3287 }
3288 4 my $unmask = shift @$args;
3289 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
3290 && scalar @$args < 2) {
3291 0 push @$ref, ['461', 'UNRESV'];
3292 0 last SWITCH;
3293 }
3294 4 my $us = 0;
3295 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
3296 1 my $on = shift @$args;
3297 1 my $peermask = shift @$args;
3298 1 my %targpeers; my $ucserver = uc $server;
3299 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3300 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3301 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3302 1 $us = 1;
3303 }
3304 else {
3305 3 $targpeers{ $self->_state_peer_route($peer) }++;
3306 }
3307 }
3308 }
3309 $self->send_output(
3310 {
3311 prefix => $self->state_user_uid($nick),
3312 command => 'UNRESV',
3313 params => [
3314 $peermask,
3315 $unmask,
3316 ],
3317 colonify => 0,
3318 },
3319 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3320 );
3321 }
3322 else {
3323 3 $us = 1;
3324 }
3325  
3326 4 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 4 4
3327  
3328 4 my $result = $self->_state_del_drkx_line( 'resv', $unmask );
3329  
3330 4 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 4 4
3331 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No RESV for [$unmask] found" ] };
3332 0 last SWITCH;
3333 }
3334  
3335 4 my $full = $self->state_user_full($nick);
3336 4 $self->send_event(
3337 "daemon_unresv",
3338 $full,
3339 $unmask,
3340 );
3341  
3342 4 push @$ref, {
3343 prefix => $server,
3344 command => 'NOTICE',
3345 params => [ $nick, "RESV for [$unmask] is removed" ],
3346 };
3347  
3348 4 $self->_send_to_realops( "$full has removed the RESV for: [$unmask]", 'Notice', 's' );
3349 }
3350  
3351 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
3352 4 return $ref;
3353 }
3354  
3355 sub _daemon_cmd_xline {
3356 3 ▶ my $self = shift;
Subroutine _daemon_cmd_xline: called CC=23 SCAR=34.3
3357 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
3358 3 my $server = $self->server_name();
3359 3 my $sid = $self->server_sid();
3360 3 my $ref = [ ];
3361 3 my $args = [ @_ ];
3362 3 my $count = @$args;
3363  
3364 SWITCH: {
3365 3 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 3 3
3366 0 push @$ref, ['481'];
3367 0 last SWITCH;
3368 }
3369 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
3370 0 push @$ref, ['461', 'XLINE'];
3371 0 last SWITCH;
3372 }
3373 3 my $duration = 0;
3374 3 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 1 3
3375 2 $duration = shift @$args;
3376 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
3377 }
3378 3 my $mask = shift @$args;
3379 3 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 3 3
3380 0 push @$ref, ['461', 'XLINE'];
3381 0 last SWITCH;
3382 }
3383 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
3384 && scalar @$args < 2) {
3385 0 push @$ref, ['461', 'XLINE'];
3386 0 last SWITCH;
3387 }
3388 3 my ($peermask,$reason);
3389 3 my $us = 0;
3390 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
3391 1 my $on = shift @$args;
3392 1 $peermask = shift @$args;
3393 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
3394 1 my %targpeers; my $ucserver = uc $server;
3395 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3396 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3397 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3398 1 $us = 1;
3399 }
3400 else {
3401 3 $targpeers{ $self->_state_peer_route($peer) }++;
3402 }
3403 }
3404 }
3405 $self->send_output(
3406 {
3407 prefix => $self->state_user_uid($nick),
3408 command => 'XLINE',
3409 params => [
3410 $peermask,
3411 ( $duration * 60 ),
3412 $mask,
3413 $reason,
3414 ],
3415 },
3416 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3417 );
3418 }
3419 else {
3420 2 $us = 1;
3421 }
3422  
3423 3 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 3 3
3424  
3425 3 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 2 1 3
3426 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
3427 }
3428  
3429 3 my $full = $self->state_user_full($nick);
3430  
3431 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
3432 $duration * 60, $mask, $reason );
3433 3 $self->send_event(
3434 "daemon_xline",
3435 $full,
3436 $mask,
3437 $duration,
3438 $reason,
3439 );
3440  
3441 3 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 1 3
3442  
3443 3 my $reply_notice = "Added ${temp}X-Line [$mask]";
3444 3 my $locop_notice = "$full added ${temp}X-Line for [$mask] [$reason]";
3445  
3446 3 push @$ref, {
3447 prefix => $server,
3448 command => 'NOTICE',
3449 params => [ $nick, $reply_notice ],
3450 };
3451  
3452 3 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3453  
3454 3 $self->_state_do_local_users_match_xline($mask,$reason);
3455 }
3456  
3457 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
3458 3 return $ref;
3459 }
3460  
3461 sub _daemon_cmd_unxline {
3462 2 ▶ my $self = shift;
Subroutine _daemon_cmd_unxline: called CC=15 SCAR=29.4
3463 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
3464 2 my $server = $self->server_name();
3465 2 my $sid = $self->server_sid();
3466 2 my $ref = [ ];
3467 2 my $args = [ @_ ];
3468 2 my $count = @$args;
3469  
3470 SWITCH: {
3471 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
3472 0 push @$ref, ['481'];
3473 0 last SWITCH;
3474 }
3475 2 ▶ if (!$count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
3476 0 push @$ref, ['461', 'UNXLINE'];
3477 0 last SWITCH;
3478 }
3479 2 my $unmask = shift @$args;
3480 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
3481 && scalar @$args < 2) {
3482 0 push @$ref, ['461', 'UNXLINE'];
3483 0 last SWITCH;
3484 }
3485 2 my $us = 0;
3486 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
3487 1 my $on = shift @$args;
3488 1 my $peermask = shift @$args;
3489 1 my %targpeers; my $ucserver = uc $server;
3490 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3491 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3492 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3493 1 $us = 1;
3494 }
3495 else {
3496 3 $targpeers{ $self->_state_peer_route($peer) }++;
3497 }
3498 }
3499 }
3500 $self->send_output(
3501 {
3502 prefix => $self->state_user_uid($nick),
3503 command => 'UNXLINE',
3504 params => [
3505 $peermask,
3506 $unmask,
3507 ],
3508 colonify => 0,
3509 },
3510 1 grep { $self->_state_peer_capab($_, 'CLUSTER') } keys %targpeers,
3511 );
3512 }
3513 else {
3514 1 $us = 1;
3515 }
3516  
3517 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
3518  
3519 2 my $result = $self->_state_del_drkx_line( 'xline', $unmask );
3520  
3521 2 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 2 2
3522 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No X-Line for [$unmask] found" ] };
3523 0 last SWITCH;
3524 }
3525  
3526 2 my $full = $self->state_user_full($nick);
3527 2 $self->send_event(
3528 "daemon_unxline",
3529 $full,
3530 $unmask,
3531 );
3532  
3533 2 push @$ref, {
3534 prefix => $server,
3535 command => 'NOTICE',
3536 params => [ $nick, "X-Line for [$unmask] is removed" ],
3537 };
3538  
3539 2 $self->_send_to_realops( "$full has removed the X-Line for: [$unmask]", 'Notice', 's' );
3540 }
3541  
3542 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
3543 2 return $ref;
3544 }
3545  
3546 sub _daemon_cmd_dline {
3547 3 ▶ my $self = shift;
Subroutine _daemon_cmd_dline: called CC=32 SCAR=44.7
3548 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
3549 3 my $server = $self->server_name();
3550 3 my $sid = $self->server_sid();
3551 3 my $ref = [ ];
3552 3 my $args = [ @_ ];
3553 3 my $count = @$args;
3554  
3555 SWITCH: {
3556 3 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 3 3
3557 0 push @$ref, ['481'];
3558 0 last SWITCH;
3559 }
3560 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
3561 0 push @$ref, ['461', 'DLINE'];
3562 0 last SWITCH;
3563 }
3564 3 my $duration = 0;
3565 3 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 2 1 3
3566 2 $duration = shift @$args;
3567 2 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 2 2
3568 }
3569 3 my $mask = shift @$args;
3570 3 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 3 3
3571 0 push @$ref, ['461', 'KLINE'];
3572 0 last SWITCH;
3573 }
3574 3 my $netmask;
3575 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
3576 0 my $uid = $self->state_user_uid($mask);
3577 0 ▶ if ( $uid !~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($uid =~ /^$sid/) 0 0 0
3578 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, 'Cannot DLINE nick on another server' ] };
3579 0 last SWITCH;
3580 }
3581 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
3582 0 my $tnick = $self->{state}{uids}{$uid}{nick};
3583 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "$tnick is E-lined" ] };
3584 0 last SWITCH;
3585 }
3586 0 my $addr = $self->{state}{uids}{$uid}{socket}[0];
3587 0 $netmask = Net::CIDR::cidrvalidate($addr);
3588 }
3589 ▶ 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
3590 0 push @$ref, ['401', $mask];
3591 0 last SWITCH;
3592 }
3593 3 ▶ if ( !$netmask ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($netmask) 3 0 3
3594 3 $netmask = Net::CIDR::cidrvalidate($mask);
3595 3 ▶ if ( !$netmask ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($netmask) 0 3 3
3596 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, 'Unable to parse provided IP mask' ] };
3597 0 last SWITCH;
3598 }
3599 }
3600 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
3601 && scalar @$args < 2) {
3602 0 push @$ref, ['461', 'DLINE'];
3603 0 last SWITCH;
3604 }
3605 3 my ($peermask,$reason,$on);
3606 3 my $us = 0;
3607 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
3608 1 $on = shift @$args;
3609 1 $peermask = shift @$args;
3610 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
3611 1 my %targpeers; my $ucserver = uc $server;
3612 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3613 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3614 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3615 1 $us = 1;
3616 }
3617 else {
3618 3 $targpeers{ $self->_state_peer_route($peer) }++;
3619 }
3620 }
3621 }
3622 $self->send_output(
3623 {
3624 prefix => $self->state_user_uid($nick),
3625 command => 'DLINE',
3626 params => [
3627 $peermask,
3628 ( $duration * 60 ),
3629 $netmask,
3630 $reason,
3631 ],
3632 },
3633 1 grep { $self->_state_peer_capab($_, 'DLN') } keys %targpeers,
3634 );
3635 }
3636 else {
3637 2 $us = 1;
3638 }
3639  
3640 3 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 3 3
3641  
3642 3 ▶ if ( !$reason ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 2 1 3
3643 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
3644 }
3645  
3646 3 my $full = $self->state_user_full($nick);
3647  
3648 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
3649 $full, time, $server, $duration * 60,
3650 $netmask, $reason );
3651  
3652 3 $self->send_event(
3653 "daemon_dline",
3654 $full,
3655 $netmask,
3656 $duration,
3657 $reason,
3658 );
3659  
3660 3 $self->add_denial( $netmask, 'You have been D-lined.' );
3661  
3662 3 ▶ my $temp = $duration ? "temporary $duration min. " : '';
Branch: 1 branch
BranchTrueFalseTotal
$duration ? : 2 1 3
3663  
3664 3 my $reply_notice = "Added ${temp}D-Line [$netmask]";
3665 3 my $locop_notice = "$full added ${temp}D-Line for [$netmask] [$reason]";
3666  
3667 3 push @$ref, {
3668 prefix => $server,
3669 command => 'NOTICE',
3670 params => [ $nick, $reply_notice ],
3671 };
3672  
3673 3 $self->_send_to_realops( $locop_notice, 'Notice', 's' );
3674  
3675 3 $self->_state_do_local_users_match_dline($netmask,$reason);
3676 }
3677  
3678 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
3679 3 return $ref;
3680 }
3681  
3682 sub _daemon_cmd_undline {
3683 2 ▶ my $self = shift;
Subroutine _daemon_cmd_undline: called CC=15 SCAR=29.3
3684 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
3685 2 my $server = $self->server_name();
3686 2 my $sid = $self->server_sid();
3687 2 my $ref = [ ];
3688 2 my $args = [ @_ ];
3689 2 my $count = @$args;
3690  
3691 SWITCH: {
3692 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 2 2
3693 0 push @$ref, ['481'];
3694 0 last SWITCH;
3695 }
3696 2 ▶ if (!$count ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
3697 0 push @$ref, ['461', 'UNDLINE'];
3698 0 last SWITCH;
3699 }
3700 2 my $unmask = shift @$args;
3701 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
3702 && scalar @$args < 2) {
3703 0 push @$ref, ['461', 'UNDLINE'];
3704 0 last SWITCH;
3705 }
3706 2 my $us = 0;
3707 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
3708 1 my $on = shift @$args;
3709 1 my $peermask = shift @$args;
3710 1 my %targpeers; my $ucserver = uc $server;
3711 1 foreach my $peer ( keys %{ $self->{state}{peers} } ) {
3712 4 ▶ if (matches_mask($peermask, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($peermask, $peer)) 4 0 4
3713 4 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 1 3 4
3714 1 $us = 1;
3715 }
3716 else {
3717 3 $targpeers{ $self->_state_peer_route($peer) }++;
3718 }
3719 }
3720 }
3721 $self->send_output(
3722 {
3723 prefix => $self->state_user_uid($nick),
3724 command => 'UNDLINE',
3725 params => [
3726 $peermask,
3727 $unmask,
3728 ],
3729 colonify => 0,
3730 },
3731 1 grep { $self->_state_peer_capab($_, 'UNDLN') } keys %targpeers,
3732 );
3733 }
3734 else {
3735 1 $us = 1;
3736 }
3737  
3738 2 ▶ last SWITCH if !$us;
Branch: 1 branch
BranchTrueFalseTotal
unless $us 0 2 2
3739  
3740 2 my $result = $self->_state_del_drkx_line( 'dline', $unmask );
3741  
3742 2 ▶ if ( !$result ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 0 2 2
3743 0 push @$ref, { prefix => $server, command => 'NOTICE', params => [ $nick, "No D-Line for [$unmask] found" ] };
3744 0 last SWITCH;
3745 }
3746  
3747 2 my $full = $self->state_user_full($nick);
3748 2 $self->send_event(
3749 "daemon_undline",
3750 $full,
3751 $unmask,
3752 );
3753  
3754 2 $self->del_denial( $unmask );
3755  
3756 2 push @$ref, {
3757 prefix => $server,
3758 command => 'NOTICE',
3759 params => [ $nick, "D-Line for [$unmask] is removed" ],
3760 };
3761  
3762 2 $self->_send_to_realops(
3763 "$full has removed the D-Line for: [$unmask]",
3764 'Notice',
3765 's',
3766 );
3767 }
3768  
3769 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
3770 2 return $ref;
3771 }
3772  
3773 sub _daemon_cmd_kill {
3774 0 ▶ my $self = shift;
Subroutine _daemon_cmd_kill: not called CC=11 SCAR=48.8
3775 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
3776 my $server = ( $self->{config}{'hidden_servers'} ?
3777 0 ▶ $self->{config}{'hidden_servers'} : $self->server_name() );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'config'}{'hidden_servers'} ? : 0 0 0
3778 0 my $ref = [ ];
3779 0 my $args = [@_];
3780 0 my $count = @$args;
3781  
3782 SWITCH: {
3783 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
3784 0 push @$ref, ['481'];
3785 0 last SWITCH;
3786 }
3787 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
3788 0 push @$ref, ['461', 'KILL'];
3789 0 last SWITCH;
3790 }
3791 0 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 0 0 0
3792 0 push @$ref, ['483'];
3793 0 last SWITCH;
3794 }
3795 0 ▶ if (!$self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($args->[0])) 0 0 0
3796 0 push @$ref, ['401', $args->[0]];
3797 0 last SWITCH;
3798 }
3799 0 my $target = $self->state_user_nick($args->[0]);
3800 0 my $targuid = $self->state_user_uid($target);
3801 0 my $uid = $self->state_user_uid($nick);
3802 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
3803 0 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 0 0 0
3804 0 my $route_id = $self->_state_user_route($target);
3805 0 $self->send_output(
3806 {
3807 prefix => $uid,
3808 command => 'KILL',
3809 params => [
3810 $targuid,
3811 join('!', $server, $nick )." ($comment)",
3812 ]
3813 },
3814 $self->_state_connected_peers(),
3815 );
3816  
3817 0 $self->send_output(
3818 {
3819 prefix => $self->state_user_full($nick),
3820 command => 'KILL',
3821 params => [$target, $comment],
3822 },
3823 $route_id,
3824 );
3825 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
3826 0 $self->call('del_spoofed_nick', $target, "Killed ($comment)");
3827 }
3828 else {
3829 0 $self->{state}{conns}{$route_id}{killed} = 1;
3830 0 $self->_terminate_conn_error($route_id, "Killed ($comment)");
3831 }
3832 }
3833 else {
3834 0 $self->{state}{uids}{$targuid}{killed} = 1;
3835 0 $self->send_output(
3836 {
3837 prefix => $uid,
3838 command => 'KILL',
3839 params => [
3840 $targuid,
3841 join('!', $server, $nick )." ($comment)",
3842 ],
3843 },
3844 $self->_state_connected_peers(),
3845 );
3846 $self->send_output(
3847 0 @{ $self->_daemon_peer_quit(
3848 $targuid,
3849 "Killed ($nick ($comment))"
3850 )}
3851 );
3852 }
3853 }
3854  
3855 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3856 0 return $ref;
3857 }
3858  
3859 sub _daemon_peer_tracing {
3860 4 ▶ my $self = shift;
Subroutine _daemon_peer_tracing: called CC=15 SCAR=34.8
3861 4 my $cmd = shift;
3862 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
3863 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
3864 4 my $server = $self->server_name();
3865 4 my $sid = $self->server_sid();
3866 4 my $args = [@_];
3867 4 my $count = @$args;
3868 4 my $ref = [ ];
3869 4 $cmd = uc $cmd;
3870  
3871 SWITCH: {
3872 4 ▶ if ($count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1) 0 4 4
3873 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
3874 0 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 0 0
3875 0 push @$ref, {
3876 prefix => $sid,
3877 command => '402',
3878 params => [
3879 $uid,
3880 $args->[1],
3881 ],
3882 };
3883 0 last SWITCH;
3884 }
3885 0 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 0 0 0
3886 0 my $psid = substr $targ, 0, 3;
3887 0 $self->send_output(
3888 {
3889 prefix => $uid,
3890 command => $cmd,
3891 params => [
3892 $args->[0],
3893 $targ,
3894 ],
3895 },
3896 $self->_state_sid_route($psid),
3897 );
3898 0 last SWITCH;
3899 }
3900 }
3901 4 ▶ if ($args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0]) 4 0 4
3902 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
3903 4 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 4 4
3904 0 push @$ref, {
3905 prefix => $sid,
3906 command => '402',
3907 params => [
3908 $uid,
3909 $args->[0],
3910 ],
3911 };
3912 0 last SWITCH;
3913 }
3914 4 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 2 2 4
3915 2 my $name;
3916 my $route_id;
3917 2 ▶ if ( length $targ == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $targ == 3) { } 2 0 2
3918 2 $name = $self->{state}{sids}{$targ}{name};
3919 2 $route_id = $self->{state}{sids}{$targ}{route_id};
3920 }
3921 else {
3922 0 $name = $self->{state}{uids}{$targ}{nick};
3923 0 $route_id = $self->{state}{uids}{$targ}{route_id};
3924 }
3925 push @$ref, {
3926 prefix => $sid,
3927 command => '200',
3928 params => [
3929 $uid,
3930 'Link',
3931 $self->server_version(),
3932 $name,
3933 $self->{state}{conns}{$route_id}{name},
3934 2 ],
3935 };
3936 2 $self->send_output(
3937 {
3938 prefix => $uid,
3939 command => $cmd,
3940 params => [
3941 $targ,
3942 ],
3943 },
3944 $route_id,
3945 );
3946 2 last SWITCH;
3947 }
3948 }
3949 2 ▶ my $method = ( $cmd eq 'ETRACE' ? '_daemon_do_etrace' : '_daemon_do_trace' );
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq 'ETRACE' ? : 1 1 2
3950 2 push @$ref, $_ for @{ $self->$method($uid, @$args) };
3951 }
3952 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4 0 4
3953 0 return $ref;
3954 }
3955  
3956 sub _state_find_peer {
3957 3 ▶ my $self = shift;
Subroutine _state_find_peer: called CC=21 SCAR=36.0
3958 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
3959 3 my $connid = shift;
3960 3 my $server = $self->server_name();
3961 3 my $sid = $self->server_sid();
3962 3 my $ume = uc $server;
3963 3 my $result;
3964  
3965 3 ▶ if ($self->state_nick_exists($targ)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($targ)) 0 3 3
3966 0 $result = $self->state_user_uid($targ);
3967 }
3968 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
3969 0 $result = $self->_state_peer_sid($targ);
3970 }
3971 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
3972 3 PEERS: foreach my $peer ( sort keys %{ $self->{state}{peers} } ) {
3973 9 ▶ if ( matches_mask($targ,$peer,'ascii') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targ, $peer, "ascii")) 1 8 9
3974 1 ▶ return $sid if $ume eq $peer;
Branch: 1 branch
BranchTrueFalseTotal
if $ume eq $peer 0 1 1
3975 1 my $peerrec = $self->{state}{peers}{$peer};
3976 next PEERS if $connid && $connid eq $peerrec->{route_id}
3977 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
3978 1 $result = $peerrec->{sid};
3979 1 last PEERS;
3980 }
3981 }
3982 3 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result) 2 1 3
3983 2 USERS: foreach my $user ( sort keys %{ $self->{state}{users} } ) {
3984 10 ▶ if ( matches_mask($targ,$user) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targ, $user)) 2 8 10
3985 2 my $rec = $self->{state}{users}{$user};
3986 2 ▶ return $sid if $rec->{uid} =~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"uid"} =~ /^$sid/ 0 2 2
3987 next USERS if $connid && $connid eq $rec->{route_id}
3988 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
3989 2 $result = $rec->{uid};
3990 last USERS
3991 2 }
3992 }
3993 }
3994 }
3995 3 ▶ return $result if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 3 0 3
3996 0 return;
3997 }
3998  
3999 sub _daemon_client_tracing {
4000 6 ▶ my $self = shift;
Subroutine _daemon_client_tracing: called CC=14 SCAR=30.0
4001 6 my $cmd = shift;
4002 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
4003 6 my $server = $self->server_name();
4004 6 my $sid = $self->server_sid();
4005 6 my $args = [@_];
4006 6 my $count = @$args;
4007 6 my $ref = [ ];
4008 6 $cmd = uc $cmd;
4009  
4010 SWITCH: {
4011 6 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 2 4 6
4012 2 ▶ if ( $cmd eq 'ETRACE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "ETRACE") 1 1 2
4013 1 push @$ref, ['481'];
4014 1 last SWITCH;
4015 }
4016 1 push @$ref, {
4017 prefix => $server,
4018 command => '262',
4019 params => [
4020 $nick, $server, 'End of TRACE',
4021 ],
4022 };
4023 1 last SWITCH;
4024 }
4025 4 ▶ if ($count > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 1) 0 4 4
4026 0 my $targ = $self->_state_find_peer($args->[1]);
4027 0 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 0 0
4028 0 push @$ref, [ '402', $args->[1] ];
4029 0 last SWITCH;
4030 }
4031 0 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 0 0 0
4032 0 my $psid = substr $targ, 0, 3;
4033 0 $self->send_output(
4034 {
4035 prefix => $self->state_user_uid($nick),
4036 command => $cmd,
4037 params => [
4038 $args->[0],
4039 $targ,
4040 ],
4041 },
4042 $self->_state_sid_route($psid),
4043 );
4044 0 last SWITCH;
4045 }
4046 }
4047 4 my $uid = $self->state_user_uid($nick);
4048 4 ▶ if ($args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0]) 2 2 4
4049 2 my $targ = $self->_state_find_peer($args->[0]);
4050 2 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 2 2
4051 0 push @$ref, [ '402', $args->[0] ];
4052 0 last SWITCH;
4053 }
4054 2 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 2 0 2
4055 2 my $name;
4056 my $route_id;
4057 2 ▶ if ( length $targ == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $targ == 3) { } 0 2 2
4058 0 $name = $self->{state}{sids}{$targ}{name};
4059 0 $route_id = $self->{state}{sids}{$targ}{route_id};
4060 }
4061 else {
4062 2 $name = $self->{state}{uids}{$targ}{nick};
4063 2 $route_id = $self->{state}{uids}{$targ}{route_id};
4064 }
4065 push @$ref, {
4066 prefix => $server,
4067 command => '200',
4068 params => [
4069 $nick,
4070 'Link',
4071 $self->server_version(),
4072 $name,
4073 $self->{state}{conns}{$route_id}{name},
4074 2 ],
4075 };
4076 2 $self->send_output(
4077 {
4078 prefix => $uid,
4079 command => $cmd,
4080 params => [
4081 $targ,
4082 ],
4083 },
4084 $route_id,
4085 );
4086 2 last SWITCH;
4087 }
4088 }
4089 2 ▶ my $method = ( $cmd eq 'ETRACE' ? '_daemon_do_etrace' : '_daemon_do_trace' );
Branch: 1 branch
BranchTrueFalseTotal
$cmd eq 'ETRACE' ? : 1 1 2
4090 2 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
4091 2 @{ $self->$method($uid, @$args) };
4092 }
4093 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
4094 0 return $ref;
4095 }
4096  
4097 sub _daemon_do_etrace {
4098 2 ▶ my $self = shift;
Subroutine _daemon_do_etrace: called CC=20 SCAR=32.3
4099 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
4100 2 my $server = $self->server_name();
4101 2 my $sid = $self->server_sid();
4102 2 my $args = [@_];
4103 2 my $count = @$args;
4104 2 my $ref = [ ];
4105  
4106 SWITCH: {
4107 2 my $rec = $self->{state}{uids}{$uid};
4108 $self->_send_to_realops(
4109 sprintf(
4110 'ETRACE requested by %s (%s@%s) [%s]',
4111 $rec->{nick},
4112 $rec->{auth}{ident},
4113 $rec->{auth}{hostname},
4114 $rec->{server},
4115 2 ),
4116 'Notice',
4117 'y',
4118 );
4119 2 my $doall = 0;
4120 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
4121 1 $doall = 1;
4122 }
4123 elsif (uc $args->[0] eq uc $server) {
4124 0 $doall = 1;
4125 }
4126 elsif ($args->[0] eq $sid) {
4127 1 $doall = 1;
4128 }
4129 2 my $name = $args->[0];
4130 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
4131 1 $name = $self->state_user_nick($name);
4132 }
4133 2 ▶ $name = uc_irc $name if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 2 2
4134 # Local clients
4135 2 my @connects;
4136 2 my $conns = $self->{state}{conns};
4137 2 foreach my $conn_id ( keys %$conns ) {
4138 12 ▶ next if $conns->{$conn_id}{type} ne 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $conns->{$conn_id}{"type"} ne "c" 6 6 12
4139 6 ▶ next if defined $self->{state}{localops}{ $conn_id };
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"localops"}{$conn_id} 2 4 6
4140 4 push @connects, $conn_id;
4141 }
4142 2 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4143 @connects ) {
4144 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 table0%0/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4145 4 my $connrec = $conns->{$conn_id};
4146 push @$ref, {
4147 prefix => $sid,
4148 command => '709',
4149 params => [
4150 $uid,
4151 'User', 'users',
4152 $connrec->{nick},
4153 $connrec->{auth}{ident},
4154 $connrec->{auth}{hostname},
4155 $connrec->{socket}[0],
4156 $connrec->{ircname},
4157 4 ],
4158 };
4159 }
4160 2 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4161 2 keys %{ $self->{state}{localops} } ) {
4162 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 table0%0/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4163 2 my $connrec = $conns->{$conn_id};
4164 push @$ref, {
4165 prefix => $sid,
4166 command => '709',
4167 params => [
4168 $uid,
4169 'Oper', 'opers',
4170 $connrec->{nick},
4171 $connrec->{auth}{ident},
4172 $connrec->{auth}{hostname},
4173 $connrec->{socket}[0],
4174 $connrec->{ircname},
4175 2 ],
4176 };
4177 }
4178 # End of ETRACE
4179 2 push @$ref, {
4180 prefix => $sid,
4181 command => '759',
4182 params => [
4183 $uid, $server, 'End of ETRACE',
4184 ],
4185 };
4186 }
4187  
4188 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4189 2 return $ref;
4190 }
4191  
4192 sub _daemon_do_trace {
4193 2 ▶ my $self = shift;
Subroutine _daemon_do_trace: called CC=36 SCAR=41.4
4194 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
4195 2 my $server = $self->server_name();
4196 2 my $sid = $self->server_sid();
4197 2 my $args = [@_];
4198 2 my $count = @$args;
4199 2 my $ref = [ ];
4200  
4201 SWITCH: {
4202 2 my $rec = $self->{state}{uids}{$uid};
4203 $self->_send_to_realops(
4204 sprintf(
4205 'TRACE requested by %s (%s@%s) [%s]',
4206 $rec->{nick},
4207 $rec->{auth}{ident},
4208 $rec->{auth}{hostname},
4209 $rec->{server},
4210 2 ),
4211 'Notice',
4212 'y',
4213 );
4214 2 my $doall = 0;
4215 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
4216 1 $doall = 1;
4217 }
4218 elsif (uc $args->[0] eq uc $server) {
4219 0 $doall = 1;
4220 }
4221 elsif ($args->[0] eq $sid) {
4222 1 $doall = 1;
4223 }
4224 2 my $name = $args->[0];
4225 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
4226 1 $name = $self->state_user_nick($name);
4227 }
4228 2 ▶ $name = uc_irc $name if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 2 2
4229 # Local clients
4230 2 my $conns = $self->{state}{conns};
4231 2 my %connects;
4232 2 foreach my $conn_id ( keys %$conns ) {
4233 12 ▶ next if defined $self->{state}{localops}{ $conn_id };
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"localops"}{$conn_id} 2 10 12
4234 10 push @{ $connects{ $conns->{$conn_id}{type} } }, $conn_id;
4235 }
4236 2 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4237 2 @{ $connects{c} } ) {
4238 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 table0%0/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4239 4 my $connrec = $conns->{$conn_id};
4240 push @$ref, {
4241 prefix => $sid,
4242 command => '205',
4243 params => [
4244 $uid,
4245 'User', 'users',
4246 $connrec->{nick},
4247 sprintf('[%s@%s]',$connrec->{auth}{ident},$connrec->{auth}{hostname}),
4248 sprintf('(%s)',$connrec->{socket}[0]),
4249 time - $connrec->{seen},
4250 time - $connrec->{idle_time},
4251 4 ],
4252 colonify => 0,
4253 };
4254 }
4255 2 foreach my $conn_id ( sort { $conns->{$a}{nick} cmp $conns->{$b}{nick} }
4256 2 keys %{ $self->{state}{localops} } ) {
4257 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 table0%0/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"nick"})
ABCresult
1XX1
0111
00X0
0100
4258 2 my $connrec = $conns->{$conn_id};
4259 push @$ref, {
4260 prefix => $sid,
4261 command => '204',
4262 params => [
4263 $uid,
4264 'Oper', 'opers',
4265 $connrec->{nick},
4266 sprintf('[%s@%s]',$connrec->{auth}{ident},$connrec->{auth}{hostname}),
4267 sprintf('(%s)',$connrec->{socket}[0]),
4268 time - $connrec->{seen},
4269 time - $connrec->{idle_time},
4270 2 ],
4271 colonify => 0,
4272 };
4273 }
4274 # Servers
4275 2 foreach my $conn_id ( sort { $conns->{$a}{name} cmp $conns->{$b}{name} }
4276 2 @{ $connects{p} } ) {
4277 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 table0%0/4
not(A) or B and C
A= not $doallB= $nameC= $name ne uc_irc($conns->{$conn_id}{"name"})
ABCresult
1XX1
0111
00X0
0100
4278 4 my $connrec = $conns->{$conn_id};
4279 4 my $srvcnt = 0; my $clicnt = 0;
4280 4 $self->_state_peer_dependents( $connrec->{sid}, \$srvcnt, \$clicnt );
4281 push @$ref, {
4282 prefix => $sid,
4283 command => '206',
4284 params => [
4285 $uid,
4286 'Serv', 'server',
4287 "${srvcnt}S", "${clicnt}C",
4288 sprintf(
4289 '%s[%s@%s]', $connrec->{name},
4290 ( $connrec->{auth}{ident} || 'unknown' ),
4291 ( $connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
4292 sprintf('%s!%s@%s','*','*',$connrec->{name}),
4293 time - $connrec->{conn_time},
4294 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
4295 colonify => 0,
4296 };
4297 }
4298 # Unknowns
4299 2 foreach my $conn_id ( sort { $conns->{$a}{nick} <=> $conns->{$b}{nick} }
4300 2 @{ $connects{u} } ) {
4301 2 ▶ next if !$doall;
Branch: 1 branch
BranchTrueFalseTotal
unless $doall 0 2 2
4302 2 my $connrec = $conns->{$conn_id};
4303 push @$ref, {
4304 prefix => $sid,
4305 command => '203',
4306 params => [
4307 $uid,
4308 '????', 'default',
4309 sprintf(
4310 '[%s@%s]', ( $connrec->{auth}{ident} || 'unknown' ),
4311 ( $connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
4312 sprintf('(%s)',$connrec->{socket}[0]),
4313 time - $connrec->{conn_time},
4314 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
4315 colonify => 0,
4316 };
4317 }
4318 2 ▶ if ($doall) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doall) 2 0 2
4319 2 ▶ my $users = ( defined $connects{c} ? @{ $connects{c} } : 0 );
Branch: 1 branch
BranchTrueFalseTotal
defined $connects{'c'} ? : 2 0 2
4320 2 ▶ my $opers = ( defined $self->{state}{localops} ? keys %{ $self->{state}{localops} } : 0 );
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'state'}{'localops'} ? : 2 0 2
4321 2 ▶ my $servers = ( defined $connects{p} ? @{ $connects{p} } : 0 );;
Branch: 1 branch
BranchTrueFalseTotal
defined $connects{'p'} ? : 2 0 2
4322 2 $users -= $opers;
4323 # 209
4324 2 ▶ if ($servers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($servers) 2 0 2
4325 2 push @$ref, {
4326 prefix => $sid,
4327 command => '209',
4328 params => [
4329 $uid,
4330 'Class', 'server', $servers,
4331 ],
4332 colonify => 0,
4333 };
4334 }
4335 2 ▶ if ($opers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opers) 2 0 2
4336 2 push @$ref, {
4337 prefix => $sid,
4338 command => '209',
4339 params => [
4340 $uid,
4341 'Class', 'opers', $opers,
4342 ],
4343 colonify => 0,
4344 };
4345 }
4346 2 ▶ if ($users) {
Branch: 1 branch
BranchTrueFalseTotal
if ($users) 2 0 2
4347 2 push @$ref, {
4348 prefix => $sid,
4349 command => '209',
4350 params => [
4351 $uid,
4352 'Class', 'users', $users,
4353 ],
4354 colonify => 0,
4355 };
4356 }
4357 }
4358 # End of TRACE
4359 2 push @$ref, {
4360 prefix => $sid,
4361 command => '262',
4362 params => [
4363 $uid, $server, 'End of TRACE',
4364 ],
4365 };
4366 }
4367  
4368 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4369 2 return $ref;
4370 }
4371  
4372 sub _state_peer_dependents {
4373 6 ▶ my $self = shift;
Subroutine _state_peer_dependents: called CC=3 SCAR=11.0
4374 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
4375 6 my $srvcnt = shift;
4376 6 my $clicnt = shift;
4377  
4378 6 $$srvcnt++;
4379 6 $$clicnt += keys %{ $self->{state}{sids}{$sid}{uids} };
4380 6 foreach my $psid ( keys %{ $self->{state}{sids}{$sid}{sids} } ) {
4381 2 $self->_state_peer_dependents($psid,$srvcnt,$clicnt);
4382 }
4383 6 return;
4384 }
4385 sub _daemon_cmd_nick {
4386 22 ▶ my $self = shift;
Subroutine _daemon_cmd_nick: called CC=31 SCAR=36.6
4387 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
4388 22 my $new = shift;
4389 22 my $server = uc $self->server_name();
4390 22 my $sid = $self->server_sid();
4391 22 my $ref = [ ];
4392  
4393 SWITCH: {
4394 22 ▶ if (!$new) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($new) 0 22 22
4395 0 push @$ref, ['431'];
4396 0 last SWITCH;
4397 }
4398 22 my $nicklen = $self->server_config('NICKLEN');
4399 22 ▶ $new = substr($new, 0, $nicklen) if length($new) > $nicklen;
Branch: 1 branch
BranchTrueFalseTotal
if length $new > $nicklen 0 22 22
4400 22 ▶ if ($nick eq $new) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick eq $new) 1 21 22
4401 1 last SWITCH;
4402 }
4403 21 ▶ if (!is_valid_nick_name($new)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_nick_name($new)) 0 21 21
4404 0 push @$ref, ['432', $new];
4405 0 last SWITCH;
4406 }
4407 21 my $unick = uc_irc($nick);
4408 21 my $record = $self->{state}{users}{$unick};
4409 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
4410 1 $self->_send_to_realops(
4411 sprintf(
4412 'Forbidding reserved nick %s from user %s',
4413 $new,
4414 $self->state_user_full($nick),
4415 ),
4416 'Notice',
4417 'j',
4418 );
4419 1 push @$ref, {
4420 prefix => $self->server_name(),
4421 command => '432',
4422 params => [
4423 $nick,
4424 $new,
4425 $reason,
4426 ],
4427 };
4428 1 last SWITCH;
4429 }
4430 20 my $unew = uc_irc($new);
4431 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
4432 0 push @$ref, ['433', $new];
4433 0 last SWITCH;
4434 }
4435 20 my $full = $record->{full}->();
4436 20 my $common = { $record->{uid} => $record->{route_id} };
4437  
4438 20 my $nonickchange = '';
4439 20 CHANS: for my $chan (keys %{ $record->{chans} }) {
4440 4 my $chanrec = $self->{state}{chans}{$chan};
4441 4 ▶ if ( $chanrec->{mode} =~ /N/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chanrec->{"mode"} =~ /N/) 2 2 4
4442 2 ▶ if ( $record->{chans} !~ /[oh]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"chans"} =~ /[oh]/) 2 0 2
4443 2 $nonickchange = $chanrec->{name};
4444 2 last CHANS;
4445 }
4446 }
4447 2 USER: for my $user ( keys %{ $chanrec->{users} } ) {
4448 4 ▶ next USER if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 0 4 4
4449 4 $common->{$user} = $self->_state_uid_route($user);
4450 }
4451 }
4452  
4453 20 ▶ if ($nonickchange) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nonickchange) 2 18 20
4454 2 push @$ref,['447',$nonickchange];
4455 2 last SWITCH;
4456 }
4457  
4458 18 my $lastattempt = $record->{_nick_last};
4459 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
4460 0 $record->{_nick_count} = 0;
4461 }
4462  
4463 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
4464 $record->{_nick_count} && ( $record->{_nick_count} >= $self->{config}{max_nick_changes} ) ) {
4465 1 push @$ref,['438',$new,$self->{config}{max_nick_time}];
4466 1 last SWITCH;
4467 }
4468  
4469 17 $record->{_nick_last} = time();
4470 17 $record->{_nick_count}++;
4471  
4472 17 ▶ if ($unick eq $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unick eq $unew) { } 0 17 17
4473 0 $record->{nick} = $new;
4474 0 $record->{ts} = time;
4475 }
4476 else {
4477 17 $record->{nick} = $new;
4478 17 $record->{ts} = time;
4479 # Remove from peoples accept lists
4480 17 for (keys %{ $record->{accepts} }) {
4481 0 delete $self->{state}{users}{$_}{accepts}{$unick};
4482 }
4483 17 delete $record->{accepts};
4484 # WATCH ON/OFF
4485 17 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 16 17
4486 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
4487 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
4488 1 my $wrec = $self->{state}{uids}{$wuid};
4489 1 my $laston = time();
4490 1 $self->{state}{watches}{$unick}{laston} = $laston;
4491 $self->send_output(
4492 {
4493 prefix => $record->{server},
4494 command => '605',
4495 params => [
4496 $wrec->{nick},
4497 $nick,
4498 $record->{auth}{ident},
4499 $record->{auth}{hostname},
4500 $laston,
4501 'is offline',
4502 ],
4503 },
4504 $wrec->{route_id},
4505 1 );
4506 }
4507 }
4508 17 ▶ if ( defined $self->{state}{watches}{$unew} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unew}) 1 16 17
4509 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unew}{uids} } ) {
4510 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
4511 1 my $wrec = $self->{state}{uids}{$wuid};
4512 $self->send_output(
4513 {
4514 prefix => $record->{server},
4515 command => '604',
4516 params => [
4517 $wrec->{nick},
4518 $record->{nick},
4519 $record->{auth}{ident},
4520 $record->{auth}{hostname},
4521 $record->{ts},
4522 'is online',
4523 ],
4524 },
4525 $wrec->{route_id},
4526 1 );
4527 }
4528 }
4529 17 delete $self->{state}{users}{$unick};
4530 17 $self->{state}{users}{$unew} = $record;
4531 17 delete $self->{state}{peers}{$server}{users}{$unick};
4532 17 $self->{state}{peers}{$server}{users}{$unew} = $record;
4533 17 ▶ if ( $record->{umode} =~ /r/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /r/) 1 16 17
4534 1 $record->{umode} =~ s/r//g;
4535 $self->send_output(
4536 {
4537 prefix => $full,
4538 command => 'MODE',
4539 params => [
4540 $record->{nick},
4541 '-r',
4542 ],
4543 },
4544 $record->{route_id},
4545 1 );
4546 }
4547 17 unshift @{ $self->{state}{whowas}{$unick} }, {
4548 logoff => time(),
4549 account => $record->{account},
4550 nick => $nick,
4551 user => $record->{auth}{ident},
4552 host => $record->{auth}{hostname},
4553 real => $record->{auth}{realhost},
4554 sock => $record->{socket}[0],
4555 ircname => $record->{ircname},
4556 server => $record->{server},
4557 17 };
4558 }
4559  
4560 17 $self->_send_to_realops(
4561 sprintf(
4562 'Nick change: From %s to %s [%s]',
4563 $nick, $new, (split /!/, $full)[1],
4564 ),
4565 'Notice',
4566 'n',
4567 );
4568  
4569 $self->send_output(
4570 {
4571 prefix => $record->{uid},
4572 command => 'NICK',
4573 17 params => [$new, $record->{ts}],
4574 },
4575 $self->_state_connected_peers(),
4576 );
4577  
4578 17 $self->send_event("daemon_nick", $full, $new);
4579  
4580 17 $self->send_output(
4581 {
4582 prefix => $full,
4583 command => 'NICK',
4584 params => [$new],
4585 },
4586 values %$common,
4587 );
4588 }
4589  
4590 22 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 22 0 22
4591 0 return $ref;
4592 }
4593  
4594 sub _daemon_cmd_away {
4595 5 ▶ my $self = shift;
Subroutine _daemon_cmd_away: called CC=4 SCAR=13.9
4596 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
4597 5 my $msg = shift;
4598 5 my $server = $self->server_name();
4599 5 my $ref = [ ];
4600  
4601 SWITCH: {
4602 5 my $rec = $self->{state}{users}{uc_irc($nick)};
4603 5 ▶ if (!$msg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 2 3 5
4604 2 delete $rec->{away};
4605 $self->send_output(
4606 {
4607 prefix => $rec->{uid},
4608 2 command => 'AWAY',
4609 },
4610 $self->_state_connected_peers(),
4611 );
4612 push @$ref, {
4613 prefix => $server,
4614 command => '305',
4615 2 params => [ $rec->{nick}, 'You are no longer marked as being away' ],
4616 };
4617 2 $self->_state_do_away_notify($rec->{uid},'*',$msg);
4618 2 last SWITCH;
4619 }
4620  
4621 3 $rec->{away} = $msg;
4622  
4623 $self->send_output(
4624 {
4625 prefix => $rec->{uid},
4626 3 command => 'AWAY',
4627 params => [$msg],
4628 },
4629 $self->_state_connected_peers(),
4630 );
4631 push @$ref, {
4632 prefix => $server,
4633 command => '306',
4634 3 params => [ $rec->{nick}, 'You have been marked as being away' ],
4635 };
4636 3 $self->_state_do_away_notify($rec->{uid},'*',$msg);
4637 }
4638  
4639 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
4640 0 return $ref;
4641 }
4642  
4643 sub _daemon_client_miscell {
4644 6 ▶ my $self = shift;
Subroutine _daemon_client_miscell: called CC=9 SCAR=25.0
4645 6 my $cmd = shift;
4646 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
4647 6 my $target = shift;
4648 6 my $server = $self->server_name();
4649 6 my $ref = [ ];
4650  
4651 SWITCH: {
4652 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
4653 0 push @$ref, ['402', $target];
4654 0 last SWITCH;
4655 }
4656 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
4657 0 $target = $self->_state_peer_sid($target);
4658 0 $self->send_output(
4659 {
4660 prefix => $self->state_user_uid($nick),
4661 command => uc $cmd,
4662 params => [$target],
4663 },
4664 $self->_state_sid_route($target),
4665 );
4666 0 last SWITCH;
4667 }
4668 6 ▶ if ($cmd =~ m!^(ADMIN|INFO|MOTD)$!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(ADMIN|INFO|MOTD)$/i) 3 3 6
4669 3 $self->_send_to_realops(
4670 sprintf(
4671 '%s requested by %s (%s) [%s]',
4672 $cmd, $nick, (split /!/,$self->state_user_full($nick))[1], $server,
4673 ), qw[Notice y],
4674 );
4675 }
4676 6 my $method = '_daemon_do_' . lc $cmd;
4677 6 my $uid = $self->state_user_uid($nick);
4678 6 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
4679 6 @{ $self->$method($uid) };
4680 }
4681  
4682 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
4683 0 return $ref;
4684 }
4685  
4686 sub _daemon_peer_miscell {
4687 5 ▶ my $self = shift;
Subroutine _daemon_peer_miscell: called CC=8 SCAR=23.8
4688 5 my $cmd = shift;
4689 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
4690 5 my $sid = $self->server_sid();
4691 5 my $args = [@_];
4692 5 my $count = @$args;
4693 5 my $ref = [ ];
4694  
4695 SWITCH: {
4696 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
4697 0 $self->send_output(
4698 {
4699 prefix => $uid,
4700 command => $cmd,
4701 params => $args,
4702 },
4703 $self->_state_sid_route(substr $args->[0], 0, 3),
4704 );
4705 0 last SWITCH;
4706 }
4707 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
4708 0 $self->send_output(
4709 {
4710 prefix => $uid,
4711 command => $cmd,
4712 params => $args,
4713 },
4714 $self->_state_sid_route(substr $args->[1], 0, 3),
4715 );
4716 0 last SWITCH;
4717 }
4718 5 ▶ if ($cmd =~ m!^(ADMIN|INFO|MOTD)$!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(ADMIN|INFO|MOTD)$/i) 3 2 5
4719 3 my $urec = $self->{state}{uids}{$uid};
4720 $self->_send_to_realops(
4721 sprintf(
4722 '%s requested by %s (%s) [%s]',
4723 $cmd, $urec->{nick}, (split /!/,$urec->{full}->())[1], $urec->{server},
4724 3 ), qw[Notice y],
4725 );
4726 }
4727 5 my $method = '_daemon_do_' . lc $cmd;
4728 5 $ref = $self->$method($uid, @$args);
4729 }
4730  
4731 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
4732 0 return $ref;
4733 }
4734  
4735 # Pseudo cmd for ISupport 005 numerics
4736 sub _daemon_do_isupport {
4737 225 ▶ my $self = shift;
Subroutine _daemon_do_isupport: called CC=5 SCAR=16.2
4738 225 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4739 225 my $sid = $self->server_sid();
4740 225 my $ref = [ ];
4741  
4742 push @$ref, {
4743 prefix => $sid,
4744 command => '005',
4745 params => [
4746 $uid,
4747 join(' ', map {
4748 225 (defined $self->{config}{isupport}{$_}
4749 2475 ▶ ? join '=', $_, $self->{config}{isupport}{$_}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'config'}{'isupport'}{$_} ? : 2025 450 2475
4750 : $_
4751 )
4752 } qw(CALLERID EXCEPTS INVEX MAXCHANNELS MAXLIST MAXTARGETS
4753 NICKLEN TOPICLEN KICKLEN KNOCK DEAF)
4754 ),
4755 'are supported by this server',
4756 ],
4757 };
4758  
4759 push @$ref, {
4760 prefix => $sid,
4761 command => '005',
4762 params => [
4763 $uid,
4764 join(' ', map {
4765 225 (defined $self->{config}{isupport}{$_}
4766 1575 ▶ ? join '=', $_, $self->{config}{isupport}{$_}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'config'}{'isupport'}{$_} ? : 1350 225 1575
4767 : $_
4768 )
4769 } qw(CHANTYPES PREFIX CHANMODES NETWORK CASEMAPPING SAFELIST ELIST)
4770 ), 'are supported by this server',
4771 ],
4772 };
4773  
4774 225 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 225 225
4775 225 return $ref;
4776 }
4777  
4778 sub _daemon_do_info {
4779 2 ▶ my $self = shift;
Subroutine _daemon_do_info: called CC=4 SCAR=14.0
4780 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
4781 2 my $sid = $self->server_sid();
4782 2 my $ref = [ ];
4783  
4784 {
4785 2 for my $info (@{ $self->server_config('Info') }) {
4786 20 push @$ref, {
4787 prefix => $sid,
4788 command => '371',
4789 params => [$uid, $info],
4790 };
4791 }
4792  
4793 2 push @$ref, {
4794 prefix => $sid,
4795 command => '374',
4796 params => [$uid, 'End of /INFO list.'],
4797 };
4798 }
4799  
4800 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4801 2 return $ref;
4802 }
4803  
4804 sub _daemon_do_version {
4805 2 ▶ my $self = shift;
Subroutine _daemon_do_version: called CC=4 SCAR=14.0
4806 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
4807 2 my $sid = $self->server_sid();
4808 2 my $ref = [ ];
4809  
4810 2 push @$ref, {
4811 prefix => $sid,
4812 command => '351',
4813 params => [
4814 $uid,
4815 $self->server_version(),
4816 $self->server_name(),
4817 'eGHIMZ6 TS6ow',
4818 ],
4819 };
4820  
4821 2 push @$ref, $_ for @{ $self->_daemon_do_isupport($uid) };
4822  
4823 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4824 2 return $ref;
4825 }
4826  
4827 sub _daemon_do_admin {
4828 2 ▶ my $self = shift;
Subroutine _daemon_do_admin: called CC=3 SCAR=11.0
4829 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
4830 2 my $sid = $self->server_sid();
4831 2 my $ref = [ ];
4832 2 my $admin = $self->server_config('Admin');
4833  
4834 {
4835 2 push @$ref, {
4836 prefix => $sid,
4837 command => '256',
4838 params => [$uid, $self->server_name(), 'Administrative Info'],
4839 };
4840  
4841 2 push @$ref, {
4842 prefix => $sid,
4843 command => '257',
4844 params => [$uid, $admin->[0]],
4845 };
4846  
4847 2 push @$ref, {
4848 prefix => $sid,
4849 command => '258',
4850 params => [$uid, $admin->[1]],
4851 };
4852  
4853 2 push @$ref, {
4854 prefix => $sid,
4855 command => '259',
4856 params => [$uid, $admin->[2]],
4857 };
4858 }
4859  
4860 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4861 2 return $ref;
4862 }
4863  
4864 sub _daemon_cmd_summon {
4865 0 ▶ my $self = shift;
Subroutine _daemon_cmd_summon: not called CC=3 SCAR=24.8
4866 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
4867 0 my $server = $self->server_name();
4868 0 my $ref = [ ];
4869 0 push @$ref, '445';
4870 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4871 0 return $ref;
4872 }
4873  
4874 sub _daemon_do_time {
4875 3 ▶ my $self = shift;
Subroutine _daemon_do_time: called CC=3 SCAR=11.1
4876 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
4877 3 my $sid = $self->server_sid();
4878 3 my $ref = [ ];
4879  
4880 {
4881 3 push @$ref, {
4882 prefix => $sid,
4883 command => '391',
4884 params => [
4885 $uid,
4886 $self->server_name(),
4887 strftime("%A %B %e %Y -- %T %z", localtime),
4888 ],
4889 };
4890 }
4891  
4892 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
4893 3 return $ref;
4894 }
4895  
4896 sub _daemon_do_users {
4897 225 ▶ my $self = shift;
Subroutine _daemon_do_users: called CC=5 SCAR=16.2
4898 225 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4899 225 my $hidden = shift;
4900 225 my $sid = $self->server_sid();
4901 225 my $ref = [ ];
4902 225 my $global = keys %{ $self->{state}{uids} };
4903 225 ▶ my $local = $hidden ? $global : scalar keys %{ $self->{state}{sids}{$sid}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 219 225
4904 225 ▶ my $maxloc = $hidden ? 'maxglobal' : 'maxlocal';
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 219 225
4905  
4906 push @$ref, {
4907 prefix => $sid,
4908 command => '265',
4909 params => [
4910 $uid,
4911 "Current local users: $local Max: "
4912 225 . $self->{state}{stats}{$maxloc},
4913 ],
4914 };
4915  
4916 push @$ref, {
4917 prefix => $sid,
4918 command => '266',
4919 params => [
4920 $uid,
4921 "Current global users: $global Max: "
4922 . $self->{state}{stats}{maxglobal},
4923 225 ],
4924 };
4925  
4926 225 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 225 0 225
4927 0 return $ref;
4928 }
4929  
4930 sub _daemon_cmd_lusers {
4931 2 ▶ my $self = shift;
Subroutine _daemon_cmd_lusers: called CC=9 SCAR=30.7
4932 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
4933 2 my $server = $self->server_name();
4934 2 my $ref = [ ];
4935 2 my $args = [@_];
4936 2 my $count = @$args;
4937  
4938 SWITCH: {
4939 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
4940 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
4941 0 ▶ if (!$target) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 0 0
4942 0 push @$ref, ['402', $args->[1]];
4943 0 last SWITCH;
4944 }
4945 0 my $targsid = substr $target, 0, 3;
4946 0 my $sid = $self->server_sid();
4947 0 ▶ if ( $targsid ne $sid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targsid ne $sid) 0 0 0
4948 0 $self->send_output(
4949 {
4950 prefix => $self->state_user_uid($nick),
4951 command => 'LUSERS',
4952 params => [
4953 $args->[0],
4954 $target,
4955 ],
4956 },
4957 $self->_state_sid_route($targsid),
4958 );
4959 0 last SWITCH;
4960 }
4961 }
4962 2 my $uid = $self->state_user_uid($nick);
4963 2 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
4964 2 @{ $self->_daemon_do_lusers($uid) };
4965 }
4966  
4967 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
4968 0 return $ref;
4969 }
4970  
4971 sub _daemon_peer_lusers {
4972 0 ▶ my $self = shift;
Subroutine _daemon_peer_lusers: not called CC=9 SCAR=45.0
4973 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
4974 0 my $sid = $self->server_sid();
4975 0 my $ref = [ ];
4976 0 my $args = [@_];
4977 0 my $count = @$args;
4978  
4979 SWITCH: {
4980 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
4981 0 last SWITCH;
4982 }
4983 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
4984 0 ▶ if (!$target) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 0 0
4985 0 push @$ref, ['402', $args->[1]];
4986 0 last SWITCH;
4987 }
4988 0 my $targsid = substr $target, 0, 3;
4989 0 ▶ if ( $targsid ne $sid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targsid ne $sid) 0 0 0
4990 0 $self->send_output(
4991 {
4992 prefix => $uid,
4993 command => 'LUSERS',
4994 params => $args,
4995 },
4996 $self->_state_sid_route($targsid),
4997 );
4998 0 last SWITCH;
4999 }
5000 0 push @$ref, $_ for @{ $self->_daemon_do_lusers($uid) };
5001 }
5002  
5003 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5004 0 return $ref;
5005 }
5006  
5007 sub _daemon_do_lusers {
5008 225 ▶ my $self = shift;
Subroutine _daemon_do_lusers: called CC=11 SCAR=24.0
5009 225 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5010 225 my $sid = $self->server_sid();
5011 225 my $ref = [ ];
5012 225 ▶ 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
21906
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
5013 225 my $invisible = $self->{state}{stats}{invisible};
5014 225 my $users = keys(%{ $self->{state}{uids} }) - $invisible;
5015 225 ▶ my $servers = $hidden ? 1 : scalar keys %{ $self->{state}{sids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 219 225
5016 225 my $chans = keys %{ $self->{state}{chans} };
5017 225 ▶ my $local = $hidden ? ( $users + $invisible ) : scalar keys %{ $self->{state}{sids}{$sid}{uids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 219 225
5018 225 ▶ my $peers = $hidden ? 0 : scalar keys %{ $self->{state}{sids}{$sid}{sids} };
Branch: 1 branch
BranchTrueFalseTotal
$hidden ? : 6 219 225
5019 225 my $totalconns = $self->{state}{stats}{conns_cumlative};
5020 225 my $mlocal = $self->{state}{stats}{maxlocal};
5021 225 my $conns = $self->{state}{stats}{maxconns};
5022  
5023 225 push @$ref, {
5024 prefix => $sid,
5025 command => '251',
5026 params => [
5027 $uid,
5028 "There are $users users and $invisible invisible on "
5029 . "$servers servers",
5030 ],
5031 };
5032  
5033 225 $servers--;
5034  
5035 push @$ref, {
5036 prefix => $sid,
5037 command => '252',
5038 params => [
5039 $uid,
5040 $self->{state}{stats}{ops_online},
5041 "IRC Operators online",
5042 ]
5043 225 ▶ } if $self->{state}{stats}{ops_online};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"stats"}{"ops_online"} 162 63 225
5044  
5045 225 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if $chans 59 166 225
5046 prefix => $sid,
5047 command => '254',
5048 params => [$uid, $chans, "channels formed"],
5049 } if $chans;
5050  
5051 225 push @$ref, {
5052 prefix => $sid,
5053 command => '255',
5054 params => [$uid, "I have $local clients and $peers servers"],
5055 };
5056  
5057 225 push @$ref, $_ for $self->_daemon_do_users($uid, $hidden);
5058  
5059 225 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
unless $hidden 219 6 225
5060 prefix => $sid,
5061 command => '250',
5062 params => [
5063 $uid, "Highest connection count: $conns ($mlocal clients) "
5064 . "($totalconns connections received)",
5065 ],
5066 } if !$hidden;
5067  
5068 225 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 225 225
5069 225 return $ref;
5070 }
5071  
5072 sub _daemon_do_motd {
5073 225 ▶ my $self = shift;
Subroutine _daemon_do_motd: called CC=6 SCAR=18.0
5074 225 ▶ my $uid = shift || return;
Condition50%1/2
shift() || (return)
l!l
2250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
5075 225 my $sid = $self->server_sid();
5076 225 my $server = $self->server_name();
5077 225 my $ref = [ ];
5078 225 my $motd = $self->server_config('MOTD');
5079  
5080 {
5081 225 ▶ if ($motd && ref $motd eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($motd and ref $motd eq 'ARRAY') { } 2 223 225
Condition66%2/3
$motd and ref $motd eq "ARRAY"
!ll&&!rl&&r
22302
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
5082 2 push @$ref, {
5083 prefix => $sid,
5084 command => '375',
5085 params => [$uid, "- $server Message of the day - "],
5086 };
5087 push @$ref, {
5088 prefix => $sid,
5089 command => '372',
5090 params => [$uid, "- $_"]
5091 2 } for @$motd;
5092 2 push @$ref, {
5093 prefix => $sid,
5094 command => '376',
5095 params => [$uid, "End of MOTD command"],
5096 };
5097 }
5098 else {
5099 push @$ref, {
5100 prefix => $sid,
5101 command => '422',
5102 223 params => [$uid, $self->{Error_Codes}{'422'}[1]],
5103 };
5104 }
5105 }
5106  
5107 225 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 225 225
5108 225 return $ref;
5109 }
5110  
5111 sub _daemon_cmd_stats {
5112 22 ▶ my $self = shift;
Subroutine _daemon_cmd_stats: called CC=14 SCAR=27.2
5113 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
5114 22 my $char = shift;
5115 22 my $target = shift;
5116 22 my $server = $self->server_name();
5117 22 my $sid = $self->server_sid();
5118 22 my $ref = [ ];
5119  
5120 SWITCH: {
5121 22 ▶ if (!$char) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($char) 0 22 22
5122 0 push @$ref, ['461', 'STATS'];
5123 0 last SWITCH;
5124 }
5125 22 $char = substr $char, 0, 1;
5126 22 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 21 1 22
5127 21 my $lastuse = $self->{state}{lastuse}{stats};
5128 21 my $pacewait = $self->{config}{pace_wait};
5129 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
5130 1 push @$ref, ['263', 'STATS'];
5131 1 last SWITCH;
5132 }
5133 20 $self->{state}{lastuse}{stats} = time();
5134 }
5135 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
5136 2 push @$ref, ['461', 'STATS'];
5137 2 last SWITCH;
5138 }
5139 19 ▶ if ($target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 18 19
5140 1 my $targ = $self->_state_find_peer($target);
5141 1 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 1 1
5142 0 push @$ref, [ '402', $target ];
5143 0 last SWITCH;
5144 }
5145 1 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 1 0 1
5146 1 my $psid = substr $targ, 0, 3;
5147 1 $self->send_output(
5148 {
5149 prefix => $self->state_user_uid($nick),
5150 command => 'STATS',
5151 params => [
5152 $char,
5153 $targ,
5154 ],
5155 },
5156 $self->_state_sid_route($psid),
5157 );
5158 1 last SWITCH;
5159 }
5160 }
5161 18 my $uid = $self->state_user_uid($nick);
5162 18 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
5163 18 @{ $self->_daemon_do_stats($uid, $char, $target) };
5164 }
5165  
5166 22 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 22 0 22
5167 0 return $ref;
5168 }
5169  
5170 sub _rbytes {
5171 4 ▶ my $bytes=shift;
Subroutine _rbytes: called CC=7 SCAR=27.8
5172 4 my $d=2;
5173 4 ▶ return undef if !defined $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 4 4
5174 4 ▶ return [ $bytes, 'Bytes' ] if abs($bytes) <= 2** 0*1000;
Branch: 1 branch
BranchTrueFalseTotal
if abs $bytes <= 1000 2 2 4
5175 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
5176 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
5177 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
5178 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
5179 0 return [ sprintf("%.*f",$d,$bytes/2**50), 'Petabytes' ];
5180 }
5181  
5182 sub _daemon_do_stats {
5183 18 ▶ my $self = shift;
Subroutine _daemon_do_stats: called CC=100 SCAR=84.3
5184 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
5185 18 my $char = shift;
5186 18 my $targ = shift;
5187 18 my $server = $self->server_name();
5188 18 my $sid = $self->server_sid();
5189 18 my $ref = [ ];
5190  
5191 18 my $rec = $self->{state}{uids}{$uid};
5192 18 my $is_oper = ( $rec->{umode} =~ /o/ );
5193 18 my $is_admin = ( $rec->{umode} =~ /a/ );
5194  
5195 18 my %perms = (
5196 admin => qr/[AaEFf]/,
5197 oper => qr/[OoCcDdeHhIiKkLlQqSsTtUvXxYyz?]/,
5198 );
5199  
5200 $self->_send_to_realops(
5201 sprintf(
5202 'STATS %s requested by %s (%s@%s) [%s]',
5203 $char, $rec->{nick}, $rec->{auth}{ident},
5204 $rec->{auth}{hostname}, $rec->{server},
5205 18 ), qw[Notice y],
5206 );
5207  
5208 SWITCH: {
5209 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
5210 ($char =~ $perms{oper} && !$is_oper)) {
5211 17 push @$ref, {
5212 prefix => $sid,
5213 command => '481',
5214 params => [
5215 $uid,
5216 'Permission denied - You are not an IRC operator',
5217 ],
5218 };
5219 17 last SWITCH;
5220 }
5221 1 ▶ if ($char =~ /^[aA]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[aA]$/) 0 1 1
5222 0 require Net::DNS::Resolver;
5223 0 foreach my $ns ( Net::DNS::Resolver->new()->nameservers ) {
5224 0 push @$ref, {
5225 prefix => $sid,
5226 command => '226',
5227 params => [
5228 $uid,
5229 $ns,
5230 ],
5231 };
5232 }
5233 0 last SWITCH;
5234 }
5235 1 ▶ if ($char =~ /^[cC]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[cC]$/) 0 1 1
5236 0 foreach my $peer ( sort keys %{ $self->{config}{peers} } ) {
5237 0 my $cblk = $self->{config}{peers}{$peer};
5238 0 my $feat;
5239 0 ▶ $feat .= 'A' if $cblk->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $cblk->{"auto"} 0 0 0
5240 0 ▶ $feat .= 'S' if $cblk->{ssl};
Branch: 1 branch
BranchTrueFalseTotal
if $cblk->{"ssl"} 0 0 0
5241 0 ▶ $feat = '*' if !length $feat;
Branch: 1 branch
BranchTrueFalseTotal
unless length $feat 0 0 0
5242 push @$ref, {
5243 prefix => $sid,
5244 command => '213',
5245 params => [
5246 $uid, 'C',
5247 ( $cblk->{raddress} || $cblk->{sockaddr} ),
5248 $feat,
5249 $cblk->{name},
5250 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
5251 'server',
5252 ],
5253 colonify => 0,
5254 };
5255 }
5256 0 last SWITCH;
5257 }
5258 1 ▶ if ($char eq 's') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "s") 0 1 1
5259 0 foreach my $pseudo ( sort keys %{ $self->{config}{pseudo} } ) {
5260 0 my $prec = $self->{config}{pseudo}{$pseudo};
5261 push @$ref, {
5262 prefix => $sid,
5263 command => '227',
5264 params => [
5265 $uid, 's',
5266 $prec->{cmd},
5267 $prec->{name},
5268 join( '@', $prec->{nick},
5269 $prec->{host}),
5270 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
5271 ],
5272 };
5273 }
5274 0 last SWITCH;
5275 }
5276 1 ▶ if ($char eq 'S') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "S") 0 1 1
5277 0 foreach my $service ( sort keys %{ $self->{state}{services} } ) {
5278 0 my $srec = $self->{state}{services}{$service};
5279 push @$ref, {
5280 prefix => $sid,
5281 command => '246',
5282 params => [
5283 $uid, 'S', '*', '*',
5284 0 $srec->{name}, 0, 0,
5285 ],
5286 colonify => 0,
5287 };
5288 }
5289 0 last SWITCH;
5290 }
5291 1 ▶ if ($char =~ /^[Dd]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Dd]$/) 0 1 1
5292 0 my $tdline = ( $char eq 'd' );
5293 0 foreach my $dline ( @{ $self->{state}{dlines} } ) {
5294 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
5295 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
5296 push @$ref, {
5297 prefix => $sid,
5298 command => '225',
5299 params => [
5300 $uid, $char,
5301 $dline->{mask}, $dline->{reason},
5302 0 ],
5303 };
5304 }
5305 0 last SWITCH;
5306 }
5307 1 ▶ if ($char eq 'e') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "e") 0 1 1
5308 0 foreach my $mask ( sort keys %{ $self->{exemptions} } ) {
5309 0 push @$ref, {
5310 prefix => $sid,
5311 command => '225',
5312 params => [
5313 $uid, $char,
5314 $mask, '',
5315 ],
5316 };
5317 }
5318 0 last SWITCH;
5319 }
5320 1 ▶ if ($char =~ /^[Xx]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Xx]$/) 0 1 1
5321 0 my $txline = ( $char eq 'x' );
5322 0 foreach my $xline ( @{ $self->{state}{xlines} } ) {
5323 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
5324 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
5325 push @$ref, {
5326 prefix => $sid,
5327 command => '247',
5328 params => [
5329 $uid, $char,
5330 $xline->{mask}, $xline->{reason},
5331 0 ],
5332 };
5333 }
5334 0 last SWITCH;
5335 }
5336 1 ▶ if ($char =~ /^[Kk]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Kk]$/) 0 1 1
5337 0 my $tkline = ( $char eq 'k' );
5338 0 foreach my $kline ( @{ $self->{state}{klines} } ) {
5339 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
5340 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
5341 push @$ref, {
5342 prefix => $sid,
5343 command => '216',
5344 params => [
5345 $uid, $char,
5346 $kline->{host}, '*',
5347 $kline->{user}, $kline->{reason},
5348 0 ],
5349 };
5350 }
5351 0 last SWITCH;
5352 }
5353 1 ▶ if ($char eq 'v') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "v") 0 1 1
5354 0 my $srec = $self->{state}{sids}{$sid};
5355 0 my $count = 0;
5356 0 foreach my $psid ( keys %{ $srec->{sids} } ) {
5357 0 my $prec = $srec->{sids}{$psid};
5358 0 my $peer = $self->{config}{peers}{uc $prec->{name}};
5359 0 my $type = '*';
5360 0 ▶ $type = 'AutoConn.' if $peer->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $peer->{"auto"} 0 0 0
5361 0 ▶ $type = 'Remote.' if $peer->{type} ne 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $peer->{"type"} ne "r" 0 0 0
5362 push @$ref, {
5363 prefix => $sid,
5364 command => '249',
5365 params => [
5366 $uid, 'v',
5367 $prec->{name},
5368 sprintf('(%s!%s@%s)', $type, '*', '*'),
5369 'Idle:',
5370 0 ( time() - $prec->{seen} ),
5371 ],
5372 colonify => 0,
5373 };
5374 0 $count++;
5375 }
5376 0 push @$ref, {
5377 prefix => $sid,
5378 command => '249',
5379 params => [
5380 $uid, 'v',
5381 "$count Server(s)",
5382 ],
5383 };
5384 0 last SWITCH;
5385 }
5386 1 ▶ if ($char eq 'P') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "P") 0 1 1
5387 0 foreach my $listener ( keys %{ $self->{listeners} } ) {
5388 0 my $lrec = $self->{listeners}{$listener};
5389 push @$ref, {
5390 prefix => $sid,
5391 command => '220',
5392 params => [
5393 $uid, 'P',
5394 $lrec->{port},
5395 ( $is_admin ?
5396 ( $lrec->{bindaddr} || '*' ) : $server ),
5397 '*',
5398 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
5399 'active',
5400 ],
5401 };
5402 }
5403 0 last SWITCH;
5404 }
5405 1 ▶ if ($char eq 'u') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "u") 0 1 1
5406 0 my $uptime = time - $self->server_config('created');
5407 0 my $days = int $uptime / 86400;
5408 0 my $remain = $uptime % 86400;
5409 0 my $hours = int $remain / 3600;
5410 0 $remain %= 3600;
5411 0 my $mins = int $remain / 60;
5412 0 $remain %= 60;
5413  
5414 0 push @$ref, {
5415 prefix => $sid,
5416 command => '242',
5417 params => [
5418 $uid,
5419 sprintf("Server Up %d days, %2.2d:%2.2d:%2.2d",
5420 $days, $hours, $mins, $remain),
5421 ],
5422 };
5423  
5424 0 my $totalconns = $self->{state}{stats}{conns_cumlative};
5425 0 my $local = $self->{state}{stats}{maxlocal};
5426 0 my $conns = $self->{state}{stats}{maxconns};
5427  
5428 0 push @$ref, {
5429 prefix => $sid,
5430 command => '250',
5431 params => [
5432 $uid, 'u',
5433 "Highest connection count: $conns ($local "
5434 ."clients) ($totalconns connections received)",
5435 ],
5436 };
5437 0 last SWITCH;
5438 }
5439 1 ▶ if ($char =~ /^[mM]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[mM]$/) 0 1 1
5440 0 my $cmds = $self->{state}{stats}{cmds};
5441 push @$ref, {
5442 prefix => $sid,
5443 command => '212',
5444 params => [
5445 $uid, 'M',
5446 $_,
5447 $cmds->{$_}{local},
5448 $cmds->{$_}{bytes},
5449 $cmds->{$_}{remote},
5450 ],
5451 0 } for sort keys %$cmds;
5452 0 last SWITCH;
5453 }
5454 1 ▶ if ($char eq 'p') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "p") 0 1 1
5455 0 my @ops = map { $self->_client_nickname( $_ ) }
5456 0 keys %{ $self->{state}{localops} };
5457 0 for my $op (sort @ops) {
5458 0 my $record = $self->{state}{users}{uc_irc($op)};
5459 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
5460 push @$ref, {
5461 prefix => $sid,
5462 command => '249',
5463 params => [
5464 $uid, 'p',
5465 sprintf("[O] %s (%s\@%s) Idle: %u",
5466 $record->{nick}, $record->{auth}{ident},
5467 $record->{auth}{hostname},
5468 0 time - $record->{idle_time}),
5469 ],
5470 colonify => 0,
5471 };
5472 }
5473  
5474 0 push @$ref, {
5475 prefix => $sid,
5476 command => '249',
5477 params => [$uid, scalar @ops . " OPER(s)"],
5478 };
5479 0 last SWITCH;
5480 }
5481 1 ▶ if ($char =~ /^[Oo]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Oo]$/) 0 1 1
5482 0 foreach my $op ( keys %{ $self->{config}{ops} } ) {
5483 0 my $orec = $self->{config}{ops}{$op};
5484 0 my $mask = 'localhost';
5485 0 ▶ if ( $orec->{ipmask} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orec->{"ipmask"}) 0 0 0
5486 0 ▶ if (ref $orec->{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $orec->{'ipmask'} eq 'ARRAY') { } 0 0 0
5487 0 $mask = '<masks>';
5488 }
5489 else {
5490 0 $mask = $orec->{ipmask};
5491 }
5492 }
5493 push @$ref, {
5494 prefix => $sid,
5495 command => '243',
5496 params => [
5497 $uid, 'O',
5498 sprintf('%s@%s','*', $mask ),
5499 '*', $orec->{username},
5500 0 $orec->{umode}, 'opers',
5501 ],
5502 };
5503 }
5504 0 last SWITCH;
5505 }
5506 1 ▶ if ($char =~ /^[Qq]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Qq]$/) 0 1 1
5507 0 my @chans; my @nicks;
5508 0 foreach my $mask ( sort keys %{ $self->{state}{resvs} } ) {
5509 0 ▶ if ($mask =~ m!^\#!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask =~ /^\#/) { } 0 0 0
5510 0 push @chans, $mask;
5511 }
5512 else {
5513 0 push @nicks, $mask;
5514 }
5515 }
5516 0 foreach my $mask (@chans,@nicks) {
5517 0 my $resv = $self->{state}{resvs}{$mask};
5518 push @$ref, {
5519 prefix => $sid,
5520 command => '217',
5521 params => [
5522 $uid,
5523 ( $resv->{duration} ? 'q' : 'Q' ),
5524 $resv->{mask}, $resv->{reason},
5525 0 ▶ ],
Branch: 1 branch
BranchTrueFalseTotal
$resv->{'duration'} ? : 0 0 0
5526 };
5527 }
5528 0 last SWITCH;
5529 }
5530 1 ▶ if ($char =~ /^[Ll]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char =~ /^[Ll]$/) 0 1 1
5531 0 my $doall = 0;
5532 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
5533 0 $doall = 1;
5534 }
5535 elsif ($targ eq $sid) {
5536 0 $doall = 1;
5537 }
5538 0 my $name = $targ;
5539 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
5540 0 $name = $self->state_user_nick($name);
5541 }
5542 0 my $conns = $self->{state}{conns};
5543 0 my %connects;
5544 0 foreach my $conn_id ( keys %$conns ) {
5545 0 push @{ $connects{ $conns->{$conn_id}{type} } }, $conn_id;
5546 }
5547 # unknown
5548 0 ▶ foreach my $conn_id ( @{ ( $doall ? $connects{u} : [] ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
$doall ? : 0 0 0
5549 0 my $connrec = $conns->{$conn_id};
5550 0 my $send = $connrec->{stats}->send();
5551 0 my $recv = $connrec->{stats}->recv();
5552 0 my $msgs = $self->connection_msgs($conn_id);
5553 push @$ref, {
5554 prefix => $sid,
5555 command => '211',
5556 params => [
5557 $uid,
5558 sprintf(
5559 '%s[%s@%s]', ( $connrec->{nick} || '' ),
5560 ( $connrec->{auth}{ident} || 'unknown' ),
5561 ( $char eq 'L' ? $connrec->{socket}[0] :
5562 ($connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
5563 ), '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5564 sprintf(
5565 '%s %s -',
5566 ( time - $connrec->{conn_time} ),
5567 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
5568 ),
5569 ],
5570 };
5571 }
5572 # clients
5573 0 foreach my $conn_id ( sort { $conns->{$a}{nick} <=> $conns->{$b}{nick} }
5574 0 @{ $connects{c} } ) {
5575 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
5576 0 my $connrec = $conns->{$conn_id};
5577 0 my $send = $connrec->{stats}->send();
5578 0 my $recv = $connrec->{stats}->recv();
5579 0 my $msgs = $self->connection_msgs($conn_id);
5580 push @$ref, {
5581 prefix => $sid,
5582 command => '211',
5583 params => [
5584 $uid,
5585 sprintf(
5586 '%s[%s@%s]', ( $connrec->{nick} || '' ),
5587 ( $connrec->{auth}{ident} || 'unknown' ),
5588 ( $char eq 'L' ? $connrec->{socket}[0] :
5589 ($connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
5590 ), '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5591 sprintf(
5592 '%s %s -',
5593 ( time - $connrec->{conn_time} ),
5594 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
5595 ),
5596 ],
5597 };
5598 }
5599 # servers
5600 0 foreach my $conn_id ( sort { $conns->{$a}{name} cmp $conns->{$b}{name} }
5601 0 @{ $connects{p} } ) {
5602 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
5603 0 my $connrec = $conns->{$conn_id};
5604 0 my $send = $connrec->{stats}->send();
5605 0 my $recv = $connrec->{stats}->recv();
5606 0 my $msgs = $self->connection_msgs($conn_id);
5607 push @$ref, {
5608 prefix => $sid,
5609 command => '211',
5610 params => [
5611 $uid,
5612 sprintf(
5613 '%s[%s@%s]', ( $connrec->{name} || '' ),
5614 ( $connrec->{auth}{ident} || 'unknown' ),
5615 ( $char eq 'L' ? $connrec->{socket}[0] :
5616 ($connrec->{auth}{hostname} || $connrec->{socket}[0] ) ),
5617 ), '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5618 sprintf(
5619 '%s %s %s',
5620 ( time - $connrec->{conn_time} ),
5621 ( time > $connrec->{seen} ? ( time - $connrec->{seen} ) : 0 ),
5622 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
5623 ),
5624 ],
5625 };
5626 }
5627 0 last SWITCH;
5628 }
5629 1 ▶ if ($char eq '?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "?") 1 0 1
5630 1 my $trecv = my $tsent = 0; my $scnt = 0;
5631 1 foreach my $link ( sort keys %{ $self->{state}{sids}{$sid}{sids} } ) {
5632 2 $scnt++;
5633 2 my $srec = $self->{state}{sids}{$link};
5634 2 my $send = $srec->{stats}->send();
5635 2 my $recv = $srec->{stats}->recv();
5636 2 my $msgs = $self->connection_msgs($srec->{route_id});
5637 2 $trecv += $recv; $tsent += $send;
5638 push @$ref, {
5639 prefix => $sid,
5640 command => '211',
5641 params => [
5642 $uid,
5643 sprintf('%s[unknown@%s]', $srec->{name}, $srec->{socket}[0]),
5644 '0', $msgs->[0], ( $send >> 10 ), $msgs->[1], ( $recv >> 10 ),
5645 sprintf(
5646 '%s %s %s',
5647 ( time - $srec->{conn_time} ),
5648 ( time > $srec->{seen} ? ( time - $srec->{seen} ) : 0 ),
5649 2 ▶ join(' ', @{ $srec->{capab} })
Branch: 1 branch
BranchTrueFalseTotal
time > $srec->{'seen'} ? : 0 2 2
5650 ),
5651 ],
5652 };
5653 }
5654 1 push @$ref, {
5655 prefix => $sid,
5656 command => '249',
5657 params => [ $uid, '?', "$scnt total server(s)", ],
5658 };
5659 push @$ref, {
5660 prefix => $sid,
5661 command => '249',
5662 params => [
5663 1 $uid, '?', sprintf('Sent total: %s %s', @{ _rbytes($tsent) }),
5664 ],
5665 };
5666 push @$ref, {
5667 prefix => $sid,
5668 command => '249',
5669 params => [
5670 1 $uid, '?', sprintf('Recv total: %s %s', @{ _rbytes($trecv) }),
5671 ],
5672 };
5673 1 my $uptime = time - $self->server_config('created');
5674 push @$ref, {
5675 prefix => $sid,
5676 command => '249',
5677 params => [
5678 $uid, '?', sprintf(
5679 'Server send: %s %s (%4.1f K/s)',
5680 1 ▶ @{ _rbytes($self->{_globalstats}{sent}) },
Branch: 1 branch
BranchTrueFalseTotal
$uptime == 0 ? : 1 0 1
5681 ( $uptime == 0 ? 0 :
5682 1 ( ($self->{_globalstats}{sent} >> 10) / $uptime )
5683 ),
5684 ),
5685 ],
5686 };
5687 push @$ref, {
5688 prefix => $sid,
5689 command => '249',
5690 params => [
5691 $uid, '?', sprintf(
5692 'Server recv: %s %s (%4.1f K/s)',
5693 1 ▶ @{ _rbytes($self->{_globalstats}{recv}) },
Branch: 1 branch
BranchTrueFalseTotal
$uptime == 0 ? : 1 0 1
5694 ( $uptime == 0 ? 0 :
5695 1 ( ($self->{_globalstats}{sent} >> 10) / $uptime )
5696 ),
5697 ),
5698 ],
5699 };
5700 1 last SWITCH;
5701 }
5702 }
5703  
5704 18 push @$ref, {
5705 prefix => $sid,
5706 command => '219',
5707 params => [$uid, $char, 'End of /STATS report'],
5708 };
5709  
5710 18 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 18 18
5711 18 return $ref;
5712 }
5713  
5714 sub _daemon_cmd_userhost {
5715 1 ▶ my $self = shift;
Subroutine _daemon_cmd_userhost: called CC=12 SCAR=25.9
5716 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
5717 1 my $server = $self->server_name();
5718 1 my $ref = [ ];
5719 1 my $str = '';
5720 1 my $cnt = 0;
5721  
5722 1 for my $query (@_) {
5723 3 ▶ last if $cnt >= 5;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt >= 5 0 3 3
5724 3 $cnt++;
5725 3 my $uid = $self->state_user_uid($query);
5726 3 ▶ next if !$uid;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid 0 3 3
5727 3 my $urec = $self->{state}{uids}{$uid};
5728 3 my ($name,$uh) = split /!/, $urec->{full}->();
5729 3 ▶ if ( $nick eq $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick eq $name) 1 2 3
5730 1 $uh = join '@', (split /\@/, $uh)[0], $urec->{socket}[0];
5731 }
5732 3 my $status = '';
5733 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
210
not $urec->{"umode"} =~ /H/ or $self->state_user_is_operator($nick)
l!l&&r!l&&!r
100
MC/DC0%0/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 table25%1/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
5734 $self->state_user_is_operator($nick) ) ) {
5735 1 $status .= '*';
5736 }
5737 3 $status .= '=';
5738 3 ▶ $status .= ( defined $urec->{away} ? '-' : '+' );
Branch: 1 branch
BranchTrueFalseTotal
defined $urec->{'away'} ? : 0 3 3
5739 3 $str = join ' ', $str, $name . $status . $uh;
5740 3 $str =~ s!^ !!g;
5741 }
5742  
5743 1 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
$str ? : 1 0 1
5744 prefix => $server,
5745 command => '302',
5746 params => [$nick, ($str ? $str : ':')],
5747 };
5748  
5749 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
5750 0 return $ref;
5751 }
5752  
5753 sub _daemon_cmd_ison {
5754 0 ▶ my $self = shift;
Subroutine _daemon_cmd_ison: not called CC=5 SCAR=34.0
5755 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
5756 0 my $server = $self->server_name();
5757 0 my $ref = [ ];
5758 0 my $args = [@_];
5759 0 my $count = @$args;
5760  
5761 SWITCH: {
5762 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
5763 0 push @$ref, ['461', 'ISON'];
5764 0 last SWITCH;
5765 }
5766 0 my $string = '';
5767 $string = join ' ', map {
5768 $self->{state}{users}{uc_irc($_)}{nick}
5769 0 } grep { $self->state_nick_exists($_) } @$args;
5770  
5771 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
$string =~ /\s+/ ? : 0 0 0
5772 prefix => $server,
5773 command => '303',
5774 params => [$nick, ($string =~ /\s+/ ? $string : ":$string")],
5775 };
5776 }
5777  
5778 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5779 0 return $ref;
5780 }
5781  
5782 sub _daemon_do_safelist {
5783 130 ▶ my ($kernel,$self,$client) = @_[KERNEL,OBJECT,ARG0];
Subroutine _daemon_do_safelist: called CC=37 SCAR=44.3
5784 130 my $server = $self->server_name();
5785 130 my $mask = $client->{safelist};
5786 130 ▶ return if !$mask;
Branch: 1 branch
BranchTrueFalseTotal
unless $mask 1 129 130
5787 129 my $start = delete $mask->{start};
5788  
5789 129 ▶ if ($start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start) { } 7 122 129
5790 $self->send_output(
5791 {
5792 prefix => $server,
5793 command => '321',
5794 params => [$client->{nick}, 'Channel', 'Users Name'],
5795 },
5796 $client->{route_id},
5797 7 );
5798 7 $mask->{chans} = [ keys %{ $self->{state}{chans} } ];
5799 7 $kernel->yield('_daemon_do_safelist',$client);
5800 7 return;
5801 }
5802 else {
5803 122 my $chan = shift @{ $mask->{chans} };
5804 122 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 6 116 122
5805 $self->send_output(
5806 {
5807 prefix => $server,
5808 command => '323',
5809 params => [$client->{nick}, 'End of /LIST'],
5810 },
5811 $client->{route_id},
5812 6 );
5813 6 delete $client->{safelist};
5814 6 return;
5815 }
5816 116 my $show = 0;
5817 SWITCH: {
5818 116 ▶ last SWITCH if !defined $self->{state}{chans}{$chan};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"chans"}{$chan} 0 116 116
5819 116 ▶ if ($mask->{all}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"all"}) 30 86 116
5820 30 $show = 1;
5821 30 last SWITCH;
5822 }
5823 86 ▶ if ($mask->{hide}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"hide"}) 0 86 86
5824 0 my $match = matches_mask_array($mask->{hide},[$chan]);
5825 0 ▶ $show = 0 if keys %$match;
Branch: 1 branch
BranchTrueFalseTotal
if keys %$match 0 0 0
5826 0 last SWITCH;
5827 }
5828 86 ▶ if ($mask->{show}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"show"}) 30 56 86
5829 30 my $match = matches_mask_array($mask->{show},[$chan]);
5830 30 ▶ if ( keys %$match ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$match) { } 8 22 30
5831 8 $show = 1;
5832 }
5833 else {
5834 22 $show = 0;
5835 22 last SWITCH;
5836 }
5837 }
5838 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
5839 28 my $usercnt = keys %{ $self->{state}{chans}{$chan}{users} };
5840 28 ▶ if ($mask->{users_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"users_max"}) 0 28 28
5841 0 ▶ if ($usercnt > $mask->{users_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($usercnt > $mask->{'users_max'}) { } 0 0 0
5842 0 $show = 1;
5843 }
5844 else {
5845 0 $show = 0;
5846 }
5847 }
5848 28 ▶ if ($mask->{users_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"users_min"}) 28 0 28
5849 28 ▶ if ($usercnt < $mask->{users_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($usercnt < $mask->{'users_min'}) { } 6 22 28
5850 6 $show = 1;
5851 }
5852 else {
5853 22 $show = 0;
5854 }
5855 }
5856 }
5857 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
5858 0 my $chants = $self->{state}{chans}{$chan}{ts};
5859 0 ▶ if ($mask->{create_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"create_max"}) 0 0 0
5860 0 ▶ if ($chants > $mask->{create_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chants > $mask->{'create_max'}) { } 0 0 0
5861 0 $show = 1;
5862 }
5863 else {
5864 0 $show = 0;
5865 }
5866 }
5867 0 ▶ if ($mask->{create_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"create_min"}) 0 0 0
5868 0 ▶ if ($chants < $mask->{create_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chants < $mask->{'create_min'}) { } 0 0 0
5869 0 $show = 1;
5870 }
5871 else {
5872 0 $show = 0;
5873 }
5874 }
5875 }
5876 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
5877 28 my $chantopic = $self->{state}{chans}{$chan}{topic};
5878 28 ▶ if (!$chantopic) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $chantopic) { } 24 4 28
5879 24 $show = 0;
5880 }
5881 else {
5882 4 ▶ if ($mask->{topic_max}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_max"}) 0 4 4
5883 0 ▶ if($mask->{topic_max} > $chantopic->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{'topic_max'} > $chantopic->[2]) { } 0 0 0
5884 0 $show = 1;
5885 }
5886 else {
5887 0 $show = 0;
5888 }
5889 }
5890 4 ▶ if ($mask->{topic_min}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_min"}) 0 4 4
5891 0 ▶ if($mask->{topic_min} < $chantopic->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{'topic_min'} < $chantopic->[2]) { } 0 0 0
5892 0 $show = 1;
5893 }
5894 else {
5895 0 $show = 0;
5896 }
5897 }
5898 4 ▶ if ($mask->{topic_msk}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask->{"topic_msk"}) 4 0 4
5899 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
5900 2 $show = 1;
5901 }
5902 else {
5903 2 $show = 0;
5904 }
5905 }
5906 }
5907 }
5908 }
5909 116 my $hidden = ( $self->{state}{chans}{$chan}{mode} =~ m![ps]! );
5910 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
5911 2 $show = 0;
5912 }
5913 116 ▶ if ($show) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show) 44 72 116
5914 44 my $chanrec = $self->{state}{chans}{$chan};
5915 44 my $bluf = sprintf('[+%s]', $chanrec->{mode});
5916 44 ▶ if ( defined $chanrec->{topic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $chanrec->{"topic"}) 11 33 44
5917 11 $bluf = join ' ', $bluf, $chanrec->{topic}[0];
5918 }
5919 $self->send_output(
5920 {
5921 prefix => $server,
5922 command => '322',
5923 params => [
5924 $client->{nick},
5925 $chanrec->{name},
5926 44 scalar keys %{ $chanrec->{users} },
5927 $bluf,
5928 ],
5929 },
5930 $client->{route_id},
5931 44 );
5932 }
5933 116 $kernel->yield('_daemon_do_safelist',$client);
5934 }
5935 116 return;
5936 }
5937  
5938 sub _daemon_cmd_list {
5939 8 ▶ my $self = shift;
Subroutine _daemon_cmd_list: called CC=22 SCAR=41.3
5940 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
5941 8 my $server = $self->server_name();
5942 8 my $ref = [ ];
5943 8 my $args = [@_];
5944 8 my $count = @$args;
5945  
5946 SWITCH: {
5947 8 my $rec = $self->{state}{users}{uc_irc $nick};
5948 8 my $task = { start => 1 };
5949 8 my $errors;
5950 8 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count) { } 3 5 8
5951 3 ▶ if ($rec->{safelist}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"safelist"}) 1 2 3
5952 1 delete $rec->{safelist};
5953 1 push @$ref, {
5954 prefix => $server,
5955 command => '323',
5956 params => [$nick, 'End of /LIST'],
5957 };
5958 1 last SWITCH;
5959 }
5960 2 $task->{all} = 1;
5961 }
5962 else {
5963 5 OPTS: foreach my $opt ( split /,/, $args->[0] ) {
5964 5 ▶ if ($opt =~ m!^T!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^T/i) 1 4 5
5965 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
5966 0 $errors++;
5967 0 last OPTS;
5968 }
5969 1 my ($pre,$act,$mins) = $opt =~ m!^(T)([<>:])(.+)$!i;
5970 1 ▶ if ($act eq '<') {
Branch: 2 branches
BranchTrueFalseTotal
if ($act eq '<') { } 0 1 1
elsif ($act eq '>') { } 0 1 1
5971 0 $task->{topic_min} = time() - ( $mins * 60 );
5972 }
5973 elsif ($act eq '>') {
5974 0 $task->{topic_max} = time() - ( $mins * 60 );
5975 }
5976 else {
5977 1 $task->{topic_msk} = $mins;
5978 }
5979 1 next OPTS;
5980 }
5981 4 ▶ if ($opt =~ m!^C!i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^C/i) 0 4 4
5982 0 ▶ if ($opt !~ m!^C[<>]\d+$!i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^C[<>]\d+$/i) 0 0 0
5983 0 $errors++;
5984 0 last OPTS;
5985 }
5986 0 my ($pre,$act,$mins) = $opt =~ m!^(C)([<>])(\d+)$!i;
5987 0 ▶ if ($act eq '<') {
Branch: 1 branch
BranchTrueFalseTotal
if ($act eq '<') { } 0 0 0
5988 0 $task->{create_min} = time() - ( $mins * 60 );
5989 }
5990 else {
5991 0 $task->{create_max} = time() - ( $mins * 60 );
5992 }
5993 0 next OPTS;
5994 }
5995 4 ▶ if ($opt =~ m!^\<!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^\</) 1 3 4
5996 1 ▶ if ($opt !~ m!^\<\d+$!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^\<\d+$/) 0 1 1
5997 0 $errors++;
5998 0 last OPTS;
5999 }
6000 1 my ($act,$users) = $opt =~ m!^(\<)(\d+)$!;
6001 1 $task->{users_min} = $users;
6002 1 next OPTS;
6003 }
6004 3 ▶ if ($opt =~ m!^\>!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^\>/) 0 3 3
6005 0 ▶ if ($opt !~ m!^\>\d+$!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt =~ /^\>\d+$/) 0 0 0
6006 0 $errors++;
6007 0 last OPTS;
6008 }
6009 0 my ($act,$users) = $opt =~ m!^(\>)(\d+)$!;
6010 0 $task->{users_max} = $users;
6011 0 next OPTS;
6012 }
6013 3 my ($hide) = $opt =~ s/^!//;
6014 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
6015 0 $errors++;
6016 0 last OPTS;
6017 }
6018 3 ▶ if ( $hide ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hide) { } 0 3 3
6019 0 push @{ $task->{hide} }, $opt;
6020 }
6021 else {
6022 3 push @{ $task->{show} }, $opt;
6023 }
6024 }
6025 }
6026 7 ▶ if ( $errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errors) 0 7 7
6027 0 push @$ref, ['521'];
6028 0 last SWITCH;
6029 }
6030 7 $rec->{safelist} = $task;
6031 7 $poe_kernel->yield('_daemon_do_safelist',$rec);
6032 }
6033  
6034 8 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 8 0 8
6035 0 return $ref;
6036 }
6037  
6038 sub _daemon_cmd_names {
6039 108 ▶ my $self = shift;
Subroutine _daemon_cmd_names: called CC=28 SCAR=43.5
6040 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
6041 108 my $server = $self->server_name();
6042 108 my $ref = [ ];
6043 108 my $args = [@_];
6044 108 my $count = @$args;
6045  
6046 # TODO: hybrid only seems to support NAMES #channel so fix this
6047 SWITCH: {
6048 108 my (@chans, $query);
6049 108 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 108 108
6050 0 @chans = $self->state_user_chans($nick);
6051 0 $query = '*';
6052 }
6053 108 my $last = pop @$args;
6054 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
6055 && !$self->state_peer_exists($last)) {
6056 0 push @$ref, ['401', $last];
6057 0 last SWITCH;
6058 }
6059 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
6060 0 $self->send_output(
6061 {
6062 prefix => $nick,
6063 command => 'NAMES',
6064 params => [@$args, $self->_state_peer_name($last)],
6065 },
6066 $self->_state_peer_route($last),
6067 );
6068 0 last SWITCH;
6069 }
6070 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
6071 0 @chans = $self->state_user_chans($nick);
6072 0 $query = '*';
6073 }
6074 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
6075 0 $last = pop @$args;
6076 }
6077 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
6078 my ($chan) = grep {
6079 108 ▶ $_ && $self->state_chan_exists($_)
Branch: 1 branch
BranchTrueFalseTotal
$_ and $self->state_chan_exists($_) and $self->state_is_chan_member($nick, $_) 108 0 108
Condition33%1/3
$_ and $self->state_chan_exists($_)
!ll&&!rl&&r
00108
MC/DC0%0/2
$_ and $self->state_chan_exists($_)
$_ $self->state_chan_exists($_)
Truth table33%1/3
A and B
A= $_B= $self->state_chan_exists($_)
ABresult
0X0
100
111
6080 && $self->state_is_chan_member($nick, $_)
6081 } split /,/, $last;
6082 108 @chans = ();
6083  
6084 108 ▶ if ($chan) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chan) { } 108 0 108
6085 108 push @chans, $chan;
6086 108 $query = $self->_state_chan_name($chan);
6087 }
6088 else {
6089 0 $query = '*';
6090 }
6091 }
6092  
6093 108 my $chan_prefix_method = 'state_chan_list_prefixed';
6094 108 my $uid = $self->state_user_uid($nick);
6095 $chan_prefix_method = 'state_chan_list_multi_prefixed'
6096 108 ▶ if $self->{state}{uids}{$uid}{caps}{'multi-prefix'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"uids"}{$uid}{"caps"}{"multi-prefix"} 14 94 108
6097  
6098 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
6099  
6100 108 for my $chan (@chans) {
6101 108 my $record = $self->{state}{chans}{uc_irc($chan)};
6102 108 my $type = '=';
6103 108 ▶ $type = '@' if $record->{mode} =~ /s/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /s/ 0 108 108
6104 108 ▶ $type = '*' if $record->{mode} =~ /p/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /p/ 0 108 108
6105 108 my $length = length($server)+3+length($chan)+length($nick)+7;
6106 108 my $buffer = '';
6107  
6108 108 for my $name (sort $self->$chan_prefix_method($record->{name},$flag)) {
6109 190 ▶ if (length(join ' ', $buffer, $name) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buffer, $name) + $length > 510) 0 190 190
6110 push @$ref, {
6111 prefix => $server,
6112 command => '353',
6113 0 params => [$nick, $type, $record->{name}, $buffer]
6114 };
6115 0 $buffer = $name;
6116 0 next;
6117 }
6118 190 ▶ if ($buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) { } 82 108 190
6119 82 $buffer = join ' ', $buffer, $name;
6120 }
6121 else {
6122 108 $buffer = $name;
6123 }
6124 }
6125 push @$ref, {
6126 prefix => $server,
6127 command => '353',
6128 108 params => [$nick, $type, $record->{name}, $buffer],
6129 };
6130 }
6131 108 push @$ref, {
6132 prefix => $server,
6133 command => '366',
6134 params => [$nick, $query, 'End of NAMES list'],
6135 };
6136 }
6137  
6138 108 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 108 0 108
6139 0 return $ref;
6140 }
6141  
6142 sub _daemon_cmd_whois {
6143 6 ▶ my $self = shift;
Subroutine _daemon_cmd_whois: called CC=22 SCAR=34.5
6144 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
6145 6 my $server = $self->server_name();
6146 6 my $ref = [ ];
6147 6 my ($first, $second) = @_;
6148  
6149 SWITCH: {
6150 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
6151 0 push @$ref, ['431'];
6152 0 last SWITCH;
6153 }
6154 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
6155 5 $second = (split /,/, $first)[0];
6156 5 $first = $server;
6157 }
6158 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
6159 6 $second = (split /,/, $second)[0];
6160 }
6161 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
6162 && $self->state_nick_exists($second)) {
6163 1 $first = $self->state_user_server($second);
6164 }
6165 6 my $query;
6166 my $target;
6167 6 ▶ $query = $first if !$second;
Branch: 1 branch
BranchTrueFalseTotal
unless $second 0 6 6
6168 6 ▶ $query = $second if $second;
Branch: 1 branch
BranchTrueFalseTotal
if $second 6 0 6
6169 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
6170 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
6171 0 push @$ref, ['402', $target];
6172 0 last SWITCH;
6173 }
6174 6 ▶ if ($target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 5 6
6175 }
6176 # Okay we got here *phew*
6177 6 ▶ if (!$self->state_nick_exists($query)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->state_nick_exists($query)) { } 0 6 6
6178 0 push @$ref, ['401', $query];
6179 }
6180 else {
6181 6 my $uid = $self->state_user_uid($nick);
6182 6 my $who = $self->state_user_uid($query);
6183 6 ▶ if ( $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 1 5 6
6184 1 my $tsid = $self->_state_peer_sid($target);
6185 1 ▶ if ( $who =~ m!^$tsid! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($who =~ /^$tsid/) 1 0 1
6186 1 $self->send_output(
6187 {
6188 prefix => $self->state_user_uid($nick),
6189 command => 'WHOIS',
6190 params => [
6191 $tsid,
6192 $query,
6193 ],
6194 },
6195 $self->_state_sid_route($tsid),
6196 );
6197 1 last SWITCH;
6198 }
6199 }
6200 5 $ref = $self->_daemon_do_whois($uid,$who);
6201 5 foreach my $reply ( @$ref ) {
6202 30 $reply->{prefix} = $server;
6203 30 $reply->{params}[0] = $nick;
6204 }
6205 }
6206 }
6207  
6208 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
6209 0 return $ref;
6210 }
6211  
6212 sub _daemon_peer_whois {
6213 2 ▶ my $self = shift;
Subroutine _daemon_peer_whois: called CC=4 SCAR=14.0
6214 2 my $peer_id = shift;
6215 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
6216 2 my $sid = $self->server_sid();
6217 2 my $ref = [ ];
6218 2 my ($first, $second) = @_;
6219  
6220 2 my $targ = substr $first, 0, 3;
6221 SWITCH: {
6222 2 ▶ if ( $targ !~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 1 1 2
6223 1 $self->send_output(
6224 {
6225 prefix => $uid,
6226 command => 'WHOIS',
6227 params => [
6228 $first,
6229 $second,
6230 ],
6231 },
6232 $self->_state_sid_route($targ),
6233 );
6234 1 last SWITCH;
6235 }
6236 1 my $who = $self->state_user_uid($second);
6237 1 $ref = $self->_daemon_do_whois($uid,$who);
6238 }
6239  
6240 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
6241 0 return $ref;
6242 }
6243  
6244 sub _daemon_do_whois {
6245 6 ▶ my $self = shift;
Subroutine _daemon_do_whois: called CC=48 SCAR=45.7
6246 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
6247 6 my $sid = $self->server_sid();
6248 6 my $server = $self->server_name();
6249 6 my $nicklen = $self->server_config('NICKLEN');
6250 6 my $ref = [ ];
6251 6 my $query = shift;
6252  
6253 6 my $querier = $self->{state}{uids}{$uid};
6254 6 my $record = $self->{state}{uids}{$query};
6255  
6256 push @$ref, {
6257 prefix => $sid,
6258 command => '311',
6259 params => [
6260 $uid,
6261 $record->{nick},
6262 $record->{auth}{ident},
6263 $record->{auth}{hostname},
6264 '*',
6265 $record->{ircname},
6266 6 ],
6267 };
6268 6 my @chans;
6269 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
6270 6 LOOP: for my $chan (keys %{ $record->{chans} }) {
6271 6 ▶ next LOOP if $noshow;
Branch: 1 branch
BranchTrueFalseTotal
if $noshow 0 6 6
6272 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
6273 && !defined $self->{state}{chans}{$chan}{users}{$uid}) {
6274 0 next LOOP;
6275 }
6276 6 my $prefix = '';
6277 6 ▶ $prefix .= '@' if $record->{chans}{$chan} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /o/ 6 0 6
6278 6 ▶ $prefix .= '%' if $record->{chans}{$chan} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /h/ 0 6 6
6279 6 ▶ $prefix .= '+' if $record->{chans}{$chan} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /v/ 0 6 6
6280 6 push @chans, $prefix . $self->{state}{chans}{$chan}{name};
6281 }
6282 6 ▶ if (@chans) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chans) 6 0 6
6283 6 my $buffer = '';
6284 my $length = length($server) + 3 + $nicklen
6285 6 + length($record->{nick}) + 7;
6286  
6287 6 LOOP2: for my $chan (@chans) {
6288 6 ▶ if (length(join ' ', $buffer, $chan) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buffer, $chan) + $length > 510) 0 6 6
6289 push @$ref, {
6290 prefix => $sid,
6291 command => '319',
6292 0 params => [$uid, $record->{nick}, $buffer],
6293 };
6294 0 $buffer = $chan;
6295 0 next LOOP2;
6296 }
6297 6 ▶ if ($buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) { } 0 6 6
6298 0 $buffer = join ' ', $buffer, $chan;
6299 }
6300 else {
6301 6 $buffer = $chan;
6302 }
6303 }
6304 push @$ref, {
6305 prefix => $sid,
6306 command => '319',
6307 6 params => [$uid, $record->{nick}, $buffer],
6308 };
6309 }
6310 # RPL_WHOISSERVER
6311 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
6312 push @$ref, {
6313 prefix => $sid,
6314 command => '312',
6315 params => [
6316 $uid,
6317 $record->{nick},
6318 ( $hidden ? $self->{config}{'hidden_servers'} : $record->{server} ),
6319 6 ▶ ( $hidden ? $self->server_config('NETWORKDESC') : $self->_state_peer_desc($record->{server}) ),
Branch: 2 branches
BranchTrueFalseTotal
$hidden ? : 2 4 6
$hidden ? : 2 4 6
6320 ],
6321 };
6322 # RPL_WHOISREGNICK
6323 push @$ref, {
6324 prefix => $sid,
6325 command => '307',
6326 params => [
6327 $uid,
6328 $record->{nick},
6329 'has identified for this nick'
6330 ],
6331 6 ▶ } if $record->{umode} =~ m!r!;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /r/ 0 6 6
6332 # RPL_WHOISACCOUNT
6333 push @$ref, {
6334 prefix => $sid,
6335 command => '330',
6336 params => [
6337 $uid,
6338 $record->{nick},
6339 $record->{account},
6340 'is logged in as'
6341 ],
6342 6 ▶ } if $record->{account} ne '*';
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"account"} ne "*" 4 2 6
6343 # RPL_AWAY
6344 push @$ref, {
6345 prefix => $sid,
6346 command => '301',
6347 params => [
6348 $uid,
6349 $record->{nick},
6350 $record->{away},
6351 ],
6352 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
6353 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
6354 6 my $operstring;
6355 6 ▶ if ( $record->{svstags}{313} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{'svstags'}{'313'}) { } 1 5 6
6356 1 $operstring = $record->{svstags}{313}{tagline};
6357 }
6358 else {
6359 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
6360 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
6361 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
6362 }
6363 push @$ref, {
6364 prefix => $sid,
6365 command => '313',
6366 6 ▶ params => [$uid, $record->{nick}, $operstring],
Branch: 1 branch
BranchTrueFalseTotal
if $operstring 4 2 6
6367 } if $operstring;
6368 }
6369 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
Condition83%5/6
$record->{"type"} eq "c" and $uid eq $query || $querier->{"umode"} =~ /o/
!ll&&!rl&&r
411
$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 table50%2/4
A and B or C
A= $record->{"type"} eq "c"B= $uid eq $queryC= $querier->{"umode"} =~ /o/
ABCresult
0XX0
1000
11X1
1011
6370 2 my $umodes = join '', '+', sort split //, $record->{umode};
6371 push @$ref, {
6372 prefix => $sid,
6373 command => '379',
6374 params => [
6375 $uid,
6376 $record->{nick},
6377 2 "is using modes $umodes"
6378 ],
6379 };
6380 }
6381 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
6382 && ($self->server_config('whoisactually')
6383 or $self->{state}{uids}{$uid}{umode} =~ /o/)) {
6384 push @$ref, {
6385 prefix => $sid,
6386 command => '338',
6387 params => [
6388 $uid,
6389 $record->{nick},
6390 join('@', $record->{auth}{ident}, $record->{auth}{realhost}),
6391 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
6392 'Actual user@host, actual IP',
6393 ],
6394 };
6395 }
6396 6 ▶ if ($record->{type} eq 'c') {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"type"} eq "c") 2 4 6
6397 push @$ref, {
6398 prefix => $sid,
6399 command => '317',
6400 params => [
6401 $uid,
6402 $record->{nick},
6403 time - $record->{idle_time},
6404 $record->{conn_time},
6405 'seconds idle, signon time',
6406 ],
6407 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 0 0 0
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
6408 }
6409 push @$ref, {
6410 prefix => $sid,
6411 command => '318',
6412 6 params => [$uid, $record->{nick}, 'End of /WHOIS list.'],
6413 };
6414  
6415 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
6416 # Send NOTICE
6417 4 my $local = ( $record->{sid} eq $sid );
6418 $self->send_output(
6419 {
6420 prefix => ( $local ? $self->server_name() : $sid ),
6421 command => 'NOTICE',
6422 params => [
6423 ( $local ? $record->{nick} : $record->{uid} ),
6424 sprintf('*** Notice -- %s (%s@%s) [%s] is doing a /whois on you',
6425 $querier->{nick}, $querier->{auth}{ident}, $querier->{auth}{hostname},
6426 $querier->{server},
6427 ),
6428 ],
6429 },
6430 $record->{route_id},
6431 4 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
$local ? : 0 4 4
$local ? : 0 4 4
6432 }
6433 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
6434 6 return $ref;
6435 }
6436  
6437 sub _daemon_cmd_whowas {
6438 3 ▶ my $self = shift;
Subroutine _daemon_cmd_whowas: called CC=12 SCAR=32.8
6439 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
6440 3 my $server = $self->server_name();
6441 3 my $sid = $self->server_sid();
6442 3 my $ref = [ ];
6443 3 my $args = [@_];
6444 3 my $count = @$args;
6445  
6446 SWITCH: {
6447 3 ▶ if (!$args->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0]) 0 3 3
6448 0 push @$ref, ['431'];
6449 0 last SWITCH;
6450 }
6451 3 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 3 0 3
6452 3 my $lastuse = $self->{state}{lastuse}{whowas};
6453 3 my $pacewait = $self->{config}{pace_wait};
6454 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
6455 0 push @$ref, ['263', 'WHOWAS'];
6456 0 last SWITCH;
6457 }
6458 3 $self->{state}{lastuse}{whowas} = time();
6459 }
6460 3 my $query = (split /,/, $args->[0])[0];
6461 3 ▶ if ($args->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2]) 0 3 3
6462 0 my $targ = $self->_state_find_peer($args->[2]);
6463 0 ▶ if (!$targ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ) 0 0 0
6464 0 push @$ref, [ '402', $args->[2] ];
6465 0 last SWITCH;
6466 }
6467 0 ▶ if ($targ !~ m!^$sid!) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 0 0 0
6468 0 my $psid = substr $targ, 0, 3;
6469 0 $self->send_output(
6470 {
6471 prefix => $self->state_user_uid($nick),
6472 command => 'WHOWAS',
6473 params => [
6474 $args->[0], $args->[1], $targ,
6475 ],
6476 },
6477 $self->_state_sid_route($psid),
6478 );
6479 0 last SWITCH;
6480 }
6481 }
6482 3 my $uid = $self->state_user_uid($nick);
6483 3 push @$ref, $_ for map { $_->{prefix} = $server; $_->{params}[0] = $nick; $_ }
6484 3 @{ $self->_daemon_do_whowas($uid,@$args) };
6485 }
6486  
6487 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
6488 0 return $ref;
6489 }
6490  
6491 sub _daemon_peer_whowas {
6492 2 ▶ my $self = shift;
Subroutine _daemon_peer_whowas: called CC=5 SCAR=16.4
6493 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
6494 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
6495 2 my $server = $self->server_name();
6496 2 my $sid = $self->server_sid();
6497 2 my $ref = [ ];
6498 2 my ($first, $second, $third) = @_;
6499  
6500 2 my $targ = substr $third, 0, 3;
6501 SWITCH: {
6502 2 ▶ if ( $targ !~ m!^$sid! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($targ =~ /^$sid/) 1 1 2
6503 1 $self->send_output(
6504 {
6505 prefix => $uid,
6506 command => 'WHOWAS',
6507 params => [
6508 $first,
6509 $second,
6510 $third,
6511 ],
6512 },
6513 $self->_state_sid_route($targ),
6514 );
6515 1 last SWITCH;
6516 }
6517 1 $ref = $self->_daemon_do_whowas($uid,$first,$second);
6518 }
6519  
6520 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
6521 0 return $ref;
6522 }
6523  
6524 sub _daemon_do_whowas {
6525 4 ▶ my $self = shift;
Subroutine _daemon_do_whowas: called CC=15 SCAR=27.6
6526 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
6527 4 my $server = $self->server_name();
6528 4 my $sid = $self->server_sid();
6529 4 my $ref = [ ];
6530 4 my $args = [@_];
6531 4 my $query = shift @$args;
6532  
6533 SWITCH: {
6534 4 my $is_oper = ( $self->{state}{uids}{$uid}{umode} =~ /o/ );
6535 4 my $max = shift @$args;
6536 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
6537 1 $max = 20;
6538 }
6539 4 ▶ if (!$self->{state}{whowas}{uc_irc $query}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"state"}{"whowas"}{uc_irc($query)}) 1 3 4
6540 1 push @$ref, {
6541 prefix => $sid,
6542 command => '406',
6543 params => [$uid, $query, 'There was no such nickname'],
6544 };
6545 1 last SWITCH;
6546 }
6547 3 my $cnt = 0;
6548 3 WASNOTWAS: foreach my $was ( @{ $self->{state}{whowas}{uc_irc $query} } ) {
6549 push @$ref, {
6550 prefix => $sid,
6551 command => '314',
6552 params => [
6553 $uid,
6554 $was->{nick}, $was->{user}, $was->{host}, '*',
6555 $was->{ircname},
6556 26 ],
6557 };
6558 push @$ref, {
6559 prefix => $sid,
6560 command => '338',
6561 params => [
6562 $uid,
6563 $was->{nick},
6564 join('@', $was->{user}, $was->{real}),
6565 $was->{sock},
6566 26 ▶ 'Actual user@host, actual IP',
Branch: 1 branch
BranchTrueFalseTotal
if $is_oper 20 6 26
6567 ],
6568 } if $is_oper;
6569 push @$ref, {
6570 prefix => $sid,
6571 command => '330',
6572 params => [
6573 $uid,
6574 $was->{nick},
6575 $was->{account},
6576 'was logged in as',
6577 ],
6578 26 ▶ } if $was->{account} ne '*';
Branch: 1 branch
BranchTrueFalseTotal
if $was->{"account"} ne "*" 26 0 26
6579 push @$ref, {
6580 prefix => $sid,
6581 command => '312',
6582 params => [
6583 $uid,
6584 $was->{nick},
6585 ( ( $self->{config}{'hidden_servers'} && !$is_oper )
6586 ? ( $self->{config}{'hidden_servers'}, $self->{config}{NETWORKDESC} ) : $was->{server} ),
6587 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
6588 ],
6589 };
6590 26 ++$cnt;
6591 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
6592 }
6593 }
6594  
6595 4 push @$ref, {
6596 prefix => $sid,
6597 command => '369',
6598 params => [$uid, $query, 'End of WHOWAS'],
6599 };
6600  
6601 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
6602 4 return $ref;
6603 }
6604  
6605 sub _daemon_cmd_who {
6606 6 ▶ my $self = shift;
Subroutine _daemon_cmd_who: called CC=16 SCAR=33.8
6607 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
6608 6 my ($who, $op_only) = @_;
6609 6 my $server = $self->server_name();
6610 6 my $ref = [ ];
6611 6 my $orig = $who;
6612  
6613 SWITCH: {
6614 6 ▶ if (!$who) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($who) 0 6 6
6615 0 push @$ref, ['461', 'WHO'];
6616 0 last SWITCH;
6617 }
6618 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
6619 && $self->state_is_chan_member($nick, $who)) {
6620 6 my $uid = $self->state_user_uid($nick);
6621 6 my $multiprefix = $self->{state}{uids}{$uid}{caps}{'multi-prefix'};
6622 6 my $record = $self->{state}{chans}{uc_irc($who)};
6623 6 $who = $record->{name};
6624 6 for my $member (keys %{ $record->{users} }) {
6625 17 my $rpl_who = {
6626 prefix => $server,
6627 command => '352',
6628 params => [$nick, $who],
6629 };
6630 17 my $memrec = $self->{state}{uids}{$member};
6631 17 push @{ $rpl_who->{params} }, $memrec->{auth}{ident};
6632 17 push @{ $rpl_who->{params} }, $memrec->{auth}{hostname};
6633 17 push @{ $rpl_who->{params} }, $memrec->{server};
6634 17 push @{ $rpl_who->{params} }, $memrec->{nick};
6635 17 ▶ my $status = ($memrec->{away} ? 'G' : 'H');
Branch: 1 branch
BranchTrueFalseTotal
$memrec->{'away'} ? : 0 17 17
6636 17 ▶ $status .= '*' if $memrec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $memrec->{"umode"} =~ /o/ 0 17 17
6637 {
6638 17 my $stat = $record->{users}{$member};
6639 17 ▶ if ( $stat ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stat) 6 11 17
6640 6 ▶ if ( !$multiprefix ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $multiprefix) { } 2 4 6
6641 2 ▶ $stat =~ s![vh]!!g if $stat =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $stat =~ /o/ 2 0 2
6642 2 ▶ $stat =~ s![v]!!g if $stat =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $stat =~ /h/ 0 2 2
6643 }
6644 else {
6645 4 my $ostat = join '', grep { $stat =~ m!$_! } qw[o h v];
6646 4 $stat = $ostat;
6647 }
6648 6 $stat =~ tr/ohv/@%+/;
6649 6 $status .= $stat;
6650 }
6651 }
6652 17 push @{ $rpl_who->{params} }, $status;
6653 17 push @{ $rpl_who->{params} }, "$memrec->{hops} "
6654 17 . $memrec->{ircname};
6655 17 push @$ref, $rpl_who;
6656 }
6657 }
6658 6 ▶ if ($self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($who)) 0 6 6
6659 0 my $nickrec = $self->{state}{users}{uc_irc($who)};
6660 0 $who = $nickrec->{nick};
6661 0 my $rpl_who = {
6662 prefix => $server,
6663 command => '352',
6664 params => [$nick, '*'],
6665 };
6666 0 push @{ $rpl_who->{params} }, $nickrec->{auth}{ident};
6667 0 push @{ $rpl_who->{params} }, $nickrec->{auth}{hostname};
6668 0 push @{ $rpl_who->{params} }, $nickrec->{server};
6669 0 push @{ $rpl_who->{params} }, $nickrec->{nick};
6670 0 ▶ my $status = ($nickrec->{away} ? 'G' : 'H');
Branch: 1 branch
BranchTrueFalseTotal
$nickrec->{'away'} ? : 0 0 0
6671 0 ▶ $status .= '*' if $nickrec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $nickrec->{"umode"} =~ /o/ 0 0 0
6672 0 push @{ $rpl_who->{params} }, $status;
6673 0 push @{ $rpl_who->{params} }, "$nickrec->{hops} "
6674 0 . $nickrec->{ircname};
6675 0 push @$ref, $rpl_who;
6676 }
6677 6 push @$ref, {
6678 prefix => $server,
6679 command => '315',
6680 params => [$nick, $orig, 'End of WHO list'],
6681 };
6682 }
6683  
6684 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 6 0 6
6685 0 return $ref;
6686 }
6687  
6688 sub _daemon_cmd_mode {
6689 53 ▶ my $self = shift;
Subroutine _daemon_cmd_mode: called CC=103 SCAR=73.0
6690 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
6691 53 my $chan = shift;
6692 53 my $server = $self->server_name();
6693 53 my $sid = $self->server_sid();
6694 53 my $maxmodes = $self->server_config('MODES');
6695 53 my $ref = [ ];
6696 53 my $args = [@_];
6697 53 my $count = @$args;
6698  
6699 SWITCH: {
6700 53 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 53 53
6701 0 push @$ref, ['403', $chan];
6702 0 last SWITCH;
6703 }
6704  
6705 53 my $record = $self->{state}{chans}{uc_irc($chan)};
6706 53 $chan = $record->{name};
6707  
6708 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
6709 push @$ref, {
6710 prefix => $server,
6711 command => '324',
6712 0 params => [$nick, $chan, '+' . $record->{mode}],
6713 colonify => 0,
6714 };
6715 push @$ref, {
6716 prefix => $server,
6717 command => '329',
6718 0 params => [$nick, $chan, $record->{ts}],
6719 colonify => 0,
6720 };
6721 0 last SWITCH;
6722 }
6723 53 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 13 40 53
6724 push @$ref, {
6725 prefix => $server,
6726 command => '324',
6727 params => [
6728 $nick,
6729 $chan,
6730 '+' . $record->{mode},
6731 ($record->{ckey} || ()),
6732 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
6733 ],
6734 colonify => 0,
6735 };
6736 push @$ref, {
6737 prefix => $server,
6738 command => '329',
6739 13 params => [$nick, $chan, $record->{ts}],
6740 colonify => 0,
6741 };
6742 13 last SWITCH;
6743 }
6744  
6745 40 my $unknown = 0;
6746 40 my $notop = 0;
6747 40 my $notoper = 0;
6748 40 my $nick_is_op = $self->state_is_chan_op($nick, $chan);
6749 40 my $nick_is_hop = $self->state_is_chan_hop($nick, $chan);
6750 40 my $nick_is_oper = $self->state_user_is_operator($nick);
6751 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
6752 40 my $mode_u_set = ( $record->{mode} =~ /u/ );
6753 40 my $reply;
6754 40 my @reply_args; my %subs;
6755 40 my $parsed_mode = parse_mode_line(@$args);
6756 40 my $mode_count = 0;
6757  
6758 40 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 59 40 99
6759 59 ▶ if ($mode !~ /[CceIbkMNRSTLOlimnpstohuv]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mode =~ /[CceIbkMNRSTLOlimnpstohuv]/) 0 59 59
6760 0 ▶ push @$ref, [
Branch: 1 branch
BranchTrueFalseTotal
unless $unknown 0 0 0
6761 '472',
6762 (split //, $mode)[1],
6763 $chan,
6764 ] if !$unknown;
6765 0 $unknown++;
6766 0 next;
6767 }
6768  
6769 59 my $arg;
6770 59 ▶ if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) 45 14 59
6771 45 $arg = shift @{ $parsed_mode->{args} };
6772 }
6773 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
6774 push @$ref, {
6775 prefix => $server,
6776 command => '367',
6777 params => [
6778 $nick,
6779 $chan,
6780 0 @{ $record->{bans}{$_} },
6781 ]
6782 2 } for grep { !$no_see_bans } keys %{ $record->{bans} };
6783 2 push @$ref, {
6784 prefix => $server,
6785 command => '368',
6786 params => [$nick, $chan, 'End of Channel Ban List'],
6787 };
6788 2 next;
6789 }
6790 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
6791 1 ▶ push @$ref, ['481'] if !$notoper;
Branch: 1 branch
BranchTrueFalseTotal
unless $notoper 1 0 1
6792 1 $notoper++;
6793 1 next;
6794 }
6795 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
6796 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
6797 0 $notop++;
6798 0 next;
6799 }
6800 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
6801 push @$ref, {
6802 prefix => $server,
6803 command => '346',
6804 params => [
6805 $nick,
6806 $chan,
6807 0 @{ $record->{invex}{$_} },
6808 ],
6809 0 } for grep { !$no_see_bans } keys %{ $record->{invex} };
6810 0 push @$ref, {
6811 prefix => $server,
6812 command => '347',
6813 params => [$nick, $chan, 'End of Channel Invite List']
6814 };
6815 0 next;
6816 }
6817 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
6818 push @$ref, {
6819 prefix => $server,
6820 command => '348',
6821 0 params => [$nick, $chan, @{ $record->{excepts}{$_} } ]
6822 0 } for grep { !$no_see_bans } keys %{ $record->{excepts} };
6823 0 push @$ref, {
6824 prefix => $server,
6825 command => '349',
6826 params => [
6827 $nick,
6828 $chan,
6829 'End of Channel Exception List',
6830 ],
6831 };
6832 0 next;
6833 }
6834 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
6835 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
6836 0 $notop++;
6837 0 next;
6838 }
6839 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
6840 && $mode =~ /h/) {
6841 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
6842 0 $notop++;
6843 0 next;
6844 }
6845 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
6846 && !defined $arg) {
6847 0 next;
6848 }
6849 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
6850 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6851 0 push @$ref, ['401', $arg];
6852 0 next;
6853 }
6854 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
6855 && !$self->state_is_chan_member($arg, $chan)) {
6856 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6857 0 push @$ref, ['441', $chan, $self->state_user_nick($arg)];
6858 0 next;
6859 }
6860 56 ▶ if (my ($flag, $char) = $mode =~ /^([-+])([ohv])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^([-+])([ohv])/) 42 14 56
6861 42 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 42 42
6862  
6863 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
6864 && $record->{users}{$self->state_user_uid($arg)} !~ /$char/) {
6865 # Update user and chan record
6866 30 $arg = $self->state_user_uid($arg);
6867 $record->{users}{$arg} = join('', sort
6868 30 split //, $record->{users}{$arg} . $char);
6869 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
6870 30 = $record->{users}{$arg};
6871 30 $reply .= $mode;
6872 30 my $anick = $self->state_user_nick($arg);
6873 30 $subs{$anick} = $arg;
6874 30 push @reply_args, $anick;
6875 }
6876  
6877 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
6878 =~ /$char/) {
6879 # Update user and chan record
6880 0 $arg = $self->state_user_uid($arg);
6881 0 $record->{users}{$arg} =~ s/$char//g;
6882 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
6883 0 = $record->{users}{$arg};
6884 0 $reply .= $mode;
6885 0 my $anick = $self->state_user_nick($arg);
6886 0 $subs{$anick} = $arg;
6887 0 push @reply_args, $anick;
6888 }
6889 42 next;
6890 }
6891 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
6892 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6893 0 $reply .= $mode;
6894 0 push @reply_args, $arg;
6895 0 ▶ if ($record->{mode} !~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /l/) 0 0 0
6896 $record->{mode} = join('', sort
6897 0 split //, $record->{mode} . 'l');
6898 }
6899 0 $record->{climit} = $arg;
6900 0 next;
6901 }
6902 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
6903 0 $record->{mode} =~ s/l//g;
6904 0 delete $record->{climit};
6905 0 $reply .= $mode;
6906 0 next;
6907 }
6908 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
6909 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6910 0 $reply .= $mode;
6911 0 push @reply_args, $arg;
6912 0 ▶ if ($record->{mode} !~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /k/) 0 0 0
6913 $record->{mode} = join('', sort
6914 0 split //, $record->{mode} . 'k');
6915 }
6916 0 $record->{ckey} = $arg;
6917 0 next;
6918 }
6919 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
6920 0 $reply .= $mode;
6921 0 push @reply_args, '*';
6922 0 $record->{mode} =~ s/k//g;
6923 0 delete $record->{ckey};
6924 0 next;
6925 }
6926 # Bans
6927 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
6928 14 ▶ if (my ($flag) = $mode =~ /([-+])b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])b/) 1 13 14
6929 1 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 1 1
6930 1 my $mask = normalize_mask($arg);
6931 1 my $umask = uc_irc $mask;
6932 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
6933 1 ▶ if ( keys %{ $record->{bans} } >= $maxbans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$record{"bans"};} >= $maxbans) 0 1 1
6934 0 push @$ref, [ '478', $record->{name}, 'b' ];
6935 0 next;
6936 }
6937 1 $record->{bans}{$umask}
6938 = [$mask, $self->state_user_full($nick), time];
6939 1 $reply .= $mode;
6940 1 push @reply_args, $mask;
6941 }
6942 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
6943 0 delete $record->{bans}{$umask};
6944 0 $reply .= $mode;
6945 0 push @reply_args, $mask;
6946 }
6947 1 next;
6948 }
6949 # Invex
6950 13 ▶ if (my ($flag) = $mode =~ /([-+])I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])I/) 0 13 13
6951 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6952 0 my $mask = normalize_mask( $arg );
6953 0 my $umask = uc_irc $mask;
6954  
6955 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
6956 0 ▶ if ( keys %{ $record->{invex} } >= $maxbans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$record{"invex"};} >= $maxbans) 0 0 0
6957 0 push @$ref, [ '478', $record->{name}, 'I' ];
6958 0 next;
6959 }
6960 0 $record->{invex}{$umask}
6961 = [$mask, $self->state_user_full($nick), time];
6962 0 $reply .= $mode;
6963 0 push @reply_args, $mask;
6964 }
6965 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
6966 0 delete $record->{invex}{$umask};
6967 0 $reply .= $mode;
6968 0 push @reply_args, $mask;
6969 }
6970 0 next;
6971 }
6972 # Exceptions
6973 13 ▶ if (my ($flag) = $mode =~ /([-+])e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])e/) 0 13 13
6974 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
6975 0 my $mask = normalize_mask($arg);
6976 0 my $umask = uc_irc($mask);
6977  
6978 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
6979 0 ▶ if ( keys %{ $record->{excepts} } >= $maxbans ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$record{"excepts"};} >= $maxbans) 0 0 0
6980 0 push @$ref, [ '478', $record->{name}, 'e' ];
6981 0 next;
6982 }
6983 0 $record->{excepts}{$umask}
6984 = [$mask, $self->state_user_full($nick), time];
6985 0 $reply .= $mode;
6986 0 push @reply_args, $mask;
6987 }
6988 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
6989 0 delete $record->{excepts}{$umask};
6990 0 $reply .= $mode;
6991 0 push @reply_args, $mask;
6992 }
6993 0 next;
6994 }
6995 # The rest should be argumentless.
6996 13 my ($flag, $char) = split //, $mode;
6997 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
6998 10 $reply .= $mode;
6999 $record->{mode} = join('', sort
7000 10 split //, $record->{mode} . $char);
7001 10 next;
7002 }
7003 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
7004 3 $reply .= $mode;
7005 3 $record->{mode} =~ s/$char//g;
7006 3 next;
7007 }
7008 } # while
7009  
7010 40 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 31 9 40
7011 31 $reply = unparse_mode_line($reply);
7012 my @reply_args_peer = map {
7013 31 ▶ ( defined $subs{$_} ? $subs{$_} : $_ )
Branch: 1 branch
BranchTrueFalseTotal
defined $subs{$_} ? : 30 1 31
7014 } @reply_args;
7015 $self->send_output(
7016 {
7017 prefix => $self->state_user_uid($nick),
7018 command => 'TMODE',
7019 31 params => [$record->{ts}, $chan, $reply, @reply_args_peer],
7020 colonify => 0,
7021 },
7022 $self->_state_connected_peers(),
7023 );
7024 31 my $full = $self->state_user_full($nick);
7025 $self->_send_output_channel_local(
7026 $record->{name},
7027 {
7028 prefix => $full,
7029 command => 'MODE',
7030 colonify => 0,
7031 params => [
7032 $record->{name},
7033 31 ▶ $reply,
Branch: 1 branch
BranchTrueFalseTotal
$mode_u_set ? : 2 29 31
7034 @reply_args,
7035 ],
7036 },
7037 '', ( $mode_u_set ? 'oh' : '' ),
7038 );
7039 31 ▶ if ($mode_u_set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode_u_set) 2 29 31
7040 2 my $bparse = parse_mode_line( $reply, @reply_args );
7041 2 my $breply; my @breply_args;
7042 2 ▶ while (my $bmode = shift (@{ $bparse->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bmode = shift @{$$bparse{"modes"};}) 2 2 4
7043 2 my $arg;
7044 2 ▶ $arg = shift @{ $bparse->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 1 1 2
7045 if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
7046 2 ▶ next if $bmode =~ m!^[+-][beI]$!;
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^[+-][beI]$/ 1 1 2
7047 1 $breply .= $bmode;
7048 1 ▶ push @breply_args, $arg if $arg;
Branch: 1 branch
BranchTrueFalseTotal
if $arg 0 1 1
7049 }
7050 2 ▶ if ($breply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breply) 1 1 2
7051 1 my $parsed_line = unparse_mode_line($breply);
7052 $self->_send_output_channel_local(
7053 $record->{name},
7054 {
7055 prefix => $full,
7056 command => 'MODE',
7057 colonify => 0,
7058 params => [
7059 $record->{name},
7060 1 $parsed_line,
7061 @breply_args,
7062 ],
7063 },
7064 '','-oh',
7065 );
7066 }
7067 }
7068 }
7069 } # SWITCH
7070  
7071 53 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 53 0 53
7072 0 return $ref;
7073 }
7074  
7075 sub _daemon_cmd_join {
7076 114 ▶ my $self = shift;
Subroutine _daemon_cmd_join: called CC=50 SCAR=50.6
7077 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
7078 114 my $server = $self->server_name();
7079 114 my $sid = $self->server_sid();
7080 114 my $ref = [ ];
7081 114 my $args = [@_];
7082 114 my $count = @$args;
7083 114 my $route_id = $self->_state_user_route($nick);
7084 114 my $uid = $self->state_user_uid($nick);
7085 114 my $unick = uc_irc($nick);
7086  
7087 SWITCH: {
7088 114 my (@channels, @chankeys);
7089 114 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 114 114
7090 0 push @$ref, ['461', 'JOIN'];
7091 0 last SWITCH;
7092 }
7093  
7094 114 @channels = split /,/, $args->[0];
7095 114 ▶ @chankeys = split /,/, $args->[1] if $args->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[1] 0 114 114
7096 114 my $channel_length = $self->server_config('CHANNELLEN');
7097 114 my $nick_is_oper = $self->state_user_is_operator($nick);
7098  
7099 114 LOOP: for my $channel (@channels) {
7100 114 my $uchannel = uc_irc($channel);
7101 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
7102 and my @chans = $self->state_user_chans($nick)) {
7103 $self->_send_output_to_client(
7104 $route_id,
7105 (ref $_ eq 'ARRAY' ? @$_ : $_),
7106 0 ▶ ) for map { $self->_daemon_cmd_part($nick, $_) } @chans;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
7107 0 next LOOP;
7108 }
7109 # Channel isn't valid
7110 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
7111 || length $channel > $channel_length) {
7112 0 $self->_send_output_to_client(
7113 $route_id,
7114 '403',
7115 $channel,
7116 );
7117 0 next LOOP;
7118 }
7119 # Too many channels
7120 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
7121 >= $self->server_config('MAXCHANNELS')
7122 && !$nick_is_oper) {
7123 0 $self->_send_output_to_client(
7124 $route_id,
7125 '405',
7126 $channel,
7127 );
7128 0 next LOOP;
7129 }
7130 # Channel is RESV
7131 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
7132 1 ▶ if ( !$nick_is_oper ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nick_is_oper) 1 0 1
7133 1 $self->_send_to_realops(
7134 sprintf(
7135 'Forbidding reserved channel %s from user %s',
7136 $channel,
7137 $self->state_user_full($nick),
7138 ),
7139 'Notice',
7140 'j',
7141 );
7142 1 $self->_send_output_to_client(
7143 $route_id,
7144 '485',
7145 $channel,
7146 $reason,
7147 );
7148 1 next LOOP;
7149 }
7150 }
7151 # Channel doesn't exist
7152 113 ▶ if (!$self->state_chan_exists($channel)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($channel)) 55 58 113
7153 55 my $record = {
7154 name => $channel,
7155 ts => time,
7156 mode => 'nt',
7157 users => { $uid => 'o' },
7158 };
7159 55 $self->{state}{chans}{$uchannel} = $record;
7160 55 $self->{state}{users}{$unick}{chans}{$uchannel} = 'o';
7161 55 my @peers = $self->_state_connected_peers();
7162 $self->send_output(
7163 {
7164 prefix => $sid,
7165 command => 'SJOIN',
7166 params => [
7167 $record->{ts},
7168 $channel,
7169 '+' . $record->{mode},
7170 55 ▶ '@' . $uid,
Branch: 1 branch
BranchTrueFalseTotal
unless $channel =~ /^&/ 55 0 55
7171 ],
7172 },
7173 @peers,
7174 ) if $channel !~ /^&/;
7175 55 my $output = {
7176 prefix => $self->state_user_full($nick),
7177 command => 'JOIN',
7178 params => [$channel],
7179 };
7180 55 $self->send_output($output, $route_id);
7181 $self->send_event(
7182 "daemon_join",
7183 $output->{prefix},
7184 55 $channel,
7185 );
7186 $self->send_output(
7187 {
7188 prefix => $server,
7189 command => 'MODE',
7190 55 params => [$channel, '+' . $record->{mode}],
7191 },
7192 $route_id,
7193 );
7194 $self->_send_output_to_client(
7195 $route_id,
7196 (ref $_ eq 'ARRAY' ? @$_ : $_),
7197 55 ▶ ) for $self->_daemon_cmd_names($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 110 110
7198 55 next LOOP;
7199 }
7200 # Numpty user is already on channel
7201 58 ▶ if ($self->state_is_chan_member($nick, $channel)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($nick, $channel)) 0 58 58
7202 0 next LOOP;
7203 }
7204 58 my $chanrec = $self->{state}{chans}{$uchannel};
7205 58 my $bypass;
7206 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
7207 0 $bypass = 1;
7208 }
7209 # OPER only channel +O
7210 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
7211 0 push @$ref, ['520',$chanrec->{name}];
7212 0 next LOOP;
7213 }
7214 58 my $umode = $self->state_user_umode($nick);
7215 # SSL only channel +S
7216 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
7217 0 push @$ref, ['489',$chanrec->{name}];
7218 0 next LOOP;
7219 }
7220 # Registered users only +R
7221 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
7222 2 push @$ref, ['477',$chanrec->{name}];
7223 2 next LOOP;
7224 }
7225 # Channel is full
7226 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
7227 0 && keys %{$chanrec->{users}} >= $chanrec->{climit}) {
7228 0 $self->_send_output_to_client($route_id, '471', $channel);
7229 0 next LOOP;
7230 }
7231 56 my $chankey;
7232 56 ▶ $chankey = shift @chankeys if $chanrec->{mode} =~ /k/;
Branch: 1 branch
BranchTrueFalseTotal
if $chanrec->{"mode"} =~ /k/ 0 56 56
7233 # Channel +k and no key or invalid key provided
7234 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
7235 && (!$chankey || $chankey ne $chanrec->{ckey})) {
7236 0 $self->_send_output_to_client($route_id, '475', $channel);
7237 0 next LOOP;
7238 }
7239 # Channel +i and not INVEX
7240 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
7241 && !$self->_state_user_invited($nick, $channel)) {
7242 3 $self->_send_output_to_client($route_id, '473', $channel);
7243 3 next LOOP;
7244 }
7245 # Channel +b and no exception
7246 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
7247 0 $self->_send_output_to_client($route_id, '474', $channel);
7248 0 next LOOP;
7249 }
7250 # Spambot checks
7251 53 ▶ $self->state_check_spambot_warning($nick,$channel) if !$nick_is_oper;
Branch: 1 branch
BranchTrueFalseTotal
unless $nick_is_oper 51 2 53
7252 53 ▶ $self->state_check_joinflood_warning($nick,$channel) if !$nick_is_oper;
Branch: 1 branch
BranchTrueFalseTotal
unless $nick_is_oper 51 2 53
7253 # JOIN the channel
7254 53 delete $self->{state}{users}{$unick}{invites}{$uchannel};
7255 53 delete $self->{state}{chans}{$uchannel}{invites}{$uid};
7256 # Add user
7257 53 $self->{state}{uids}{$uid}{chans}{$uchannel} = '';
7258 53 $self->{state}{chans}{$uchannel}{users}{$uid} = '';
7259 # Send JOIN message to peers and local users.
7260 $self->send_output(
7261 {
7262 prefix => $uid,
7263 command => 'JOIN',
7264 53 ▶ params => [$chanrec->{ts}, $channel, '+'],
Branch: 1 branch
BranchTrueFalseTotal
unless $channel =~ /^&/ 53 0 53
7265 },
7266 $self->_state_connected_peers(),
7267 ) if $channel !~ /^&/;
7268  
7269 53 my $output = {
7270 prefix => $self->state_user_full($nick),
7271 command => 'JOIN',
7272 params => [$channel],
7273 };
7274 my $extout = {
7275 prefix => $self->state_user_full($nick),
7276 command => 'JOIN',
7277 params => [
7278 $channel,
7279 $self->{state}{uids}{$uid}{account},
7280 $self->{state}{uids}{$uid}{ircname},
7281 53 ],
7282 };
7283 53 $self->_send_output_to_client($route_id, $output);
7284 53 $self->_send_output_channel_local($channel, $output, $route_id, '', '', 'extended-join');
7285 53 $self->_send_output_channel_local($channel, $extout, $route_id, '', 'extended-join');
7286  
7287 # Send NAMES and TOPIC to client
7288 $self->_send_output_to_client(
7289 $route_id,
7290 (ref $_ eq 'ARRAY' ? @$_ : $_),
7291 53 ▶ ) for $self->_daemon_cmd_names($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 106 106
7292 $self->_send_output_to_client(
7293 $route_id,
7294 (ref $_ eq 'ARRAY' ? @$_ : $_),
7295 53 ▶ ) for $self->_daemon_cmd_topic($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 53 53
7296  
7297 53 ▶ if ( $self->{state}{uids}{$uid}{away} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"uids"}{$uid}{"away"}) 1 52 53
7298 1 $self->_state_do_away_notify($uid,$channel,$self->{state}{uids}{$uid}{away});
7299 }
7300 }
7301 }
7302  
7303 114 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 113 1 114
7304 1 return $ref;
7305 }
7306  
7307 sub _daemon_cmd_part {
7308 8 ▶ my $self = shift;
Subroutine _daemon_cmd_part: called CC=14 SCAR=29.7
7309 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
7310 8 my $chan = shift;
7311 8 my $server = $self->server_name();
7312 8 my $ref = [ ];
7313 8 my $args = [@_];
7314 8 my $count = @$args;
7315  
7316 SWITCH: {
7317 8 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 0 8 8
7318 0 push @$ref, ['461', 'PART'];
7319 0 last SWITCH;
7320 }
7321 8 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 8 8
7322 0 push @$ref, ['403', $chan];
7323 0 last SWITCH;
7324 }
7325 8 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 8 8
7326 0 push @$ref, ['442', $chan];
7327 0 last SWITCH;
7328 }
7329  
7330 8 $chan = $self->_state_chan_name($chan);
7331 8 my $uid = $self->state_user_uid($nick);
7332 8 my $urec = $self->{state}{uids}{$uid};
7333  
7334 8 my $pmsg = $args->[0];
7335 8 my $params = [ $chan ];
7336  
7337 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
7338 0 ▶ $pmsg = '' if time - $urec->{conn_time} < $msgtime;
Branch: 1 branch
BranchTrueFalseTotal
if time - $urec->{"conn_time"} < $msgtime 0 0 0
7339 }
7340  
7341 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
7342 0 $pmsg = '';
7343 }
7344  
7345 8 ▶ push @$params, $pmsg if $pmsg;
Branch: 1 branch
BranchTrueFalseTotal
if $pmsg 6 2 8
7346  
7347 8 ▶ $self->state_check_spambot_warning($nick) if $urec->{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $urec->{"umode"} =~ /o/ 7 1 8
7348  
7349 8 $self->send_output(
7350 {
7351 prefix => $uid,
7352 command => 'PART',
7353 params => $params,
7354 },
7355 $self->_state_connected_peers(),
7356 );
7357 8 $self->_send_output_channel_local(
7358 $chan,
7359 {
7360 prefix => $self->state_user_full($nick),
7361 command => 'PART',
7362 params => $params,
7363 },
7364 );
7365  
7366 8 $chan = uc_irc($chan);
7367 8 delete $self->{state}{chans}{$chan}{users}{$uid};
7368 8 delete $self->{state}{uids}{$uid}{chans}{$chan};
7369 8 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 5 3 8
7370 5 delete $self->{state}{chans}{$chan};
7371 }
7372 }
7373  
7374 8 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 8 0 8
7375 0 return $ref;
7376 }
7377  
7378 sub _daemon_cmd_kick {
7379 7 ▶ my $self = shift;
Subroutine _daemon_cmd_kick: called CC=15 SCAR=31.1
7380 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
7381 7 my $server = $self->server_name();
7382 7 my $ref = [ ];
7383 7 my $args = [@_];
7384 7 my $count = @$args;
7385  
7386 SWITCH: {
7387 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
7388 0 push @$ref, ['461', 'KICK'];
7389 0 last SWITCH;
7390 }
7391 7 my $chan = (split /,/, $args->[0])[0];
7392 7 my $who = (split /,/, $args->[1])[0];
7393 7 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 7 7
7394 0 push @$ref, ['403', $chan];
7395 0 last SWITCH;
7396 }
7397 7 $chan = $self->_state_chan_name($chan);
7398 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
7399 0 push @$ref, ['482', $chan];
7400 0 last SWITCH;
7401 }
7402 7 ▶ if (!$self->state_nick_exists($who) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 7 7
7403 0 push @$ref, ['401', $who];
7404 0 last SWITCH;
7405 }
7406 7 $who = $self->state_user_nick($who);
7407 7 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 3 4 7
7408 3 push @$ref, ['441', $who, $chan];
7409 3 last SWITCH;
7410 }
7411 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
7412 $self->state_is_chan_hop($nick, $chan) &&
7413 !$self->state_is_chan_op($nick, $chan) &&
7414 $self->state_is_chan_op($who, $chan)
7415 ) {
7416 3 push @$ref, ['482', $chan];
7417 3 last SWITCH;
7418 }
7419 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
7420 1 my $uid = $self->state_user_uid($nick);
7421 1 my $wuid = $self->state_user_uid($who);
7422 1 $self->send_output(
7423 {
7424 prefix => $uid,
7425 command => 'KICK',
7426 params => [$chan, $wuid, $comment],
7427 },
7428 $self->_state_connected_peers(),
7429 );
7430 1 $self->_send_output_channel_local(
7431 $chan,
7432 {
7433 prefix => $self->state_user_full($nick),
7434 command => 'KICK',
7435 params => [$chan, $who, $comment],
7436 },
7437 );
7438 1 $chan = uc_irc($chan);
7439 1 delete $self->{state}{chans}{$chan}{users}{$wuid};
7440 1 delete $self->{state}{uids}{$wuid}{chans}{$chan};
7441 1 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 1 1
7442 0 delete $self->{state}{chans}{$chan};
7443 }
7444 }
7445  
7446 7 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 7 0 7
7447 0 return $ref;
7448 }
7449  
7450 sub _daemon_cmd_remove {
7451 3 ▶ my $self = shift;
Subroutine _daemon_cmd_remove: called CC=15 SCAR=30.8
7452 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
7453 3 my $server = $self->server_name();
7454 3 my $ref = [ ];
7455 3 my $args = [@_];
7456 3 my $count = @$args;
7457  
7458 SWITCH: {
7459 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
7460 0 push @$ref, ['461', 'REMOVE'];
7461 0 last SWITCH;
7462 }
7463 3 my $chan = (split /,/, $args->[0])[0];
7464 3 my $who = (split /,/, $args->[1])[0];
7465 3 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 3 3
7466 0 push @$ref, ['403', $chan];
7467 0 last SWITCH;
7468 }
7469 3 $chan = $self->_state_chan_name($chan);
7470 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
7471 0 push @$ref, ['482', $chan];
7472 0 last SWITCH;
7473 }
7474 3 ▶ if (!$self->state_nick_exists($who) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 3 3
7475 0 push @$ref, ['401', $who];
7476 0 last SWITCH;
7477 }
7478 3 $who = $self->state_user_nick($who);
7479 3 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 1 2 3
7480 1 push @$ref, ['441', $who, $chan];
7481 1 last SWITCH;
7482 }
7483 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
7484 $self->state_is_chan_hop($nick, $chan) &&
7485 !$self->state_is_chan_op($nick, $chan) &&
7486 $self->state_is_chan_op($who, $chan)
7487 ) {
7488 1 push @$ref, ['482', $chan];
7489 1 last SWITCH;
7490 }
7491 1 my $comment = "Requested by $nick";
7492 1 ▶ $comment .= qq{ "$args->[2]"} if $args->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[2] 1 0 1
7493 1 my $uid = $self->state_user_uid($who);
7494 1 $self->send_output(
7495 {
7496 prefix => $uid,
7497 command => 'PART',
7498 params => [$chan, $comment],
7499 },
7500 $self->_state_connected_peers(),
7501 );
7502 1 $self->_send_output_channel_local(
7503 $chan,
7504 {
7505 prefix => $self->state_user_full($who),
7506 command => 'PART',
7507 params => [$chan, $comment],
7508 },
7509 );
7510 1 $chan = uc_irc($chan);
7511 1 delete $self->{state}{chans}{$chan}{users}{$uid};
7512 1 delete $self->{state}{uids}{$uid}{chans}{$chan};
7513 1 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 1 1
7514 0 delete $self->{state}{chans}{$chan};
7515 }
7516 }
7517  
7518 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
7519 0 return $ref;
7520 }
7521  
7522 sub _daemon_cmd_invite {
7523 0 ▶ my $self = shift;
Subroutine _daemon_cmd_invite: not called CC=18 SCAR=58.3
7524 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
7525 0 my $server = $self->server_name();
7526 0 my $sid = $self->server_sid();
7527 0 my $ref = [ ];
7528 0 my $args = [@_];
7529 0 my $count = @$args;
7530  
7531 SWITCH: {
7532 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
7533 0 push @$ref, ['461', 'INVITE'];
7534 0 last SWITCH;
7535 }
7536 0 my ($who, $chan) = @$args;
7537 0 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
7538 0 push @$ref, ['401', $who];
7539 0 last SWITCH;
7540 }
7541 0 $who = $self->state_user_nick($who);
7542 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
7543 0 push @$ref, ['403', $chan];
7544 0 last SWITCH;
7545 }
7546 0 $chan = $self->_state_chan_name($chan);
7547 0 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 0 0
7548 0 push @$ref, ['442', $chan];
7549 0 last SWITCH;
7550 }
7551 0 ▶ if ($self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($who, $chan)) 0 0 0
7552 0 push @$ref, ['443', $who, $chan];
7553 0 last SWITCH;
7554 }
7555 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
7556 && ( !$self->state_is_chan_op($nick, $chan)
7557 || !$self->state_is_chan_hop($nick, $chan) ) ) {
7558 0 push @$ref, ['482', $chan];
7559 0 last SWITCH;
7560 }
7561 0 my $local; my $invite_only;
7562 0 my $wuid = $self->state_user_uid($who);
7563 0 my $settime = time;
7564 # Only store the INVITE if the channel is invite-only
7565 0 ▶ if ($self->state_chan_mode_set($chan, 'i')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_mode_set($chan, "i")) 0 0 0
7566 0 $self->{state}{chans}{uc_irc $chan}{invites}{$wuid} = $settime;
7567 0 ▶ if ($self->_state_is_local_uid($wuid)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_uid($wuid)) 0 0 0
7568 0 my $record = $self->{state}{uids}{$wuid};
7569 0 $record->{invites}{uc_irc($chan)} = $settime;
7570 0 $local = 1;
7571 }
7572 0 $invite_only = 1;
7573 }
7574 0 my $invite;
7575 {
7576 0 my $route_id = $self->_state_uid_route($wuid);
7577 0 $invite = {
7578 prefix => $self->state_user_full($nick),
7579 command => 'INVITE',
7580 params => [$who, $chan],
7581 colonify => 0,
7582 };
7583 0 ▶ if ($route_id eq 'spoofed') {
Branch: 2 branches
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
elsif ($local) { } 0 0 0
7584 $self->send_event(
7585 "daemon_invite",
7586 $invite->{prefix},
7587 0 @{ $invite->{params} }
7588 );
7589 }
7590 elsif ( $local ) {
7591 0 $self->send_output($invite, $route_id);
7592 }
7593 }
7594 # Send INVITE to all connected peers
7595 $self->send_output(
7596 {
7597 0 prefix => $self->state_user_uid($nick),
7598 command => 'INVITE',
7599 params => [ $wuid, $chan, $self->_state_chan_timestamp($chan) ],
7600 colonify => 0,
7601 },
7602 $self->_state_connected_peers(),
7603 );
7604 0 push @$ref, {
7605 prefix => $server,
7606 command => '341',
7607 params => [$chan, $who],
7608 };
7609 # Send NOTICE to local channel +oh users or invite-notify if applicable
7610 0 ▶ if ( $invite_only ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invite_only) 0 0 0
7611 0 my $notice = {
7612 prefix => $server,
7613 command => 'NOTICE',
7614 params => [
7615 $chan,
7616 sprintf(
7617 "%s is inviting %s to %s.",
7618 $nick,
7619 $who,
7620 $chan,
7621 ),
7622 ],
7623 };
7624 0 $self->_send_output_channel_local($chan,$notice,'','oh','','invite-notify'); # Traditional NOTICE
7625 0 $self->_send_output_channel_local($chan,$invite,'','oh','invite-notify',''); # invite-notify extension
7626 }
7627 0 my $away = $self->{state}{uids}{$wuid}{away};
7628 0 ▶ if (defined $away) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $away) 0 0 0
7629 0 push @$ref, {
7630 prefix => $server,
7631 command => '301',
7632 params => [$nick, $who, $away],
7633 };
7634 }
7635 }
7636  
7637 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
7638 0 return $ref;
7639 }
7640  
7641 sub _daemon_cmd_umode {
7642 227 ▶ my $self = shift;
Subroutine _daemon_cmd_umode: called CC=22 SCAR=37.1
7643 227 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
2270
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7644 227 my $args = [ @_ ];
7645 227 my $count = @$args;
7646 227 my $server = $self->server_name();
7647 227 my $ref = [ ];
7648 227 my $record = $self->{state}{users}{uc_irc($nick)};
7649  
7650 227 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count) { } 2 225 227
7651 push @$ref, {
7652 prefix => $server,
7653 command => '221',
7654 2 params => [$nick, '+' . $record->{umode}],
7655 };
7656 }
7657 else {
7658 225 my $modestring = join('', @$args);
7659 225 $modestring =~ s/\s+//g;
7660 225 my $cnt += $modestring =~ s/[^a-zA-Z+-]+//g;
7661 225 $cnt += $modestring =~ s/[^DFGHRSWXabcdefgijklnopqrsuwy+-]+//g;
7662  
7663 # These can only be set by servers/services
7664 225 $modestring =~ s/[SWr]+//g;
7665  
7666 # These can only be set by an OPER
7667 225 ▶ $cnt += $modestring =~ s/[FHXabcdefjklnsuy]+//g if $record->{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"umode"} =~ /o/ 225 0 225
7668  
7669 225 ▶ push @$ref, ['501'] if $cnt;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt 1 224 225
7670  
7671 225 my $umode = unparse_mode_line($modestring);
7672 225 my $peer_ignore;
7673 225 my $parsed_mode = parse_mode_line($umode);
7674 225 my $route_id = $self->_state_user_route($nick);
7675 225 my $previous = $record->{umode};
7676  
7677 225 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 224 225 449
7678 224 ▶ next if $mode eq '+o';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+o" 0 224 224
7679 224 my ($action, $char) = split //, $mode;
7680 224 ▶ if ($action eq '+' && $record->{umode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and not $record->{"umode"} =~ /$char/) 224 0 224
Condition33%1/3
$action eq "+" and not $record->{"umode"} =~ /$char/
!ll&&!rl&&r
00224
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
7681 224 $record->{umode} .= $char;
7682 224 ▶ if ($char eq 'i') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "i") 223 1 224
7683 223 $self->{state}{stats}{invisible}++;
7684 223 $peer_ignore = delete $record->{_ignore_i_umode};
7685 }
7686 224 ▶ if ($char eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w") 0 224 224
7687 0 $self->{state}{wallops}{$route_id} = time;
7688 }
7689 224 ▶ if ($char eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l") 0 224 224
7690 0 $self->{state}{locops}{$route_id} = time;
7691 }
7692 }
7693 224 ▶ if ($action eq '-' && $record->{umode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "-" and $record->{"umode"} =~ /$char/) 0 224 224
Condition33%1/3
$action eq "-" and $record->{"umode"} =~ /$char/
!ll&&!rl&&r
22400
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
7694 0 $record->{umode} =~ s/$char//g;
7695 0 ▶ $self->{state}{stats}{invisible}-- if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
7696  
7697 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
7698 0 $self->{state}{stats}{ops_online}--;
7699 0 delete $self->{state}{localops}{$route_id};
7700 0 $self->antiflood( $route_id, 1);
7701 0 delete $record->{svstags}{313};
7702 }
7703 0 ▶ if ($char eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w") 0 0 0
7704 0 delete $self->{state}{wallops}{$route_id};
7705 }
7706 0 ▶ if ($char eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l") 0 0 0
7707 0 delete $self->{state}{locops}{$route_id};
7708 }
7709 }
7710 }
7711  
7712 225 $record->{umode} = join '', sort split //, $record->{umode};
7713 225 my $set = gen_mode_change($previous, $record->{umode});
7714 225 ▶ if ($set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set) 224 1 225
7715 224 my $full = $self->state_user_full($nick);
7716 $self->send_output(
7717 {
7718 prefix => $record->{uid},
7719 command => 'MODE',
7720 224 ▶ params => [$record->{uid}, $set],
Branch: 1 branch
BranchTrueFalseTotal
unless $peer_ignore 1 223 224
7721 },
7722 $self->_state_connected_peers(),
7723 ) if !$peer_ignore;
7724 224 my $hashref = {
7725 prefix => $full,
7726 command => 'MODE',
7727 params => [$nick, $set],
7728 };
7729 224 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
unless $peer_ignore 1 223 224
7730 "daemon_umode",
7731 $full,
7732 $set,
7733 ) if !$peer_ignore;
7734 224 push @$ref, $hashref;
7735 }
7736 }
7737  
7738 227 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 227 0 227
7739 0 return $ref;
7740 }
7741  
7742 sub _daemon_cmd_topic {
7743 59 ▶ my $self = shift;
Subroutine _daemon_cmd_topic: called CC=15 SCAR=34.2
7744 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
7745 59 my $server = $self->server_name();
7746 59 my $ref = [ ];
7747 59 my $args = [@_];
7748 59 my $count = @$args;
7749  
7750 SWITCH:{
7751 59 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 59 59
7752 0 push @$ref, ['461', 'TOPIC'];
7753 0 last SWITCH;
7754 }
7755 59 ▶ if (!$self->state_chan_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($args->[0])) 0 59 59
7756 0 push @$ref, ['403', $args->[0]];
7757 0 last SWITCH;
7758 }
7759 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
7760 && !$self->state_is_chan_member($nick, $args->[0])) {
7761 0 push @$ref, ['442', $args->[0]];
7762 0 last SWITCH;
7763 }
7764 59 my $chan_name = $self->_state_chan_name($args->[0]);
7765 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
7766 and my $topic = $self->state_chan_topic($args->[0])) {
7767 0 push @$ref, {
7768 prefix => $server,
7769 command => '332',
7770 params => [$nick, $chan_name, $topic->[0]],
7771 };
7772 push @$ref, {
7773 prefix => $server,
7774 command => '333',
7775 0 params => [$nick, $chan_name, @{ $topic }[1..2]],
7776 };
7777 0 last SWITCH;
7778 }
7779 59 ▶ if ($count == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 1) 56 3 59
7780 56 push @$ref, {
7781 prefix => $server,
7782 command => '331',
7783 params => [$nick, $chan_name, 'No topic is set'],
7784 };
7785 56 last SWITCH;
7786 }
7787 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
7788 0 push @$ref, ['442', $args->[0]];
7789 0 last SWITCH;
7790 }
7791 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
7792 && !$self->state_is_chan_op($nick, $args->[0])) {
7793 0 push @$ref, ['482', $args->[0]];
7794 0 last SWITCH;
7795 }
7796 3 my $record = $self->{state}{chans}{uc_irc($args->[0])};
7797 3 my $topic_length = $self->server_config('TOPICLEN');
7798 3 ▶ if (length $args->[0] > $topic_length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $args->[0] > $topic_length) 0 3 3
7799 0 $args->[1] = substr $args->[0], 0, $topic_length;
7800 }
7801 3 ▶ if ($args->[1] eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] eq '') { } 1 2 3
7802 1 delete $record->{topic};
7803 }
7804 else {
7805 $record->{topic} = [
7806 2 $args->[1],
7807 $self->state_user_full($nick),
7808 time,
7809 ];
7810 }
7811 3 $self->send_output(
7812 {
7813 prefix => $self->state_user_uid($nick),
7814 command => 'TOPIC',
7815 params => [$chan_name, $args->[1]],
7816 },
7817 $self->_state_connected_peers(),
7818 );
7819  
7820 3 $self->_send_output_channel_local(
7821 $args->[0],
7822 {
7823 prefix => $self->state_user_full($nick),
7824 command => 'TOPIC',
7825 params => [$chan_name, $args->[1]],
7826 },
7827 );
7828 }
7829  
7830 59 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 59 0 59
7831 0 return $ref;
7832 }
7833  
7834 sub _daemon_cmd_map {
7835 2 ▶ my $self = shift;
Subroutine _daemon_cmd_map: called CC=8 SCAR=23.2
7836 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
7837 2 my $server = $self->server_name();
7838 2 my $sid = $self->server_sid();
7839 2 my $ref = [ ];
7840  
7841 SWITCH: {
7842 2 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 2 0 2
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 2 my $full = $self->state_user_full($nick);
7853 2 my $msg = sprintf('MAP requested by %s (%s) [%s]',
7854 $nick, (split /!/,$full)[1], $server,
7855 );
7856  
7857 2 $self->_send_to_realops( $msg, 'Notice', 'y' );
7858  
7859 2 push @$ref, $_ for
7860 $self->_state_do_map( $nick, $sid, 0 );
7861  
7862 2 push @$ref, {
7863 prefix => $server,
7864 command => '017',
7865 params => [
7866 $nick,
7867 'End of /MAP',
7868 ],
7869 };
7870 }
7871  
7872 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
7873 0 return $ref;
7874 }
7875  
7876 sub _daemon_cmd_links {
7877 7 ▶ my $self = shift;
Subroutine _daemon_cmd_links: called CC=13 SCAR=25.7
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 sub _daemon_do_links {
7934 5 ▶ my $self = shift;
Subroutine _daemon_do_links: called CC=7 SCAR=19.8
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 sub _daemon_cmd_knock {
7966 7 ▶ my $self = shift;
Subroutine _daemon_cmd_knock: called CC=19 SCAR=32.9
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 sub _daemon_peer_certfp {
8054 0 ▶ my $self = shift;
Subroutine _daemon_peer_certfp: not called CC=7 SCAR=40.3
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 sub _daemon_peer_knock {
8086 1 ▶ my $self = shift;
Subroutine _daemon_peer_knock: called CC=7 SCAR=20.2
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') }
Branch: 1 branch
BranchTrueFalseTotal
$_ ne $peer_id and $self->_state_peer_capab($_, "KNOCK") 1 1 2
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 sub _daemon_peer_squit {
8134 224 ▶ my $self = shift;
Subroutine _daemon_peer_squit: called CC=17 SCAR=30.0
8135 224 ▶ my $peer_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
8136 224 my $sid = $self->server_sid();
8137 224 my $ref = [ ];
8138 224 my $args = [ @_ ];
8139 224 my $count = @$args;
8140 224 ▶ return if !$self->state_sid_exists($args->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($args->[0]) 0 224 224
8141  
8142 SWITCH: {
8143 224 ▶ 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 224 224
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 224 ▶ if ($peer_id eq $self->_state_sid_route($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer_id eq $self->_state_sid_route($args->[0])) 224 0 224
8154 $self->send_output(
8155 {
8156 command => 'SQUIT',
8157 params => $args,
8158 },
8159 224 grep { $_ ne $peer_id } $self->_state_connected_peers(),
8160 );
8161 224 my $qsid = $args->[0];
8162 224 my $qpeer = $self->_state_sid_name($qsid);
8163 224 $self->send_event("daemon_squit", $qpeer, $args->[1]);
8164 my $quit_msg = join ' ',
8165 224 $self->{state}{sids}{$qsid}{peer}, $qpeer;
8166  
8167 224 ▶ if ($sid eq $self->{state}{sids}{$qsid}{psid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sid eq $self->{'state'}{'sids'}{$qsid}{'psid'}) { } 223 1 224
8168 223 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 223 $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 224 for my $uid ($self->_state_server_squit($qsid)) {
8186 515 my $output = {
8187 prefix => $self->state_user_full($uid),
8188 command => 'QUIT',
8189 params => [$quit_msg],
8190 };
8191 515 my $common = { };
8192 515 for my $uchan ( keys %{ $self->{state}{uids}{$uid}{chans} } ) {
8193 1989 delete $self->{state}{chans}{$uchan}{users}{$uid};
8194 1989 for my $user ( keys %{ $self->{state}{chans}{$uchan}{users} } ) {
8195 124668 ▶ next if $user !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $user =~ /^$sid/ 124663 5 124668
8196 5 $common->{$user} = $self->_state_uid_route($user);
8197 }
8198 1989 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 57 1932 1989
8199 57 delete $self->{state}{chans}{$uchan};
8200 }
8201 }
8202 515 $self->send_output($output, values %$common);
8203 $self->send_event(
8204 "daemon_quit",
8205 $output->{prefix},
8206 515 $output->{params}[0],
8207 );
8208 515 my $record = delete $self->{state}{uids}{$uid};
8209 515 my $nick = uc_irc $record->{nick};
8210 515 delete $self->{state}{users}{$nick};
8211 # WATCH LOGOFF
8212 515 ▶ if ( defined $self->{state}{watches}{$nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$nick}) 0 515 515
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 515 ▶ if ($record->{umode} =~ /o/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /o/) 212 303 515
8236 212 $self->{state}{stats}{ops_online}--;
8237 }
8238 515 ▶ if ($record->{umode} =~ /i/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /i/) 515 0 515
8239 515 $self->{state}{stats}{invisible}--;
8240 }
8241 515 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 515 };
8252 }
8253 224 last SWITCH;
8254 }
8255 }
8256  
8257 224 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 224 224
8258 224 return $ref;
8259 }
8260  
8261 sub _daemon_peer_resv {
8262 2 ▶ my $self = shift;
Subroutine _daemon_peer_resv: called CC=16 SCAR=30.7
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 sub _daemon_peer_unresv {
8355 1 ▶ my $self = shift;
Subroutine _daemon_peer_unresv: called CC=11 SCAR=25.3
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 sub _daemon_peer_xline {
8431 2 ▶ my $self = shift;
Subroutine _daemon_peer_xline: called CC=15 SCAR=29.2
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 sub _daemon_peer_unxline {
8517 1 ▶ my $self = shift;
Subroutine _daemon_peer_unxline: called CC=11 SCAR=25.3
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 sub _daemon_peer_dline {
8593 2 ▶ my $self = shift;
Subroutine _daemon_peer_dline: called CC=14 SCAR=27.6
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 sub _daemon_peer_undline {
8683 1 ▶ my $self = shift;
Subroutine _daemon_peer_undline: called CC=11 SCAR=25.3
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 sub _daemon_peer_encap {
8761 2 ▶ my $self = shift;
Subroutine _daemon_peer_encap: called CC=10 SCAR=23.8
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 sub _daemon_peer_kline {
8815 2 ▶ my $self = shift;
Subroutine _daemon_peer_kline: called CC=12 SCAR=25.9
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 sub _daemon_peer_unkline {
8885 1 ▶ my $self = shift;
Subroutine _daemon_peer_unkline: called CC=11 SCAR=25.3
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 sub _daemon_peer_wallops {
8954 0 ▶ my $self = shift;
Subroutine _daemon_peer_wallops: not called CC=5 SCAR=34.0
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 sub _daemon_peer_globops {
8990 0 ▶ my $self = shift;
Subroutine _daemon_peer_globops: not called CC=5 SCAR=34.0
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 sub _daemon_peer_eob {
9025 379 ▶ my $self = shift;
Subroutine _daemon_peer_eob: called CC=5 SCAR=16.3
9026 379 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
3790
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9027 379 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
3790
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9028 379 my $ref = [ ];
9029 379 ▶ if ($self->{state}{conns}{$peer_id}{sid} eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"conns"}{$peer_id}{"sid"} eq $peer) 252 127 379
9030 252 my $crec = $self->{state}{conns}{$peer_id};
9031 $self->_send_to_realops(
9032 sprintf(
9033 'End of burst from %s (%u seconds)',
9034 252 $crec->{name}, ( time() - $crec->{conn_time} ),
9035 ),
9036 'Notice',
9037 's',
9038 );
9039 }
9040 379 $self->send_event('daemon_eob', $self->{state}{sids}{$peer}{name}, $peer);
9041 379 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 379 379
9042 379 return $ref;
9043 }
9044  
9045 sub _daemon_peer_kill {
9046 6 ▶ my $self = shift;
Subroutine _daemon_peer_kill: called CC=9 SCAR=33.3
9047 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
9048 6 ▶ my $killer = 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
9049 6 my $server = $self->server_name();
9050 6 my $ref = [ ];
9051 6 my $args = [ @_ ];
9052 6 my $count = @$args;
9053  
9054 SWITCH: {
9055 6 ▶ if ($self->state_sid_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_sid_exists($args->[0])) 0 6 6
9056 0 last SWITCH;
9057 }
9058 6 ▶ if (!$self->state_uid_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_uid_exists($args->[0])) 6 0 6
9059 6 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 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
9122 6 return $ref;
9123 }
9124  
9125 sub _daemon_peer_svinfo {
9126 253 ▶ my $self = shift;
Subroutine _daemon_peer_svinfo: called CC=5 SCAR=16.3
9127 253 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9128 253 my $ref = [ ];
9129 253 my $args = [ @_ ];
9130 253 my $count = @$args;
9131 # SVINFO 6 6 0 :1525185763
9132 253 ▶ if ( !( $args->[0] eq '6' && $args->[1] eq '6' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0] eq 6 and $args->[1] eq 6) 1 252 253
Condition66%2/3
$args->[0] eq 6 and $args->[1] eq 6
!ll&&!rl&&r
01252
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 252 $self->{state}{conns}{$peer_id}{svinfo} = $args;
9137 252 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 252 252
9138 252 return $ref;
9139 }
9140  
9141 sub _daemon_peer_ping {
9142 248 ▶ my $self = shift;
Subroutine _daemon_peer_ping: called CC=9 SCAR=26.3
9143 248 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2480
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9144 248 my $server = $self->server_name();
9145 248 my $sid = $self->server_sid();
9146 248 my $ref = [ ];
9147 248 my $prefix = shift;
9148 248 my $args = [ @_ ];
9149 248 my $count = @$args;
9150  
9151 SWITCH: {
9152 248 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 248 248
9153 0 last SWITCH;
9154 }
9155 248 ▶ if ($count >= 2 && $sid ne $args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and $sid ne $args->[1]) 2 246 248
Condition66%2/3
$count >= 2 and $sid ne $args->[1]
!ll&&!rl&&r
24602
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 246 prefix => $sid,
9195 command => 'PONG',
9196 params => [$server, $args->[0]],
9197 },
9198 $peer_id,
9199 );
9200 }
9201  
9202 248 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 248 248
9203 248 return $ref;
9204 }
9205  
9206 sub _daemon_peer_pong {
9207 3 ▶ my $self = shift;
Subroutine _daemon_peer_pong: called CC=9 SCAR=24.0
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 sub _daemon_peer_sid {
9265 129 ▶ my $self = shift;
Subroutine _daemon_peer_sid: called CC=15 SCAR=28.6
9266 129 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
1290
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9267 129 ▶ my $prefix = shift || return;
Condition50%1/2
shift() || (return)
l!l
1290
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9268 129 my $server = $self->server_name();
9269 129 my $ref = [ ];
9270 129 my $args = [ @_ ];
9271 129 my $count = @$args;
9272 129 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 129 ▶ if (!$count || $count < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 2) 0 129 129
Condition33%1/3
not $count or $count < 2
l!l&&r!l&&!r
00129
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 129 ▶ if ($args->[0] !~ $host_re) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0] =~ /$host_re/) 0 129 129
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 129 ▶ if ($args->[2] !~ $sid_re) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[2] =~ /$sid_re/) 0 129 129
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 129 ▶ if ($self->state_sid_exists($args->[2])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_sid_exists($args->[2])) 1 128 129
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 128 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 1 127 128
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 127 ▶ my $record = {
Condition50%1/2
$args->[3] || ''
l!l
1270
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 127 ▶ if ( $record->{desc} && $record->{desc} =~ m!^\(H\) ! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"desc"} and $record->{"desc"} =~ /^\(H\) /) 1 126 127
Condition66%2/3
$record->{"desc"} and $record->{"desc"} =~ /^\(H\) /
!ll&&!rl&&r
01261
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 127 $self->{state}{sids}{ $prefix }{sids}{ $record->{sid} } = $record;
9341 127 $self->{state}{sids}{ $record->{sid} } = $record;
9342 127 my $uname = uc $record->{name};
9343 127 ▶ $record->{serv} = 1 if $self->{state}{services}{$uname};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"services"}{$uname} 42 85 127
9344 127 $self->{state}{peers}{$uname} = $record;
9345 127 $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 127 ▶ grep { $_ ne $peer_id } $self->_state_connected_peers(),
Branch: 1 branch
BranchTrueFalseTotal
$record->{'hidden'} ? : 1 126 127
9359 );
9360 $self->_send_to_realops(
9361 sprintf(
9362 'Server %s being introduced by %s',
9363 $record->{name}, $record->{peer},
9364 127 ),
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 127 );
9376 $self->send_event(
9377 'daemon_server',
9378 $record->{name},
9379 $prefix,
9380 $record->{hops},
9381 $record->{desc},
9382 127 );
9383 }
9384 129 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 129 129
9385 129 return $ref;
9386 }
9387  
9388 sub _daemon_peer_quit {
9389 5 ▶ my $self = shift;
Subroutine _daemon_peer_quit: called CC=18 SCAR=32.3
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 3 2 5
9398 2 my $full = $record->{full}->();
9399 2 my $nick = uc_irc($record->{nick});
9400 2 delete $self->{state}{users}{$nick};
9401 2 delete $self->{state}{sids}{ $record->{sid} }{users}{$nick};
9402 2 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 }
Branch: 1 branch
BranchTrueFalseTotal
not $conn_id or $_ ne $conn_id 4 0 4
9410 $self->_state_connected_peers(),
9411 2 ▶ ) if !$record->{killed};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"killed"} 2 0 2
9412  
9413 2 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 2 $record->{auth}{realhost}, $record->{ipaddress}, $qmsg,
9424 ),
9425 'Notice', 'F',
9426 );
9427  
9428 2 $self->send_event("daemon_quit", $full, $qmsg);
9429  
9430 # Remove for peoples accept lists
9431 delete $self->{state}{users}{$_}{accepts}{uc_irc($nick)}
9432 2 for keys %{ $record->{accepts} };
9433  
9434 # WATCH LOGOFF
9435 2 ▶ if ( defined $self->{state}{watches}{$nick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$nick}) 1 1 2
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 2 my $common = { };
9460 2 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 2 push @$ref, $common->{$_} for keys %$common;
9472 2 ▶ $self->{state}{stats}{ops_online}-- if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 0 2 2
9473 2 ▶ $self->{state}{stats}{invisible}-- if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 2 0 2
9474 2 delete $self->{state}{peers}{uc $record->{server}}{users}{$nick};
9475 2 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 2 };
9486 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
9487 2 return $ref;
9488 }
9489  
9490 sub _daemon_peer_uid {
9491 551 ▶ my $self = shift;
Subroutine _daemon_peer_uid: called CC=20 SCAR=30.3
9492 551 ▶ my $peer_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
5510
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
9493 551 my $prefix = shift;
9494 551 my $server = $self->server_name();
9495 551 my $mysid = $self->server_sid();
9496 551 my $ref = [ ];
9497 551 my $args = [ @_ ];
9498 551 my $count = @$args;
9499 551 ▶ 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
05456
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 551 ▶ if (!$count || $count < 9) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 9) 0 551 551
Condition33%1/3
not $count or $count < 9
l!l&&r!l&&!r
00551
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 551 ▶ if ( $self->state_nick_exists( $args->[0] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($args->[0])) 12 539 551
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"}) 5 7 12
9518 # If userhosts different, collide existing user
9519 5 ▶ if ( $incoming ne $userhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incoming ne $userhost) { } 4 1 5
9520 # Send KILL for existing user UID to all servers
9521 4 $exist->{nick_collision} = 1;
9522 4 $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"}) 6 4 10
9555 # If userhosts same, collide existing user
9556 6 ▶ if ( $incoming eq $userhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($incoming eq $userhost) { } 1 5 6
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 5 $self->send_output(
9565 {
9566 prefix => $mysid,
9567 command => 'KILL',
9568 params => [$args->[7+$rhost], 'Nick Collision'],
9569 },
9570 $peer_id,
9571 );
9572 5 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 544 ▶ my $record = {
Condition50%1/2
$$args[9 + $rhost] || ''
l!l
5440
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 $record->{full} = sub {
9600 return sprintf('%s!%s@%s',
9601 $record->{nick},
9602 $record->{auth}{ident},
9603 2551 ▶ $record->{auth}{hostname});
Subroutine __ANON__: called CC=1 SCAR=0.0
9604 544 };
9605  
9606 544 ▶ if ( $rhost ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rhost) { } 3 541 544
9607 3 $record->{auth}{realhost} = $args->[6];
9608 }
9609 else {
9610 541 $record->{auth}{realhost} = $record->{auth}{hostname};
9611 }
9612  
9613 544 my $unick = uc_irc( $args->[0] );
9614  
9615 544 $self->{state}{users}{ $unick } = $record;
9616 544 $self->{state}{uids}{ $record->{uid} } = $record;
9617 544 ▶ $self->{state}{stats}{ops_online}++ if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 236 308 544
9618 544 ▶ $self->{state}{stats}{invisible}++ if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 544 0 544
9619 544 $self->{state}{sids}{$prefix}{users}{$unick} = $record;
9620 544 $self->{state}{sids}{$prefix}{uids}{ $record->{uid} } = $record;
9621 544 $self->_state_update_stats();
9622  
9623 544 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 543 544
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 544 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 544 ),
9661 'Notice', 'F',
9662 );
9663  
9664 544 $self->send_event('daemon_uid', $prefix, @$args);
9665 544 ▶ $self->send_event('daemon_nick', @{ $args }[0..5], $record->{server}, ( $args->[9+$rhost] || '' ) );
Condition50%1/2
$$args[9 + $rhost] || ''
l!l
5440
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 551 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 551 551
9670 551 return $ref;
9671 }
9672  
9673 sub _daemon_peer_nick {
9674 2 ▶ my $self = shift;
Subroutine _daemon_peer_nick: called CC=26 SCAR=43.6
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;
Condition33%1/3
$args->[1] || time
l!l&&r!l&&!r
200
MC/DC0%0/2
$args->[1] || time
$args->[1] time
Truth table33%1/3
A || B
A= $args->[1]B= time
ABresult
1X1
011
000
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 2 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 sub _daemon_peer_part {
9885 1 ▶ my $self = shift;
Subroutine _daemon_peer_part: called CC=10 SCAR=25.5
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 sub _daemon_peer_kick {
9931 1 ▶ my $self = shift;
Subroutine _daemon_peer_kick: called CC=11 SCAR=27.2
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 sub _daemon_peer_sjoin {
9983 125 ▶ my $self = shift;
Subroutine _daemon_peer_sjoin: called CC=1 SCAR=0.0
9984 125 my $peer_id = shift;
9985 125 $self->_daemon_do_joins( $peer_id, 'SJOIN', @_ );
9986 }
9987  
9988 sub _daemon_peer_join {
9989 1 ▶ my $self = shift;
Subroutine _daemon_peer_join: called CC=1 SCAR=0.0
9990 1 my $peer_id = shift;
9991 1 $self->_daemon_do_joins( $peer_id, 'JOIN', @_ );
9992 }
9993  
9994 sub _daemon_do_joins {
9995 126 ▶ my $self = shift;
Subroutine _daemon_do_joins: called CC=95 SCAR=62.2
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 20 713 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 20 713 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 19 1254 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} 15 1258 1273
10420 1258 $chanrec->{users}{$uid} = $umode;
10421 1258 $self->{state}{uids}{$uid}{chans}{$uchan} = $umode;
10422 1258 push @op_list, $self->state_user_nick($uid) for split //, $umode;
10423 1258 my $full = $self->state_user_full($uid);
10424 1258 ▶ if ( @local_nextjoin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local_nextjoin) 20 1238 1258
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 1258 ▶ if ( @local_extjoin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local_extjoin) 0 1258 1258
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 1258 );
10449 1258 ▶ if ($umode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umode) 19 1239 1258
10450 19 $modes .= $umode;
10451 19 push @mode_parms, @op_list;
10452 }
10453 1258 ▶ if ( $self->{state}{uids}{$uid}{away} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"uids"}{$uid}{"away"}) 2 1256 1258
10454 2 push @aways, { uid => $uid, msg => $self->{state}{uids}{$uid}{away} };
10455 }
10456 }
10457 76 ▶ if ($modes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modes) 19 57 76
10458 $self->send_event(
10459 "daemon_mode",
10460 $server,
10461 $chanrec->{name},
10462 19 '+' . $modes,
10463 @mode_parms,
10464 );
10465 19 my @output_modes;
10466 19 my $length = length($server) + 4 + length($chan) + 4;
10467 19 my @buffer = ('+', '');
10468 19 for my $umode (split //, $modes) {
10469 19 my $arg = shift @mode_parms;
10470 19 ▶ if (length(join ' ', @buffer, $arg) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", @buffer, $arg) + $length > 510) 0 19 19
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 19 $buffer[0] .= $umode;
10487 19 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 19 19
10488 0 $buffer[1] = join ' ', $buffer[1], $arg;
10489 }
10490 else {
10491 19 $buffer[1] = $arg;
10492 }
10493 }
10494 push @output_modes, {
10495 prefix => $server,
10496 command => 'MODE',
10497 colonify => 0,
10498 params => [
10499 $chanrec->{name},
10500 19 $buffer[0],
10501 split /\s+/,
10502 $buffer[1],
10503 ],
10504 };
10505 $self->send_output($_, @local_users)
10506 19 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 sub _daemon_peer_tmode {
10519 0 ▶ my $self = shift;
Subroutine _daemon_peer_tmode: not called CC=58 SCAR=81.4
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 sub _daemon_peer_bmask {
10750 72 ▶ my $self = shift;
Subroutine _daemon_peer_bmask: called CC=18 SCAR=29.3
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]/ }
Branch: 1 branch
BranchTrueFalseTotal
not $mode_u_set or $chanrec->{"users"}{$_} =~ /[oh]/ 0 72 72
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) 6 303 309
10811 $arg) + $length > 510) {
10812 push @output_modes, {
10813 prefix => $server,
10814 command => 'MODE',
10815 colonify => 0,
10816 params => [
10817 $chanrec->{name},
10818 6 $buffer[0],
10819 split /\s+/,
10820 $buffer[1],
10821 ],
10822 };
10823 6 $buffer[0] = $type;
10824 6 $buffer[1] = $arg;
10825 6 next;
10826 }
10827 303 $buffer[0] = $mode_line;
10828 303 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 270 33 303
10829 270 $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 sub _daemon_peer_tburst {
10854 10 ▶ my $self = shift;
Subroutine _daemon_peer_tburst: called CC=15 SCAR=30.7
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 sub _daemon_peer_umode {
10916 0 ▶ my $self = shift;
Subroutine _daemon_peer_umode: not called CC=14 SCAR=53.5
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 sub _daemon_peer_message {
10961 7 ▶ my $self = shift;
Subroutine _daemon_peer_message: called CC=100 SCAR=72.3
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 sub _daemon_peer_topic {
11370 0 ▶ my $self = shift;
Subroutine _daemon_peer_topic: not called CC=7 SCAR=40.3
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 sub _daemon_peer_invite {
11417 1 ▶ my $self = shift;
Subroutine _daemon_peer_invite: called CC=10 SCAR=24.7
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 sub _daemon_peer_away {
11498 10 ▶ my $self = shift;
Subroutine _daemon_peer_away: called CC=5 SCAR=17.6
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 sub _daemon_peer_links {
11537 1 ▶ my $self = shift;
Subroutine _daemon_peer_links: called CC=8 SCAR=23.2
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 sub _daemon_peer_svsjoin {
11578 6 ▶ my $self = shift;
Subroutine _daemon_peer_svsjoin: called CC=13 SCAR=32.4
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 sub _daemon_peer_svspart {
11627 1 ▶ my $self = shift;
Subroutine _daemon_peer_svspart: called CC=13 SCAR=33.1
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 sub _daemon_peer_svshost {
11676 2 ▶ my $self = shift;
Subroutine _daemon_peer_svshost: called CC=12 SCAR=28.0
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 sub _daemon_peer_svsmode {
11717 29 ▶ my $self = shift;
Subroutine _daemon_peer_svsmode: called CC=42 SCAR=51.6
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 sub _daemon_peer_svsnick {
11843 3 ▶ my $self = shift;
Subroutine _daemon_peer_svsnick: called CC=32 SCAR=45.3
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 sub _daemon_peer_svskill {
12057 1 ▶ my $self = shift;
Subroutine _daemon_peer_svskill: called CC=14 SCAR=32.4
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 sub _daemon_peer_svstag {
12115 3 ▶ my $self = shift;
Subroutine _daemon_peer_svstag: called CC=15 SCAR=33.4
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 sub _state_create {
12185 182 ▶ my $self = shift;
Subroutine _state_create: called CC=2 SCAR=6.9
12186  
12187 182 $self->_state_delete();
12188  
12189 # Connection specific tables
12190 182 $self->{state}{conns} = { };
12191  
12192 # IRC State specific
12193 182 $self->{state}{users} = { };
12194 182 $self->{state}{peers} = { };
12195 182 $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 182 ts => 6,
12203 };
12204  
12205 182 ▶ if ( my $sid = $self->{config}{SID} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sid = $self->{"config"}{"SID"}) 182 0 182
12206 182 my $rec = $self->{state}{peers}{uc $self->server_name()};
12207 182 $rec->{sid} = $sid;
12208 182 $rec->{ts} = 6;
12209 182 $self->{state}{sids}{uc $sid} = $rec;
12210 182 $self->{state}{uids} = { };
12211 182 $self->{genuid} = $sid . 'AAAAAA';
12212 }
12213  
12214 $self->{state}{stats} = {
12215 182 maxconns => 0,
12216 maxlocal => 0,
12217 maxglobal => 0,
12218 ops_online => 0,
12219 invisible => 0,
12220 cmds => { },
12221 };
12222  
12223 $self->{state}{caps} = {
12224 182 '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 182 return 1;
12234 }
12235  
12236 sub _state_rand_sid {
12237 2 ▶ my $self = shift;
Subroutine _state_rand_sid: called CC=1 SCAR=0.0
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 sub _state_gen_uid {
12245 10566 ▶ my $self = shift;
Subroutine _state_gen_uid: called CC=2 SCAR=7.6
12246 10566 my $uid = $self->{genuid};
12247 10566 $self->{genuid} = _add_one_uid( $uid );
12248 10566 ▶ while ( defined $self->{state}{uids}{$uid} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"uids"}{$uid}) 0 10566 10566
12249 0 $uid = $self->{genuid};
12250 0 $self->{genuid} = _add_one_uid( $uid );
12251 }
12252 10566 return $uid;
12253 }
12254  
12255 sub _add_one_uid {
12256 10566 ▶ my $UID = shift;
Subroutine _add_one_uid: called CC=1 SCAR=0.2
12257 10566 my @cols = unpack 'a' x length $UID, $UID;
12258 10566 my ($add,$add1);
12259 $add1 = $add = sub {
12260 10858 ▶ my $idx = shift;
Subroutine __ANON__: called CC=5 SCAR=17.8
12261 10858 ▶ if ( $idx != 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx != 3) { } 10858 0 10858
12262 10858 ▶ if ( $cols[$idx] eq 'Z' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cols[$idx] eq 'Z') { } 293 10565 10858
elsif ($cols[$idx] eq '9') { } 292 10273 10565
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 10273 $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 10566 };
12282 10566 $add->(8);
12283 10566 return pack 'a' x scalar @cols, @cols;
12284 }
12285  
12286 sub _state_delete {
12287 182 ▶ my $self = shift;
Subroutine _state_delete: called CC=1 SCAR=0.0
12288 182 delete $self->{state};
12289 182 return 1;
12290 }
12291  
12292 sub _state_update_stats {
12293 808 ▶ my $self = shift;
Subroutine _state_update_stats: called CC=3 SCAR=11.0
12294 808 my $server = $self->server_name();
12295 808 my $global = keys %{ $self->{state}{users} };
12296 808 my $local = keys %{ $self->{state}{peers}{uc $server}{users} };
12297  
12298 $self->{state}{stats}{maxglobal}
12299 808 ▶ = $global if $global > $self->{state}{stats}{maxglobal};
Branch: 1 branch
BranchTrueFalseTotal
if $global > $self->{"state"}{"stats"}{"maxglobal"} 803 5 808
12300 $self->{state}{stats}{maxlocal}
12301 808 ▶ = $local if $local > $self->{state}{stats}{maxlocal};
Branch: 1 branch
BranchTrueFalseTotal
if $local > $self->{"state"}{"stats"}{"maxlocal"} 264 544 808
12302 808 return 1;
12303 }
12304  
12305 sub _state_conn_stats {
12306 519 ▶ my $self = shift;
Subroutine _state_conn_stats: called CC=2 SCAR=6.9
12307  
12308 519 $self->{state}{stats}{conns_cumlative}++;
12309 519 my $conns = keys %{ $self->{state}{conns} };
12310 $self->{state}{stats}{maxconns} = $conns
12311 519 ▶ if $conns > $self->{state}{stats}{maxconns};
Branch: 1 branch
BranchTrueFalseTotal
if $conns > $self->{"state"}{"stats"}{"maxconns"} 489 30 519
12312 519 return 1;
12313 }
12314  
12315 sub _state_cmd_stat {
12316 4081 ▶ my $self = shift;
Subroutine _state_cmd_stat: called CC=6 SCAR=17.9
12317 4081 ▶ my $cmd = shift || return;
Condition50%1/2
shift() || (return)
l!l
40810
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12318 4081 ▶ my $line = shift || return;
Condition100%2/2
shift() || (return)
l!l
3858223
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
12319 3858 my $remote = shift;
12320 3858 ▶ my $record = $self->{state}{stats}{cmds}{$cmd} || {
Condition100%2/2
$self->{'state'}{'stats'}{'cmds'}{$cmd} || {'remote', 0, 'local', 0, 'bytes', 0}
l!l
20461812
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 3858 ▶ $record->{local}++ if !$remote;
Branch: 1 branch
BranchTrueFalseTotal
unless $remote 1973 1885 3858
12327 3858 ▶ $record->{remote}++ if $remote;
Branch: 1 branch
BranchTrueFalseTotal
if $remote 1885 1973 3858
12328 3858 $record->{bytes} += length $line;
12329 3858 $self->{state}{stats}{cmds}{$cmd} = $record;
12330 3858 return 1;
12331 }
12332  
12333 sub _state_find_user_host {
12334 0 ▶ my $self = shift;
Subroutine _state_find_user_host: not called CC=6 SCAR=37.4
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 sub _state_add_drkx_line {
12350 26 ▶ my $self = shift;
Subroutine _state_add_drkx_line: called CC=12 SCAR=25.5
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 sub _state_del_drkx_line {
12390 15 ▶ my $self = shift;
Subroutine _state_del_drkx_line: called CC=17 SCAR=30.2
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 179 my %drkxlines = (
12433 'rklines' => 'RK-Line',
12434 'klines' => 'K-Line',
12435 'dlines' => 'D-Line',
12436 'xlines' => 'X-Line',
12437 'resvs' => 'RESV',
12438 );
12439  
12440 sub _state_drkx_line_alarm {
12441 9 ▶ my ($kernel,$self,$type,$ref) = @_[KERNEL,OBJECT,ARG0,ARG1];
Subroutine _state_drkx_line_alarm: called CC=7 SCAR=19.6
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 179 sub _state_is_resv {
12469 382 ▶ my $self = shift;
Subroutine _state_is_resv: called CC=8 SCAR=20.8
12470 382 ▶ my $thing = 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
12471 382 my $conn_id = shift;
12472 382 ▶ if ($conn_id && !$self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn_id and not $self->_connection_exists($conn_id)) 1 381 382
Condition66%2/3
$conn_id and not $self->_connection_exists($conn_id)
!ll&&!rl&&r
03811
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 382 ▶ 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 381 382
Condition100%3/3
$conn_id and $self->{"state"}{"conns"}{$conn_id}{"resv_exempt"}
!ll&&!rl&&r
13801
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 381 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 374 return 0;
12484 }
12485  
12486 sub _state_have_resv {
12487 8 ▶ my $self = shift;
Subroutine _state_have_resv: called CC=3 SCAR=11.4
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 sub _state_do_away_notify {
12494 18 ▶ my $self = shift;
Subroutine _state_do_away_notify: called CC=11 SCAR=24.0
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 sub _state_do_local_users_match_xline {
12526 5 ▶ my $self = shift;
Subroutine _state_do_local_users_match_xline: called CC=8 SCAR=28.3
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 sub _state_do_local_users_match_dline {
12555 5 ▶ my $self = shift;
Subroutine _state_do_local_users_match_dline: called CC=7 SCAR=24.6
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 sub _state_do_local_users_match_rkline {
12584 2 ▶ my $self = shift;
Subroutine _state_do_local_users_match_rkline: called CC=11 SCAR=36.1
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 sub _state_do_local_users_match_kline {
12616 6 ▶ my $self = shift;
Subroutine _state_do_local_users_match_kline: called CC=18 SCAR=49.6
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 sub _state_user_matches_rkline {
12672 225 ▶ my $self = shift;
Subroutine _state_user_matches_rkline: called CC=9 SCAR=23.2
12673 225 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2250
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12674 225 my $record = $self->{state}{conns}{$conn_id};
12675 225 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition66%2/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
12240
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 225 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition100%2/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
1224
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 225 my $ip = $record->{socket}[0];
12678  
12679 225 ▶ return 0 if $record->{kline_exempt};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kline_exempt"} 1 224 225
12680  
12681 224 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 222 return 0;
12688 }
12689  
12690 sub _state_user_matches_kline {
12691 230 ▶ my $self = shift;
Subroutine _state_user_matches_kline: called CC=12 SCAR=30.4
12692 230 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2300
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12693 230 my $record = $self->{state}{conns}{$conn_id};
12694 230 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition66%2/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
12290
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 230 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition100%2/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
1229
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 230 my $ip = $record->{socket}[0];
12697  
12698 230 ▶ return 0 if $record->{kline_exempt};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kline_exempt"} 1 229 230
12699  
12700 229 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 224 return 0;
12715 }
12716  
12717 sub _state_user_matches_xline {
12718 235 ▶ my $self = shift;
Subroutine _state_user_matches_xline: called CC=5 SCAR=16.5
12719 235 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2350
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12720 235 my $record = $self->{state}{conns}{$conn_id};
12721 235 ▶ my $ircname = $record->{ircname} || return;
Condition50%1/2
$record->{'ircname'} || (return)
l!l
2350
MC/DC0%0/1
$record->{'ircname'} || (return)
$record->{'ircname'}
Truth table50%1/2
A
A= $record->{'ircname'}
Aresult
11
00
12722  
12723 235 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 230 return 0;
12730 }
12731  
12732 sub _state_auth_client_conn {
12733 241 ▶ my $self = shift;
Subroutine _state_auth_client_conn: called CC=17 SCAR=28.4
12734 241 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2410
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12735  
12736 241 ▶ if (!$self->{config}{auth} || !@{ $self->{config}{auth} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}) 231 10 241
Condition66%2/3
$self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}
!ll&&!rl&&r
231010
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 231 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 sub _state_auth_peer_conn {
12778 255 ▶ my $self = shift;
Subroutine _state_auth_peer_conn: called CC=20 SCAR=38.7
12779 255 my ($conn_id, $name, $pass) = @_;
12780  
12781 255 ▶ if (!$conn_id || !$self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn_id and $self->_connection_exists($conn_id)) 0 255 255
Condition33%1/3
$conn_id and $self->_connection_exists($conn_id)
!ll&&!rl&&r
00255
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 255 ▶ return 0 if !$name || !$pass;
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $pass 0 255 255
Condition33%1/3
$name and $pass
!ll&&!rl&&r
00255
MC/DC0%0/2
$name and $pass
$name $pass
Truth table33%1/3
A and B
A= $nameB= $pass
ABresult
0X0
100
111
12786 255 my $peers = $self->{config}{peers};
12787 255 ▶ return 0 if !$peers->{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $$peers{uc $name} 0 255 255
12788 255 my $peer = $peers->{uc $name};
12789 255 ▶ return -1 if !chkpasswd($pass,$peer->{pass});
Branch: 1 branch
BranchTrueFalseTotal
unless chkpasswd($pass, $peer->{"pass"}) 1 254 255
12790  
12791 254 my $conn = $self->{state}{conns}{$conn_id};
12792  
12793 254 ▶ if ($peer->{certfp} && $conn->{secured}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer->{"certfp"} and $conn->{"secured"}) 4 250 254
Condition66%2/3
$peer->{"certfp"} and $conn->{"secured"}
!ll&&!rl&&r
25004
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 253 ▶ if (!$peer->{ipmask} && $conn->{socket}[0] =~ /^(127\.|::1)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $peer->{"ipmask"} and $conn->{"socket"}[0] =~ /^(127\.|::1)/) 250 3 253
Condition66%2/3
not $peer->{"ipmask"} and $conn->{"socket"}[0] =~ /^(127\.|::1)/
!ll&&!rl&&r
30250
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 250 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 179 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 sub _state_auth_flags_notices {
12832 223 ▶ my $self = shift;
Subroutine _state_auth_flags_notices: called CC=6 SCAR=18.0
12833 223 ▶ my $conn_id = 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
12834 223 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 223 223
12835 223 my $server = $self->server_name();
12836 223 my $crec = $self->{state}{conns}{$conn_id};
12837 223 my $nick = $crec->{nick};
12838  
12839 223 foreach my $feat ( qw(kline_exempt resv_exempt exceed_limit can_flood) ) {
12840 892 ▶ next if !$crec->{$feat};
Branch: 1 branch
BranchTrueFalseTotal
unless $crec->{$feat} 888 4 892
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 223 return 1;
12852 }
12853  
12854 }
12855  
12856 179 sub _state_send_credentials {
12857 253 ▶ my $self = shift;
Subroutine _state_send_credentials: called CC=9 SCAR=22.4
12858 253 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12859 253 ▶ my $name = shift || return;
Condition50%1/2
shift() || (return)
l!l
2530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12860 253 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 253 253
12861 253 ▶ return if !$self->{config}{peers}{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"config"}{"peers"}{uc $name} 0 253 253
12862 253 ▶ return if $self->_connection_terminated($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_terminated($conn_id) 0 253 253
12863  
12864 253 my $peer = $self->{config}{peers}{uc $name};
12865 253 my $rec = $self->{state}{peers}{uc $self->server_name()};
12866 253 my $sid = $rec->{sid};
12867  
12868 $self->send_output(
12869 {
12870 command => 'PASS',
12871 253 ▶ params => [$peer->{rpass}, 'TS', ( $sid ? ( 6 => $sid ) : () )],
Branch: 1 branch
BranchTrueFalseTotal
$sid ? : 253 0 253
12872 },
12873 $conn_id,
12874 );
12875  
12876 $self->send_output(
12877 {
12878 command => 'CAPAB',
12879 params => [
12880 253 ▶ join (' ', @{ $self->{config}{capab} },
Branch: 1 branch
BranchTrueFalseTotal
$peer->{'zip'} ? : 249 4 253
12881 253 ($peer->{zip} ? 'ZIP' : ())
12882 ),
12883 ],
12884 },
12885 $conn_id,
12886 );
12887  
12888 253 my $desc = '';
12889 253 ▶ $desc = '(H) ' if $self->{config}{hidden};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"config"}{"hidden"} 2 251 253
12890 253 $desc .= $rec->{desc};
12891  
12892 $self->send_output(
12893 {
12894 command => 'SERVER',
12895 params => [
12896 $rec->{name},
12897 253 $rec->{hops} + 1,
12898 $desc,
12899 ],
12900 },
12901 $conn_id,
12902 );
12903  
12904 253 $self->send_output(
12905 {
12906 command => 'SVINFO',
12907 params => [6, 6, 0, time],
12908 },
12909 $conn_id,
12910 );
12911  
12912 253 $self->{state}{conns}{$conn_id}{zip} = $peer->{zip};
12913 253 return 1;
12914 }
12915  
12916 sub _state_send_burst {
12917 253 ▶ my $self = shift;
Subroutine _state_send_burst: called CC=32 SCAR=34.8
12918 253 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
12919 253 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 253 253
12920 253 ▶ return if $self->_connection_terminated($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_terminated($conn_id) 0 253 253
12921 253 my $server = $self->server_name();
12922 253 my $sid = $self->server_sid();
12923 253 my $conn = $self->{state}{conns}{$conn_id};
12924 253 my $burst = grep { /^EOB$/i } @{ $conn->{capab} };
12925 253 my $invex = grep { /^IE$/i } @{ $conn->{capab} };
12926 253 my $excepts = grep { /^EX$/i } @{ $conn->{capab} };
12927 253 my $tburst = grep { /^TBURST$/i } @{ $conn->{capab} };
12928 253 my $rhost = grep { /^RHOST$/i } @{ $conn->{capab} };
12929 253 ▶ $rhost = ( $self->_state_our_capab('RHOST') && $rhost );
Condition66%2/3
$self->_state_our_capab('RHOST') && $rhost
!ll&&!rl&&r
02476
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 253 my %map = qw(bans b excepts e invex I);
12931 253 my @lists = qw(bans);
12932 253 ▶ push @lists, 'excepts' if $excepts;
Branch: 1 branch
BranchTrueFalseTotal
if $excepts 247 6 253
12933 253 ▶ push @lists, 'invex' if $invex;
Branch: 1 branch
BranchTrueFalseTotal
if $invex 247 6 253
12934  
12935 # Send SERVER burst
12936 253 my %eobs;
12937 253 for ($self->_state_server_burst($sid, $conn->{sid})) {
12938 183 $eobs{ $_->{prefix} }++;
12939 183 $self->send_output($_, $conn_id );
12940 }
12941  
12942 # Send NICK burst
12943 253 for my $uid (keys %{ $self->{state}{uids} }) {
12944 322 my $record = $self->{state}{uids}{$uid};
12945 322 ▶ next if $record->{route_id} eq $conn_id;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"route_id"} eq $conn_id 0 322 322
12946  
12947 322 my $umode_fixed = $record->{umode};
12948 322 $umode_fixed =~ s/[^aiow]//g;
12949 322 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 322 ];
12958 322 ▶ push @$arrayref, $record->{auth}{realhost} if $rhost;
Branch: 1 branch
BranchTrueFalseTotal
if $rhost 6 316 322
12959 push @$arrayref, ( $record->{ipaddress} || 0 ),
12960 322 ▶ $record->{uid}, $record->{account}, $record->{ircname};
Condition100%2/2
$record->{'ipaddress'} || 0
l!l
28294
MC/DC100%1/1
$record->{'ipaddress'} || 0
$record->{'ipaddress'}
Truth table100%2/2
A
A= $record->{'ipaddress'}
Aresult
11
00
12961 322 my @uid_burst = (
12962 {
12963 prefix => $prefix,
12964 command => 'UID',
12965 params => $arrayref,
12966 },
12967 );
12968 322 ▶ if ( $record->{away} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"away"}) 8 314 322
12969 push @uid_burst, {
12970 prefix => $record->{uid},
12971 command => 'AWAY',
12972 8 params => [ $record->{away} ],
12973 };
12974 }
12975 322 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 322 $self->send_output( $_, $conn_id ) for @uid_burst;
12989 }
12990  
12991 # Send SJOIN+MODE burst
12992 253 for my $chan (keys %{ $self->{state}{chans} }) {
12993 55 ▶ next if $chan =~ /^\&/;
Branch: 1 branch
BranchTrueFalseTotal
if $chan =~ /^\&/ 0 55 55
12994 55 my $chanrec = $self->{state}{chans}{$chan};
12995 1017 my @uids = map { $_->[1] }
12996 4522 sort { $a->[0] cmp $b->[0] }
12997 55 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 55 ▶ ($chanrec->{climit} || ()),
Condition50%3/6
$chanrec->{'ckey'} || ()
l!l&&r!l&&!r
0550
$chanrec->{'climit'} || ()
l!l&&r!l&&!r
1540
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 55 my $length = length( join ' ', @$chanref ) + 11;
13009 55 my $buf = '';
13010 55 UID: foreach my $uid ( @uids ) {
13011 1017 ▶ if (length(join ' ', $buf, '1', $uid)+$length+1 > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buf, 1, $uid) + $length + 1 > 510) 11 1006 1017
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 1006 $buf = join ' ', $buf, $uid;
13024 1006 $buf =~ s!^\s+!!;
13025 }
13026 55 ▶ if ($buf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf) 55 0 55
13027 55 $self->send_output(
13028 {
13029 prefix => $sid,
13030 command => 'SJOIN',
13031 params => [ @$chanref, $buf ],
13032 },
13033 $conn_id,
13034 );
13035 }
13036  
13037 55 my @output_modes;
13038 55 OUTER: for my $type (@lists) {
13039 165 my $length = length($sid) + 5 + length($chan) + 4 + length($chanrec->{ts}) + 2;
13040 165 my @buffer = ( '', '' );
13041 165 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 165 ▶ $map{$type},
Branch: 1 branch
BranchTrueFalseTotal
if $buffer[1] 9 156 165
13079 $buffer[1],
13080 ],
13081 } if $buffer[1];
13082 }
13083 55 $self->send_output($_, $conn_id) for @output_modes;
13084  
13085 55 ▶ if ( $tburst && $chanrec->{topic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tburst and $chanrec->{"topic"}) 8 47 55
Condition66%2/3
$tburst and $chanrec->{"topic"}
!ll&&!rl&&r
0478
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 253 ▶ if ( $burst ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($burst) 253 0 253
13105 253 $self->send_output(
13106 {
13107 prefix => $sid,
13108 command => 'EOB',
13109 },
13110 $conn_id,
13111 );
13112 253 delete $eobs{$sid};
13113 $self->send_output(
13114 {
13115 prefix => $_,
13116 command => 'EOB',
13117 },
13118 $conn_id,
13119 253 ) for keys %eobs;
13120 }
13121  
13122 253 return 1;
13123 }
13124  
13125 sub _state_server_burst {
13126 436 ▶ my $self = shift;
Subroutine _state_server_burst: called CC=10 SCAR=24.1
13127 436 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
4360
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13128 436 ▶ my $targ = shift || return;
Condition50%1/2
shift() || (return)
l!l
4360
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13129 436 ▶ if (!$self->state_peer_exists( $peer )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_peer_exists($peer) and $self->state_peer_exists($targ)) 436 0 436
Condition33%1/3
$self->state_peer_exists($peer) and $self->state_peer_exists($targ)
!ll&&!rl&&r
43600
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 436 my $ref = [ ];
13134  
13135 436 for my $server (keys %{ $self->{state}{sids}{$peer}{sids} }) {
13136 436 ▶ next if $server eq $targ;
Branch: 1 branch
BranchTrueFalseTotal
if $server eq $targ 253 183 436
13137 183 my $rec = $self->{state}{sids}{$server};
13138 183 my $desc = '';
13139 183 ▶ $desc = '(H) ' if $rec->{hidden};
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"hidden"} 1 182 183
13140 183 $desc .= $rec->{desc};
13141 push @$ref, {
13142 prefix => $peer,
13143 command => 'SID',
13144 183 params => [$rec->{name}, $rec->{hops} + 1, $server, $desc],
13145 };
13146 183 push @$ref, $_ for $self->_state_server_burst($rec->{sid}, $targ);
13147 }
13148  
13149 436 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 436 0 436
13150 0 return $ref;
13151 }
13152  
13153 sub _state_do_change_hostmask {
13154 6 ▶ my $self = shift;
Subroutine _state_do_change_hostmask: called CC=14 SCAR=27.3
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 sub _state_do_map {
13278 14 ▶ my $self = shift;
Subroutine _state_do_map: called CC=12 SCAR=25.4
13279 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
13280 14 ▶ my $psid = 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
13281 14 my $plen = shift;
13282 14 my $ctn = shift;
13283 14 my $ref = [ ];
13284 14 ▶ return if !$self->state_sid_exists($psid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($psid) 0 14 14
13285 14 my $rec = $self->{state}{sids}{$psid};
13286  
13287 SWITCH: {
13288 14 my $global = scalar keys %{ $self->{state}{uids} };
13289 14 my $local = scalar keys %{ $rec->{uids} };
13290 14 my $suffix = sprintf(" | Users: %5d (%1.2f%%)", $local, ( 100 * $local / $global ) );
13291  
13292 14 my $prompt = ' ' x $plen;
13293 14 ▶ substr $prompt, -2, 2, '|-' if $plen;
Branch: 1 branch
BranchTrueFalseTotal
if $plen 12 2 14
13294 14 ▶ substr $prompt, -2, 2, '`-' if !$ctn && $plen;
Branch: 1 branch
BranchTrueFalseTotal
if not $ctn and $plen 10 4 14
Condition100%3/3
not $ctn and $plen
!ll&&!rl&&r
2210
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
13295 14 my $buffer = $rec->{name} . ' ';
13296 14 $buffer .= '-' x ( 64 - length($buffer) - length($prompt) );
13297 14 $buffer .= $suffix;
13298  
13299 14 ▶ if ( $plen && $plen > 60 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plen and $plen > 60) 0 14 14
Condition66%2/3
$plen and $plen > 60
!ll&&!rl&&r
2120
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
13300 push @$ref, {
13301 prefix => $self->server_name(),
13302 command => '016',
13303 params => [
13304 $nick,
13305 join '', $prompt, $rec->{name}
13306 0 ],
13307 };
13308 0 last SWITCH;
13309 }
13310  
13311 14 push @$ref, {
13312 prefix => $self->server_name(),
13313 command => '015',
13314 params => [
13315 $nick,
13316 join '', $prompt, $buffer
13317 ],
13318 };
13319 14 my $sids = $self->{state}{sids}{$psid}{sids};
13320 14 my $cnt = keys %$sids;
13321 14 foreach my $server (sort { keys %{ $sids->{$a}{sids} } <=> keys %{ $sids->{$b}{sids} } } keys %$sids) {
13322 12 push @$ref, $_ for $self->_state_do_map( $nick, $server, $plen + 2, --$cnt );
13323 }
13324 }
13325  
13326 14 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 14 0 14
13327 0 return $ref;
13328 }
13329  
13330 sub _state_sid_links {
13331 20 ▶ my $self = shift;
Subroutine _state_sid_links: called CC=10 SCAR=23.6
13332 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
13333 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
13334 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
13335 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
13336 20 ▶ return if !$self->state_sid_exists($psid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($psid) 0 20 20
13337  
13338 20 my $ref = [ ];
13339 20 my $peer = $self->_state_sid_name($psid);
13340  
13341 20 my $sids = $self->{state}{sids}{$psid}{sids};
13342 20 for my $server (sort { keys %{ $sids->{$b}{sids} } <=> keys %{ $sids->{$a}{sids} } } keys %$sids) {
13343 15 my $rec = $self->{state}{sids}{$server};
13344 15 for ($self->_state_sid_links($server, $orig, $nick)) {
13345 5 push @$ref, $_;
13346 }
13347 push @$ref, {
13348 prefix => $orig,
13349 command => '364',
13350 params => [
13351 $nick,
13352 $rec->{name},
13353 $peer,
13354 join( ' ', $rec->{hops}, $rec->{desc}),
13355 ],
13356 15 ▶ } if matches_mask($mask, $rec->{name});
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($mask, $rec->{"name"}) 13 2 15
13357 }
13358  
13359 20 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 20 0 20
13360 0 return $ref;
13361 }
13362  
13363 sub _state_peer_for_peer {
13364 0 ▶ my $self = shift;
Subroutine _state_peer_for_peer: not called CC=3 SCAR=24.8
13365 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
13366 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
13367 0 $peer = uc $peer;
13368 0 return $self->{state}{peers}{$peer}{peer};
13369 }
13370  
13371 sub _state_server_squit {
13372 339 ▶ my $self = shift;
Subroutine _state_server_squit: called CC=8 SCAR=20.9
13373 339 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
3390
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13374 339 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 1 338 339
13375 338 my $ref = [ ];
13376 338 push @$ref, $_ for keys %{ $self->{state}{sids}{$sid}{uids} };
13377  
13378 338 for my $psid (keys %{ $self->{state}{sids}{$sid}{sids} }) {
13379 115 push @$ref, $_ for $self->_state_server_squit($psid);
13380 }
13381  
13382 338 my $rec = delete $self->{state}{sids}{$sid};
13383 338 my $upeer = uc $rec->{name};
13384 338 my $me = uc $self->server_name();
13385 338 my $mysid = $self->server_sid();
13386  
13387 $self->_send_to_realops(
13388 sprintf(
13389 'Server %s split from %s',
13390 $rec->{name},
13391 $self->{state}{sids}{ $rec->{psid} }{name},
13392 ), qw[Notice e],
13393 338 ▶ ) if $mysid ne $rec->{psid};
Branch: 1 branch
BranchTrueFalseTotal
if $mysid ne $rec->{"psid"} 115 223 338
13394  
13395 338 delete $self->{state}{peers}{$upeer};
13396 338 delete $self->{state}{peers}{$me}{peers}{$upeer};
13397 338 delete $self->{state}{peers}{$me}{sids}{$sid};
13398 338 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 338 0 338
13399 0 return $ref;
13400 }
13401  
13402 sub _state_register_peer {
13403 253 ▶ my $self = shift;
Subroutine _state_register_peer: called CC=8 SCAR=20.8
13404 253 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
2530
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13405 253 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 253 253
13406 253 my $server = $self->server_name();
13407 253 my $mysid = $self->server_sid();
13408 253 my $record = $self->{state}{conns}{$conn_id};
13409 253 my $psid = $record->{ts_data}[1];
13410 253 ▶ return if !$psid;
Branch: 1 branch
BranchTrueFalseTotal
unless $psid 0 253 253
13411  
13412 253 ▶ if (!$record->{cntr}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"cntr"}) 250 3 253
13413 250 $self->_state_send_credentials($conn_id, $record->{name});
13414 }
13415  
13416 253 $record->{burst} = $record->{registered} = 1;
13417 253 $record->{conn_time} = time;
13418 253 $record->{type} = 'p';
13419 253 $record->{route_id} = $conn_id;
13420 253 $record->{peer} = $server;
13421 253 $record->{psid} = $mysid;
13422 253 $record->{users} = { };
13423 253 $record->{peers} = { };
13424 253 $record->{sid} = $psid;
13425 253 my $ucname = uc $record->{name};
13426 253 ▶ $record->{serv} = 1 if $self->{state}{services}{$ucname};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"services"}{$ucname} 3 250 253
13427 253 $self->{state}{peers}{uc $server}{peers}{ $ucname } = $record;
13428 253 $self->{state}{peers}{ $ucname } = $record;
13429 253 $self->{state}{sids}{ $mysid }{sids}{ $psid } = $record;
13430 253 $self->{state}{sids}{ $psid } = $record;
13431 253 $self->antiflood($conn_id, 0);
13432  
13433 253 ▶ if (my $sslinfo = $self->connection_secured($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sslinfo = $self->connection_secured($conn_id)) { } 6 247 253
13434 $self->_send_to_realops(
13435 sprintf(
13436 'Link with %s[unknown@%s] established: [TLS: %s] (Capabilities: %s)',
13437 6 $record->{name}, $record->{socket}[0], $sslinfo, join(' ', @{ $record->{capab} }),
13438 ),
13439 'Notice',
13440 's',
13441 );
13442 }
13443 else {
13444 $self->_send_to_realops(
13445 sprintf(
13446 'Link with %s[unknown@%s] established: (Capabilities: %s)',
13447 247 $record->{name}, $record->{socket}[0], join(' ', @{ $record->{capab} }),
13448 ),
13449 'Notice',
13450 's',
13451 );
13452 }
13453  
13454 $self->send_output(
13455 {
13456 prefix => $mysid,
13457 command => 'SID',
13458 params => [
13459 $record->{name},
13460 $record->{hops} + 1,
13461 $psid,
13462 ( $record->{hidden} ? '(H) ' : '' ) .
13463 $record->{desc},
13464 ],
13465 },
13466 253 ▶ grep { $_ ne $conn_id } $self->_state_connected_peers(),
Branch: 1 branch
BranchTrueFalseTotal
$record->{'hidden'} ? : 0 253 253
13467 );
13468  
13469 $self->send_event(
13470 'daemon_sid',
13471 $record->{name},
13472 $mysid,
13473 $record->{hops},
13474 $psid,
13475 $record->{desc},
13476 253 );
13477 $self->send_event(
13478 'daemon_server',
13479 $record->{name},
13480 $server,
13481 $record->{hops},
13482 $record->{desc},
13483 253 );
13484  
13485 253 return 1;
13486 }
13487  
13488 sub _state_register_client {
13489 223 ▶ my $self = shift;
Subroutine _state_register_client: called CC=20 SCAR=30.5
13490 223 ▶ my $conn_id = 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
13491 223 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 223 223
13492  
13493 223 my $record = $self->{state}{conns}{$conn_id};
13494 223 $record->{ts} = $record->{idle_time} = $record->{conn_time} = time;
13495 223 $record->{_ignore_i_umode} = 1;
13496 223 $record->{server} = $self->server_name();
13497 223 $record->{hops} = 0;
13498 223 $record->{route_id} = $conn_id;
13499 223 $record->{umode} = '';
13500  
13501  
13502 223 $record->{uid} = $self->_state_gen_uid();
13503 223 $record->{sid} = substr $record->{uid}, 0, 3;
13504  
13505 223 ▶ if (!$record->{auth}{ident}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"auth"}{"ident"}) 222 1 223
13506 222 $record->{auth}{ident} = '~' . $record->{user};
13507 }
13508  
13509 223 ▶ 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)/) 222 1 223
Condition66%4/6
$record->{"auth"}{"hostname"} eq "localhost" or not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^(127\.|::1)/
l!l&&r!l&&!r
02221
not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^(127\.|::1)/
!ll&&!rl&&r
10222
MC/DC0%0/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 table25%1/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
13510 !$record->{auth}{hostname} && $record->{socket}[0] =~ /^(127\.|::1)/) {
13511 222 $record->{auth}{hostname} = $self->server_name();
13512 }
13513  
13514 223 ▶ if (!$record->{auth}{hostname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"auth"}{"hostname"}) 0 223 223
13515 0 $record->{auth}{hostname} = $record->{socket}[0];
13516 }
13517  
13518 223 $record->{auth}{realhost} = $record->{auth}{hostname};
13519  
13520 223 $record->{account} = '*';
13521  
13522 223 $record->{ipaddress} = $record->{socket}[0]; # Needed later for UID command
13523 223 ▶ $record->{ipaddress} = '0' if $record->{ipaddress} =~ m!^:!;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"ipaddress"} =~ /^:/ 1 222 223
13524  
13525 223 my $unick = uc_irc $record->{nick};
13526 223 my $ucserver = uc $record->{server};
13527 223 $self->{state}{users}{$unick} = $record;
13528 223 ▶ $self->{state}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 223 0 223
13529 223 $self->{state}{peers}{$ucserver}{users}{$unick} = $record;
13530 223 ▶ $self->{state}{peers}{$ucserver}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 223 0 223
13531  
13532 $record->{full} = sub {
13533 return sprintf('%s!%s@%s',
13534 $record->{nick},
13535 $record->{auth}{ident},
13536 883 ▶ $record->{auth}{hostname});
Subroutine __ANON__: called CC=1 SCAR=0.0
13537 223 };
13538  
13539 223 my $umode = '+i';
13540 223 ▶ if ( $record->{secured} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"secured"}) 5 218 223
13541 5 $umode .= 'S';
13542 5 $record->{umode} = 'S';
13543 5 ▶ if (my $certfp = $self->connection_certfp($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $certfp = $self->connection_certfp($conn_id)) 5 0 5
13544 5 $record->{certfp} = $certfp;
13545 }
13546 }
13547  
13548 my $arrayref = [
13549 $record->{nick},
13550 $record->{hops} + 1,
13551 $record->{ts}, $umode,
13552 $record->{auth}{ident},
13553 $record->{auth}{hostname},
13554 $record->{ipaddress},
13555 $record->{uid},
13556 $record->{account},
13557 $record->{ircname},
13558 223 ];
13559  
13560 my $rhostref = [
13561 $record->{nick},
13562 $record->{hops} + 1,
13563 $record->{ts}, $umode,
13564 $record->{auth}{ident},
13565 $record->{auth}{hostname},
13566 $record->{auth}{realhost},
13567 $record->{ipaddress},
13568 $record->{uid},
13569 $record->{account},
13570 $record->{ircname},
13571 223 ];
13572  
13573 223 delete $self->{state}{pending}{uc_irc($record->{nick})};
13574  
13575 223 foreach my $peer_id ( $self->_state_connected_peers() ) {
13576 324 ▶ if ( $self->_state_peer_capab( $peer_id, 'RHOST' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_peer_capab($peer_id, 'RHOST')) { } 0 324 324
13577 $self->send_output(
13578 {
13579 prefix => $record->{sid},
13580 0 command => 'UID',
13581 params => $rhostref,
13582 },
13583 $peer_id,
13584 );
13585 }
13586 else {
13587 $self->send_output(
13588 {
13589 prefix => $record->{sid},
13590 324 command => 'UID',
13591 params => $arrayref,
13592 },
13593 $peer_id,
13594 );
13595 }
13596 324 ▶ if ($record->{certfp}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"certfp"}) 8 316 324
13597 $self->send_output(
13598 {
13599 prefix => $record->{uid},
13600 command => 'CERTFP',
13601 8 params => [ $record->{certfp} ],
13602 colonify => 0,
13603 },
13604 $peer_id,
13605 );
13606 }
13607 }
13608  
13609 $self->_send_to_realops(
13610 sprintf(
13611 'Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>',
13612 223 @{ $rhostref }[0,4,6], $record->{socket}[0],
13613 'users', $record->{ircname}, $record->{uid},
13614 223 ),
13615 'Notice',
13616 'c',
13617 );
13618  
13619 223 $self->send_event('daemon_uid', @$arrayref);
13620 223 ▶ $self->send_event('daemon_nick', @{ $arrayref }[0..5], $record->{server}, ( $arrayref->[9] || '' ) );
Condition50%1/2
$arrayref->[9] || ''
l!l
2230
MC/DC0%0/1
$arrayref->[9] || ''
$arrayref->[9]
Truth table50%1/2
A
A= $arrayref->[9]
Aresult
11
00
13621 223 $self->_state_update_stats();
13622  
13623 223 ▶ if ( defined $self->{state}{watches}{$unick} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"state"}{"watches"}{$unick}) 1 222 223
13624 1 foreach my $wuid ( keys %{ $self->{state}{watches}{$unick}{uids} } ) {
13625 1 ▶ next if !defined $self->{state}{uids}{$wuid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"uids"}{$wuid} 0 1 1
13626 1 my $wrec = $self->{state}{uids}{$wuid};
13627 $self->send_output(
13628 {
13629 prefix => $record->{server},
13630 command => '600',
13631 params => [
13632 $wrec->{nick},
13633 $record->{nick},
13634 $record->{auth}{ident},
13635 $record->{auth}{hostname},
13636 $record->{ts},
13637 'logged online',
13638 ],
13639 },
13640 $wrec->{route_id},
13641 1 );
13642 }
13643 }
13644 223 return $record->{uid};
13645 }
13646  
13647 sub state_nicks {
13648 0 ▶ my $self = shift;
Subroutine state_nicks: not called CC=1 SCAR=6.9
Pod documented
13649 0 return map { $self->{state}{users}{$_}{nick} }
13650 0 keys %{ $self->{state}{users} };
13651 }
13652  
13653 sub state_nick_exists {
13654 4113 ▶ my $self = shift;
Subroutine state_nick_exists: called CC=4 SCAR=13.9
Pod documented
13655 4113 ▶ my $nick = shift || return 1;
Condition50%1/2
shift() || (return 1)
l!l
41130
MC/DC0%0/1
shift() || (return 1)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13656 4113 $nick = uc_irc($nick);
13657  
13658 4113 ▶ if (!defined $self->{state}{users}{$nick}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}) 917 3196 4113
Condition100%3/3
defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}
l!l&&r!l&&!r
31951917
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
13659 && !defined $self->{state}{pending}{$nick}) {
13660 917 return 0;
13661 }
13662 3196 return 1;
13663 }
13664  
13665 sub state_uid_exists {
13666 6628 ▶ my $self = shift;
Subroutine state_uid_exists: called CC=3 SCAR=11.0
Pod undocumented
13667 6628 ▶ my $uid = shift || return 1;
Condition50%1/2
shift() || (return 1)
l!l
66280
MC/DC0%0/1
shift() || (return 1)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13668 6628 ▶ return 1 if defined $self->{state}{uids}{$uid};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"state"}{"uids"}{$uid} 6616 12 6628
13669 12 return 0;
13670 }
13671  
13672 sub state_chans {
13673 0 ▶ my $self = shift;
Subroutine state_chans: not called CC=1 SCAR=6.9
Pod documented
13674 0 return map { $self->{state}{chans}{$_}{name} }
13675 0 keys %{ $self->{state}{chans} };
13676 }
13677  
13678 sub state_chan_exists {
13679 1850 ▶ my $self = shift;
Subroutine state_chan_exists: called CC=3 SCAR=11.0
Pod documented
13680 1850 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
18500
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13681 1850 ▶ return 0 if !defined $self->{state}{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"chans"}{uc_irc($chan)} 105 1745 1850
13682 1745 return 1;
13683 }
13684  
13685 sub state_peers {
13686 0 ▶ my $self = shift;
Subroutine state_peers: not called CC=1 SCAR=6.9
Pod documented
13687 0 return map { $self->{state}{peers}{$_}{name} }
13688 0 keys %{ $self->{state}{peers} };
13689 }
13690  
13691 sub state_peer_exists {
13692 871 ▶ my $self = shift;
Subroutine state_peer_exists: called CC=3 SCAR=11.0
Pod documented
13693 871 ▶ my $peer = shift || return;
Condition50%1/2
shift() || (return)
l!l
8710
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13694 871 ▶ return 0 if !defined $self->{state}{peers}{uc $peer};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"peers"}{uc $peer} 822 49 871
13695 49 return 1;
13696 }
13697  
13698 sub state_sid_exists {
13699 2437 ▶ my $self = shift;
Subroutine state_sid_exists: called CC=3 SCAR=11.0
Pod undocumented
13700 2437 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
24370
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13701 2437 ▶ return 0 if !defined $self->{state}{sids}{ $sid };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"sids"}{$sid} 393 2044 2437
13702 2044 return 1;
13703 }
13704  
13705 sub state_check_joinflood_warning {
13706 51 ▶ my $self = shift;
Subroutine state_check_joinflood_warning: called CC=11 SCAR=31.4
Pod undocumented
13707 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
13708 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
13709 51 my $joincount = $self->{config}{joinfloodcount};
13710 51 my $jointime = $self->{config}{joinfloodtime};
13711 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
13712 51 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 51 51
13713 51 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 51 51
13714 51 my $crec = $self->{state}{chans}{uc_irc $chan};
13715 51 $crec->{_num_joined}++;
13716 51 ▶ $crec->{_num_joined} -= ( time - ( $self->{_last_joined} || time ) ) *
Condition33%1/3
$self->{'_last_joined'} || time
l!l&&r!l&&!r
0510
MC/DC0%0/2
$self->{'_last_joined'} || time
$self->{'_last_joined'} time
Truth table33%1/3
A || B
A= $self->{'_last_joined'}B= time
ABresult
1X1
011
000
13717 ( $joincount / $jointime );
13718 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
13719 0 $crec->{_num_joined} = 0;
13720 0 delete $crec->{_jfnotice};
13721 }
13722 elsif ( $crec->{_num_joined} >= $joincount ) {
13723 0 ▶ if ( !$crec->{_jfnotice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($crec->{"_jfnotice"}) 0 0 0
13724 0 $crec->{_jfnotice} = 1;
13725 0 my $urec = $self->{state}{users}{uc_irc $nick};
13726 $self->_send_to_realops(
13727 sprintf(
13728 'Possible Join Flooder %s[%s] on %s target: %s',
13729 $urec->{nick}, (split /!/,$urec->{full}->())[1],
13730 $urec->{server}, $crec->{name},
13731 0 ),
13732 qw[Notice b],
13733 );
13734 }
13735 }
13736 51 $crec->{_last_joined} = time();
13737 }
13738  
13739 sub state_check_spambot_warning {
13740 58 ▶ my $self = shift;
Subroutine state_check_spambot_warning: called CC=17 SCAR=42.1
Pod undocumented
13741 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
13742 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
13743 51 my $spamnum = $self->{config}{MAX_JOIN_LEAVE_COUNT};
13744 51 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 51 51
13745 51 my $urec = $self->{state}{users}{uc_irc $nick};
13746  
13747 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
13748 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
13749 0 $urec->{_owcd}--;
13750 }
13751 else {
13752 0 $urec->{_owcd} = 0;
13753 }
13754 0 ▶ if ( $urec->{_owcd} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($urec->{"_owcd"} == 0) 0 0 0
13755 my $msg = $chan ?
13756 sprintf(
13757 'User %s (%s) trying to join %s is a possible spambot',
13758 $urec->{nick}, (split /!/,$urec->{full}->())[1], $chan,
13759 ) :
13760 sprintf(
13761 'User %s (%s) is a possible spambot',
13762 0 ▶ $urec->{nick}, (split /!/,$urec->{full}->())[1],
Branch: 1 branch
BranchTrueFalseTotal
$chan ? : 0 0 0
13763 );
13764 0 $self->_send_to_realops(
13765 $msg, qw[Notice b],
13766 );
13767 0 $urec->{_owcd} = $self->{config}{OPER_SPAM_COUNTDOWN};
13768 }
13769 }
13770 else {
13771 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
13772 51 ▶ if ( $delta > $self->{config}{JOIN_LEAVE_COUNT_EXPIRE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($delta > $self->{'config'}{'JOIN_LEAVE_COUNT_EXPIRE'}) { } 51 0 51
13773 51 my $dec_cnt = $delta / $self->{config}{JOIN_LEAVE_COUNT_EXPIRE};
13774 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
13775 51 $urec->{_jl_cnt} = 0;
13776 }
13777 else {
13778 0 $urec->{_jl_cnt} -= $dec_cnt;
13779 }
13780 }
13781 else {
13782 $urec->{_jl_cnt}++ if ( time() - $urec->{_last_join} )
13783 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
13784 }
13785 51 ▶ if ( $chan ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chan) { } 51 0 51
13786 51 $urec->{_last_join} = time();
13787 }
13788 else {
13789 0 $urec->{_last_leave} = time();
13790 }
13791 }
13792 }
13793  
13794 sub state_flood_attack_channel {
13795 8 ▶ my $self = shift;
Subroutine state_flood_attack_channel: called CC=19 SCAR=34.4
Pod undocumented
13796 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
13797 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
13798 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
13799 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
13800 8 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 8 8
13801 8 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 8 8
13802 8 my $urec = $self->{state}{users}{uc_irc $nick};
13803 8 ▶ return 0 if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 0 8 8
13804 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
13805 8 my $crec = $self->{state}{chans}{uc_irc $chan};
13806 8 my $first = $crec->{_first_msg};
13807 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
13808 0 ▶ if ( $crec->{_recv_msgs} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{'_recv_msgs'}) { } 0 0 0
13809 0 $crec->{_recv_msgs} = 0;
13810 }
13811 else {
13812 0 $crec->{_flood_notice} = 0;
13813 }
13814 0 $crec->{_first_msg} = time();
13815 }
13816 8 my $recv = $crec->{_recv_msgs};
13817 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
13818 1 ▶ if ( !$crec->{_flood_notice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($crec->{"_flood_notice"}) 1 0 1
13819 $self->_send_to_realops(
13820 sprintf(
13821 'Possible Flooder %s[%s] on %s target: %s',
13822 $urec->{nick}, (split /!/, $urec->{full}->())[1],
13823 $urec->{server}, $crec->{name},
13824 1 ), qw[Notice b],
13825 );
13826 1 $crec->{_flood_notice} = 1;
13827 }
13828 1 ▶ if ( $type ne 'NOTICE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "NOTICE") 1 0 1
13829 $self->send_output(
13830 {
13831 prefix => $self->server_name(),
13832 command => 'NOTICE',
13833 params => [
13834 $urec->{nick},
13835 "*** Message to $crec->{name} throttled due to flooding",
13836 ],
13837 },
13838 $urec->{route_id},
13839 1 );
13840 }
13841 1 return 1;
13842 }
13843 7 ▶ $crec->{_first_msg} = time() if !$first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first 3 4 7
13844 7 $crec->{_recv_msgs}++;
13845 7 return 0;
13846 }
13847  
13848 sub state_flood_attack_client {
13849 14 ▶ my $self = shift;
Subroutine state_flood_attack_client: called CC=19 SCAR=33.4
Pod undocumented
13850 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
13851 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
13852 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
13853 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
13854 14 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 14 14
13855 14 ▶ return if !$self->state_nick_exists($targ);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($targ) 0 14 14
13856 14 my $urec = $self->{state}{users}{uc_irc $nick};
13857 14 ▶ return 0 if $urec->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $urec->{"route_id"} eq "spoofed" 0 14 14
13858 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
13859 12 my $trec = $self->{state}{users}{uc_irc $targ};
13860 12 my $first = $trec->{_first_msg};
13861 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
13862 0 ▶ if ( $trec->{_recv_msgs} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trec->{'_recv_msgs'}) { } 0 0 0
13863 0 $trec->{_recv_msgs} = 0;
13864 }
13865 else {
13866 0 $trec->{_flood_notice} = 0;
13867 }
13868 0 $trec->{_first_msg} = time();
13869 }
13870 12 my $recv = $trec->{_recv_msgs};
13871 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
13872 1 ▶ if ( !$trec->{_flood_notice} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($trec->{"_flood_notice"}) 1 0 1
13873 $self->_send_to_realops(
13874 sprintf(
13875 'Possible Flooder %s[%s] on %s target: %s',
13876 $urec->{nick}, (split /!/, $urec->{full}->())[1],
13877 $urec->{server}, $trec->{nick},
13878 1 ), qw[Notice b],
13879 );
13880 1 $trec->{_flood_notice} = 1;
13881 }
13882 1 ▶ if ( $type ne 'NOTICE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "NOTICE") 1 0 1
13883 $self->send_output(
13884 {
13885 prefix => $self->server_name(),
13886 command => 'NOTICE',
13887 params => [
13888 $urec->{nick},
13889 "*** Message to $trec->{nick} throttled due to flooding",
13890 ],
13891 },
13892 $urec->{route_id},
13893 1 );
13894 }
13895 1 return 1;
13896 }
13897 11 ▶ $trec->{_first_msg} = time() if !$first;
Branch: 1 branch
BranchTrueFalseTotal
unless $first 5 6 11
13898 11 $trec->{_recv_msgs}++;
13899 11 return 0;
13900 }
13901  
13902 sub state_can_send_to_channel {
13903 23 ▶ my $self = shift;
Subroutine state_can_send_to_channel: called CC=23 SCAR=34.0
Pod undocumented
13904 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
13905 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
13906 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
13907 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
13908 23 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 23 23
13909 23 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 23 23
13910 23 my $uid = $self->state_user_uid($nick);
13911 23 my $crec = $self->{state}{chans}{uc_irc $chan};
13912 23 my $urec = $self->{state}{uids}{$uid};
13913 23 my $member = defined $crec->{users}{$uid};
13914  
13915 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
Condition66%4/6
$crec->{"mode"} =~ /c/ and has_color($msg) || has_formatting($msg)
!ll&&!rl&&r
2030
has_color($msg) or has_formatting($msg)
l!l&&r!l&&!r
201
MC/DC0%0/3
$crec->{"mode"} =~ /c/ and has_color($msg) || has_formatting($msg)
$crec->{"mode"} =~ /c/ has_color($msg) has_formatting($msg)
Truth table50%2/4
A and B or C
A= $crec->{"mode"} =~ /c/B= has_color($msg)C= has_formatting($msg)
ABCresult
0XX0
1000
11X1
1011
13916 2 return [ '408', $crec->{name} ];
13917 }
13918 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
13919 1 return [ '492', $crec->{name} ];
13920 }
13921 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
13922 0 return [ '404', $crec->{name} ];
13923 }
13924 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
13925 2 return [ '477', $crec->{name} ];
13926 }
13927 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
13928 8 return 2;
13929 }
13930 10 ▶ if ( $crec->{mode} =~ /m/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crec->{"mode"} =~ /m/) 0 10 10
13931 0 return [ '404', $crec->{name} ];
13932 }
13933 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
13934 2 return [ '404', $crec->{name} ];
13935 }
13936 8 ▶ if ( $self->_state_user_banned($nick, $chan) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_user_banned($nick, $chan)) 0 8 8
13937 0 return [ '404', $crec->{name} ];
13938 }
13939 8 return 1;
13940 }
13941  
13942 sub _state_peer_name {
13943 2 ▶ my $self = shift;
Subroutine _state_peer_name: called CC=3 SCAR=11.0
13944 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
13945 2 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 1 1 2
13946 1 return $self->{state}{peers}{uc $peer}{name};
13947 }
13948  
13949 sub _state_peer_sid {
13950 7 ▶ my $self = shift;
Subroutine _state_peer_sid: called CC=5 SCAR=16.5
13951 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
13952 7 ▶ if ( $peer =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer =~ /^\d/) { } 4 3 7
13953 4 ▶ return if !$self->state_sid_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($peer) 0 4 4
13954 4 return $self->{state}{sids}{$peer}{sid};
13955 }
13956 else {
13957 3 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 3 3
13958 3 return $self->{state}{peers}{uc $peer}{sid};
13959 }
13960 }
13961  
13962 sub _state_sid_name {
13963 935 ▶ my $self = shift;
Subroutine _state_sid_name: called CC=3 SCAR=11.4
13964 935 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
9350
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13965 935 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 0 935 935
13966 935 return $self->{state}{sids}{$sid}{name};
13967 }
13968  
13969 sub _state_sid_serv {
13970 50 ▶ my $self = shift;
Subroutine _state_sid_serv: called CC=4 SCAR=14.1
13971 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
13972 50 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 0 50 50
13973 50 ▶ return 0 if !$self->{state}{sids}{$sid}{serv};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"sids"}{$sid}{"serv"} 9 41 50
13974 41 return 1;
13975 }
13976  
13977 sub _state_peer_desc {
13978 4 ▶ my $self = shift;
Subroutine _state_peer_desc: called CC=3 SCAR=11.4
13979 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
13980 4 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 4 4
13981 4 return $self->{state}{peers}{uc $peer}{desc};
13982 }
13983  
13984 sub _state_peer_capab {
13985 912 ▶ my $self = shift;
Subroutine _state_peer_capab: called CC=4 SCAR=14.2
13986 912 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
9120
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13987 912 ▶ my $capab = shift || return;
Condition50%1/2
shift() || (return)
l!l
9120
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13988 912 $capab = uc $capab;
13989 912 ▶ return if !$self->_connection_is_peer($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_is_peer($conn_id) 0 912 912
13990 912 my $conn = $self->{state}{conns}{$conn_id};
13991 912 return scalar grep { $_ eq $capab } @{ $conn->{capab} };
13992 }
13993  
13994 sub _state_our_capab {
13995 804 ▶ my $self = shift;
Subroutine _state_our_capab: called CC=2 SCAR=7.0
13996 804 ▶ my $capab = shift || return;
Condition50%1/2
shift() || (return)
l!l
8040
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
13997 804 $capab = uc $capab;
13998 804 my $capabs = $self->{config}{capab};
13999 804 return scalar grep { $_ eq $capab } @{ $capabs };
14000 }
14001  
14002 sub state_user_full {
14003 3131 ▶ my $self = shift;
Subroutine state_user_full: called CC=7 SCAR=19.7
Pod documented
14004 3131 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
31310
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14005 3131 my $oper = shift;
14006 3131 my $opuser = '';
14007 3131 my $record;
14008 3131 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 2542 589 3131
14009 2542 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 0 2542 2542
14010 2542 $record = $self->{state}{uids}{$nick};
14011 }
14012 else {
14013 589 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 589 589
14014 589 $record = $self->{state}{users}{uc_irc($nick)};
14015 }
14016 3131 ▶ if ( $oper && defined $record->{opuser} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oper and defined $record->{"opuser"}) 1 3130 3131
Condition66%2/3
$oper and defined $record->{"opuser"}
!ll&&!rl&&r
313001
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
14017 1 $opuser = '{' . $record->{opuser} . '}';
14018 }
14019 3131 return $record->{full}->() . $opuser;
14020 }
14021  
14022 sub state_user_nick {
14023 183 ▶ my $self = shift;
Subroutine state_user_nick: called CC=5 SCAR=16.1
Pod documented
14024 183 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
1830
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14025 183 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 111 72 183
14026 111 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 2 109 111
14027 109 return $self->{state}{uids}{$nick}{nick};
14028 }
14029 else {
14030 72 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 1 71 72
14031 71 return $self->{state}{users}{uc_irc($nick)}{nick};
14032 }
14033 }
14034  
14035 sub state_user_uid {
14036 578 ▶ my $self = shift;
Subroutine state_user_uid: called CC=5 SCAR=16.1
Pod undocumented
14037 578 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
5780
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14038 578 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 44 534 578
14039 44 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 4 40 44
14040 40 return $self->{state}{uids}{$nick}{uid};
14041 }
14042 else {
14043 534 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 4 530 534
14044 530 return $self->{state}{users}{uc_irc($nick)}{uid};
14045 }
14046 }
14047  
14048 sub _state_user_ip {
14049 21 ▶ my $self = shift;
Subroutine _state_user_ip: called CC=4 SCAR=15.2
14050 21 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
210
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14051 21 ▶ 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 21 21
Condition33%1/3
$self->state_nick_exists($nick) and $self->_state_is_local_user($nick)
!ll&&!rl&&r
0021
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
14052 || !$self->_state_is_local_user($nick);
14053 21 my $record = $self->{state}{users}{uc_irc($nick)};
14054 21 return $record->{socket}[0];
14055 }
14056  
14057 sub _state_user_away {
14058 0 ▶ my $self = shift;
Subroutine _state_user_away: not called CC=4 SCAR=30.0
14059 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
14060 0 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 0 0
14061 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
14062 0 return 0;
14063 }
14064  
14065 sub _state_user_away_msg {
14066 17 ▶ my $self = shift;
Subroutine _state_user_away_msg: called CC=3 SCAR=11.4
14067 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
14068 17 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 17 17
14069 17 return $self->{state}{users}{uc_irc($nick)}{away};
14070 }
14071  
14072 sub state_user_umode {
14073 75 ▶ my $self = shift;
Subroutine state_user_umode: called CC=3 SCAR=11.4
Pod documented
14074 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
14075 75 ▶ return if! $self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 75 75
14076 75 return $self->{state}{users}{uc_irc($nick)}{umode};
14077 }
14078  
14079 sub state_user_is_operator {
14080 262 ▶ my $self = shift;
Subroutine state_user_is_operator: called CC=4 SCAR=14.1
Pod documented
14081 262 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
2620
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14082 262 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 262 262
14083 262 ▶ return 0 if $self->{state}{users}{uc_irc($nick)}{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"users"}{uc_irc($nick)}{"umode"} =~ /o/ 202 60 262
14084 60 return 1;
14085 }
14086  
14087 sub _state_user_is_deaf {
14088 31 ▶ my $self = shift;
Subroutine _state_user_is_deaf: called CC=4 SCAR=15.6
14089 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
14090 31 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 31 31
14091 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
14092 0 return 1;
14093 }
14094  
14095 sub state_user_chans {
14096 114 ▶ my $self = shift;
Subroutine state_user_chans: called CC=3 SCAR=11.2
Pod documented
14097 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
14098 114 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 114 114
14099 114 my $record = $self->{state}{users}{uc_irc($nick)};
14100 2 return map { $self->{state}{chans}{$_}{name} }
14101 114 keys %{ $record->{chans} };
14102 }
14103  
14104 sub _state_user_route {
14105 441 ▶ my $self = shift;
Subroutine _state_user_route: called CC=3 SCAR=11.3
14106 441 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
4410
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14107 441 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 441 441
14108 441 my $record = $self->{state}{users}{uc_irc($nick)};
14109 441 return $record->{route_id};
14110 }
14111  
14112 sub _state_uid_route {
14113 615 ▶ my $self = shift;
Subroutine _state_uid_route: called CC=3 SCAR=11.3
14114 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
14115 615 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 615 615
14116 615 my $record = $self->{state}{uids}{ $uid };
14117 615 return $record->{route_id};
14118 }
14119  
14120 sub state_user_server {
14121 1 ▶ my $self = shift;
Subroutine state_user_server: called CC=3 SCAR=11.3
Pod documented
14122 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
14123 1 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 1 1
14124 1 my $record = $self->{state}{users}{uc_irc($nick)};
14125 1 return $record->{server};
14126 }
14127  
14128 sub state_uid_sid {
14129 0 ▶ my $self = shift;
Subroutine state_uid_sid: not called CC=3 SCAR=24.8
Pod undocumented
14130 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
14131 0 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 0 0
14132 0 return substr( $uid, 0, 3 );
14133 }
14134  
14135 sub _state_peer_route {
14136 37 ▶ my $self = shift;
Subroutine _state_peer_route: called CC=3 SCAR=11.3
14137 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
14138 37 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 37 37
14139 37 my $record = $self->{state}{peers}{uc $peer};
14140 37 return $record->{route_id};
14141 }
14142  
14143 sub _state_sid_route {
14144 455 ▶ my $self = shift;
Subroutine _state_sid_route: called CC=3 SCAR=11.3
14145 455 ▶ my $sid = shift || return;
Condition50%1/2
shift() || (return)
l!l
4550
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14146 455 ▶ return if !$self->state_sid_exists($sid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_sid_exists($sid) 0 455 455
14147 455 my $record = $self->{state}{sids}{$sid};
14148 455 return $record->{route_id};
14149 }
14150  
14151 sub _state_connected_peers {
14152 2102 ▶ my $self = shift;
Subroutine _state_connected_peers: called CC=2 SCAR=7.0
14153 2102 my $server = uc $self->server_name();
14154 2102 ▶ return if !keys %{ $self->{state}{peers} } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if !keys(%{$$self{"state"}{"peers"};}) > 1 0 2102 2102
14155 2102 my $record = $self->{state}{peers}{$server};
14156 3122 return map { $record->{peers}{$_}{route_id} }
14157 2102 keys %{ $record->{peers} };
14158 }
14159  
14160 sub state_chan_list {
14161 10 ▶ my $self = shift;
Subroutine state_chan_list: called CC=6 SCAR=24.5
Pod documented
14162 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
14163 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
14164 10 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 10 10
14165  
14166 10 $status_msg =~ s/[^@%+]//g;
14167 10 my $record = $self->{state}{chans}{uc_irc($chan)};
14168 31 return map { $self->{state}{uids}{$_}{nick} }
14169 10 ▶ keys %{ $record->{users} } if !$status_msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $status_msg 10 0 10
14170  
14171 0 my %map = qw(o 3 h 2 v 1);
14172 0 my %sym = qw(@ 3 % 2 + 1);
14173 0 my $lowest = (sort map { $sym{$_} } split //, $status_msg)[0];
14174  
14175 0 return map { $self->{state}{uids}{$_}{nick} }
14176 grep {
14177 0 $record->{users}{ $_ } and (reverse sort map { $map{$_} }
14178 0 ▶ split //, $record->{users}{$_})[0] >= $lowest
Branch: 1 branch
BranchTrueFalseTotal
$record->{"users"}{$_} and (reverse sort map({$map{$_};} split(//, $record->{"users"}{$_}, 0)))[0] >= $lowest 0 0 0
14179 0 } keys %{ $record->{users} };
14180 }
14181  
14182 sub state_chan_list_prefixed {
14183 94 ▶ my $self = shift;
Subroutine state_chan_list_prefixed: called CC=10 SCAR=23.3
Pod documented
14184 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
14185 94 my $flag = shift;
14186 94 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 94 94
14187 94 my $record = $self->{state}{chans}{uc_irc($chan)};
14188  
14189 return map {
14190 168 my $n = $self->{state}{uids}{$_}{nick};
14191 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
14192 168 my $m = $record->{users}{$_};
14193 168 my $p = '';
14194 168 ▶ $p = '@' if $m =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /o/ 94 74 168
14195 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
14196 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
14197 168 $p . $n;
14198 94 } keys %{ $record->{users} };
14199 }
14200  
14201 sub state_chan_list_multi_prefixed {
14202 69 ▶ my $self = shift;
Subroutine state_chan_list_multi_prefixed: called CC=10 SCAR=23.0
Pod undocumented
14203 69 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
690
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14204 69 my $flag = shift;
14205 69 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 69 69
14206 69 my $record = $self->{state}{chans}{uc_irc($chan)};
14207  
14208 return map {
14209 1039 my $rec = $self->{state}{uids}{$_};
14210 1039 ▶ my $n = ( ($flag && $flag eq 'UIDS') ? $_ : $rec->{nick} );
Branch: 1 branch
BranchTrueFalseTotal
$flag && $flag eq 'UIDS' ? : 1017 22 1039
Condition100%3/3
$flag and $flag eq "UIDS"
!ll&&!rl&&r
1661017
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
14211 1039 ▶ $n = (($flag && $flag eq 'FULL') ? $self->state_user_full($_) : $n );
Branch: 1 branch
BranchTrueFalseTotal
$flag && $flag eq 'FULL' ? : 6 1033 1039
Condition100%3/3
$flag and $flag eq "FULL"
!ll&&!rl&&r
1610176
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
14212 1039 my $m = $record->{users}{$_};
14213 1039 my $p = '';
14214 1039 ▶ $p .= '@' if $m =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /o/ 45 994 1039
14215 1039 ▶ $p .= '%' if $m =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /h/ 4 1035 1039
14216 1039 ▶ $p .= '+' if $m =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /v/ 4 1035 1039
14217 1039 $p . $n;
14218 69 } keys %{ $record->{users} };
14219 }
14220  
14221 sub _state_chan_timestamp {
14222 1 ▶ my $self = shift;
Subroutine _state_chan_timestamp: called CC=3 SCAR=11.4
14223 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
14224 1 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 1 1
14225 1 return $self->{state}{chans}{uc_irc($chan)}{ts};
14226 }
14227  
14228 sub state_chan_topic {
14229 56 ▶ my $self = shift;
Subroutine state_chan_topic: called CC=4 SCAR=15.9
Pod documented
14230 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
14231 56 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 56 56
14232 56 my $record = $self->{state}{chans}{uc_irc($chan)};
14233 56 ▶ return if !$record->{topic};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"topic"} 56 0 56
14234 0 return [@{ $record->{topic} }];
14235 }
14236  
14237 sub _state_is_local_user {
14238 27 ▶ my $self = shift;
Subroutine _state_is_local_user: called CC=7 SCAR=26.4
14239 27 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
270
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14240 27 my $record = $self->{state}{sids}{uc $self->server_sid()};
14241 27 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 0 27 27
14242 0 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 0 0 0
14243 0 ▶ return 1 if defined $record->{uids}{$nick};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"uids"}{$nick} 0 0 0
14244 }
14245 else {
14246 27 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 27 27
14247 27 ▶ return 1 if defined $record->{users}{uc_irc($nick)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"users"}{uc_irc($nick)} 27 0 27
14248 }
14249 0 return 0;
14250 }
14251  
14252 sub _state_is_local_uid {
14253 3274 ▶ my $self = shift;
Subroutine _state_is_local_uid: called CC=4 SCAR=14.1
14254 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
14255 3274 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 3274 3274
14256 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
14257 3245 return 0;
14258 }
14259  
14260 sub _state_chan_name {
14261 208 ▶ my $self = shift;
Subroutine _state_chan_name: called CC=3 SCAR=11.4
14262 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
14263 208 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 208 208
14264 208 return $self->{state}{chans}{uc_irc($chan)}{name};
14265 }
14266  
14267 sub state_chan_mode_set {
14268 68 ▶ my $self = shift;
Subroutine state_chan_mode_set: called CC=6 SCAR=18.5
Pod documented
14269 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
14270 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
14271 68 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 68 68
14272  
14273 68 $mode =~ s/[^a-zA-Z]+//g;
14274 68 ▶ $mode = (split //, $mode )[0] if length $mode > 1;
Branch: 1 branch
BranchTrueFalseTotal
if length $mode > 1 0 68 68
14275 68 my $record = $self->{state}{chans}{uc_irc($chan)};
14276 68 ▶ return 1 if $record->{mode} =~ /$mode/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /$mode/ 4 64 68
14277 64 return 0;
14278 }
14279  
14280 sub _state_user_invited {
14281 4 ▶ my $self = shift;
Subroutine _state_user_invited: called CC=7 SCAR=20.4
14282 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
14283 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
14284 4 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 4 4
14285 4 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 4 4
14286 4 my $nickrec = $self->{state}{users}{uc_irc($nick)};
14287 4 ▶ return 1 if $nickrec->{invites}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if $nickrec->{"invites"}{uc_irc($chan)} 1 3 4
14288 # Check if user matches INVEX
14289 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
14290 3 return 0;
14291 }
14292  
14293 sub _state_user_banned {
14294 68 ▶ my $self = shift;
Subroutine _state_user_banned: called CC=5 SCAR=20.9
14295 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
14296 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
14297 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
14298 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
14299 0 return 0;
14300 }
14301  
14302 sub _state_user_matches_list {
14303 71 ▶ my $self = shift;
Subroutine _state_user_matches_list: called CC=8 SCAR=22.0
14304 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
14305 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
14306 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
14307 71 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 71 71
14308 71 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 71 71
14309 71 my $full = $self->state_user_full($nick);
14310 71 my $record = $self->{state}{chans}{uc_irc($chan)};
14311  
14312 71 for my $mask (keys %{ $record->{$list} }) {
14313 3 ▶ return 1 if matches_mask($mask, $full);
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($mask, $full) 0 3 3
14314 }
14315 71 return 0;
14316 }
14317  
14318 sub state_is_chan_member {
14319 377 ▶ my $self = shift;
Subroutine state_is_chan_member: called CC=6 SCAR=18.6
Pod documented
14320 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
14321 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
14322 377 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 377 377
14323 377 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 377 377
14324 377 my $record = $self->{state}{users}{uc_irc($nick)};
14325 377 ▶ return 1 if defined $record->{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"chans"}{uc_irc($chan)} 307 70 377
14326 70 return 0;
14327 }
14328  
14329 sub state_uid_chan_member {
14330 2 ▶ my $self = shift;
Subroutine state_uid_chan_member: called CC=6 SCAR=19.9
Pod undocumented
14331 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
14332 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
14333 2 ▶ return if !$self->state_uid_exists($uid);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($uid) 0 2 2
14334 2 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 2 2
14335 2 my $record = $self->{state}{uids}{$uid};
14336 2 ▶ return 1 if defined $record->{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"chans"}{uc_irc($chan)} 2 0 2
14337 0 return 0;
14338 }
14339 sub state_user_chan_mode {
14340 0 ▶ my $self = shift;
Subroutine state_user_chan_mode: not called CC=4 SCAR=30.0
Pod documented
14341 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
14342 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
14343 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
14344 0 return $self->{state}{users}{uc_irc($nick)}{chans}{uc_irc($chan)};
14345 }
14346  
14347 sub state_is_chan_op {
14348 63 ▶ my $self = shift;
Subroutine state_is_chan_op: called CC=7 SCAR=21.0
Pod documented
14349 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
14350 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
14351 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
14352 63 my $record = $self->{state}{users}{uc_irc($nick)};
14353 63 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /o/ 49 14 63
14354 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
14355 14 return 0;
14356 }
14357  
14358 sub state_is_chan_hop {
14359 54 ▶ my $self = shift;
Subroutine state_is_chan_hop: called CC=5 SCAR=16.5
Pod documented
14360 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
14361 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
14362 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
14363 54 my $record = $self->{state}{users}{uc_irc($nick)};
14364 54 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /h/ 21 33 54
14365 33 return 0;
14366 }
14367  
14368 sub state_has_chan_voice {
14369 0 ▶ my $self = shift;
Subroutine state_has_chan_voice: not called CC=5 SCAR=34.0
Pod documented
14370 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
14371 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
14372 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
14373 0 my $record = $self->{state}{users}{uc_irc($nick)};
14374 0 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /v/ 0 0 0
14375 0 return 0;
14376 }
14377  
14378 sub _state_o_line {
14379 24 ▶ my $self = shift;
Subroutine _state_o_line: called CC=23 SCAR=44.0
14380 24 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
240
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14381 24 my ($user, $pass) = @_;
14382 24 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 24 24
14383 24 ▶ return if !$user || !$pass;
Branch: 1 branch
BranchTrueFalseTotal
unless $user and $pass 0 24 24
Condition33%1/3
$user and $pass
!ll&&!rl&&r
0024
MC/DC0%0/2
$user and $pass
$user $pass
Truth table33%1/3
A and B
A= $userB= $pass
ABresult
0X0
100
111
14384  
14385 24 my $ops = $self->{config}{ops};
14386 24 ▶ return if !$ops->{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless $ops->{$user} 1 23 24
14387 23 ▶ return -1 if !chkpasswd ($pass, $ops->{$user}{password});
Branch: 1 branch
BranchTrueFalseTotal
unless chkpasswd($pass, $ops->{$user}{"password"}) 0 23 23
14388  
14389 23 ▶ if ($ops->{$user}{ssl_required}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops->{$user}{"ssl_required"}) 5 18 23
14390 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
14391 }
14392  
14393 22 ▶ if ($ops->{$user}{certfp}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ops->{$user}{"certfp"}) 4 18 22
14394 4 my $certfp = $self->{state}{users}{uc_irc $nick}{certfp};
14395 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
14396 1 return -3;
14397 }
14398 }
14399  
14400 21 my $client_ip = $self->_state_user_ip($nick);
14401 21 ▶ return if !$client_ip;
Branch: 1 branch
BranchTrueFalseTotal
unless $client_ip 0 21 21
14402 21 ▶ 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)/)) 21 0 21
Condition33%2/6
not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^(127\.|::1)/)
!ll&&!rl&&r
0021
$client_ip and $client_ip =~ /^(127\.|::1)/
!ll&&!rl&&r
0021
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
14403 21 return 1;
14404 }
14405 0 ▶ return 0 if !$ops->{$user}{ipmask};
Branch: 1 branch
BranchTrueFalseTotal
unless $ops->{$user}{"ipmask"} 0 0 0
14406  
14407 0 ▶ if (ref $ops->{$user}{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ops->{$user}{"ipmask"} eq "ARRAY") 0 0 0
14408 0 for my $block (@{ $ops->{$user}{ipmask} }) {
14409 0 ▶ if ( eval { $block->isa('Net::Netmask') } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $block->isa("Net::Netmask") } }) 0 0 0
14410 0 ▶ return 1 if $block->match($client_ip);
Branch: 1 branch
BranchTrueFalseTotal
if $block->match($client_ip) 0 0 0
14411 0 next;
14412 }
14413 0 ▶ return 1 if Net::CIDR::cidrlookup( $client_ip, $block );
Branch: 1 branch
BranchTrueFalseTotal
if Net::CIDR::cidrlookup($client_ip, $block) 0 0 0
14414 }
14415 }
14416 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
14417 0 return 0;
14418 }
14419  
14420 sub _state_users_share_chan {
14421 0 ▶ my $self = shift;
Subroutine _state_users_share_chan: not called CC=7 SCAR=40.3
14422 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
14423 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
14424 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
14425 || !$self->state_nick_exists($nick2);
14426 0 my $rec1 = $self->{state}{users}{uc_irc($nick1)};
14427 0 my $rec2 = $self->{state}{users}{uc_irc($nick2)};
14428 0 for my $chan (keys %{ $rec1->{chans} }) {
14429 0 ▶ return 1 if $rec2->{chans}{$chan};
Branch: 1 branch
BranchTrueFalseTotal
if $rec2->{"chans"}{$chan} 0 0 0
14430 }
14431 0 return 0;
14432 }
14433  
14434 sub _state_parse_msg_targets {
14435 38 ▶ my $self = shift;
Subroutine _state_parse_msg_targets: called CC=10 SCAR=25.0
14436 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
14437 38 my %results;
14438  
14439 38 for my $target (split /,/, $targets) {
14440 38 ▶ if ($target =~ /^[#&]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^[#&]/) 18 20 38
14441 18 $results{$target} = ['channel'];
14442 18 next;
14443 }
14444 20 ▶ if ($target =~ /^([@%+]+)([#&].+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^([\@%+]+)([#&].+)$/) 0 20 20
14445 0 $results{$target} = ['channel_ext', $1, $2];
14446 0 next;
14447 }
14448 20 ▶ if ( $target =~ /^\$([^#].+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^\$([^#].+)$/) 1 19 20
14449 1 $results{$target} = ['servermask', $1];
14450 1 next;
14451 }
14452 19 ▶ if ( $target =~ /^\$#(.+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^\$#(.+)$/) 1 18 19
14453 1 $results{$target} = ['hostmask', $1];
14454 1 next;
14455 }
14456 18 ▶ if ($target =~ /@/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /@/) 0 18 18
14457 0 my ($nick, $server) = split /@/, $target, 2;
14458 0 my $host;
14459 0 ▶ ($nick, $host) = split ( /%/, $nick, 2 ) if $nick =~ /%/;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ /%/ 0 0 0
14460 0 $results{$target} = ['nick_ext', $nick, $server, $host];
14461 0 next;
14462 }
14463 18 ▶ if ($target =~ $uid_re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /$uid_re/) 4 14 18
14464 4 $results{$target} = ['uid'];
14465 4 next;
14466 }
14467 14 $results{$target} = ['nick'];
14468 }
14469  
14470 38 return \%results;
14471 }
14472  
14473 sub server_name {
14474 13797 ▶ return $_[0]->{config}{'SERVERNAME'};
Subroutine server_name: called CC=1 SCAR=0.0
Pod documented
14475 }
14476  
14477 sub server_version {
14478 229 ▶ return $_[0]->{config}{'VERSION'};
Subroutine server_version: called CC=1 SCAR=0.0
Pod documented
14479 }
14480  
14481 sub server_sid {
14482 9202 ▶ return $_[0]->{config}{'SID'};
Subroutine server_sid: called CC=1 SCAR=0.0
Pod undocumented
14483 }
14484  
14485 sub server_created {
14486 223 ▶ return strftime("This server was created %a %h %d %Y at %H:%M:%S %Z",
Subroutine server_created: called CC=1 SCAR=0.0
Pod documented
14487 localtime($_[0]->server_config('created')));
14488 }
14489  
14490 sub _client_nickname {
14491 3774 ▶ my $self = shift;
Subroutine _client_nickname: called CC=3 SCAR=11.0
14492 3774 ▶ my $wheel_id = $_[0] || return;
Condition50%1/2
$_[0] || (return)
l!l
37740
MC/DC0%0/1
$_[0] || (return)
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
14493 3774 ▶ return '*' if !$self->{state}{conns}{$wheel_id}{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$wheel_id}{"nick"} 218 3556 3774
14494 3556 return $self->{state}{conns}{$wheel_id}{nick};
14495 }
14496  
14497 sub _client_uid {
14498 787 ▶ my $self = shift;
Subroutine _client_uid: called CC=3 SCAR=11.4
14499 787 ▶ my $wheel_id = $_[0] || return;
Condition50%1/2
$_[0] || (return)
l!l
7870
MC/DC0%0/1
$_[0] || (return)
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
14500 787 ▶ return '*' if !$self->{state}{conns}{$wheel_id}{uid};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$wheel_id}{"uid"} 0 787 787
14501 787 return $self->{state}{conns}{$wheel_id}{uid};
14502 }
14503  
14504 sub _client_ip {
14505 236 ▶ my $self = shift;
Subroutine _client_ip: called CC=2 SCAR=7.1
14506 236 ▶ my $wheel_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
14507 236 return $self->{state}{conns}{$wheel_id}{socket}[0];
14508 }
14509  
14510 sub server_config {
14511 1284 ▶ my $self = shift;
Subroutine server_config: called CC=2 SCAR=7.1
Pod documented
14512 1284 ▶ my $value = shift || return;
Condition50%1/2
shift() || (return)
l!l
12840
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14513 1284 return $self->{config}{uc $value};
14514 }
14515  
14516 sub configure {
14517 182 ▶ my $self = shift;
Subroutine configure: called CC=26 SCAR=37.7
Pod documented
14518 182 ▶ my $opts = ref $_[0] eq 'HASH' ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 180 2 182
14519 182 $opts->{uc $_} = delete $opts->{$_} for keys %$opts;
14520  
14521 my %defaults = (
14522 CREATED => time(),
14523 CASEMAPPING => 'rfc1459',
14524 SERVERNAME => 'poco.server.irc',
14525 SERVERDESC => 'Poco? POCO? POCO!',
14526 182 VERSION => do {
14527 179 ▶ no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
14528 182 ▶ ref($self) . '-' . (defined $VERSION ? $VERSION : 'dev-git');
Branch: 1 branch
BranchTrueFalseTotal
defined $VERSION ? : 182 0 182
14529 },
14530 NETWORK => 'poconet',
14531 NETWORKDESC => 'poco mcpoconet',
14532 HOSTLEN => 63,
14533 NICKLEN => 9,
14534 USERLEN => 10,
14535 REALLEN => 50,
14536 KICKLEN => 120,
14537 TOPICLEN => 80,
14538 AWAYLEN => 160,
14539 CHANNELLEN => 50,
14540 PASSWDLEN => 20,
14541 KEYLEN => 23,
14542 MAXCHANNELS => 15, # Think this is called CHANLIMIT now
14543 MAXACCEPT => 20,
14544 MODES => 4,
14545 MAXTARGETS => 4,
14546 MAXCLIENTS => 512,
14547 MAXBANS => 50,
14548 MAXBANLENGTH => 1024,
14549 AUTH => 1,
14550 ANTIFLOOD => 1,
14551 OPHACKS => 0,
14552 JOIN_LEAVE_COUNT_EXPIRE => 120,
14553 OPER_SPAM_COUNTDOWN => 5,
14554 MAX_JOIN_LEAVE_COUNT => 25,
14555 MIN_JOIN_LEAVE_TIME => 60,
14556 knock_client_count => 1,
14557 knock_client_time => 5 * 60,
14558 knock_delay_channel => 60,
14559 pace_wait => 10,
14560 max_watch => 50,
14561 max_bans_large => 500,
14562 oper_umode => 'aceklnswy',
14563 anti_spam_exit_message_time => 5 * 60,
14564 anti_nick_flood => 1,
14565 max_nick_time => 20,
14566 max_nick_changes => 5,
14567 floodcount => 10,
14568 floodtime => 1,
14569 joinfloodcount => 18,
14570 joinfloodtime => 6,
14571 hidden_servers => '',
14572 hidden => '',
14573 );
14574 182 $self->{config}{$_} = $defaults{$_} for keys %defaults;
14575  
14576 182 for my $opt (qw(HOSTLEN NICKLEN USERLEN REALLEN TOPICLEN CHANNELLEN
14577 PASSWDLEN KEYLEN MAXCHANNELS MAXACCEPT MODES MAXTARGETS MAXBANS)) {
14578 2366 my $new = delete $opts->{$opt};
14579 2366 ▶ if (defined $new && $new > $self->{config}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new and $new > $self->{"config"}{$opt}) 0 2366 2366
Condition33%1/3
defined $new and $new > $self->{"config"}{$opt}
!ll&&!rl&&r
236600
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
14580 0 $self->{config}{$opt} = $new;
14581 }
14582 }
14583  
14584 182 for my $opt (qw(KICKLEN AWAYLEN)) {
14585 364 my $new = delete $opts->{$opt};
14586 364 ▶ if (defined $new && $new < $self->{config}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new and $new < $self->{"config"}{$opt}) 0 364 364
Condition33%1/3
defined $new and $new < $self->{"config"}{$opt}
!ll&&!rl&&r
36400
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
14587 0 $self->{config}{$opt} = $new;
14588 }
14589 }
14590  
14591 182 for my $opt (keys %$opts) {
14592 465 ▶ 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 340 125 465
14593 $self->{config}{lc $opt} = delete $opts->{$opt}
14594 125 ▶ if defined $opts->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$opt} 125 0 125
14595 }
14596  
14597 182 $self->{config}{oper_umode} =~ s/[^DFGHRSWXabcdefgijklnopqrsuwy]+//g;
14598 182 $self->{config}{oper_umode} =~ s/[SWori]+//g;
14599  
14600 182 for my $opt (keys %$opts) {
14601 340 ▶ $self->{config}{$opt} = $opts->{$opt} if defined $opts->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$opt} 340 0 340
14602 }
14603  
14604 {
14605 182 my $sid = delete $self->{config}{SID};
14606 182 ▶ if (!$sid || $sid !~ $sid_re) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $sid && $sid =~ /$sid_re/) { } 2 180 182
Condition66%2/3
$sid && $sid =~ /$sid_re/
!ll&&!rl&&r
20180
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
14607 2 warn "No SID or SID is invalid, generating a random one\n";
14608 2 $self->_state_rand_sid();
14609 }
14610 else {
14611 180 $self->{config}{SID} = uc $sid;
14612 }
14613 }
14614  
14615 $self->{config}{BANLEN}
14616 182 = sum(@{ $self->{config} }{qw(NICKLEN USERLEN HOSTLEN)}, 3);
14617 $self->{config}{USERHOST_REPLYLEN}
14618 182 = sum(@{ $self->{config} }{qw(NICKLEN USERLEN HOSTLEN)}, 5);
14619  
14620 182 $self->{config}{SERVERNAME} =~ s/[^a-zA-Z0-9\-.]//g;
14621 182 ▶ if ($self->{config}{SERVERNAME} !~ /\./) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"}{"SERVERNAME"} =~ /\./) 0 182 182
14622 0 $self->{config}{SERVERNAME} .= '.';
14623 }
14624  
14625 182 ▶ 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) 0 0 0
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
18200
not defined $self->{"config"}{"ADMIN"} or ref $self->{"config"}{"ADMIN"} ne "ARRAY"
l!l&&r!l&&!r
18200
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
14626 || ref $self->{config}{ADMIN} ne 'ARRAY'
14627 0 || @{ $self->{config}{ADMIN} } != 3) {
14628 182 $self->{config}{ADMIN} = [];
14629 182 $self->{config}{ADMIN}[0] = 'Somewhere, Somewhere, Somewhere';
14630 182 $self->{config}{ADMIN}[1] = 'Some Institution';
14631 182 $self->{config}{ADMIN}[2] = 'someone@somewhere';
14632 }
14633  
14634 182 ▶ if (!defined $self->{config}{INFO}
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY" or !@{$self->{"config"}{"INFO"};} == 1) 0 0 0
Condition33%2/6
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY" or !@{$self->{"config"}{"INFO"};} == 1
l!l&&r!l&&!r
18200
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY"
l!l&&r!l&&!r
18200
MC/DC0%0/3
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY" or !@{$self->{"config"}{"INFO"};} == 1
not defined $self->{"config"}{"INFO"} ref $self->{"config"}{"INFO"} ne "ARRAY" !@{$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= !@{$self->{"config"}{"INFO"};} == 1
ABCresult
1XX1
01X1
0011
0000
14635 || ref $self->{config}{INFO} ne 'ARRAY'
14636 0 || !@{ $self->{config}{INFO} } == 1) {
14637 182 $self->{config}{INFO} = [split /\n/, <<'EOF'];
14638 # POE::Component::Server::IRC
14639 #
14640 # Author: Chris "BinGOs" Williams
14641 #
14642 # Filter-IRCD Written by Hachi
14643 #
14644 # This module may be used, modified, and distributed under the same
14645 # terms as Perl itself. Please see the license that came with your Perl
14646 # distribution for details.
14647 #
14648 EOF
14649 }
14650  
14651 $self->{Error_Codes} = {
14652 182 263 => [1, "Server load is temporarily too heavy. Please wait a while and try again."],
14653 401 => [1, "No such nick/channel"],
14654 402 => [1, "No such server"],
14655 403 => [1, "No such channel"],
14656 404 => [1, "Cannot send to channel"],
14657 405 => [1, "You have joined too many channels"],
14658 406 => [1, "There was no such nickname"],
14659 407 => [1, "Too many targets"],
14660 408 => [1, "You cannot use control codes on this channel"],
14661 409 => [0, "No origin specified"],
14662 410 => [1, "Invalid CAP subcommand"],
14663 411 => [0, "No recipient given (%s)"],
14664 412 => [0, "No text to send"],
14665 413 => [1, "No toplevel domain specified"],
14666 414 => [1, "Wildcard in toplevel domain"],
14667 415 => [1, "Bad server/host mask"],
14668 421 => [1, "Unknown command"],
14669 422 => [0, "MOTD File is missing"],
14670 423 => [1, "No administrative info available"],
14671 424 => [1, "File error doing % on %"],
14672 431 => [1, "No nickname given"],
14673 432 => [1, "Erroneous nickname"],
14674 433 => [1, "Nickname is already in use"],
14675 436 => [1, "Nickname collision KILL from %s\@%s"],
14676 437 => [1, "Nick/channel is temporarily unavailable"],
14677 438 => [1, "Nick change too fast. Please wait %s seconds."],
14678 440 => [1, "Services are currently unavailable."],
14679 441 => [1, "They aren\'t on that channel"],
14680 442 => [1, "You\'re not on that channel"],
14681 443 => [2, "is already on channel"],
14682 444 => [1, "User not logged in"],
14683 445 => [0, "SUMMON has been disabled"],
14684 446 => [0, "USERS has been disabled"],
14685 447 => [0, "Cannot change nickname while on %s (+N)"],
14686 451 => [0, "You have not registered"],
14687 461 => [1, "Not enough parameters"],
14688 462 => [0, "Unauthorised command (already registered)"],
14689 463 => [0, "Your host isn\'t among the privileged"],
14690 464 => [0, "Password incorrect"],
14691 465 => [0, "You are banned from this server"],
14692 466 => [0, "You will be banned from this server"],
14693 467 => [1, "Channel key already set"],
14694 471 => [1, "Cannot join channel (+l)"],
14695 472 => [1, "is unknown mode char to me for %s"],
14696 473 => [1, "Cannot join channel (+i)"],
14697 474 => [1, "Cannot join channel (+b)"],
14698 475 => [1, "Cannot join channel (+k)"],
14699 476 => [1, "Bad Channel Mask"],
14700 477 => [1, "You need to identify to a registered nick to join or speak in that channel."],
14701 478 => [2, "Channel list is full"],
14702 481 => [0, "Permission Denied- You\'re not an IRC operator"],
14703 482 => [1, "You\'re not channel operator"],
14704 483 => [0, "You can\'t kill a server!"],
14705 484 => [0, "Your connection is restricted!"],
14706 485 => [1, "Cannot join channel (%s)"],
14707 489 => [1, "Cannot join channel (+S) - SSL/TLS required"],
14708 491 => [0, "Only few of mere mortals may try to enter the twilight zone"],
14709 492 => [1, "You cannot send CTCPs to this channel."],
14710 501 => [0, "Unknown MODE flag"],
14711 502 => [0, "Cannot change mode for other users"],
14712 512 => [0, "Maximum size for WATCH-list is %s entries"],
14713 520 => [1, "Cannot join channel (+O)"],
14714 521 => [0, "Bad list syntax"],
14715 524 => [1, "Help not found"],
14716 710 => [2, "has asked for an invite."],
14717 711 => [1, "Your KNOCK has been delivered."],
14718 712 => [1, "Too many KNOCKs (%s)."],
14719 713 => [1, "Channel is open."],
14720 714 => [1, "You are already on that channel."],
14721 723 => [1, "Insufficient oper privileges."],
14722 };
14723  
14724 $self->{config}{isupport} = {
14725 INVEX => 'I',
14726 EXCEPTS => 'e',
14727 CALLERID => undef,
14728 CHANTYPES => '#&',
14729 KNOCK => undef,
14730 PREFIX => '(ohv)@%+',
14731 CHANMODES => 'beI,k,l,cimnprstuCLMNORST',
14732 STATUSMSG => '@%+',
14733 DEAF => 'D',
14734 MAXLIST => 'beI:' . $self->{config}{MAXBANS},
14735 SAFELIST => undef,
14736 ELIST => 'CMNTU',
14737 182 map { ($_, $self->{config}{$_}) }
14738 qw(MAXCHANNELS MAXTARGETS NICKLEN TOPICLEN KICKLEN CASEMAPPING
14739 NETWORK MODES AWAYLEN),
14740 };
14741  
14742 182 $self->{config}{capab} = [qw(KNOCK DLN TBURST UNDLN ENCAP UNKLN KLN RHOST SVS CLUSTER EOB QS)];
14743  
14744 182 $self->{config}{cmds}{uc $_}++ for
14745 qw[accept admin away bmask cap close connect die dline encap eob etrace globops info invite ison isupport join kick kill],
14746 qw[kline knock links list locops lusers map message mode motd names nick oper part pass ping pong quit rehash remove],
14747 qw[resv rkline set sid sjoin squit stats summon svinfo svshost svsjoin svskill svsmode svsnick svspart svstag tburst time],
14748 qw[tmode topic trace uid umode undline unkline unresv unrkline unxline user userhost users version wallops watch who whois whowas xline];
14749  
14750 182 return 1;
14751 }
14752  
14753 sub _send_to_realops {
14754 2127 ▶ my $self = shift;
Subroutine _send_to_realops: called CC=6 SCAR=17.9
14755 2127 ▶ my $msg = shift || return;
Condition50%1/2
shift() || (return)
l!l
21270
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14756 2127 ▶ my $type = shift || 'Notice';
Condition100%2/2
shift() || 'Notice'
l!l
207255
MC/DC100%1/1
shift() || 'Notice'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
14757 2127 my $flags = shift; # Future use
14758 2127 my $server = $self->server_name();
14759 2127 ▶ $flags =~ s/[^a-zA-Z]+//g if $flags;
Branch: 1 branch
BranchTrueFalseTotal
if $flags 2072 55 2127
14760  
14761 2127 my %types = (
14762 NOTICE => 'Notice',
14763 LOCOPS => 'LocOps',
14764 GLOBOPS => 'Global',
14765 );
14766  
14767 my $notice =
14768 2127 ▶ sprintf('*** %s -- %s', ( $types{uc $type} || 'Notice' ), $msg );
Condition50%1/2
$types{uc $type} || 'Notice'
l!l
21270
MC/DC0%0/1
$types{uc $type} || 'Notice'
$types{uc $type}
Truth table50%1/2
A
A= $types{uc $type}
Aresult
11
00
14769  
14770 2127 my @locops;
14771  
14772 2127 ▶ if ( $flags ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags) { } 2072 55 2127
14773 39 @locops = grep { $self->{state}{conns}{$_}{umode} =~ m![$flags]! }
14774 2072 keys %{ $self->{state}{localops} };
14775 }
14776 else {
14777 55 @locops = keys %{ $self->{state}{localops} };
14778 }
14779  
14780 2127 $self->send_event( 'daemon_snotice', $notice );
14781  
14782 2127 $self->send_output(
14783 {
14784 prefix => $server,
14785 command => 'NOTICE',
14786 params => [
14787 '*',
14788 $notice,
14789 ],
14790 },
14791 @locops,
14792 );
14793 2127 return 1;
14794 }
14795  
14796 sub _send_output_to_client {
14797 2453 ▶ my $self = shift;
Subroutine _send_output_to_client: called CC=10 SCAR=23.1
14798 2453 ▶ my $wheel_id = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
24530
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14799 2453 my $nick = $self->_client_nickname($wheel_id);
14800 2453 my $prefix = $self->server_name();
14801 2453 ▶ if ( $self->_connection_is_peer($wheel_id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_peer($wheel_id)) 34 2419 2453
14802 34 $nick = shift;
14803 34 $prefix = $self->server_sid();
14804 }
14805 2453 ▶ my $err = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
24530
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
14806 2453 ▶ return if !$self->_connection_exists($wheel_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($wheel_id) 0 2453 2453
14807  
14808 SWITCH: {
14809 2453 ▶ if (ref $err eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $err eq "HASH") 2391 62 2453
14810 2391 $self->send_output($err, $wheel_id);
14811 2391 last SWITCH;
14812 }
14813 62 ▶ if (defined $self->{Error_Codes}{$err}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"Error_Codes"}{$err}) 62 0 62
14814 62 my $input = {
14815 command => $err,
14816 prefix => $self->server_name(),
14817 params => [$nick],
14818 };
14819 62 ▶ if ($self->{Error_Codes}{$err}[0] > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Error_Codes"}{$err}[0] > 0) 40 22 62
14820 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
14821 40 push @{ $input->{params} }, shift;
14822 }
14823 }
14824 62 ▶ if ($self->{Error_Codes}{$err}[1] =~ /%/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Error_Codes'}{$err}[1] =~ /%/) { } 6 56 62
14825 6 push @{ $input->{params} },
14826 6 sprintf($self->{Error_Codes}{$err}[1], @_);
14827 }
14828 else {
14829 56 push @{ $input->{params} }, $self->{Error_Codes}{$err}[1];
14830 }
14831 62 $self->send_output($input, $wheel_id);
14832 }
14833 }
14834  
14835 2453 return 1;
14836 }
14837  
14838 sub _send_output_channel_local {
14839 199 ▶ my $self = shift;
Subroutine _send_output_channel_local: called CC=29 SCAR=33.9
14840 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
14841 199 ▶ return if !$self->state_chan_exists($channel);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($channel) 0 199 199
14842 199 my ($output,$conn_id,$status,$poscap,$negcap) = @_;
14843 199 ▶ return if !$output;
Branch: 1 branch
BranchTrueFalseTotal
unless $output 0 199 199
14844 199 my $sid = $self->server_sid();
14845  
14846 199 ▶ my $is_msg = ( $output->{command} =~ m!^(PRIVMSG|NOTICE)$! ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$output->{'command'} =~ /^(PRIVMSG|NOTICE)$/ ? : 6 193 199
14847 199 my $chanrec = $self->{state}{chans}{uc_irc($channel)};
14848 199 my @targs;
14849 199 ▶ my $negative = ( $status ? $status =~ s!^\-!! : '' );
Branch: 1 branch
BranchTrueFalseTotal
$status ? : 13 186 199
14850 199 UID: foreach my $uid ( keys %{ $chanrec->{users} } ) {
14851 771 ▶ next if $uid !~ m!^$sid!;
Branch: 1 branch
BranchTrueFalseTotal
unless $uid =~ /^$sid/ 339 432 771
14852 432 my $route_id = $self->_state_uid_route( $uid );
14853 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
14854 125 next UID;
14855 }
14856 307 ▶ if ( $status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) 21 286 307
14857 21 my $matched;
14858 21 STATUS: foreach my $stat ( split //, $status ) {
14859 42 ▶ $matched++ if $chanrec->{users}{$uid} =~ m!$stat!;
Branch: 1 branch
BranchTrueFalseTotal
if $chanrec->{"users"}{$uid} =~ /$stat/ 15 27 42
14860 }
14861 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
14862 }
14863 298 ▶ if ( $poscap ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($poscap) 88 210 298
14864 88 ▶ foreach my $cap ( @{ ref $poscap eq 'ARRAY' ? $poscap : [ $poscap ] } ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $poscap eq 'ARRAY' ? : 0 88 88
14865 88 ▶ next UID if !$self->{state}{uids}{$uid}{caps}{$cap};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"uids"}{$uid}{"caps"}{$cap} 75 13 88
14866 }
14867 }
14868 223 ▶ if ( $negcap ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($negcap) 90 133 223
14869 90 ▶ foreach my $cap ( @{ ref $negcap eq 'ARRAY' ? $negcap : [ $negcap ] } ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $negcap eq 'ARRAY' ? : 6 84 90
14870 93 ▶ next UID if $self->{state}{uids}{$uid}{caps}{$cap};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"uids"}{$uid}{"caps"}{$cap} 15 78 93
14871 }
14872 }
14873 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
14874 0 next UID;
14875 }
14876 # Default
14877 208 push @targs, $route_id;
14878 }
14879  
14880 199 $self->send_output($output,@targs);
14881  
14882 199 my $spoofs = grep { $_ eq 'spoofed' } @targs;
14883  
14884 $self->send_event(
14885 "daemon_" . lc $output->{command},
14886 $output->{prefix},
14887 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
14888 ) if !$is_msg || $spoofs;
14889  
14890 199 return 1;
14891 }
14892  
14893 sub _duration {
14894 223 ▶ my $duration = shift;
Subroutine _duration: called CC=7 SCAR=24.8
14895 223 ▶ $duration = 0 if !defined $duration || $duration !~ m!^\d+$!;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $duration and $duration =~ /^\d+$/ 0 223 223
Condition33%1/3
defined $duration and $duration =~ /^\d+$/
!ll&&!rl&&r
00223
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
14896 223 my $timestr;
14897 223 my $days = my $hours = my $mins = my $secs = 0;
14898 223 ▶ while ($duration >= 60 * 60 * 24) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration >= 86400) 0 223 223
14899 0 $duration -= 60 * 60 * 24;
14900 0 ++$days;
14901 }
14902 223 ▶ while ($duration >= 60 * 60) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration >= 3600) 0 223 223
14903 0 $duration -= 60 * 60;
14904 0 ++$hours;
14905 }
14906 223 ▶ while ($duration >= 60) {
Branch: 1 branch
BranchTrueFalseTotal
if ($duration >= 60) 0 223 223
14907 0 $duration -= 60;
14908 0 ++$mins;
14909 }
14910 223 $secs = $duration;
14911 223 ▶ return sprintf(
Branch: 1 branch
BranchTrueFalseTotal
$days == 1 ? : 0 223 223
14912 '%u day%s, %02u:%02u:%02u',
14913 $days, ($days == 1 ? '' : 's'), $hours, $mins, $secs,
14914 );
14915 }
14916  
14917 sub add_operator {
14918 29 ▶ my $self = shift;
Subroutine add_operator: called CC=14 SCAR=37.5
Pod documented
14919 29 my $ref;
14920 29 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 29 0 29
14921 29 $ref = $_[0];
14922 }
14923 else {
14924 0 $ref = { @_ };
14925 }
14926 29 $ref->{lc $_} = delete $ref->{$_} for keys %$ref;
14927  
14928 29 ▶ if (!defined $ref->{username} || !defined $ref->{password}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ref->{"username"} and defined $ref->{"password"}) 0 29 29
Condition33%1/3
defined $ref->{"username"} and defined $ref->{"password"}
!ll&&!rl&&r
0029
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
14929 0 warn "Not enough parameters\n";
14930 0 return;
14931 }
14932  
14933 29 ▶ 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 29 29
Condition66%4/6
$ref->{"ssl_required"} || $ref->{"certfp"} and not $self->{"got_ssl"}
!ll&&!rl&&r
2450
$ref->{"ssl_required"} or $ref->{"certfp"}
l!l&&r!l&&!r
5024
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
14934 0 warn "SSL required, but it is not supported, ignoring\n";
14935 0 delete $ref->{ssl_required};
14936 0 delete $ref->{certfp};
14937 }
14938  
14939 29 ▶ if ( $ref->{ipmask} && $ref->{ipmask} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->{"ipmask"} and $ref->{"ipmask"} eq "ARRAY") 0 29 29
Condition33%1/3
$ref->{"ipmask"} and $ref->{"ipmask"} eq "ARRAY"
!ll&&!rl&&r
2900
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
14940 0 my @validated;
14941 0 foreach my $mask ( @{ $ref->{ipmask} } ) {
14942 0 ▶ if ( eval { $mask->isa('Net::Netmask' ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $mask->isa("Net::Netmask") } }) 0 0 0
14943 0 push @validated, $mask;
14944 0 next;
14945 }
14946 0 my $valid = Net::CIDR::cidrvalidate($mask);
14947 0 ▶ push @validated, $valid if $valid;
Branch: 1 branch
BranchTrueFalseTotal
if $valid 0 0 0
14948 }
14949 0 $ref->{ipmask} = \@validated;
14950 }
14951  
14952 29 ▶ if ( $ref->{umode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->{"umode"}) 27 2 29
14953 27 $ref->{umode} =~ s/[^DFGHRSWXabcdefgijklnopqrsuwy]+//g;
14954 27 $ref->{umode} =~ s/[SWori]+//g;
14955 }
14956  
14957 29 my $record = $self->{state}{peers}{uc $self->server_name()};
14958 29 my $user = delete $ref->{username};
14959 29 $self->{config}{ops}{$user} = $ref;
14960 29 return 1;
14961 }
14962  
14963 sub del_operator {
14964 0 ▶ my $self = shift;
Subroutine del_operator: not called CC=3 SCAR=24.8
Pod documented
14965 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
14966 0 ▶ return if !defined $self->{config}{ops}{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{"ops"}{$user} 0 0 0
14967 0 delete $self->{config}{ops}{$user};
14968 0 return;
14969 }
14970  
14971 sub add_service {
14972 45 ▶ my $self = shift;
Subroutine add_service: called CC=2 SCAR=7.0
Pod documented
14973 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
14974 45 $self->{state}{services}{uc $host} = $host;
14975 45 return 1;
14976 }
14977  
14978 sub del_service {
14979 0 ▶ my $self = shift;
Subroutine del_service: not called CC=2 SCAR=17.9
Pod documented
14980 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
14981 0 delete $self->{state}{services}{uc $host};
14982 0 return 1;
14983 }
14984  
14985 sub add_auth {
14986 6 ▶ my $self = shift;
Subroutine add_auth: called CC=4 SCAR=15.0
Pod documented
14987 6 my $parms;
14988 6 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 6 6
14989 0 $parms = $_[0];
14990 }
14991 else {
14992 6 $parms = { @_ };
14993 }
14994 6 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
14995  
14996 6 ▶ if (!$parms->{mask}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parms->{"mask"}) 0 6 6
14997 0 warn "Not enough parameters specified\n";
14998 0 return;
14999 }
15000 6 push @{ $self->{config}{auth} }, $parms;
15001 6 return 1;
15002 }
15003  
15004 sub del_auth {
15005 0 ▶ my $self = shift;
Subroutine del_auth: not called CC=4 SCAR=30.0
Pod documented
15006 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
15007 0 my $i = 0;
15008  
15009 0 for (@{ $self->{config}{auth} }) {
15010 0 ▶ if ($_->{mask} eq $mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"mask"} eq $mask) 0 0 0
15011 0 splice( @{ $self->{config}{auth} }, $i, 1 );
15012 0 last;
15013 }
15014 0 ++$i;
15015 }
15016 0 return;
15017 }
15018  
15019 sub add_peer {
15020 286 ▶ my $self = shift;
Subroutine add_peer: called CC=23 SCAR=40.5
Pod documented
15021 286 my $parms;
15022 286 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 286 286
15023 0 $parms = $_[0];
15024 }
15025 else {
15026 286 $parms = { @_ };
15027 }
15028 286 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
15029  
15030 286 ▶ if (!defined $parms->{name} || !defined $parms->{pass}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}) 0 286 286
Condition33%2/6
defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}
!ll&&!rl&&r
00286
defined $parms->{"name"} and defined $parms->{"pass"}
!ll&&!rl&&r
00286
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
15031 || !defined $parms->{rpass}) {
15032 0 croak((caller(0))[3].": Not enough parameters specified\n");
15033 0 return;
15034 }
15035  
15036 286 ▶ $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" 283 3 286
Condition66%2/3
not $parms->{"type"} or lc $parms->{"type"} ne "r"
l!l&&r!l&&!r
02833
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
15037 286 $parms->{type} = lc $parms->{type};
15038 286 ▶ $parms->{rport} = 6667 if $parms->{type} eq 'r' && !$parms->{rport};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"type"} eq "r" and not $parms->{"rport"} 0 286 286
Condition66%2/3
$parms->{"type"} eq "r" and not $parms->{"rport"}
!ll&&!rl&&r
28330
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
15039  
15040 286 for (qw(sockport sockaddr)) {
15041 572 ▶ $parms->{ $_ } = '*' if !$parms->{ $_ };
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{$_} 572 0 572
15042 }
15043  
15044 286 ▶ $parms->{ipmask} = $parms->{raddress} if $parms->{raddress};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"raddress"} 3 283 286
15045 286 ▶ $parms->{zip} = 0 if !$parms->{zip};
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{"zip"} 4 282 286
15046 286 ▶ $parms->{ssl} = 0 if !$parms->{ssl};
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{"ssl"} 285 1 286
15047  
15048 286 ▶ if ( $parms->{ipmask} && $parms->{ipmask} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parms->{"ipmask"} and $parms->{"ipmask"} eq "ARRAY") 0 286 286
Condition66%2/3
$parms->{"ipmask"} and $parms->{"ipmask"} eq "ARRAY"
!ll&&!rl&&r
28330
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
15049 0 my @validated;
15050 0 foreach my $mask ( @{ $parms->{ipmask} } ) {
15051 0 ▶ if ( eval { $mask->isa('Net::Netmask' ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $mask->isa("Net::Netmask") } }) 0 0 0
15052 0 push @validated, $mask;
15053 0 next;
15054 }
15055 0 my $valid = Net::CIDR::cidrvalidate($mask);
15056 0 ▶ push @validated, $valid if $valid;
Branch: 1 branch
BranchTrueFalseTotal
if $valid 0 0 0
15057 }
15058 0 $parms->{ipmask} = \@validated;
15059 }
15060  
15061 286 my $name = $parms->{name};
15062 286 $self->{config}{peers}{uc $name} = $parms;
15063 286 ▶ $self->add_service( $name ) if $parms->{service};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"service"} 0 286 286
15064 $self->add_connector(
15065 remoteaddress => $parms->{raddress},
15066 remoteport => $parms->{rport},
15067 name => $name,
15068 usessl => $parms->{ssl},
15069 286 ▶ ) if $parms->{type} eq 'r' && $parms->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"type"} eq "r" and $parms->{"auto"} 3 283 286
Condition66%2/3
$parms->{"type"} eq "r" and $parms->{"auto"}
!ll&&!rl&&r
28303
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
15070  
15071 286 return 1;
15072 }
15073  
15074 sub del_peer {
15075 0 ▶ my $self = shift;
Subroutine del_peer: not called CC=4 SCAR=30.0
Pod documented
15076 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
15077 0 ▶ return if !defined $self->{config}{peers}{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{"peers"}{uc $name} 0 0 0
15078 0 my $rec = delete $self->{config}{peers}{uc $name};
15079 0 ▶ $self->del_service( $rec->{name} ) if $rec->{service};
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"service"} 0 0 0
15080 0 return;
15081 }
15082  
15083 sub add_pseudo {
15084 2 ▶ my $self = shift;
Subroutine add_pseudo: called CC=11 SCAR=31.1
Pod documented
15085 2 my $parms;
15086 2 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 2 0 2
15087 2 $parms = $_[0];
15088 }
15089 else {
15090 0 $parms = { @_ };
15091 }
15092 2 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
15093  
15094 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
15095 || !defined $parms->{target}) {
15096 0 croak((caller(0))[3].": Not enough parameters specified\n");
15097 0 return;
15098 }
15099  
15100 2 my ($nick,$user,$host) = parse_user( $parms->{target} );
15101  
15102 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
15103 0 croak((caller(0))[3].": target is invalid\n");
15104 0 return;
15105 }
15106  
15107 2 $parms->{nick} = $nick;
15108 2 $parms->{user} = $user;
15109 2 $parms->{host} = $host;
15110  
15111 2 my $cmd = delete $parms->{cmd};
15112 2 $cmd = uc $cmd;
15113  
15114 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
15115 0 croak((caller(0))[3].": That command already exists\n");
15116 0 return;
15117 }
15118  
15119 2 $self->{config}{pseudo}{$cmd} = $parms;
15120 2 return 1;
15121 }
15122  
15123 sub del_pseudo {
15124 0 ▶ my $self = shift;
Subroutine del_pseudo: not called CC=2 SCAR=17.9
Pod documented
15125 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
15126 0 delete $self->{config}{pseudo}{uc $cmd};
15127 0 return 1;
15128 }
15129  
15130 sub _terminate_conn_error {
15131 236 ▶ my $self = shift;
Subroutine _terminate_conn_error: called CC=6 SCAR=18.0
15132 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
15133 236 my $msg = shift;
15134 236 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 236 236
15135  
15136 236 $self->disconnect($conn_id, $msg);
15137 236 $self->{state}{conns}{$conn_id}{terminated} = 1;
15138 236 ▶ if ( $self->{state}{conns}{$conn_id}{type} eq 'c' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"conns"}{$conn_id}{"type"} eq "c") 201 35 236
15139 201 my $conn = $self->{state}{conns}{$conn_id};
15140 $self->_send_to_realops(
15141 sprintf(
15142 'Client exiting: %s (%s@%s) [%s] [%s]',
15143 $conn->{nick},
15144 $conn->{auth}{ident},
15145 $conn->{auth}{realhost},
15146 201 $conn->{socket}[0],
15147 $msg,
15148 ),
15149 'Notice',
15150 'c',
15151 );
15152 }
15153 $self->send_output(
15154 {
15155 236 command => 'ERROR',
15156 params => [
15157 'Closing Link: ' . $self->_client_ip($conn_id)
15158 . ' (' . $msg . ')',
15159 ],
15160 },
15161 $conn_id,
15162 );
15163  
15164 236 foreach my $nick ( keys %{ $self->{state}{pending} }) {
15165 19 my $id = $self->{state}{pending}{$nick};
15166 19 ▶ if ($id == $conn_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id == $conn_id) 19 0 19
15167 19 delete $self->{state}{pending}{$nick};
15168 19 last;
15169 }
15170 }
15171  
15172 236 return 1;
15173 }
15174  
15175 sub daemon_server_join {
15176 4 ▶ my $self = shift;
Subroutine daemon_server_join: called CC=9 SCAR=27.0
Pod documented
15177 4 my $server = $self->server_name();
15178 4 my $mysid = $self->server_sid();
15179 4 my $ref = [ ];
15180 4 my $args = [ @_ ];
15181 4 my $count = @$args;
15182  
15183 SWITCH: {
15184 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
15185 0 last SWITCH;
15186 }
15187 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
15188 0 last SWITCH;
15189 }
15190 ▶ 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
15191 0 last SWITCH;
15192 }
15193 4 ▶ if ( $args->[1] !~ m!^[#&]! ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[1] =~ /^[#&]/) 0 4 4
15194 0 last SWITCH;
15195 }
15196 4 $ref = $self->_daemon_peer_svsjoin( 'spoofed', $mysid, @$args );
15197 }
15198  
15199 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
15200 4 return $ref;
15201 }
15202  
15203 sub daemon_server_kill {
15204 6 ▶ my $self = shift;
Subroutine daemon_server_kill: called CC=14 SCAR=31.4
Pod documented
15205 6 my $server = $self->server_name();
15206 6 my $mysid = $self->server_sid();
15207 6 my $ref = [ ];
15208 6 my $args = [ @_ ];
15209 6 my $count = @$args;
15210  
15211 SWITCH: {
15212 6 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 6 6
15213 0 last SWITCH;
15214 }
15215 6 ▶ 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 6 6
elsif (not $args->[0] =~ /^\d/ || $self->state_nick_exists($args->[0])) { } 0 6 6
Condition33%1/3
$args->[0] =~ /^\d/ and not $self->state_uid_exists($args->[0])
!ll&&!rl&&r
060
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
15216 0 last SWITCH;
15217 }
15218 ▶ 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
600
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
15219 0 last SWITCH;
15220 }
15221  
15222  
15223 6 my $target = $self->state_user_nick($args->[0]);
15224 6 ▶ my $comment = $args->[1] || '<No reason given>';
Condition50%1/2
$args->[1] || '<No reason given>'
l!l
60
MC/DC0%0/1
$args->[1] || '<No reason given>'
$args->[1]
Truth table50%1/2
A
A= $args->[1]
Aresult
11
00
15225 6 ▶ my $conn_id = ($args->[2] && $self->_connection_exists($args->[2])
Branch: 1 branch
BranchTrueFalseTotal
$args->[2] && $self->_connection_exists($args->[2]) ? : 1 5 6
Condition66%2/3
$args->[2] and $self->_connection_exists($args->[2])
!ll&&!rl&&r
501
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
15226 ? $args->[2]
15227 : '');
15228  
15229 6 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 6 0 6
15230 6 my $route_id = $self->_state_user_route($target);
15231 6 $self->send_output(
15232 {
15233 prefix => $server,
15234 command => 'KILL',
15235 params => [$target, $comment],
15236 },
15237 $route_id,
15238 );
15239 $self->send_output(
15240 {
15241 prefix => $mysid,
15242 command => 'KILL',
15243 params => [
15244 $self->state_user_uid($target),
15245 join('!', $server, $target )." ($comment)",
15246 ],
15247 },
15248 6 ▶ grep { !$conn_id || $_ ne $conn_id }
Branch: 1 branch
BranchTrueFalseTotal
not $conn_id or $_ ne $conn_id 2 7 9
15249 $self->_state_connected_peers(),
15250 );
15251 6 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 3 3 6
15252 3 $self->call(
15253 'del_spoofed_nick',
15254 $target,
15255 "Killed ($server ($comment))",
15256 );
15257 }
15258 else {
15259 3 $self->{state}{conns}{$route_id}{killed} = 1;
15260 3 $self->_terminate_conn_error(
15261 $route_id,
15262 "Killed ($server ($comment))",
15263 );
15264 }
15265 }
15266 else {
15267 0 my $tuid = $self->state_user_uid( $target );
15268 0 $self->{state}{uids}{$tuid}{killed} = 1;
15269 $self->send_output(
15270 {
15271 prefix => $mysid,
15272 command => 'KILL',
15273 params => [$tuid, "$server ($comment)"],
15274 },
15275 0 ▶ grep { !$conn_id || $_ ne $conn_id }
Branch: 1 branch
BranchTrueFalseTotal
not $conn_id or $_ ne $conn_id 0 0 0
15276 $self->_state_connected_peers(),
15277 );
15278 $self->send_output(
15279 0 @{ $self->_daemon_peer_quit(
15280 $tuid,
15281 "Killed ($server ($comment))"
15282 ) });
15283 }
15284 }
15285  
15286 6 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 6 6
15287 6 return $ref;
15288 }
15289  
15290 sub daemon_server_mode {
15291 10 ▶ my $self = shift;
Subroutine daemon_server_mode: called CC=53 SCAR=59.0
Pod documented
15292 10 my $chan = shift;
15293 10 my $server = $self->server_name();
15294 10 my $sid = $self->server_sid();
15295 10 my $ref = [ ];
15296 10 my $args = [ @_ ];
15297 10 my $count = @$args;
15298  
15299 SWITCH: {
15300 10 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 10 10
15301 0 last SWITCH;
15302 }
15303 10 my $record = $self->{state}{chans}{uc_irc($chan)};
15304 10 $chan = $record->{name};
15305 10 my $mode_u_set = ( $record->{mode} =~ /u/ );
15306 10 my $full = $server;
15307 10 my %subs; my @reply_args; my $reply;
15308 10 my $parsed_mode = parse_mode_line(@$args);
15309  
15310 10 ▶ while(my $mode = shift (@{ $parsed_mode->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 13 10 23
15311 13 ▶ next if $mode !~ /^[+-][CceIbkMNRSTLOlimnpstohuv]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $mode =~ /^[+-][CceIbkMNRSTLOlimnpstohuv]$/ 0 13 13
15312 13 my $arg;
15313 13 ▶ if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) 3 10 13
15314 3 $arg = shift @{ $parsed_mode->{args} };
15315 }
15316 13 ▶ if (my ($flag, $char) = $mode =~ /^([-+])([ohv])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^([-+])([ohv])/) 2 11 13
15317  
15318 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
15319 && $record->{users}{$self->state_user_uid($arg)} !~ /$char/) {
15320 # Update user and chan record
15321 2 $arg = $self->state_user_uid($arg);
15322 $record->{users}{$arg} = join('', sort
15323 2 split //, $record->{users}{$arg} . $char);
15324 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
15325 2 = $record->{users}{$arg};
15326 2 $reply .= $mode;
15327 2 my $anick = $self->state_user_nick($arg);
15328 2 $subs{$anick} = $arg;
15329 2 push @reply_args, $anick;
15330 }
15331  
15332 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
15333 =~ /$char/) {
15334 # Update user and chan record
15335 0 $arg = $self->state_user_uid($arg);
15336 0 $record->{users}{$arg} =~ s/$char//g;
15337 $self->{state}{uids}{$arg}{chans}{uc_irc($chan)}
15338 0 = $record->{users}{$arg};
15339 0 $reply .= $mode;
15340 0 my $anick = $self->state_user_nick($arg);
15341 0 $subs{$anick} = $arg;
15342 0 push @reply_args, $anick;
15343 }
15344 2 next;
15345 }
15346 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
15347 0 $reply .= $mode;
15348 0 push @reply_args, $arg;
15349 0 ▶ if ($record->{mode} !~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /l/) 0 0 0
15350 $record->{mode} = join('', sort split //,
15351 0 $record->{mode} . 'l');
15352 }
15353 0 $record->{climit} = $arg;
15354 0 next;
15355 }
15356 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
15357 0 $reply .= $mode;
15358 0 $record->{mode} =~ s/l//g;
15359 0 delete $record->{climit};
15360 0 next;
15361 }
15362 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
15363 0 $reply .= $mode;
15364 0 push @reply_args, $arg;
15365 0 ▶ if ($record->{mode} !~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /k/) 0 0 0
15366 $record->{mode} = join('', sort split //,
15367 0 $record->{mode} . 'k');
15368 }
15369 0 $record->{ckey} = $arg;
15370 0 next;
15371 }
15372 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
15373 0 $reply .= $mode;
15374 0 push @reply_args, '*';
15375 0 $record->{mode} =~ s/k//g;
15376 0 delete $record->{ckey};
15377 0 next;
15378 }
15379 # Bans
15380 11 ▶ if (my ($flag) = $mode =~ /(\+|-)b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)b/) 1 10 11
15381 1 my $mask = normalize_mask($arg);
15382 1 my $umask = uc_irc($mask);
15383 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
15384 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
15385 = [$mask, ($full || $server), time];
15386 1 $reply .= $mode;
15387 1 push @reply_args, $mask;
15388 }
15389 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
15390 0 delete $record->{bans}{$umask};
15391 0 $reply .= $mode;
15392 0 push @reply_args, $mask;
15393 }
15394 1 next;
15395 }
15396 # Invex
15397 10 ▶ if (my ($flag) = $mode =~ /(\+|-)I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)I/) 0 10 10
15398 0 my $mask = normalize_mask($arg);
15399 0 my $umask = uc_irc($mask);
15400 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
15401 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
15402 = [$mask, ($full || $server), time];
15403 0 $reply .= $mode;
15404 0 push @reply_args, $mask;
15405 }
15406 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
15407 0 delete $record->{invex}{$umask};
15408 0 $reply .= $mode;
15409 0 push @reply_args, $mask;
15410 }
15411 0 next;
15412 }
15413 # Exceptions
15414 10 ▶ if (my ($flag) = $mode =~ /(\+|-)e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)e/) 0 10 10
15415 0 my $mask = normalize_mask($arg);
15416 0 my $umask = uc_irc($mask);
15417 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
15418 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
15419 = [$mask, ($full || $server), time];
15420 0 $reply .= $mode;
15421 0 push @reply_args, $mask;
15422 }
15423 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
15424 0 delete $record->{excepts}{$umask};
15425 0 $reply .= $mode;
15426 0 push @reply_args, $mask;
15427 }
15428 0 next;
15429 }
15430 # The rest should be argumentless.
15431 10 my ($flag, $char) = split //, $mode;
15432 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
15433 $record->{mode} = join('', sort split //,
15434 7 $record->{mode} . $char);
15435 7 $reply .= $mode;
15436 7 next;
15437 }
15438 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
15439 3 $record->{mode} =~ s/$char//g;
15440 3 $reply .= $mode;
15441 3 next;
15442 }
15443 } # while
15444  
15445 10 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 10 0 10
15446 10 $reply = unparse_mode_line($reply);
15447 my @reply_args_peer = map {
15448 10 ▶ ( defined $subs{$_} ? $subs{$_} : $_ )
Branch: 1 branch
BranchTrueFalseTotal
defined $subs{$_} ? : 2 1 3
15449 } @reply_args;
15450 $self->send_output(
15451 {
15452 prefix => $sid,
15453 command => 'TMODE',
15454 10 params => [$record->{ts}, $chan, $reply, @reply_args_peer],
15455 colonify => 0,
15456 },
15457 $self->_state_connected_peers(),
15458 );
15459 $self->_send_output_channel_local(
15460 $record->{name},
15461 {
15462 prefix => $server,
15463 command => 'MODE',
15464 colonify => 0,
15465 params => [
15466 $record->{name},
15467 10 ▶ $reply,
Branch: 1 branch
BranchTrueFalseTotal
$mode_u_set ? : 2 8 10
15468 @reply_args,
15469 ],
15470 },
15471 '', ( $mode_u_set ? 'oh' : '' ),
15472 );
15473 10 ▶ if ($mode_u_set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode_u_set) 2 8 10
15474 2 my $bparse = parse_mode_line( $reply, @reply_args );
15475 2 my $breply; my @breply_args;
15476 2 ▶ while (my $bmode = shift (@{ $bparse->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $bmode = shift @{$$bparse{"modes"};}) 2 2 4
15477 2 my $arg;
15478 2 ▶ $arg = shift @{ $bparse->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 1 1 2
15479 if $bmode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
15480 2 ▶ next if $bmode =~ m!^[+-][beI]$!;
Branch: 1 branch
BranchTrueFalseTotal
if $bmode =~ /^[+-][beI]$/ 1 1 2
15481 1 $breply .= $bmode;
15482 1 ▶ push @breply_args, $arg if $arg;
Branch: 1 branch
BranchTrueFalseTotal
if $arg 0 1 1
15483 }
15484 2 ▶ if ($breply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($breply) 1 1 2
15485 1 my $parsed_line = unparse_mode_line($breply);
15486 $self->_send_output_channel_local(
15487 $record->{name},
15488 {
15489 prefix => $server,
15490 command => 'MODE',
15491 colonify => 0,
15492 params => [
15493 $record->{name},
15494 1 $parsed_line,
15495 @breply_args,
15496 ],
15497 },
15498 '','-oh',
15499 );
15500 }
15501 }
15502 }
15503 } # SWITCH
15504  
15505 10 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 10 10
15506 10 return $ref;
15507 }
15508  
15509 sub daemon_server_kick {
15510 2 ▶ my $self = shift;
Subroutine daemon_server_kick: called CC=9 SCAR=24.3
Pod documented
15511 2 my $server = $self->server_name();
15512 2 my $sid = $self->server_sid();
15513 2 my $ref = [ ];
15514 2 my $args = [ @_ ];
15515 2 my $count = @$args;
15516  
15517 SWITCH: {
15518 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
15519 0 last SWITCH;
15520 }
15521 2 my $chan = (split /,/, $args->[0])[0];
15522 2 my $who = (split /,/, $args->[1])[0];
15523 2 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 2 2
15524 0 last SWITCH;
15525 }
15526 2 $chan = $self->_state_chan_name($chan);
15527 2 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 2 2
15528 0 last SWITCH;
15529 }
15530 2 $who = $self->state_user_nick($who);
15531 2 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 2 2
15532 0 last SWITCH;
15533 }
15534 2 my $wuid = $self->state_user_uid($who);
15535 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
15536 2 $self->send_output(
15537 {
15538 prefix => $sid,
15539 command => 'KICK',
15540 params => [$chan, $wuid, $comment],
15541 },
15542 $self->_state_connected_peers(),
15543 );
15544 2 $self->_send_output_channel_local(
15545 $chan,
15546 {
15547 prefix => $server,
15548 command => 'KICK',
15549 params => [$chan, $who, $comment],
15550 },
15551 );
15552 2 $chan = uc_irc($chan);
15553 2 delete $self->{state}{chans}{$chan}{users}{$wuid};
15554 2 delete $self->{state}{uids}{$wuid}{chans}{$chan};
15555 2 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 2 2
15556 0 delete $self->{state}{chans}{$chan};
15557 }
15558 }
15559  
15560 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
15561 2 return $ref;
15562 }
15563  
15564 sub daemon_server_remove {
15565 1 ▶ my $self = shift;
Subroutine daemon_server_remove: called CC=9 SCAR=23.5
Pod documented
15566 1 my $server = $self->server_name();
15567 1 my $ref = [ ];
15568 1 my $args = [ @_ ];
15569 1 my $count = @$args;
15570  
15571 SWITCH: {
15572 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
15573 0 last SWITCH;
15574 }
15575 1 my $chan = (split /,/, $args->[0])[0];
15576 1 my $who = (split /,/, $args->[1])[0];
15577 1 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 1 1
15578 0 last SWITCH;
15579 }
15580 1 $chan = $self->_state_chan_name($chan);
15581 1 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 1 1
15582 0 last SWITCH;
15583 }
15584 1 my $fullwho = $self->state_user_full($who);
15585 1 $who = (split /!/, $who)[0];
15586 1 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 1 1
15587 0 last SWITCH;
15588 }
15589 1 my $wuid = $self->state_user_uid($who);
15590 1 my $comment = 'Enforced PART';
15591 1 ▶ $comment .= " \"$args->[2]\"" if $args->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[2] 1 0 1
15592 1 $self->send_output(
15593 {
15594 prefix => $wuid,
15595 command => 'PART',
15596 params => [$chan, $comment],
15597 },
15598 $self->_state_connected_peers(),
15599 );
15600 1 $self->_send_output_channel_local(
15601 $chan,
15602 {
15603 prefix => $fullwho,
15604 command => 'PART',
15605 params => [$chan, $comment],
15606 },
15607 );
15608 1 $chan = uc_irc($chan);
15609 1 delete $self->{state}{chans}{$chan}{users}{$wuid};
15610 1 delete $self->{state}{uids}{$wuid}{chans}{$chan};
15611 1 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 1 0 1
15612 1 delete $self->{state}{chans}{$chan};
15613 }
15614 }
15615  
15616 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
15617 1 return $ref;
15618 }
15619  
15620 sub daemon_server_wallops {
15621 0 ▶ my $self = shift;
Subroutine daemon_server_wallops: not called CC=3 SCAR=24.8
Pod documented
15622 0 my $server = $self->server_name();
15623 0 my $sid = $self->server_sid();
15624 0 my $ref = [ ];
15625 0 my $args = [ @_ ];
15626 0 my $count = @$args;
15627  
15628 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
15629 0 $self->send_output(
15630 {
15631 prefix => $sid,
15632 command => 'WALLOPS',
15633 params => [$args->[0]],
15634 },
15635 $self->_state_connected_peers(),
15636 );
15637 $self->send_output(
15638 {
15639 prefix => $server,
15640 command => 'WALLOPS',
15641 params => [$args->[0]],
15642 },
15643 0 keys %{ $self->{state}{wallops} },
15644 );
15645 0 $self->send_event("daemon_wallops", $server, $args->[0]);
15646 }
15647  
15648 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
15649 0 return $ref;
15650 }
15651  
15652 sub daemon_server_realops {
15653 0 ▶ my $self = shift;
Subroutine daemon_server_realops: not called CC=3 SCAR=24.8
Pod documented
15654 0 my $ref = [ ];
15655 0 my $args = [ @_ ];
15656 0 my $count = @$args;
15657  
15658 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
15659 0 $self->_send_to_realops( @$args );
15660 }
15661  
15662 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
15663 0 return $ref;
15664 }
15665  
15666 sub add_spoofed_nick {
15667 41 ▶ my ($kernel, $self) = @_[KERNEL, OBJECT];
Subroutine add_spoofed_nick: called CC=21 SCAR=33.6
Pod documented
15668 41 my $ref;
15669 41 ▶ if (ref $_[ARG0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[10] eq 'HASH') { } 41 0 41
15670 41 $ref = $_[ARG0];
15671 }
15672 else {
15673 0 $ref = { @_[ARG0..$#_] };
15674 }
15675  
15676 41 $ref->{ lc $_ } = delete $ref->{$_} for keys %$ref;
15677 41 ▶ return if !$ref->{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->{"nick"} 0 41 41
15678 41 ▶ return if $self->state_nick_exists($ref->{nick});
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_nick_exists($ref->{"nick"}) 0 41 41
15679 41 my $record = $ref;
15680 41 $record->{uid} = $self->_state_gen_uid();
15681 41 $record->{sid} = substr $record->{uid}, 0, 3;
15682 41 ▶ $record->{ts} = time if !$record->{ts};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"ts"} 35 6 41
15683 41 $record->{type} = 's';
15684 41 $record->{server} = $self->server_name();
15685 41 $record->{hops} = 0;
15686 41 $record->{route_id} = 'spoofed';
15687 41 ▶ $record->{umode} = 'i' if !$record->{umode};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"umode"} 0 41 41
15688 41 ▶ if (!defined $record->{ircname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record->{"ircname"}) 31 10 41
15689 31 $record->{ircname} = "* I'm too lame to read the documentation *";
15690 }
15691 41 ▶ $self->{state}{stats}{invisible}++ if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 8 33 41
15692 41 ▶ $self->{state}{stats}{ops_online}++ if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 34 7 41
15693 41 $record->{idle_time} = $record->{conn_time} = $record->{ts};
15694 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
15695 $record->{auth}{hostname} = delete $record->{hostname}
15696 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
15697 41 $record->{auth}{realhost} = $record->{auth}{hostname};
15698 41 ▶ $record->{account} = '*' if !$record->{account};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"account"} 41 0 41
15699 41 $record->{ipaddress} = 0;
15700 41 $self->{state}{users}{uc_irc($record->{nick})} = $record;
15701 41 ▶ $self->{state}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 41 0 41
15702 41 $self->{state}{peers}{uc $record->{server}}{users}{uc_irc($record->{nick})} = $record;
15703 41 ▶ $self->{state}{peers}{uc $record->{server}}{uids}{ $record->{uid} } = $record if $record->{uid};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"uid"} 41 0 41
15704  
15705 $record->{full} = sub {
15706 return sprintf('%s!%s@%s',
15707 $record->{nick},
15708 $record->{auth}{ident},
15709 82 ▶ $record->{auth}{hostname});
Subroutine __ANON__: called CC=1 SCAR=0.0
15710 41 };
15711  
15712 my $arrayref = [
15713 $record->{nick},
15714 $record->{hops} + 1,
15715 $record->{ts},
15716 '+' . $record->{umode},
15717 $record->{auth}{ident},
15718 $record->{auth}{hostname},
15719 $record->{ipaddress},
15720 $record->{uid},
15721 $record->{account},
15722 $record->{ircname},
15723 41 ];
15724  
15725 my $rhostref = [
15726 $record->{nick},
15727 $record->{hops} + 1,
15728 $record->{ts},
15729 '+' . $record->{umode},
15730 $record->{auth}{ident},
15731 $record->{auth}{hostname},
15732 $record->{auth}{realhost},
15733 $record->{ipaddress},
15734 $record->{uid},
15735 $record->{account},
15736 $record->{ircname},
15737 41 ];
15738  
15739 41 ▶ if (my $whois = $record->{whois}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $whois = $record->{"whois"}) 0 41 41
15740 0 $record->{svstags}{313} = {
15741 numeric => '313',
15742 umodes => '+',
15743 tagline => $whois,
15744 };
15745 }
15746  
15747 41 foreach my $peer_id ( $self->_state_connected_peers() ) {
15748 0 ▶ if ( $self->_state_peer_capab( $peer_id, 'RHOST' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_peer_capab($peer_id, 'RHOST')) { } 0 0 0
15749 $self->send_output(
15750 {
15751 prefix => $record->{sid},
15752 0 command => 'UID',
15753 params => $rhostref,
15754 },
15755 $peer_id,
15756 );
15757 }
15758 else {
15759 $self->send_output(
15760 {
15761 prefix => $record->{sid},
15762 0 command => 'UID',
15763 params => $arrayref,
15764 },
15765 $peer_id,
15766 );
15767 }
15768 $self->send_output(
15769 {
15770 prefix => $record->{sid},
15771 command => 'SVSTAG',
15772 params => [
15773 $record->{uid},
15774 $record->{ts},
15775 '313', '+', $record->{whois},
15776 ],
15777 },
15778 $peer_id,
15779 0 ▶ ) if $record->{whois};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"whois"} 0 0 0
15780 }
15781  
15782  
15783 41 $self->send_event('daemon_uid', @$arrayref);
15784 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
15785 41 ▶ if ( $record->{umode} =~ /o/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /o/) 34 7 41
15786 34 my $notice = sprintf("%s{%s} is now an operator",$record->{full}->(),$record->{nick});
15787 34 $self->_send_to_realops($notice);
15788 }
15789 41 $self->_state_update_stats();
15790 41 return;
15791 }
15792  
15793 sub del_spoofed_nick {
15794 9 ▶ my ($kernel, $self, $nick) = @_[KERNEL, OBJECT, ARG0];
Subroutine del_spoofed_nick: called CC=7 SCAR=23.0
Pod documented
15795 9 ▶ if ( $nick =~ m!^\d! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick =~ /^\d/) { } 0 9 9
15796 0 ▶ return if !$self->state_uid_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_uid_exists($nick) 0 0 0
15797 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
15798 }
15799 else {
15800 9 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 9 9
15801 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
15802 }
15803 9 $nick = $self->state_user_nick($nick);
15804  
15805 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
15806 $self->send_output(
15807 9 @{ $self->_daemon_cmd_quit($nick, qq{"$message"}) },
15808 qq{"$message"},
15809 );
15810 9 return;
15811 }
15812  
15813 sub _spoofed_command {
15814 31 ▶ my ($kernel, $self, $state, $nick) = @_[KERNEL, OBJECT, STATE, ARG0];
Subroutine _spoofed_command: called CC=9 SCAR=24.1
15815 31 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 31 31
15816 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
15817  
15818 31 $nick = $self->state_user_nick($nick);
15819 31 my $uid = $self->state_user_uid($nick);
15820 31 $state =~ s/daemon_cmd_//;
15821 31 my $command = "_daemon_cmd_" . $state;
15822  
15823 31 ▶ if ($state =~ /^(privmsg|notice)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state =~ /^(privmsg|notice)$/) { } 0 31 31
elsif ($state eq 'sjoin') { } 1 30 31
15824 0 my $type = uc $1;
15825 0 $self->_daemon_cmd_message($nick, $type, @_[ARG1 .. $#_]);
15826 0 return;
15827 }
15828 elsif ($state eq 'sjoin') {
15829 1 my $chan = $_[ARG1];
15830 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
15831 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
15832 1 $chan = $self->_state_chan_name($chan);
15833 1 my $ts = $self->_state_chan_timestamp($chan) - 10;
15834 1 $self->_daemon_peer_sjoin(
15835 'spoofed',
15836 $self->server_sid(),
15837 $ts,
15838 $chan,
15839 '+nt',
15840 '@' . $uid,
15841 );
15842 1 return;
15843 }
15844  
15845 30 ▶ $self->$command($nick, @_[ARG1 .. $#_]) if $self->can($command);
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($command) 30 0 30
15846 30 return;
15847 }
15848  
15849 179 1;
15850  
15851 =encoding utf8
15852  
15853 =head1 NAME
15854  
15855 POE::Component::Server::IRC - A fully event-driven networkable IRC server daemon module.
15856  
15857 =head1 SYNOPSIS
15858  
15859 # A fairly simple example:
15860 use strict;
15861 use warnings;
15862 use POE qw(Component::Server::IRC);
15863  
15864 my %config = (
15865 servername => 'simple.poco.server.irc',
15866 nicklen => 15,
15867 network => 'SimpleNET'
15868 );
15869  
15870 my $pocosi = POE::Component::Server::IRC->spawn( config => \%config );
15871  
15872 POE::Session->create(
15873 package_states => [
15874 'main' => [qw(_start _default)],
15875 ],
15876 heap => { ircd => $pocosi },
15877 );
15878  
15879 $poe_kernel->run();
15880  
15881 sub _start {
15882 my ($kernel, $heap) = @_[KERNEL, HEAP];
15883  
15884 $heap->{ircd}->yield('register', 'all');
15885  
15886 # Anyone connecting from the loopback gets spoofed hostname
15887 $heap->{ircd}->add_auth(
15888 mask => '*@localhost',
15889 spoof => 'm33p.com',
15890 no_tilde => 1,
15891 );
15892  
15893 # We have to add an auth as we have specified one above.
15894 $heap->{ircd}->add_auth(mask => '*@*');
15895  
15896 # Start a listener on the 'standard' IRC port.
15897 $heap->{ircd}->add_listener(port => 6667);
15898  
15899 # Add an operator who can connect from localhost
15900 $heap->{ircd}->add_operator(
15901 {
15902 username => 'moo',
15903 password => 'fishdont',
15904 }
15905 );
15906 }
15907  
15908 sub _default {
15909 my ($event, $args) = @_[ARG0 .. $#_];
15910  
15911 print "$event: ";
15912 for my $arg (@$args) {
15913 if (ref($arg) eq 'ARRAY') {
15914 print "[", join ( ", ", @$arg ), "] ";
15915 }
15916 elsif (ref($arg) eq 'HASH') {
15917 print "{", join ( ", ", %$arg ), "} ";
15918 }
15919 else {
15920 print "'$arg' ";
15921 }
15922 }
15923  
15924 print "\n";
15925 }
15926  
15927 =head1 DESCRIPTION
15928  
15929 POE::Component::Server::IRC is a POE component which implements an IRC
15930 server (also referred to as an IRC daemon or IRCd). It should be compliant
15931 with the pertient IRC RFCs and is based on reverse engineering Hybrid IRCd
15932 behaviour with regards to interactions with IRC clients and other IRC
15933 servers.
15934  
15935 Yes, that's right. POE::Component::Server::IRC is capable of linking to
15936 foreign IRC networks. It supports the TS6 server to server protocol and
15937 has been tested with linking to Hybrid-8 based networks. It should in
15938 theory work with any TS6-based IRC network.
15939  
15940 POE::Component::Server::IRC also has a services API, which enables one to
15941 extend the IRCd to create IRC Services. This is fully event-driven (of
15942 course =]). There is also a Plugin system, similar to that sported by
15943 L<POE::Component::IRC|POE::Component::IRC>.
15944  
15945 B<Note:> This is a subclass of
15946 L<POE::Component::Server::IRC::Backend|POE::Component::Server::IRC::Backend>.
15947 You should read its documentation too.
15948  
15949 =head1 CONSTRUCTOR
15950  
15951 =head2 C<spawn>
15952  
15953 Returns a new instance of the component. Takes the following parameters:
15954  
15955 =over 4
15956  
15957 =item * B<'config'>, a hashref of configuration options, see the
15958 L<C<configure>|/configure> method for details.
15959  
15960 =back
15961  
15962 Any other parameters will be passed along to
15963 L<POE::Component::Server::IRC::Backend|POE::Component::Server::IRC::Backend>'s
15964 L<C<create>|POE::Component::Server::IRC::Backend/create> method.
15965  
15966 If the component is spawned from within another session then that session
15967 will automagically be registered with the component to receive events and
15968 be sent an L<C<ircd_registered>|POE::Component::IRC::Server::Backend/ircd_registered>
15969 event.
15970  
15971 =head1 METHODS
15972  
15973 =head2 Information
15974  
15975 =head3 C<server_name>
15976  
15977 No arguments, returns the name of the ircd.
15978  
15979 =head3 C<server_version>
15980  
15981 No arguments, returns the software version of the ircd.
15982  
15983 =head3 C<server_created>
15984  
15985 No arguments, returns a string signifying when the ircd was created.
15986  
15987 =head3 C<server_config>
15988  
15989 Takes one argument, the server configuration value to query.
15990  
15991 =head2 Configuration
15992  
15993 These methods provide mechanisms for configuring and controlling the IRCd
15994 component.
15995  
15996 =head3 C<configure>
15997  
15998 Configures your new shiny IRCd.
15999  
16000 Takes a number of parameters:
16001  
16002 =over 4
16003  
16004 =item * B<'servername'>, a name to bless your shiny new IRCd with,
16005 defaults to 'poco.server.irc';
16006  
16007 =item * B<'serverdesc'>, a description for your IRCd, defaults to
16008 'Poco? POCO? POCO!';
16009  
16010 =item * B<'network'>, the name of the IRC network you will be creating,
16011 defaults to 'poconet';
16012  
16013 =item * B<'nicklen'>, the max length of nicknames to support, defaults
16014 to 9. B<Note>: the nicklen must be the same on all servers on your IRC
16015 network;
16016  
16017 =item * B<'maxtargets'>, max number of targets a user can send
16018 PRIVMSG/NOTICE's to, defaults to 4;
16019  
16020 =item * B<'maxchannels'>, max number of channels users may join, defaults
16021 to 15;
16022  
16023 =item * B<'version'>, change the server version that is reported;
16024  
16025 =item * B<'admin'>, an arrayref consisting of the 3 lines that will be
16026 returned by ADMIN;
16027  
16028 =item * B<'info'>, an arrayref consisting of lines to be returned by INFO;
16029  
16030 =item * B<'ophacks'>, set to true to enable oper hacks. Default is false;
16031  
16032 =item * B<'whoisactually'>, setting this to a false value means that only
16033 opers can see 338. Defaults to true;
16034  
16035 =item * B<'sid'>, servers unique ID. This is three characters long and must be in
16036 the form [0-9][A-Z0-9][A-Z0-9]. Specifying this enables C<TS6>.
16037  
16038 =back
16039  
16040 =head3 C<add_auth>
16041  
16042 By default the IRCd allows any user to connect to the server without a
16043 password. Configuring auths enables you to control who can connect and
16044 set passwords required to connect.
16045  
16046 Takes the following parameters:
16047  
16048 =over 4
16049  
16050 =item * B<'mask'>, a user@host or user@ipaddress mask to match against,
16051 mandatory;
16052  
16053 =item * B<'password'>, if specified, any client matching the mask must
16054 provide this to connect;
16055  
16056 =item * B<'spoof'>, if specified, any client matching the mask will have
16057 their hostname changed to this;
16058  
16059 =item * B<'no_tilde'>, if specified, the '~' prefix is removed from their
16060 username;
16061  
16062 =item * B<'exceed_limit'>, if specified, any client matching the mask will not
16063 have their connection limited, if the server is full;
16064  
16065 =item * B<'kline_exempt'>, if true, any client matching the mask will be exempt
16066 from KLINEs and RKLINEs;
16067  
16068 =item * B<'resv_exempt'>, if true, any client matching the mask will be exempt
16069 from RESVs;
16070  
16071 =item * B<'can_flood'>, if true, any client matching the mask will be exempt
16072 from flood protection;
16073  
16074 =item * B<'need_ident'>, if true, any client matching the mask will be
16075 required to have a valid response to C<Ident> queries;
16076  
16077 =back
16078  
16079 Auth masks are processed in order of addition.
16080  
16081 If auth masks have been defined, then a connecting user *must* match one
16082 of the masks in order to be authorised to connect. This is a feature >;)
16083  
16084 =head3 C<del_auth>
16085  
16086 Takes a single argument, the mask to remove.
16087  
16088 =head3 C<add_operator>
16089  
16090 This adds an O line to the IRCd. Takes a number of parameters:
16091  
16092 =over 4
16093  
16094 =item * B<'username'>, the username of the IRC oper, mandatory;
16095  
16096 =item * B<'password'>, the password, mandatory;
16097  
16098 =item * B<'ipmask'>, either a scalar ipmask or an arrayref of addresses or CIDRs
16099 as understood by L<Net::CIDR>::cidrvalidate;
16100  
16101 =item * B<'ssl_required'>, set to true to require that the oper is connected
16102 securely using SSL/TLS;
16103  
16104 =item * B<'certfp'>, specify the fingerprint of the oper's client certificate
16105 to verify;
16106  
16107 =back
16108  
16109 A scalar ipmask can contain '*' to match any number of characters or '?' to
16110 match one character. If no 'ipmask' is provided, operators are only allowed
16111 to OPER from the loopback interface.
16112  
16113 B<'password'> can be either plain-text, L<C<crypt>|crypt>'d or unix/apache
16114 md5. See the C<mkpasswd> function in
16115 L<POE::Component::Server::IRC::Common|POE::Component::Server::IRC::Common>
16116 for how to generate passwords.
16117  
16118 B<'ssl_required'> and B<'certfp'> obviously both require that the server
16119 supports SSL/TLS connections. B<'certfp'> is the SHA256 digest fingerprint
16120 of the client certificate. This can be obtained from the PEM formated cert
16121 using one of the following methods:
16122  
16123 OpenSSL/LibreSSL:
16124 openssl x509 -sha256 -noout -fingerprint -in cert.pem | sed -e 's/^.*=//;s/://g'
16125  
16126 GnuTLS:
16127 certtool -i < cert.pem | egrep -A 1 'SHA256 fingerprint'
16128  
16129 =head3 C<del_operator>
16130  
16131 Takes a single argument, the username to remove.
16132  
16133 =head3 C<add_peer>
16134  
16135 Adds peer servers that we will allow to connect to us and who we will
16136 connect to. Takes the following parameters:
16137  
16138 =over 4
16139  
16140 =item * B<'name'>, the name of the server. This is the IRC name, not
16141 hostname, mandatory;
16142  
16143 =item * B<'pass'>, the password they must supply to us, mandatory;
16144  
16145 =item * B<'rpass'>, the password we need to supply to them, mandatory;
16146  
16147 =item * B<'type'>, the type of server, 'c' for a connecting server, 'r'
16148 for one that we will connect to;
16149  
16150 =item * B<'raddress'>, the remote address to connect to, implies 'type'
16151 eq 'r';
16152  
16153 =item * B<'rport'>, the remote port to connect to, default is 6667;
16154  
16155 =item * B<'ipmask'>, either a scalar ipmask or an arrayref of addresses or CIDRs
16156 as understood by L<Net::CIDR>::cidrvalidate;
16157  
16158 =item * B<'auto'>, if set to true value will automatically connect to
16159 remote server if type is 'r';
16160  
16161 =item * B<'zip'>, set to a true value to enable ziplink support. This must
16162 be done on both ends of the connection. Requires
16163 L<POE::Filter::Zlib::Stream|POE::Filter::Zlib::Stream>;
16164  
16165 =item * B<'service'>, set to a true value to enable the peer to be
16166 accepted as a services peer.
16167  
16168 =item * B<'ssl'>, set to a true value to enable SSL/TLS support. This must
16169 be done on both ends of the connection. Requires L<POE::Component::SSLify>.
16170  
16171 =item * B<'certfp'>, specify the fingerprint of the peer's client certificate
16172 to verify;
16173  
16174 =back
16175  
16176 B<'certfp'> is the SHA256 digest fingerprint of the client certificate.
16177 This can be obtained from the PEM formated cert using one of the following
16178 methods:
16179  
16180 OpenSSL/LibreSSL:
16181 openssl x509 -sha256 -noout -fingerprint -in cert.pem | sed -e 's/^.*=//;s/://g'
16182  
16183 GnuTLS:
16184 certtool -i < cert.pem | egrep -A 1 'SHA256 fingerprint'
16185  
16186 =head3 C<del_peer>
16187  
16188 Takes a single argument, the peer to remove. This does not disconnect the
16189 said peer if it is currently connected.
16190  
16191 =head3 C<add_service>
16192  
16193 Adds a service peer. A service peer is a peer that is accepted to send
16194 service commands C<SVS*>. Takes a single argument the service peer to add.
16195 This does not have to be a directly connected peer as defined with C<add_peer>.
16196  
16197 =head3 C<del_service>
16198  
16199 Takes a single argument, the service peer to remove. This does not disconnect
16200 the said service peer, but it will deny the peer access to service commands.
16201  
16202 =head3 C<add_pseudo>
16203  
16204 Adds a pseudo command, also known as a service alias. The command is transformed
16205 by the server into a C<PRIVMSG> and sent to the given target.
16206  
16207 Takes several arguments:
16208  
16209 =over 4
16210  
16211 =item * B<'cmd'>, (mandatory) command/alias to be added.
16212  
16213 =item * B<'name'>, (mandatory) the service name, eg. NickServ, this is
16214 used in error messages reported to users.
16215  
16216 =item * B<'target'>, (mandatory) the target for the command in nick!user@host
16217 format.
16218  
16219 =item * B<'prepend'>, (optional) text that will prepended to the user's
16220 message.
16221  
16222 =back
16223  
16224 =head3 C<del_pseudo>
16225  
16226 Removes a previously defined pseudo command/alias.
16227  
16228 =head2 State queries
16229  
16230 The following methods allow you to query state information regarding
16231 nicknames, channels, and peers.
16232  
16233 =head3 C<state_nicks>
16234  
16235 Takes no arguments, returns a list of all nicknames in the state.
16236  
16237 =head3 C<state_chans>
16238  
16239 Takes no arguments, returns a list of all channels in the state.
16240  
16241 =head3 C<state_peers>
16242  
16243 Takes no arguments, returns a list of all irc servers in the state.
16244  
16245 =head3 C<state_nick_exists>
16246  
16247 Takes one argument, a nickname, returns true or false dependent on whether
16248 the given nickname exists or not.
16249  
16250 =head3 C<state_chan_exists>
16251  
16252 Takes one argument, a channel name, returns true or false dependent on
16253 whether the given channel exists or not.
16254  
16255 =head3 C<state_peer_exists>
16256  
16257 Takes one argument, a peer server name, returns true or false dependent
16258 on whether the given peer exists or not.
16259  
16260 =head3 C<state_user_full>
16261  
16262 Takes one argument, a nickname, returns that users full nick!user@host
16263 if they exist, undef if they don't.
16264  
16265 If a second argument is provided and the nickname provided is an oper,
16266 then the returned value will be nick!user@host{opuser}
16267  
16268 =head3 C<state_user_nick>
16269  
16270 Takes one argument, a nickname, returns the proper nickname for that user.
16271 Returns undef if the nick doesn't exist.
16272  
16273 =head3 C<state_user_umode>
16274  
16275 Takes one argument, a nickname, returns that users mode setting.
16276  
16277 =head3 C<state_user_is_operator>
16278  
16279 Takes one argument, a nickname, returns true or false dependent on whether
16280 the given nickname is an IRC operator or not.
16281  
16282 =head3 C<state_user_chans>
16283  
16284 Takes one argument, a nickname, returns a list of channels that that nick
16285 is a member of.
16286  
16287 =head3 C<state_user_server>
16288  
16289 Takes one argument, a nickname, returns the name of the peer server that
16290 that user is connected from.
16291  
16292 =head3 C<state_chan_list>
16293  
16294 Takes one argument, a channel name, returns a list of the member nicks on
16295 that channel.
16296  
16297 =head3 C<state_chan_list_prefixed>
16298  
16299 Takes one argument, a channel name, returns a list of the member nicks on
16300 that channel, nicknames will be prefixed with @%+ if they are +o +h or +v,
16301 respectively.
16302  
16303 =head3 C<state_chan_topic>
16304  
16305 Takes one argument, a channel name, returns undef if no topic is set on
16306 that channel, or an arrayref consisting of the topic, who set it and the
16307 time they set it.
16308  
16309 =head3 C<state_chan_mode_set>
16310  
16311 Takes two arguments, a channel name and a channel mode character. Returns
16312 true if that channel mode is set, false otherwise.
16313  
16314 =head3 C<state_is_chan_member>
16315  
16316 Takes two arguments, a nick and a channel name. Returns true if that nick
16317 is on channel, false otherwise.
16318  
16319 =head3 C<state_user_chan_mode>
16320  
16321 Takes two arguments, a nick and a channel name. Returns that nicks status
16322 (+ohv or '') on that channel.
16323  
16324 =head3 C<state_is_chan_op>
16325  
16326 Takes two arguments, a nick and a channel name. Returns true if that nick
16327 is an channel operator, false otherwise.
16328  
16329 =head3 C<state_is_chan_hop>
16330  
16331 Takes two arguments, a nick and a channel name. Returns true if that nick
16332 is an channel half-operator, false otherwise.
16333  
16334 =head3 C<state_has_chan_voice>
16335  
16336 Takes two arguments, a nick and a channel name. Returns true if that nick
16337 has channel voice, false otherwise.
16338  
16339 =head2 Server actions
16340  
16341 =head3 C<daemon_server_kill>
16342  
16343 Takes two arguments, a nickname and a comment (which is optional); Issues
16344 a SERVER KILL of the given nick;
16345  
16346 =head3 C<daemon_server_mode>
16347  
16348 First argument is a channel name, remaining arguments are channel modes
16349 and their parameters to apply.
16350  
16351 =head3 C<daemon_server_join>
16352  
16353 Takes two arguments that are mandatory: a nickname of a user and a channel
16354 name. The user will join the channel.
16355  
16356 =head3 C<daemon_server_kick>
16357  
16358 Takes two arguments that are mandatory and an optional one: channel name,
16359 nickname of the user to kick and a pithy comment.
16360  
16361 =head3 C<daemon_server_remove>
16362  
16363 Takes two arguments that are mandatory and an optional one: channel name,
16364 nickname of the user to remove and a pithy comment.
16365  
16366 =head3 C<daemon_server_wallops>
16367  
16368 Takes one argument, the message text to send.
16369  
16370 =head3 C<daemon_server_realops>
16371  
16372 Sends server notices.
16373  
16374 Takes one mandatory argument, the message text to send.
16375  
16376 Second argument is the notice type, this can be C<Notice>, C<locops>
16377 or C<Globops>. Defaults to C<Notice>.
16378  
16379 Third argument is a umode flag. The notice will be sent to OPERs who
16380 have this umode set. Default is none and the notice will be sent to
16381 all OPERs.
16382  
16383 =head1 INPUT EVENTS
16384  
16385 These are POE events that can be sent to the component.
16386  
16387 =head2 C<add_spoofed_nick>
16388  
16389 Takes a single argument a hashref which should have the following keys:
16390  
16391 =over 4
16392  
16393 =item * B<'nick'>, the nickname to add, mandatory;
16394  
16395 =item * B<'user'>, the ident you want the nick to have, defaults to the
16396 same as the nick;
16397  
16398 =item * B<'hostname'>, the hostname, defaults to the server name;
16399  
16400 =item * B<'umode'>, specify whether this is to be an IRCop etc, defaults
16401 to 'i';
16402  
16403 =item * B<'ts'>, unixtime, default is time(), best not to meddle;
16404  
16405 =back
16406  
16407 B<Note:> spoofed nicks are currently only really functional for use as IRC
16408 services.
16409  
16410 =head2 C<del_spoofed_nick>
16411  
16412 Takes a single mandatory argument, the spoofed nickname to remove.
16413 Optionally, you may specify a quit message for the spoofed nick.
16414  
16415 =head2 Spoofed nick commands
16416  
16417 The following input events are for the benefit of spoofed nicks. All
16418 require a nickname of a spoofed nick as the first argument.
16419  
16420 =head3 C<daemon_cmd_join>
16421  
16422 Takes two arguments, a spoofed nick and a channel name to join.
16423  
16424 =head3 C<daemon_cmd_part>
16425  
16426 Takes two arguments, a spoofed nick and a channel name to part from.
16427  
16428 =head3 C<daemon_cmd_mode>
16429  
16430 Takes at least three arguments, a spoofed nick, a channel and a channel
16431 mode to apply. Additional arguments are parameters for the channel modes.
16432  
16433 =head3 C<daemon_cmd_kick>
16434  
16435 Takes at least three arguments, a spoofed nick, a channel name and the
16436 nickname of a user to kick from that channel. You may supply a fourth
16437 argument which will be the kick comment.
16438  
16439 =head3 C<daemon_cmd_topic>
16440  
16441 Takes three arguments, a spoofed nick, a channel name and the topic to
16442 set on that channel. If the third argument is an empty string then the
16443 channel topic will be unset.
16444  
16445 =head3 C<daemon_cmd_nick>
16446  
16447 Takes two arguments, a spoofed nick and a new nickname to change to.
16448  
16449 =head3 C<daemon_cmd_kline>
16450  
16451 Takes a number of arguments depending on where the KLINE is to be applied
16452 and for how long:
16453  
16454 To set a permanent KLINE:
16455  
16456 $ircd->yield(
16457 'daemon_cmd_kline',
16458 $spoofed_nick,
16459 $nick || $user_host_mask,
16460 $reason,
16461 );
16462  
16463 To set a temporary 10 minute KLINE:
16464  
16465 $ircd->yield(
16466 'daemon_cmd_kline',
16467 $spoofed_nick,
16468 10,
16469 $nick || $user_host_mask,
16470 $reason,
16471 );
16472  
16473 To set a temporary 10 minute KLINE on all servers:
16474  
16475 $ircd->yield(
16476 'daemon_cmd_kline',
16477 $spoofed_nick,
16478 10,
16479 $nick || $user_host_mask,
16480 'on',
16481 '*',
16482 $reason,
16483 );
16484  
16485 =head3 C<daemon_cmd_unkline>
16486  
16487 Removes a KLINE as indicated by the user@host mask supplied.
16488  
16489 To remove a KLINE:
16490  
16491 $ircd->yield(
16492 'daemon_cmd_unkline',
16493 $spoofed_nick,
16494 $user_host_mask,
16495 );
16496  
16497 To remove a KLINE from all servers:
16498  
16499 $ircd->yield(
16500 'daemon_cmd_unkline',
16501 $spoofed_nick,
16502 $user_host_mask,
16503 'on',
16504 '*',
16505 );
16506  
16507 =head3 C<daemon_cmd_rkline>
16508  
16509 Used to set a regex based KLINE. The regex given must be based on a
16510 user@host mask.
16511  
16512 To set a permanent RKLINE:
16513  
16514 $ircd->yield(
16515 'daemon_cmd_rkline',
16516 $spoofed_nick,
16517 '^.*$@^(yahoo|google|microsoft)\.com$',
16518 $reason,
16519 );
16520  
16521 To set a temporary 10 minute RKLINE:
16522  
16523 $ircd->yield(
16524 'daemon_cmd_rkline',
16525 $spoofed_nick,
16526 10,
16527 '^.*$@^(yahoo|google|microsoft)\.com$',
16528 $reason,
16529 );
16530  
16531 =head3 C<daemon_cmd_unrkline>
16532  
16533 Removes an RKLINE as indicated by the user@host mask supplied.
16534  
16535 To remove a RKLINE:
16536  
16537 $ircd->yield(
16538 'daemon_cmd_unrkline',
16539 $spoofed_nick,
16540 $user_host_mask,
16541 );
16542  
16543 =head3 C<daemon_cmd_sjoin>
16544  
16545 Takes two arguments a spoofed nickname and an existing channel name. This
16546 command will then manipulate the channel timestamp to clear all modes on
16547 that channel, including existing channel operators, reset the channel mode
16548 to '+nt', the spoofed nick will then join the channel and gain channel ops.
16549  
16550 =head3 C<daemon_cmd_privmsg>
16551  
16552 Takes three arguments, a spoofed nickname, a target (which can be a
16553 nickname or a channel name) and whatever text you wish to send.
16554  
16555 =head3 C<daemon_cmd_notice>
16556  
16557 Takes three arguments, a spoofed nickname, a target (which can be a
16558 nickname or a channel name) and whatever text you wish to send.
16559  
16560 =head3 C<daemon_cmd_locops>
16561  
16562 Takes two arguments, a spoofed nickname and the text message to send to
16563 local operators.
16564  
16565 =head3 C<daemon_cmd_wallops>
16566  
16567 Takes two arguments, a spoofed nickname and the text message to send to
16568 all operators.
16569  
16570 =head3 C<daemon_cmd_globops>
16571  
16572 Takes two arguments, a spoofed nickname and the text message to send to
16573 all operators.
16574  
16575 =head1 OUTPUT EVENTS
16576  
16577 =head2 C<ircd_daemon_error>
16578  
16579 =over
16580  
16581 =item Emitted: when we fail to register with a peer;
16582  
16583 =item Target: all plugins and registered sessions;
16584  
16585 =item Args:
16586  
16587 =over 4
16588  
16589 =item * C<ARG0>, the connection id;
16590  
16591 =item * C<ARG1>, the server name;
16592  
16593 =item * C<ARG2>, the reason;
16594  
16595 =back
16596  
16597 =back
16598  
16599 =head2 C<ircd_daemon_server>
16600  
16601 =over
16602  
16603 =item Emitted: when a server is introduced onto the network;
16604  
16605 =item Target: all plugins and registered sessions;
16606  
16607 =item Args:
16608  
16609 =over 4
16610  
16611 =item * C<ARG0>, the server name;
16612  
16613 =item * C<ARG1>, the name of the server that is introducing them;
16614  
16615 =item * C<ARG2>, the hop count;
16616  
16617 =item * C<ARG3>, the server description;
16618  
16619 =back
16620  
16621 =back
16622  
16623 =head2 C<ircd_daemon_squit>
16624  
16625 =over
16626  
16627 =item Emitted: when a server quits the network;
16628  
16629 =item Target: all plugins and registered sessions;
16630  
16631 =item Args:
16632  
16633 =over 4
16634  
16635 =item * C<ARG0>, the server name;
16636  
16637 =back
16638  
16639 =back
16640  
16641 =head2 C<ircd_daemon_nick>
16642  
16643 =over
16644  
16645 =item Emitted: when a user is introduced onto the network or changes their
16646 nickname
16647  
16648 =item Target: all plugins and registered sessions;
16649  
16650 =item Args (new user):
16651  
16652 =over 4
16653  
16654 =item * C<ARG0>, the nickname;
16655  
16656 =item * C<ARG1>, the hop count;
16657  
16658 =item * C<ARG2>, the time stamp (TS);
16659  
16660 =item * C<ARG3>, the user mode;
16661  
16662 =item * C<ARG4>, the ident;
16663  
16664 =item * C<ARG5>, the hostname;
16665  
16666 =item * C<ARG6>, the server name;
16667  
16668 =item * C<ARG7>, the real name;
16669  
16670 =back
16671  
16672 =item Args (nick change):
16673  
16674 =over 4
16675  
16676 =item * C<ARG0>, the full nick!user@host;
16677  
16678 =item * C<ARG1>, the new nickname;
16679  
16680 =back
16681  
16682 =back
16683  
16684 =head2 C<ircd_daemon_umode>
16685  
16686 =over
16687  
16688 =item Emitted: when a user changes their user mode;
16689  
16690 =item Target: all plugins and registered sessions;
16691  
16692 =item Args:
16693  
16694 =over 4
16695  
16696 =item * C<ARG0>, the full nick!user@host;
16697  
16698 =item * C<ARG1>, the user mode change;
16699  
16700 =back
16701  
16702 =back
16703  
16704 =head2 C<ircd_daemon_quit>
16705  
16706 =over
16707  
16708 =item Emitted: when a user quits or the server they are on squits;
16709  
16710 =item Target: all plugins and registered sessions;
16711  
16712 =item Args:
16713  
16714 =over 4
16715  
16716 =item * C<ARG0>, the full nick!user@host;
16717  
16718 =item * C<ARG1>, the quit message;
16719  
16720 =back
16721  
16722 =back
16723  
16724 =head2 C<ircd_daemon_join>
16725  
16726 =over
16727  
16728 =item Emitted: when a user joins a channel
16729  
16730 =item Target: all plugins and registered sessions;
16731  
16732 =item Args:
16733  
16734 =over 4
16735  
16736 =item * C<ARG0>, the full nick!user@host;
16737  
16738 =item * C<ARG1>, the channel name;
16739  
16740 =back
16741  
16742 =back
16743  
16744 =head2 C<ircd_daemon_part>
16745  
16746 =over
16747  
16748 =item Emitted: when a user parts a channel;
16749  
16750 =item Target: all plugins and registered sessions;
16751  
16752 =item Args:
16753  
16754 =over 4
16755  
16756 =item * C<ARG0>, the full nick!user@host;
16757  
16758 =item * C<ARG1>, the channel name;
16759  
16760 =item * C<ARG2>, the part message;
16761  
16762 =back
16763  
16764 =back
16765  
16766 =head2 C<ircd_daemon_kick>
16767  
16768 =over
16769  
16770 =item Emitted: when a user is kicked from a channel;
16771  
16772 =item Target: all plugins and registered sessions;
16773  
16774 =item Args:
16775  
16776 =over 4
16777  
16778 =item * C<ARG0>, the full nick!user@host of the kicker;
16779  
16780 =item * C<ARG1>, the channel name;
16781  
16782 =item * C<ARG2>, the nick of the kicked user;
16783  
16784 =item * C<ARG3>, the kick message;
16785  
16786 =back
16787  
16788 =back
16789  
16790 =head2 C<ircd_daemon_mode>
16791  
16792 =over
16793  
16794 =item Emitted: when a channel mode is changed;
16795  
16796 =item Target: all plugins and registered sessions;
16797  
16798 =item Args:
16799  
16800 =over 4
16801  
16802 =item * C<ARG0>, the full nick!user@host or server name;
16803  
16804 =item * C<ARG1>, the channel name;
16805  
16806 =item * C<ARG2..$#_>, the modes and their arguments;
16807  
16808 =back
16809  
16810 =back
16811  
16812 =head2 C<ircd_daemon_topic>
16813  
16814 =over
16815  
16816 =item Emitted: when a channel topic is changed
16817  
16818 =item Target: all plugins and registered sessions;
16819  
16820 =item Args:
16821  
16822 =over 4
16823  
16824 =item * C<ARG0>, the full nick!user@host of the changer;
16825  
16826 =item * C<ARG1>, the channel name;
16827  
16828 =item * C<ARG2>, the new topic;
16829  
16830 =back
16831  
16832 =back
16833  
16834 =head2 C<ircd_daemon_public>
16835  
16836 =over
16837  
16838 =item Emitted: when a channel message is sent (a spoofed nick must be in
16839 the channel)
16840  
16841 =item Target: all plugins and registered sessions;
16842  
16843 =item Args:
16844  
16845 =over 4
16846  
16847 =item * C<ARG0>, the full nick!user@host of the sender;
16848  
16849 =item * C<ARG1>, the channel name;
16850  
16851 =item * C<ARG2>, the message;
16852  
16853 =back
16854  
16855 =back
16856  
16857 =head2 C<ircd_daemon_privmsg>
16858  
16859 =over
16860  
16861 =item Emitted: when someone sends a private message to a spoofed nick
16862  
16863 =item Target: all plugins and registered sessions;
16864  
16865 =item Args:
16866  
16867 =over 4
16868  
16869 =item * C<ARG0>, the full nick!user@host of the sender;
16870  
16871 =item * C<ARG1>, the spoofed nick targeted;
16872  
16873 =item * C<ARG2>, the message;
16874  
16875 =back
16876  
16877 =back
16878  
16879 =head2 C<ircd_daemon_notice>
16880  
16881 =over
16882  
16883 =item Emitted: when someone sends a notice to a spoofed nick or channel
16884  
16885 =item Target: all plugins and registered sessions;
16886  
16887 =item Args:
16888  
16889 =over 4
16890  
16891 =item * C<ARG0>, the full nick!user@host of the sender;
16892  
16893 =item * C<ARG1>, the spoofed nick targeted or channel spoofed nick is in;
16894  
16895 =item * C<ARG2>, the message;
16896  
16897 =back
16898  
16899 =back
16900  
16901 =head2 C<ircd_daemon_snotice>
16902  
16903 =over
16904  
16905 =item Emitted: when the server issues a notice for various reasons
16906  
16907 =item Target: all plugins and registered sessions;
16908  
16909 =item Args:
16910  
16911 =over 4
16912  
16913 =item * C<ARG0>, the message;
16914  
16915 =back
16916  
16917 =back
16918  
16919 =head2 C<ircd_daemon_invite>
16920  
16921 =over
16922  
16923 =item Emitted: when someone invites a spoofed nick to a channel;
16924  
16925 =item Target: all plugins and registered sessions;
16926  
16927 =item Args:
16928  
16929 =over 4
16930  
16931 =item * C<ARG0>, the full nick!user@host of the inviter;
16932  
16933 =item * C<ARG1>, the spoofed nick being invited;
16934  
16935 =item * C<ARG2>, the channel being invited to;
16936  
16937 =back
16938  
16939 =back
16940  
16941 =head2 C<ircd_daemon_rehash>
16942  
16943 =over
16944  
16945 =item Emitted: when an oper issues a REHASH command;
16946  
16947 =item Target: all plugins and registered sessions;
16948  
16949 =item Args:
16950  
16951 =over 4
16952  
16953 =item * C<ARG0>, the full nick!user@host of the oper;
16954  
16955 =back
16956  
16957 =back
16958  
16959 =head2 C<ircd_daemon_die>
16960  
16961 =over
16962  
16963 =item Emitted: when an oper issues a DIE command;
16964  
16965 =item Target: all plugins and registered sessions;
16966  
16967 =item Args:
16968  
16969 =over 4
16970  
16971 =item * C<ARG0>, the full nick!user@host of the oper;
16972  
16973 =back
16974  
16975 =back
16976  
16977 B<Note:> the component will shutdown, this is a feature;
16978  
16979 =head2 C<ircd_daemon_dline>
16980  
16981 =over
16982  
16983 =item Emitted: when an oper issues a DLINE command;
16984  
16985 =item Target: all plugins and registered sessions;
16986  
16987 =item Args:
16988  
16989 =over 4
16990  
16991 =item * C<ARG0>, the full nick!user@host;
16992  
16993 =item * C<ARG1>, the duration;
16994  
16995 =item * C<ARG2>, the network mask;
16996  
16997 =item * C<ARG3>, the reason;
16998  
16999 =back
17000  
17001 =back
17002  
17003 =head2 C<ircd_daemon_kline>
17004  
17005 =over
17006  
17007 =item Emitted: when an oper issues a KLINE command;
17008  
17009 =item Target: all plugins and registered sessions;
17010  
17011 =item Args:
17012  
17013 =over 4
17014  
17015 =item * C<ARG0>, the full nick!user@host;
17016  
17017 =item * C<ARG1>, the target for the KLINE;
17018  
17019 =item * C<ARG2>, the duration in seconds;
17020  
17021 =item * C<ARG3>, the user mask;
17022  
17023 =item * C<ARG4>, the host mask;
17024  
17025 =item * C<ARG5>, the reason;
17026  
17027 =back
17028  
17029 =back
17030  
17031 =head2 C<ircd_daemon_rkline>
17032  
17033 =over
17034  
17035 =item Emitted: when an oper issues an RKLINE command;
17036  
17037 =item Target: all plugins and registered sessions;
17038  
17039 =item Args:
17040  
17041 =over 4
17042  
17043 =item * C<ARG0>, the full nick!user@host;
17044  
17045 =item * C<ARG1>, the target for the RKLINE;
17046  
17047 =item * C<ARG2>, the duration in seconds;
17048  
17049 =item * C<ARG3>, the user mask;
17050  
17051 =item * C<ARG4>, the host mask;
17052  
17053 =item * C<ARG5>, the reason;
17054  
17055 =back
17056  
17057 =back
17058  
17059 =head2 C<ircd_daemon_unkline>
17060  
17061 =over
17062  
17063 =item Emitted: when an oper issues an UNKLINE command;
17064  
17065 =item Target: all plugins and registered sessions;
17066  
17067 =item Args:
17068  
17069 =over 4
17070  
17071 =item * C<ARG0>, the full nick!user@host;
17072  
17073 =item * C<ARG1>, the target for the UNKLINE;
17074  
17075 =item * C<ARG2>, the user mask;
17076  
17077 =item * C<ARG3>, the host mask;
17078  
17079 =back
17080  
17081 =back
17082  
17083 =head2 C<ircd_daemon_expired>
17084  
17085 =over
17086  
17087 =item Emitted: when a temporary D-Line, X-Line, K-Line or RK-Line expires
17088  
17089 =item Target: all plugins and registered sessions;
17090  
17091 =item Args:
17092  
17093 =over 4
17094  
17095 =item * C<ARG0>, What expired, can be C<d-line>, C<x-line>, C<k-line> or C<rk-line>;
17096  
17097 =item * C<ARG1>, the mask (D-Line and X-Line) or user@host (K-Line and RK-Line);
17098  
17099 =back
17100  
17101 =back
17102  
17103 =head2 C<ircd_daemon_encap>
17104  
17105 =over
17106  
17107 =item Emitted: when the server receives an C<ENCAP> message;
17108  
17109 =item Target: all plugins and registered sessions;
17110  
17111 =item Args:
17112  
17113 =over 4
17114  
17115 =item * C<ARG0>, the server name or full nick!user@host;
17116  
17117 =item * C<ARG1>, peermask of targets for the C<ENCAP>;
17118  
17119 =item * C<ARG2>, the sub command being propagated;
17120  
17121 =item * Subsequent ARGs are dependent on the sub command;
17122  
17123 =back
17124  
17125 =back
17126  
17127 =head2 C<ircd_daemon_locops>
17128  
17129 =over
17130  
17131 =item Emitted: when an oper issues a LOCOPS command;
17132  
17133 =item Target: all plugins and registered sessions;
17134  
17135 =item Args:
17136  
17137 =over 4
17138  
17139 =item * C<ARG0>, the full nick!user@host;
17140  
17141 =item * C<ARG1>, the locops message;
17142  
17143 =back
17144  
17145 =back
17146  
17147 =head2 C<ircd_daemon_globops>
17148  
17149 =over
17150  
17151 =item Emitted: when an oper or server issues a GLOBOPS;
17152  
17153 =item Target: all plugins and registered sessions;
17154  
17155 =item Args:
17156  
17157 =over 4
17158  
17159 =item * C<ARG0>, the full nick!user@host or server name;
17160  
17161 =item * C<ARG1>, the globops message;
17162  
17163 =back
17164  
17165 =back
17166  
17167 =head2 C<ircd_daemon_wallops>
17168  
17169 =over
17170  
17171 =item Emitted: when a server issues a WALLOPS;
17172  
17173 =item Target: all plugins and registered sessions;
17174  
17175 =item Args:
17176  
17177 =over 4
17178  
17179 =item * C<ARG0>, the server name;
17180  
17181 =item * C<ARG1>, the wallops message;
17182  
17183 =back
17184  
17185 =back
17186  
17187 =head1 BUGS
17188  
17189 A few have turned up in the past and they are sure to again. Please use
17190 L<http://rt.cpan.org/> to report any. Alternatively, email the current
17191 maintainer.
17192  
17193 =head1 DEVELOPMENT
17194  
17195 You can find the latest source on github:
17196 L<http://github.com/bingos/poe-component-server-irc>
17197  
17198 The project's developers usually hang out in the C<#poe> IRC channel on
17199 irc.perl.org. Do drop us a line.
17200  
17201 =head1 MAINTAINER
17202  
17203 Hinrik E<Ouml>rn SigurE<eth>sson <hinrik.sig@gmail.com>
17204  
17205 =head1 AUTHOR
17206  
17207 Chris 'BinGOs' Williams
17208  
17209 =head1 LICENSE
17210  
17211 Copyright C<(c)> Chris Williams
17212  
17213 This module may be used, modified, and distributed under the same terms as
17214 Perl itself. Please see the license that came with your Perl distribution
17215 for details.
17216  
17217 =head1 KUDOS
17218  
17219 Rocco Caputo for creating POE.
17220  
17221 Buu for pestering me when I started to procrastinate =]
17222  
17223 =head1 SEE ALSO
17224  
17225 L<POE|POE> L<http://poe.perl.org/>
17226  
17227 L<POE::Component::Server::IRC::Backend|POE::Component::IRC::Server::Backend>
17228  
17229 L<Net::CIDR|Net::CIDR>
17230  
17231 Hybrid IRCD L<http://ircd-hybrid.com/>
17232  
17233 RFC 2810 L<http://www.faqs.org/rfcs/rfc2810.html>
17234  
17235 RFC 2811 L<http://www.faqs.org/rfcs/rfc2811.html>
17236  
17237 RFC 2812 L<http://www.faqs.org/rfcs/rfc2812.html>
17238  
17239 RFC 2813 L<http://www.faqs.org/rfcs/rfc2813.html>
17240  
17241 =cut
↑ Summary blib/lib/POE/Component/Server/IRC/Plugin/Auth.pm »