IRC.pm

filter: Statementstmt 35.9% 1512 / 4203 Branchbran 26.0% 494 / 1898 Conditioncond 20.0% 289 / 1444 MC/DCmcdc 2.3% 20 / 838 Subroutinesub 57.4% 108 / 188 Podpod 81.6% 40 / 49 totaltotal 28.5% 2463 / 8620 CC 1629 SCAR 67.4
CC
1629
Cov
30%
_daemon_peer_message
6806.0
_daemon_cmd_mode
3522.7
_daemon_peer_mode
3080.0
CRAP 845.7
↑ Summary IRC/Plugin/OperServ.pm »
1 package POE::Component::Server::IRC;
2 BEGIN {
3 20 ▶ $POE::Component::Server::IRC::AUTHORITY = 'cpan:HINRIK';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 {
6 20 $POE::Component::Server::IRC::VERSION = '1.54';
7 }
8  
9 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 20 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 use IRC::Utils qw(uc_irc parse_mode_line unparse_mode_line normalize_mask
13 matches_mask gen_mode_change is_valid_nick_name
14 20 ▶ is_valid_chan_name);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 20 ▶use List::Util qw(sum);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 20 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 20 ▶use POE::Component::Server::IRC::Common qw(chkpasswd);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 20 ▶use POE::Component::Server::IRC::Plugin qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 20 ▶use POSIX 'strftime';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 20 ▶use base qw(POE::Component::Server::IRC::Backend);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 sub spawn {
23 21 ▶ my ($package, %args) = @_;
Subroutine spawn: called CC=4 SCAR=13.9
Pod documented
24 21 $args{lc $_} = delete $args{$_} for keys %args;
25 21 my $config = delete $args{config};
26 21 my $debug = delete $args{debug};
27 my $self = $package->create(
28 ($debug ? (raw_events => 1) : ()),
29 %args,
30 states => [
31 [qw(add_spoofed_nick del_spoofed_nick)],
32 {
33 21 ▶ map { +"daemon_cmd_$_" => '_spoofed_command' }
Branch: 1 branch
BranchTrueFalseTotal
$debug ? : 0 21 21
34 qw(join part mode kick topic nick privmsg notice gline
35 kline unkline sjoin locops wallops operwall)
36 },
37 ],
38 );
39  
40 20 ▶ $self->configure($config ? $config : ());
Branch: 1 branch
BranchTrueFalseTotal
$config ? : 4 16 20
41 20 $self->{debug} = $debug;
42 20 $self->_state_create();
43 20 return $self;
44 }
45  
46 sub IRCD_connection {
47 21 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connection: called CC=3 SCAR=11.1
Pod undocumented
48 21 pop @_;
49 my ($conn_id, $peeraddr, $peerport, $sockaddr, $sockport, $needs_auth)
50 21 = map { ${ $_ } } @_;
51  
52 21 ▶ if ($self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_exists($conn_id)) 0 21 21
53 0 delete $self->{state}{conns}{$conn_id};
54 }
55  
56 21 $self->{state}{conns}{$conn_id}{registered} = 0;
57 21 $self->{state}{conns}{$conn_id}{type} = 'u';
58 21 $self->{state}{conns}{$conn_id}{seen} = time();
59 $self->{state}{conns}{$conn_id}{socket}
60 21 = [$peeraddr, $peerport, $sockaddr, $sockport];
61  
62 21 $self->_state_conn_stats();
63  
64 21 ▶ if (!$needs_auth) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($needs_auth) 21 0 21
65 $self->{state}{conns}{$conn_id}{auth} = {
66 21 hostname => '',
67 ident => '',
68 };
69 21 $self->_client_register($conn_id);
70 }
71  
72 21 return PCSI_EAT_CLIENT;
73 }
74  
75 sub IRCD_connected {
76 2 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connected: called CC=2 SCAR=7.0
Pod undocumented
77 2 pop @_;
78 my ($conn_id, $peeraddr, $peerport, $sockaddr, $sockport, $name)
79 2 = map { ${ $_ } } @_;
80  
81 2 ▶ if ($self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_exists($conn_id)) 0 2 2
82 0 delete $self->{state}{conns}{$conn_id};
83 }
84  
85 2 $self->{state}{conns}{$conn_id}{peer} = $name;
86 2 $self->{state}{conns}{$conn_id}{registered} = 0;
87 2 $self->{state}{conns}{$conn_id}{cntr} = 1;
88 2 $self->{state}{conns}{$conn_id}{type} = 'u';
89 2 $self->{state}{conns}{$conn_id}{seen} = time();
90 $self->{state}{conns}{$conn_id}{socket}
91 2 = [$peeraddr, $peerport, $sockaddr, $sockport];
92  
93 2 $self->_state_conn_stats();
94 2 $self->_state_send_credentials($conn_id, $name);
95 2 return PCSI_EAT_CLIENT;
96 }
97  
98 sub IRCD_connection_flood {
99 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connection_flood: not called CC=1 SCAR=6.9
Pod undocumented
100 0 pop @_;
101 0 my ($conn_id) = map { ${ $_ } } @_;
102 0 $self->_terminate_conn_error($conn_id, 'Excess Flood');
103 0 return PCSI_EAT_CLIENT;
104 }
105  
106 sub IRCD_connection_idle {
107 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_connection_idle: not called CC=4 SCAR=30.0
Pod undocumented
108 0 pop @_;
109 0 my ($conn_id, $interval) = map { ${ $_ } } @_;
110 0 ▶ return PCSI_EAT_NONE if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 0 0
111  
112 0 my $conn = $self->{state}{conns}{$conn_id};
113 0 ▶ if ($conn->{type} eq 'u') {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"type"} eq "u") 0 0 0
114 0 $self->_terminate_conn_error($conn_id, 'Connection Timeout');
115 0 return PCSI_EAT_CLIENT;
116 }
117  
118 0 ▶ if ($conn->{pinged}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{"pinged"}) 0 0 0
119 0 my $msg = 'Ping timeout: '.(time - $conn->{seen}).' seconds';
120 0 $self->_terminate_conn_error($conn_id, $msg);
121 0 return PCSI_EAT_CLIENT;
122 }
123  
124 0 $conn->{pinged} = 1;
125 0 $self->send_output(
126 {
127 command => 'PING',
128 params => [$self->server_name()],
129 },
130 $conn_id,
131 );
132 0 return PCSI_EAT_CLIENT;
133 }
134  
135 sub IRCD_auth_done {
136 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_auth_done: not called CC=2 SCAR=17.9
Pod undocumented
137 0 pop @_;
138 0 my ($conn_id, $ref) = map { ${ $_ } } @_;
139 0 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 0 0
140  
141 0 $self->{state}{conns}{$conn_id}{auth} = $ref;
142 0 $self->_client_register($conn_id);
143 0 return PCSI_EAT_CLIENT;
144 }
145  
146 sub IRCD_disconnected {
147 12 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_disconnected: called CC=4 SCAR=14.5
Pod undocumented
148 12 pop @_;
149 12 my ($conn_id, $errstr) = map { ${ $_ } } @_;
150 12 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 12 12
151  
152 12 ▶ if ($self->_connection_is_peer($conn_id)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_connection_is_peer($conn_id)) { } 0 12 12
elsif ($self->_connection_is_client($conn_id)) { } 9 3 12
153 0 my $peer = $self->{state}{conns}{$conn_id}{name};
154 $self->send_output(
155 0 @{ $self->_daemon_peer_squit($conn_id, $peer, $errstr) }
156 );
157 }
158 elsif ($self->_connection_is_client($conn_id)) {
159 $self->send_output(
160 9 @{ $self->_daemon_cmd_quit(
161 $self->_client_nickname($conn_id,$errstr ),
162 $errstr,
163 )}
164 );
165 }
166  
167 12 delete $self->{state}{conns}{$conn_id};
168 12 return PCSI_EAT_CLIENT;
169 }
170  
171 sub IRCD_compressed_conn {
172 2 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_compressed_conn: called CC=1 SCAR=0.0
Pod undocumented
173 2 pop @_;
174 2 my ($conn_id) = map { ${ $_ } } @_;
175 2 $self->_state_send_burst($conn_id);
176 2 return PCSI_EAT_CLIENT;
177 }
178  
179 sub IRCD_raw_input {
180 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_raw_input: not called CC=2 SCAR=17.9
Pod undocumented
181 0 ▶ return PCSI_EAT_CLIENT if !$self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"debug"} 0 0 0
182 0 my $conn_id = ${ $_[0] };
183 0 my $input = ${ $_[1] };
184 0 warn "<<< $conn_id: $input\n";
185 0 return PCSI_EAT_CLIENT;
186 }
187  
188 sub IRCD_raw_output {
189 0 ▶ my ($self, $ircd) = splice @_, 0, 2;
Subroutine IRCD_raw_output: not called CC=2 SCAR=17.9
Pod undocumented
190 0 ▶ return PCSI_EAT_CLIENT if !$self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"debug"} 0 0 0
191 0 my $conn_id = ${ $_[0] };
192 0 my $output = ${ $_[1] };
193 0 warn ">>> $conn_id: $output\n";
194 0 return PCSI_EAT_CLIENT;
195 }
196  
197 sub _default {
198 347 ▶ my ($self, $ircd, $event) = splice @_, 0, 3;
Subroutine _default: called CC=6 SCAR=18.0
199 347 ▶ return PCSI_EAT_NONE if $event !~ /^IRCD_cmd_/;
Branch: 1 branch
BranchTrueFalseTotal
unless $event =~ /^IRCD_cmd_/ 124 223 347
200 223 pop @_;
201 223 my ($conn_id, $input) = map { $$_ } @_;
202  
203 223 ▶ return PCSI_EAT_CLIENT if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 223 223
204 223 $self->{state}{conns}{$conn_id}{seen} = time;
205  
206 223 ▶ if (!$self->_connection_registered($conn_id)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $self->_connection_registered($conn_id)) { } 127 96 223
elsif ($self->_connection_is_peer($conn_id)) { } 10 86 96
elsif ($self->_connection_is_client($conn_id)) { } 86 0 86
207 127 $self->_cmd_from_unknown($conn_id, $input);
208 }
209 elsif ($self->_connection_is_peer($conn_id)) {
210 10 $self->_cmd_from_peer($conn_id, $input);
211 }
212 elsif ($self->_connection_is_client($conn_id)) {
213 86 delete $input->{prefix};
214 86 $self->_cmd_from_client($conn_id, $input);
215 }
216  
217 223 return PCSI_EAT_CLIENT;
218 }
219  
220 sub _auth_finished {
221 18 ▶ my $self = shift;
Subroutine _auth_finished: called CC=3 SCAR=11.4
222 18 ▶ my $conn_id = 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
223 18 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 18 18
224 18 return $self->{state}{conns}{$conn_id}{auth};
225 }
226  
227 sub _connection_exists {
228 1476 ▶ my $self = shift;
Subroutine _connection_exists: called CC=3 SCAR=11.0
229 1476 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
14760
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
230 1476 ▶ return if !defined $self->{state}{conns}{$conn_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"conns"}{$conn_id} 25 1451 1476
231 1451 return 1;
232 }
233  
234 sub _client_register {
235 58 ▶ my $self = shift;
Subroutine _client_register: called CC=11 SCAR=25.0
236 58 ▶ my $conn_id = 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
237 58 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 58 58
238 58 ▶ return if !$self->{state}{conns}{$conn_id}{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"nick"} 22 36 58
239 36 ▶ return if !$self->{state}{conns}{$conn_id}{user};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"user"} 18 18 36
240  
241 18 my $auth = $self->_auth_finished($conn_id);
242 18 ▶ return if !$auth;
Branch: 1 branch
BranchTrueFalseTotal
unless $auth 0 18 18
243 # pass required for link
244 18 ▶ if (!$self->_state_auth_client_conn($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_state_auth_client_conn($conn_id)) 2 16 18
245 2 $self->_terminate_conn_error(
246 $conn_id,
247 'You are not authorized to use this server',
248 );
249 2 return;
250 }
251 16 ▶ if ($self->_state_user_matches_gline($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_user_matches_gline($conn_id)) 0 16 16
252 0 $self->_terminate_conn_error($conn_id, 'G-Lined');
253 0 return;
254 }
255 16 ▶ if ($self->_state_user_matches_kline($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_user_matches_kline($conn_id)) 0 16 16
256 0 $self->_terminate_conn_error($conn_id, 'K-Lined');
257 0 return;
258 }
259 16 ▶ if ($self->_state_user_matches_rkline($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_user_matches_rkline($conn_id)) 0 16 16
260 0 $self->_terminate_conn_error($conn_id, 'K-Lined');
261 0 return;
262 }
263  
264 # Add new nick
265 16 $self->_state_register_client($conn_id);
266 16 my $server = $self->server_name();
267 16 my $nick = $self->_client_nickname($conn_id);
268 16 my $port = $self->{state}{conns}{$conn_id}{socket}[3];
269 16 my $version = $self->server_version();
270 16 my $network = $self->server_config('NETWORK');
271 16 my $server_is = "$server\[$server/$port]";
272  
273 16 $self->_send_output_to_client(
274 $conn_id,
275 {
276 prefix => $server,
277 command => '001',
278 params => [
279 $nick,
280 "Welcome to the $network Internet Relay Chat network $nick"
281 ],
282 }
283 );
284 16 $self->_send_output_to_client(
285 $conn_id,
286 {
287 prefix => $server,
288 command => '002',
289 params => [
290 $nick,
291 "Your host is $server_is, running version $version",
292 ],
293 },
294 );
295 16 $self->_send_output_to_client(
296 $conn_id,
297 {
298 prefix => $server,
299 command => '003',
300 params => [$nick, $self->server_created()],
301 },
302 );
303 16 $self->_send_output_to_client(
304 $conn_id,
305 {
306 prefix => $server,
307 command => '004',
308 colonify => 0,
309 params => [
310 $nick,
311 $server,
312 $version,
313 'Dilowz',
314 'biklmnopstveIh',
315 'bkloveIh',
316 ],
317 }
318 );
319  
320 16 for my $output (@{ $self->_daemon_cmd_isupport($nick) }) {
321 32 $self->_send_output_to_client($conn_id, $output);
322 }
323  
324 16 $self->{state}{conns}{$conn_id}{registered} = 1;
325 16 $self->{state}{conns}{$conn_id}{type} = 'c';
326 16 $self->send_event(
327 'cmd_lusers',
328 $conn_id,
329 { command => 'LUSERS' },
330 );
331 16 $self->send_event(
332 'cmd_motd',
333 $conn_id,
334 { command => 'MOTD' },
335 );
336 16 $self->send_event(
337 'cmd_mode',
338 $conn_id,
339 {
340 command => 'MODE',
341 params => [$nick, '+i'],
342 },
343 );
344  
345 16 return 1;
346 }
347  
348 sub _connection_registered {
349 223 ▶ my $self = shift;
Subroutine _connection_registered: called CC=3 SCAR=11.4
350 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
351 223 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 223 223
352 223 return $self->{state}{conns}{$conn_id}{registered};
353 }
354  
355 sub _connection_is_peer {
356 440 ▶ my $self = shift;
Subroutine _connection_is_peer: called CC=5 SCAR=16.2
357 440 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
4400
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
358  
359 440 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 440 440
360 440 ▶ return if !$self->{state}{conns}{$conn_id}{registered};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"registered"} 180 260 440
361 260 ▶ return 1 if $self->{state}{conns}{$conn_id}{type} eq 'p';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} eq "p" 10 250 260
362 250 return;
363 }
364  
365 sub _connection_is_client {
366 99 ▶ my $self = shift;
Subroutine _connection_is_client: called CC=5 SCAR=17.2
367 99 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
990
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
368  
369 99 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 99 99
370 99 ▶ return if !$self->{state}{conns}{$conn_id}{registered};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$conn_id}{"registered"} 3 96 99
371 96 ▶ return 1 if $self->{state}{conns}{$conn_id}{type} eq 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$conn_id}{"type"} eq "c" 96 0 96
372 0 return;
373 }
374  
375 sub _cmd_from_unknown {
376 127 ▶ my ($self, $wheel_id, $input) = @_;
Subroutine _cmd_from_unknown: called CC=34 SCAR=40.9
377  
378 127 my $cmd = uc $input->{command};
379 127 ▶ my $params = $input->{params} || [ ];
Condition100%2/2
$input->{'params'} || []
l!l
1261
MC/DC100%1/1
$input->{'params'} || []
$input->{'params'}
Truth table100%2/2
A
A= $input->{'params'}
Aresult
11
00
380 127 my $pcount = @$params;
381 127 my $invalid = 0;
382  
383 SWITCH: {
384 127 ▶ if ($cmd eq 'ERROR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "ERROR") 0 127 127
385 0 my $peer = $self->{state}{conns}{$wheel_id}{peer};
386 0 ▶ if (defined $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $peer) 0 0 0
387 0 $self->send_event_next(
388 'daemon_error',
389 $wheel_id,
390 $peer,
391 $params->[0],
392 );
393 }
394 }
395 127 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 1 126 127
396 1 $self->_terminate_conn_error($wheel_id, 'Client Quit');
397 1 last SWITCH;
398 }
399  
400 # PASS or NICK cmd but no parameters.
401 126 ▶ if ($cmd =~ /^(PASS|NICK|SERVER)$/ && !$pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount) 0 126 126
Condition66%2/3
$cmd =~ /^(PASS|NICK|SERVER)$/ and not $pcount
!ll&&!rl&&r
99270
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
402 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
403 0 last SWITCH;
404 }
405  
406 # PASS or NICK cmd with one parameter, connection from client
407 126 ▶ if ($cmd eq 'PASS' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "PASS" and $pcount) 4 122 126
Condition66%2/3
$cmd eq "PASS" and $pcount
!ll&&!rl&&r
12204
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
408 4 $self->{state}{conns}{$wheel_id}{lc $cmd} = $params->[0];
409  
410 4 ▶ if ($params->[1] && $params->[1] =~ /TS$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->[1] and $params->[1] =~ /TS$/) 4 0 4
Condition33%1/3
$params->[1] and $params->[1] =~ /TS$/
!ll&&!rl&&r
004
MC/DC0%0/2
$params->[1] and $params->[1] =~ /TS$/
$params->[1] $params->[1] =~ /TS$/
Truth table33%1/3
A and B
A= $params->[1]B= $params->[1] =~ /TS$/
ABresult
0X0
100
111
411 4 $self->{state}{conns}{$wheel_id}{ts_server} = 1;
412 4 $self->antiflood($wheel_id, 0);
413 }
414 4 last SWITCH;
415 }
416  
417 # SERVER stuff.
418 122 ▶ if ($cmd eq 'CAPAB' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "CAPAB" and $pcount) 4 118 122
Condition66%2/3
$cmd eq "CAPAB" and $pcount
!ll&&!rl&&r
11804
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
419 $self->{state}{conns}{$wheel_id}{capab}
420 4 = [split /\s+/, $params->[0]];
421 4 last SWITCH;
422 }
423 118 ▶ if ($cmd eq 'SERVER' && $pcount < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SERVER" and $pcount < 2) 0 118 118
Condition66%2/3
$cmd eq "SERVER" and $pcount < 2
!ll&&!rl&&r
11440
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
424 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
425 0 last SWITCH;
426 }
427 118 ▶ if ($cmd eq 'SERVER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SERVER") 4 114 118
428 4 my $conn = $self->{state}{conns}{$wheel_id};
429 4 $conn->{name} = $params->[0];
430 4 ▶ $conn->{hops} = $params->[1] || 1;
Condition50%1/2
$params->[1] || 1
l!l
40
MC/DC0%0/1
$params->[1] || 1
$params->[1]
Truth table50%1/2
A
A= $params->[1]
Aresult
11
00
431 4 ▶ $conn->{desc} = $params->[2] || '';
Condition50%1/2
$params->[2] || ''
l!l
40
MC/DC0%0/1
$params->[2] || ''
$params->[2]
Truth table50%1/2
A
A= $params->[2]
Aresult
11
00
432  
433 4 ▶ if (!$conn->{ts_server}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn->{"ts_server"}) 0 4 4
434 0 $self->_terminate_conn_error($wheel_id, 'Non-TS server.');
435 0 last SWITCH;
436 }
437 4 ▶ if (!$self->_state_auth_peer_conn($wheel_id,
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_state_auth_peer_conn($wheel_id, $conn->{"name"}, $conn->{"pass"})) 0 4 4
438 $conn->{name}, $conn->{pass})) {
439 0 $self->_terminate_conn_error(
440 $wheel_id,
441 'Unauthorised server.',
442 );
443 0 last SWITCH;
444 }
445 4 ▶ if ($self->state_peer_exists($conn->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($conn->{"name"})) 0 4 4
446 0 $self->_terminate_conn_error($wheel_id, 'Server exists.');
447 0 last SWITCH;
448 }
449 4 $self->_state_register_peer($wheel_id);
450  
451 4 ▶ if ($conn->{zip} && grep { $_ eq 'ZIP' } @{ $conn->{capab} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conn->{'zip'} and grep {$_ eq 'ZIP';} @{$$conn{'capab'};}) { } 2 2 4
Condition66%2/3
$conn->{"zip"} and grep {$_ eq "ZIP";} @{$$conn{"capab"};}
!ll&&!rl&&r
202
MC/DC50%1/2
$conn->{"zip"} and grep {$_ eq "ZIP";} @{$$conn{"capab"};}
$conn->{"zip"} grep {$_ eq "ZIP";} @{$$conn{"capab"};}
Truth table66%2/3
A and B
A= $conn->{"zip"}B= grep {$_ eq "ZIP";} @{$$conn{"capab"};}
ABresult
0X0
100
111
452 2 $self->compressed_link($wheel_id, 1, $conn->{cntr});
453 }
454 else {
455 2 $self->_state_send_burst($wheel_id);
456 }
457  
458 $self->send_event(
459 "daemon_capab",
460 $conn->{name},
461 4 @{ $conn->{capab} },
462 );
463 4 last SWITCH;
464 }
465  
466 114 ▶ if ($cmd eq 'NICK' && $pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "NICK" and $pcount) 19 95 114
Condition66%2/3
$cmd eq "NICK" and $pcount
!ll&&!rl&&r
95019
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
467 19 ▶ if (!is_valid_nick_name($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_nick_name($params->[0])) 0 19 19
468 0 $self->_send_output_to_client(
469 $wheel_id,
470 '432',
471 $params->[0],
472 );
473 0 last SWITCH;
474 }
475 19 ▶ if ($self->state_nick_exists($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($params->[0])) 1 18 19
476 1 $self->_send_output_to_client(
477 $wheel_id,
478 '433',
479 $params->[0],
480 );
481 1 last SWITCH;
482 }
483  
484 18 my $nicklen = $self->server_config('NICKLEN');
485 18 ▶ if (length($params->[0]) > $nicklen) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $params->[0] > $nicklen) 0 18 18
486 0 $params->[0] = substr($params->[0], 0, $nicklen);
487 }
488  
489 18 $self->{state}{conns}{$wheel_id}{lc $cmd} = $params->[0];
490 18 $self->{state}{pending}{uc_irc($params->[0])} = $wheel_id;
491 18 $self->_client_register($wheel_id);
492 18 last SWITCH;
493 }
494 95 ▶ if ($cmd eq 'USER' && $pcount < 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "USER" and $pcount < 4) 0 95 95
Condition66%2/3
$cmd eq "USER" and $pcount < 4
!ll&&!rl&&r
76190
MC/DC0%0/2
$cmd eq "USER" and $pcount < 4
$cmd eq "USER" $pcount < 4
Truth table66%2/3
A and B
A= $cmd eq "USER"B= $pcount < 4
ABresult
0X0
100
111
495 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
496 0 last SWITCH;
497 }
498 95 ▶ if ($cmd eq 'USER') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "USER") 19 76 95
499 19 $self->{state}{conns}{$wheel_id}{user} = $params->[0];
500 19 ▶ $self->{state}{conns}{$wheel_id}{ircname} = $params->[3] || '';
Condition50%1/2
$params->[3] || ''
l!l
190
MC/DC0%0/1
$params->[3] || ''
$params->[3]
Truth table50%1/2
A
A= $params->[3]
Aresult
11
00
501 19 $self->_client_register($wheel_id);
502 19 last SWITCH;
503 }
504  
505 76 ▶ last SWITCH if $self->{state}{conns}{$wheel_id}{cntr};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"conns"}{$wheel_id}{"cntr"} 0 76 76
506 76 $invalid = 1;
507 76 $self->_send_output_to_client($wheel_id, '451');
508 }
509  
510 127 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 76 51 127
511 51 $self->_state_cmd_stat($cmd, $input->{raw_line});
512 51 return 1;
513 }
514  
515 sub _cmd_from_peer {
516 10 ▶ my ($self, $conn_id, $input) = @_;
Subroutine _cmd_from_peer: called CC=19 SCAR=41.1
517  
518 10 my $cmd = $input->{command};
519 10 my $params = $input->{params};
520 10 my $prefix = $input->{prefix};
521 10 my $invalid = 0;
522  
523 SWITCH: {
524 10 my $method = '_daemon_peer_' . lc $cmd;
525 10 ▶ if ($cmd eq 'SQUIT' && !$prefix ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "SQUIT" and not $prefix) 0 10 10
Condition33%1/3
$cmd eq "SQUIT" and not $prefix
!ll&&!rl&&r
1000
MC/DC0%0/2
$cmd eq "SQUIT" and not $prefix
$cmd eq "SQUIT" not $prefix
Truth table33%1/3
A and not(B)
A= $cmd eq "SQUIT"B= not $prefix
ABresult
0X0
100
111
526 0 $self->_daemon_peer_squit($conn_id, @$params);
527 #$self->_send_output_to_client(
528 # $conn_id,
529 # $prefix,
530 # (ref $_ eq 'ARRAY' ? @{ $_ } : $_)
531 #) for $self->_daemon_cmd_squit($prefix, @$params);
532 0 last SWITCH;
533 }
534  
535 10 ▶ if ($cmd =~ /\d{3}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /\d{3}/) 0 10 10
536 0 $self->send_output(
537 $input,
538 $self->_state_user_route($params->[0])
539 );
540 0 last SWITCH;
541 }
542 10 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 0 10 10
543 $self->send_output(
544 0 @{ $self->_daemon_peer_quit(
545 $prefix, @$params, $conn_id
546 )}
547 );
548 0 last SWITCH;
549 }
550  
551 10 ▶ if ($cmd =~ /^(PRIVMSG|NOTICE)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PRIVMSG|NOTICE)$/) 0 10 10
552 $self->_send_output_to_client(
553 $conn_id,
554 $prefix,
555 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_)
556 0 ▶ ) for $self->_daemon_peer_message(
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
557 $conn_id,
558 $prefix,
559 $cmd,
560 @$params
561 );
562 0 last SWITCH;
563 }
564  
565 10 ▶ if ($cmd =~ /^(WHOIS|VERSION|TIME|NAMES|LINKS|ADMIN|INFO|MOTD|SQUIT)$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(WHOIS|VERSION|TIME|NAMES|LINKS|ADMIN|INFO|MOTD|SQUIT)$/i) 0 10 10
566 0 my $client_method = '_daemon_cmd_' . lc $cmd;
567 $self->_send_output_to_client(
568 $conn_id,
569 $prefix,
570 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_ )
571 0 ▶ ) for $self->$client_method($prefix, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
572 0 last SWITCH;
573 }
574  
575 10 ▶ if ($cmd =~ /^(PING|PONG)$/i && $self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PING|PONG)$/i and $self->can($method)) 0 10 10
Condition33%1/3
$cmd =~ /^(PING|PONG)$/i and $self->can($method)
!ll&&!rl&&r
1000
MC/DC0%0/2
$cmd =~ /^(PING|PONG)$/i and $self->can($method)
$cmd =~ /^(PING|PONG)$/i $self->can($method)
Truth table33%1/3
A and B
A= $cmd =~ /^(PING|PONG)$/iB= $self->can($method)
ABresult
0X0
100
111
576 0 $self->$method($conn_id, @{ $params });
577 0 last SWITCH;
578 }
579  
580 10 ▶ if ($cmd =~ /^SVINFO$/i && $self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^SVINFO$/i and $self->can($method)) 4 6 10
Condition66%2/3
$cmd =~ /^SVINFO$/i and $self->can($method)
!ll&&!rl&&r
604
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
581 4 $self->$method($conn_id, @$params);
582 4 my $conn = $self->{state}{conns}{$conn_id};
583 $self->send_event(
584 "daemon_svinfo",
585 $conn->{name},
586 4 @$params,
587 );
588 4 last SWITCH;
589 }
590  
591 6 ▶ 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])) 0 6 6
Condition33%1/3
$cmd eq "MODE" and $self->state_nick_exists($params->[0])
!ll&&!rl&&r
600
MC/DC0%0/2
$cmd eq "MODE" and $self->state_nick_exists($params->[0])
$cmd eq "MODE" $self->state_nick_exists($params->[0])
Truth table33%1/3
A and B
A= $cmd eq "MODE"B= $self->state_nick_exists($params->[0])
ABresult
0X0
100
111
592 0 $method = '_daemon_peer_umode';
593 }
594  
595 6 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 6 0 6
596 6 $self->$method($conn_id, $prefix, @$params);
597 6 last SWITCH;
598 }
599 0 $invalid = 1;
600 }
601  
602 10 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 10 10
603 10 $self->_state_cmd_stat($cmd, $input->{raw_line}, 1);
604 10 return 1;
605 }
606  
607 sub _cmd_from_client {
608 86 ▶ my ($self, $wheel_id, $input) = @_;
Subroutine _cmd_from_client: called CC=20 SCAR=32.5
609  
610 86 my $cmd = uc $input->{command};
611 86 ▶ my $params = $input->{params} || [ ];
Condition100%2/2
$input->{'params'} || []
l!l
4640
MC/DC100%1/1
$input->{'params'} || []
$input->{'params'}
Truth table100%2/2
A
A= $input->{'params'}
Aresult
11
00
612 86 my $pcount = @$params;
613 86 my $server = $self->server_name();
614 86 my $nick = $self->_client_nickname($wheel_id);
615 86 my $invalid = 0;
616  
617 SWITCH: {
618 86 my $method = '_daemon_cmd_' . lc $cmd;
619 86 ▶ if ($cmd eq 'QUIT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "QUIT") 9 77 86
620 9 ▶ $self->_terminate_conn_error(
Branch: 1 branch
BranchTrueFalseTotal
$pcount ? : 4 5 9
621 $wheel_id,
622 ($pcount ? qq{"$params->[0]"} : 'Client Quit'),
623 );
624 9 last SWITCH;
625 }
626  
627 77 ▶ if ($cmd =~ /^(USERHOST|MODE)$/ && !$pcount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(USERHOST|MODE)$/ and not $pcount) 0 77 77
Condition66%2/3
$cmd =~ /^(USERHOST|MODE)$/ and not $pcount
!ll&&!rl&&r
59180
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
628 0 $self->_send_output_to_client($wheel_id, '461', $cmd);
629 0 last SWITCH;
630 }
631 77 ▶ if ($cmd =~ /^(USERHOST)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(USERHOST)$/) 0 77 77
632 $self->_send_output_to_client($wheel_id, $_)
633 0 ▶ for $self->$method(
Branch: 1 branch
BranchTrueFalseTotal
$pcount <= 5 ? : 0 0 0
634 $nick,
635 ($pcount <= 5
636 ? @$params
637 0 : @{ $params }[0..5]
638 )
639 );
640 0 last SWITCH;
641 }
642  
643 77 ▶ if ($cmd =~ /^(PRIVMSG|NOTICE)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^(PRIVMSG|NOTICE)$/) 4 73 77
644 4 $self->{state}{conns}{$wheel_id}{idle_time} = time;
645 $self->_send_output_to_client(
646 $wheel_id,
647 0 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
648 4 ▶ ) for $self->_daemon_cmd_message($nick, $cmd, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 2 2
649 4 last SWITCH;
650 }
651  
652 73 ▶ 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])) 17 56 73
Condition100%3/3
$cmd eq "MODE" and $self->state_nick_exists($params->[0])
!ll&&!rl&&r
55117
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
653 17 ▶ if (uc_irc($nick) ne uc_irc($params->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (uc_irc($nick) ne uc_irc($params->[0])) 0 17 17
654 0 $self->_send_output_to_client($wheel_id => '502');
655 0 last SWITCH;
656 }
657  
658 17 my $modestring = join('', @{ $params }[1..$#{ $params }]);
659 17 $modestring =~ s/\s+//g;
660 17 $modestring =~ s/[^a-zA-Z+-]+//g;
661 17 $modestring =~ s/[^DGglwiozl+-]+//g;
662 17 $modestring = unparse_mode_line($modestring);
663 $self->_send_output_to_client($wheel_id, $_)
664 17 for $self->_daemon_cmd_umode($nick, $modestring);
665 17 last SWITCH;
666 }
667  
668 56 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 56 0 56
669 $self->_send_output_to_client(
670 $wheel_id,
671 1 (ref $_ eq 'ARRAY' ? @{ $_ } : $_),
672 56 ▶ ) for $self->$method($nick, @$params);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 109 110
673 56 last SWITCH;
674 }
675  
676 0 $invalid = 1;
677 0 $self->_send_output_to_client($wheel_id, '421', $cmd);
678 }
679  
680 86 ▶ return 1 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 86 86
681 86 $self->_state_cmd_stat($cmd, $input->{raw_line});
682 86 return 1;
683 }
684  
685 sub _daemon_cmd_message {
686 4 ▶ my $self = shift;
Subroutine _daemon_cmd_message: called CC=81 SCAR=72.7
687 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
688 4 ▶ my $type = 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
689 4 my $ref = [ ];
690 4 my $args = [@_];
691 4 my $count = @$args;
692  
693 SWITCH: {
694 4 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 4 4
695 0 push @$ref, ['461', $type];
696 0 last SWITCH;
697 }
698 4 ▶ if ($count < 2 || !$args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < 2 or not $args->[1]) 0 4 4
Condition33%1/3
$count < 2 or not $args->[1]
l!l&&r!l&&!r
004
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
699 0 push @$ref, ['412'];
700 0 last SWITCH;
701 }
702  
703 4 my $targets = 0;
704 4 my $max_targets = $self->server_config('MAXTARGETS');
705 4 my $full = $self->state_user_full($nick);
706 4 my $targs = $self->_state_parse_msg_targets($args->[0]);
707  
708 4 LOOP: for my $target (keys %$targs) {
709 4 my $targ_type = shift @{ $targs->{$target} };
710  
711 4 ▶ 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 4 4
Condition33%1/3
$targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
400
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
712 && !$self->state_user_is_operator($nick)) {
713 0 push @$ref, ['481'];
714 0 next LOOP;
715 }
716  
717 4 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./) 0 4 4
Condition33%1/3
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
!ll&&!rl&&r
400
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
718 && $targs->{$target}[0] !~ /\./) {
719 0 push @$ref, ['413', $target];
720 0 next LOOP;
721 }
722  
723 4 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/) 0 4 4
Condition33%1/3
$targ_type =~ /(server|host)mask/ and $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/
!ll&&!rl&&r
400
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 table33%1/3
A and B
A= $targ_type =~ /(server|host)mask/B= $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/
ABresult
0X0
100
111
724 && $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/) {
725 0 push @$ref, ['414', $target];
726 0 next LOOP;
727 }
728  
729 4 ▶ 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 4 4
Condition33%1/3
$targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])
!ll&&!rl&&r
400
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
730 && !$self->state_chan_exists($targs->{$target}[1])) {
731 0 push @$ref, ['401', $targs->{$target}[1]];
732 0 next LOOP;
733 }
734  
735 4 ▶ if ($targ_type eq 'channel'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel" and not $self->state_chan_exists($target)) 0 4 4
Condition66%2/3
$targ_type eq "channel" and not $self->state_chan_exists($target)
!ll&&!rl&&r
310
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
736 && !$self->state_chan_exists($target)) {
737 0 push @$ref, ['401', $target];
738 0 next LOOP;
739 }
740  
741 4 ▶ if ($targ_type eq 'nick'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick" and not $self->state_nick_exists($target)) 0 4 4
Condition66%2/3
$targ_type eq "nick" and not $self->state_nick_exists($target)
!ll&&!rl&&r
130
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
742 && !$self->state_nick_exists($target)) {
743 0 push @$ref, ['401', $target];
744 0 next LOOP;
745 }
746  
747 4 ▶ 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 4 4
Condition33%1/3
$targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])
!ll&&!rl&&r
400
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
748 && !$self->state_peer_exists($targs->{$target}[1])) {
749 0 push @$ref, ['402', $targs->{$target}[1]];
750 0 next LOOP;
751 }
752  
753 4 $targets++;
754 4 ▶ if ($targets > $max_targets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targets > $max_targets) 0 4 4
755 0 push @$ref, ['407', $target];
756 0 last SWITCH;
757 }
758  
759 # $$whatever
760 4 ▶ if ($targ_type eq 'servermask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "servermask") 0 4 4
761 0 my $us = 0;
762 0 my %targets;
763 0 my $ucserver = uc $self->server_name();
764  
765 0 for my $peer (keys %{ $self->{state}{peers} }) {
766 0 ▶ if (matches_mask( $targs->{$target}[0], $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targs->{$target}[0], $peer)) 0 0 0
767 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
768 0 $us = 1;
769 }
770 else {
771 0 $targets{ $self->_state_peer_route($peer) }++;
772 }
773 }
774 }
775  
776 $self->send_output(
777 {
778 0 prefix => $nick,
779 command => $type,
780 params => [$target, $args->[1]],
781 },
782 keys %targets,
783 );
784  
785 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
786 my $local
787 0 = $self->{state}{peers}{uc $self->server_name()}{users};
788 0 my @local;
789 0 my $spoofed = 0;
790  
791 0 for my $luser (values %$local) {
792 0 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 0 0
793 0 $spoofed = 1;
794 }
795 else {
796 0 push @local, $luser->{route_id};
797 }
798 }
799  
800 $self->send_output(
801 {
802 0 prefix => $full,
803 command => $type,
804 params => [$target, $args->[1]],
805 },
806 @local,
807 );
808  
809 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
810 "daemon_" . lc $type,
811 $full,
812 $target,
813 $args->[1],
814 ) if $spoofed;
815 }
816 0 next LOOP;
817 }
818  
819 # $#whatever
820 4 ▶ if ($targ_type eq 'hostmask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "hostmask") 0 4 4
821 0 my $spoofed = 0;
822 0 my %targets; my @local;
823  
824 0 HOST: for my $luser (values %{ $self->{state}{users} }) {
825 0 ▶ if (!matches_mask($targs->{$target}[0],
Branch: 1 branch
BranchTrueFalseTotal
unless (matches_mask($targs->{$target}[0], $luser->{"auth"}{"hostname"})) 0 0 0
826 $luser->{auth}{hostname})) {;
827 0 next HOST;
828 }
829  
830 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
831 0 $spoofed = 1;
832 }
833 elsif ($luser->{type} eq 'r') {
834 0 $targets{ $luser->{route_id} }++;
835 }
836 else {
837 0 push @local, $luser->{route_id};
838 }
839 }
840  
841 $self->send_output(
842 {
843 0 prefix => $nick,
844 command => $type,
845 params => [$target, $args->[1]],
846 },
847 keys %targets,
848 );
849  
850 0 $self->send_output(
851 {
852 prefix => $full,
853 command => $type,
854 params => [$target, $args->[1]],
855 },
856 @local,
857 );
858  
859 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
860 "daemon_" . lc $type,
861 $full,
862 $target,
863 $args->[1],
864 ) if $spoofed;
865  
866 0 next LOOP;
867 }
868  
869 4 ▶ if ($targ_type eq 'nick_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext") 0 4 4
870 $targs->{$target}[1] = $self->_state_peer_name(
871 0 $targs->{$target}[1]);
872  
873 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
874 && !$self->state_user_is_operator($nick)) {
875 0 push @$ref, ['481'];
876 0 next LOOP;
877 }
878  
879 0 ▶ if ($targs->{$target}[1] ne $self->server_name()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[1] ne $self->server_name) 0 0 0
880 $self->send_output(
881 {
882 prefix => $nick,
883 command => $type,
884 params => [$target, $args->[1]],
885 },
886 0 $self->_state_peer_route($targs->{$target}[1]),
887 );
888 0 next LOOP;
889 }
890  
891 0 ▶ if (uc $targs->{$target}[0] eq 'OPERS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $targs->{$target}[0] eq "OPERS") 0 0 0
892 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
893 0 push @$ref, ['481'];
894 0 next LOOP;
895 }
896  
897 $self->send_output(
898 {
899 prefix => $full,
900 command => $type,
901 params => [$target, $args->[1]],
902 },
903 0 keys %{ $self->{state}{localops} },
904 );
905 0 next LOOP;
906 }
907  
908 my @local = $self->_state_find_user_host(
909 $targs->{$target}[0],
910 0 $targs->{$target}[2],
911 );
912  
913 0 ▶ if (@local == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local == 1) { } 0 0 0
914 0 my $ref = shift @local;
915 0 ▶ if ($ref->[0] eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->[0] eq 'spoofed') { } 0 0 0
916 0 $self->send_event(
917 "daemon_" . lc $type,
918 $full,
919 $ref->[1],
920 $args->[1],
921 );
922 }
923 else {
924 0 $self->send_output(
925 {
926 prefix => $full,
927 command => $type,
928 params => [$target, $args->[1]],
929 },
930 $ref->[0],
931 );
932 }
933 }
934 else {
935 0 push @$ref, ['407', $target];
936 0 next LOOP;
937 }
938 }
939  
940 4 my ($channel, $status_msg);
941 4 ▶ if ($targ_type eq 'channel') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel") 1 3 4
942 1 $channel = $self->_state_chan_name($target);
943 }
944 4 ▶ if ($targ_type eq 'channel_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext") 0 4 4
945 0 $channel = $self->_state_chan_name($targs->{target}[1]);
946 0 $status_msg = $targs->{target}[0];
947 }
948 4 ▶ if ($channel && $status_msg
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)) 0 4 4
Condition50%3/6
$channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
400
$channel and $status_msg
!ll&&!rl&&r
310
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
949 && !$self->state_user_chan_mode($nick, $channel)) {
950 0 push @$ref, ['482', $target];
951 0 next LOOP;
952 }
953 4 ▶ 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 4 4
Condition66%4/6
$channel and $self->state_chan_mode_set($channel, "n") and not $self->state_is_chan_member($nick, $channel)
!ll&&!rl&&r
310
$channel and $self->state_chan_mode_set($channel, "n")
!ll&&!rl&&r
301
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
954 && !$self->state_is_chan_member($nick, $channel)) {
955 0 push @$ref, ['404', $channel];
956 0 next LOOP;
957 }
958 4 ▶ 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 4 4
Condition50%3/6
$channel and $self->state_chan_mode_set($channel, "m") and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
400
$channel and $self->state_chan_mode_set($channel, "m")
!ll&&!rl&&r
310
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
959 && !$self->state_user_chan_mode($nick, $channel)) {
960 0 push @$ref, ['404', $channel];
961 0 next LOOP;
962 }
963 4 ▶ 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 4 4
Condition50%3/6
$channel and $self->_state_user_banned($nick, $channel) and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
400
$channel and $self->_state_user_banned($nick, $channel)
!ll&&!rl&&r
310
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
964 && !$self->state_user_chan_mode($nick, $channel)) {
965 0 push @$ref, ['404', $channel];
966 0 next LOOP;
967 }
968 4 ▶ if ($channel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($channel) 1 3 4
969 1 my $common = { };
970 1 ▶ my $msg = {
Branch: 1 branch
BranchTrueFalseTotal
$status_msg ? : 0 1 1
971 command => $type,
972 params => [
973 ($status_msg ? $target : $channel), $args->[1]
974 ],
975 };
976 1 for my $member ($self->state_chan_list($channel, $status_msg)) {
977 2 ▶ next if $self->_state_user_is_deaf($member);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_is_deaf($member) 0 2 2
978 2 $common->{ $self->_state_user_route($member) }++;
979 }
980 1 delete $common->{ $self->_state_user_route($nick) };
981 1 for my $route_id (keys %$common) {
982 1 $msg->{prefix} = $nick;
983 1 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 1 0 1
984 1 $msg->{prefix} = $full;
985 }
986 1 ▶ if ($route_id ne 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id ne 'spoofed') { } 1 0 1
987 1 $self->send_output($msg, $route_id);
988 }
989 else {
990 0 ▶ my $tmsg = $type eq 'PRIVMSG' ? 'public' : 'notice';
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'PRIVMSG' ? : 0 0 0
991 0 $self->send_event(
992 "daemon_$tmsg",
993 $full,
994 $channel,
995 $args->[1],
996 );
997 }
998 }
999 1 next LOOP;
1000 }
1001  
1002 3 my $server = $self->server_name();
1003 3 ▶ if ($self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($target)) 3 0 3
1004 3 $target = $self->state_user_nick($target);
1005  
1006 3 ▶ if (my $away = $self->_state_user_away_msg($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $away = $self->_state_user_away_msg($target)) 0 3 3
1007 0 push @$ref, {
1008 prefix => $server,
1009 command => '301',
1010 params => [$nick, $target, $away],
1011 };
1012 }
1013  
1014 3 my $targ_umode = $self->state_user_umode($target);
1015  
1016 # Target user has CALLERID on
1017 3 ▶ if ($targ_umode && $targ_umode =~ /[Gg]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_umode and $targ_umode =~ /[Gg]/) 1 2 3
Condition66%2/3
$targ_umode and $targ_umode =~ /[Gg]/
!ll&&!rl&&r
021
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
1018 1 my $targ_rec = $self->{state}{users}{uc_irc($target)};
1019 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
1020 && (!$self->state_users_share_chan($target, $nick)
1021 || !$targ_rec->{accepts}{uc_irc($nick)}))
1022 || ($targ_umode =~ /g/
1023 && !$targ_rec->{accepts}{uc_irc($nick)})) {
1024  
1025 1 push @$ref, {
1026 prefix => $server,
1027 command => '716',
1028 params => [
1029 $nick,
1030 $target,
1031 'is in +g mode (server side ignore)',
1032 ],
1033 };
1034  
1035 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
1036 || time() - $targ_rec->{last_caller} >= 60) {
1037  
1038 1 my ($n, $uh) = split /!/,
1039 $self->state_user_full($nick);
1040 $self->send_output(
1041 {
1042 prefix => $server,
1043 command => '718',
1044 params => [
1045 $target,
1046 "$n\[$uh\]",
1047 'is messaging you, and you are umode +g.',
1048 ]
1049 },
1050 $targ_rec->{route_id},
1051 1 ▶ ) if $targ_rec->{route_id} ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $targ_rec->{"route_id"} ne "spoofed" 0 1 1
1052 1 push @$ref, {
1053 prefix => $server,
1054 command => '717',
1055 params => [
1056 $nick,
1057 $target,
1058 'has been informed that you messaged them.',
1059 ],
1060 };
1061 }
1062 1 $targ_rec->{last_caller} = time();
1063 1 next LOOP;
1064 }
1065 }
1066  
1067 2 my $msg = {
1068 prefix => $nick,
1069 command => $type,
1070 params => [$target, $args->[1]],
1071 };
1072 2 my $route_id = $self->_state_user_route($target);
1073  
1074 2 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 2 0 2
1075 2 $msg->{prefix} = $full;
1076 2 $self->send_event(
1077 "daemon_" . lc $type,
1078 $full,
1079 $target,
1080 $args->[1],
1081 );
1082 }
1083 else {
1084 0 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 0 0 0
1085 0 $msg->{prefix} = $full;
1086 }
1087 0 $self->send_output($msg, $route_id);
1088 }
1089 2 next LOOP;
1090 }
1091 }
1092 }
1093  
1094 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4 0 4
1095 0 return $ref;
1096 }
1097  
1098 sub _daemon_cmd_accept {
1099 0 ▶ my $self = shift;
Subroutine _daemon_cmd_accept: not called CC=21 SCAR=61.4
1100 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
1101 0 my $server = $self->server_name();
1102 0 my $ref = [ ];
1103 0 my $args = [ @_ ];
1104 0 my $count = @$args;
1105  
1106 SWITCH: {
1107 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
1108 0 my $record = $self->{state}{users}{uc_irc($nick)};
1109 0 my @list;
1110 0 for my $accept (keys %{ $record->{accepts} }) {
1111 0 ▶ if (!$self->state_nick_exists($accept)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($accept)) 0 0 0
1112 0 delete $record->{accepts}{$accept};
1113 0 next;
1114 }
1115 0 push @list, $self->state_user_nick($accept);
1116 }
1117 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if @list 0 0 0
1118 prefix => $server,
1119 command => '281',
1120 params => [$nick, join( ' ', @list)],
1121 } if @list;
1122  
1123 0 push @$ref, {
1124 prefix => $server,
1125 command => '282',
1126 params => [$nick, 'End of /ACCEPT list'],
1127 };
1128 0 last SWITCH;
1129 }
1130 }
1131  
1132 0 my $record = $self->{state}{users}{uc_irc($nick)};
1133  
1134 0 for (keys %{ $record->{accepts} }) {
1135 0 ▶ delete $record->{accepts}{$_} if !$self->state_nick_exists($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($_) 0 0 0
1136 }
1137  
1138 0 OUTER: for my $target (split /,/, $args->[0]) {
1139 0 ▶ if (my ($foo) = $target =~ /^\-(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($foo) = $target =~ /^\-(.+)$/) 0 0 0
1140 0 my $dfoo = delete $record->{accepts}{uc_irc($foo)};
1141 0 ▶ if (!$dfoo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dfoo) 0 0 0
1142 0 push @$ref, {
1143 prefix => $server,
1144 command => '458',
1145 params => [$nick, $foo, "doesn\'t exist"],
1146 };
1147 }
1148 0 delete $self->{state}{accepts}{uc_irc($foo)}{uc_irc($nick)};
1149 0 ▶ if (!keys %{ $self->{state}{accepts}{uc_irc($foo)} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$self->{"state"}{"accepts"}{uc_irc($foo)};}) 0 0 0
1150 0 delete $self->{state}{accepts}{uc_irc($foo)};
1151 }
1152 0 next OUTER;
1153 }
1154  
1155 0 ▶ if (!$self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($target)) 0 0 0
1156 0 push @$ref, ['401', $target];
1157 0 next OUTER;
1158 }
1159 # 457 ERR_ACCEPTEXIST
1160 0 ▶ if ($record->{accepts}{uc_irc($target)}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"accepts"}{uc_irc($target)}) 0 0 0
1161 0 push @$ref, {
1162 prefix => $server,
1163 command => '457',
1164 params => [
1165 $nick,
1166 $self->state_user_nick($target),
1167 'already exists',
1168 ],
1169 };
1170 0 next OUTER;
1171 }
1172  
1173 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
1174 && $self->_state_users_share_chan($nick, $target) ) {
1175 0 push @$ref, {
1176 prefix => $server,
1177 command => '457',
1178 params => [
1179 $nick,
1180 $self->state_user_nick($target),
1181 'already exists',
1182 ],
1183 };
1184 0 next OUTER;
1185 }
1186  
1187 $self->{state}{accepts}{uc_irc($target)}{uc_irc($nick)}
1188 0 = $record->{accepts}{uc_irc($target)} = time;
1189 0 my @list = map { $self->state_user_nick($_) } keys %{ $record->{accepts} };
1190  
1191 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if @list 0 0 0
1192 prefix => $server,
1193 command => '281',
1194 params => [
1195 $nick,
1196 join(' ', @list),
1197 ],
1198 } if @list;
1199  
1200 0 push @$ref, {
1201 prefix => $server,
1202 command => '282',
1203 params => [$nick, 'End of /ACCEPT list'],
1204 };
1205 }
1206  
1207 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1208 0 return $ref;
1209 }
1210  
1211 sub _daemon_cmd_quit {
1212 14 ▶ my $self = shift;
Subroutine _daemon_cmd_quit: called CC=14 SCAR=26.7
1213 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
1214 14 ▶ my $qmsg = shift || 'Client Quit';
Condition50%1/2
shift() || 'Client Quit'
l!l
140
MC/DC0%0/1
shift() || 'Client Quit'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1215 14 my $ref = [ ];
1216 14 my $full = $self->state_user_full($nick);
1217  
1218 14 $nick = uc_irc($nick);
1219 14 my $record = delete $self->{state}{peers}{uc $self->server_name()}{users}{$nick};
1220 $self->send_output(
1221 {
1222 prefix => $record->{nick},
1223 command => 'QUIT',
1224 params => [$qmsg],
1225 },
1226 $self->_state_connected_peers(),
1227 14 ▶ ) if !$record->{killed};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"killed"} 14 0 14
1228  
1229 14 push @$ref, {
1230 prefix => $full,
1231 command => 'QUIT',
1232 params => [$qmsg],
1233 };
1234 14 $self->send_event("daemon_quit", $full, $qmsg);
1235  
1236 # Remove for peoples accept lists
1237 14 for my $user (keys %{ $record->{accepts} }) {
1238 0 delete $self->{state}{users}{$user}{accepts}{uc_irc($nick)};
1239 }
1240  
1241 # Okay, all 'local' users who share a common channel with user.
1242 14 my $common = { };
1243 14 for my $uchan (keys %{ $record->{chans} }) {
1244 6 delete $self->{state}{chans}{$uchan}{users}{$nick};
1245 6 for my $user ($self->state_chan_list($uchan)) {
1246 3 ▶ next if !$self->_state_is_local_user($user);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_is_local_user($user) 0 3 3
1247 3 $common->{$user} = $self->_state_user_route($user);
1248 }
1249  
1250 6 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 3 3 6
1251 3 delete $self->{state}{chans}{$uchan};
1252 }
1253 }
1254  
1255 14 push @$ref, $common->{$_} for keys %$common;
1256 14 ▶ $self->{state}{stats}{ops_online}-- if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 3 11 14
1257 14 ▶ $self->{state}{stats}{invisible}-- if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 12 2 14
1258 14 ▶ delete $self->{state}{users}{$nick} if !$record->{nick_collision};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"nick_collision"} 12 2 14
1259 14 delete $self->{state}{localops}{$record->{route_id}};
1260 14 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 14 14
1261 14 return $ref;
1262 }
1263  
1264 sub _daemon_cmd_ping {
1265 0 ▶ my $self = shift;
Subroutine _daemon_cmd_ping: not called CC=8 SCAR=42.8
1266 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
1267 0 my $server = $self->server_name();
1268 0 my $args = [ @_ ];
1269 0 my $count = @$args;
1270 0 my $ref = [ ];
1271  
1272 SWITCH: {
1273 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1274 0 push @$ref, [ '409' ];
1275 0 last SWITCH;
1276 }
1277  
1278 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
1279 0 push @$ref, ['402', $args->[1]];
1280 0 last SWITCH;
1281 }
1282 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
1283 0 my $target = $self->_state_peer_name($args->[1]);
1284 0 $self->send_output(
1285 {
1286 command => 'PING',
1287 params => [$nick, $target],
1288 },
1289 $self->_state_peer_route($args->[1]),
1290 );
1291 0 last SWITCH;
1292 }
1293 0 push @$ref, {
1294 prefix => $server,
1295 command => 'PONG',
1296 params => [$server, $args->[0]],
1297 };
1298 }
1299 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1300 0 return $ref;
1301 }
1302  
1303 sub _daemon_cmd_pong {
1304 0 ▶ my $self = shift;
Subroutine _daemon_cmd_pong: not called CC=8 SCAR=42.8
1305 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
1306 0 my $server = uc $self->server_name();
1307 0 my $args = [ @_ ];
1308 0 my $count = @$args;
1309 0 my $ref = [ ];
1310  
1311 SWITCH: {
1312 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1313 0 push @$ref, ['409'];
1314 0 last SWITCH;
1315 }
1316 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
1317 0 push @$ref, ['402', $args->[1]];
1318 0 last SWITCH;
1319 }
1320 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
1321 0 my $target = $self->_state_peer_name($args->[1]);
1322 0 $self->send_output(
1323 {
1324 command => 'PONG',
1325 params => [$nick, $target],
1326 },
1327 $self->_state_peer_route($args->[1]),
1328 );
1329 0 last SWITCH;
1330 }
1331 0 delete $self->{state}{users}{uc_irc($nick)}{pinged};
1332 }
1333  
1334 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1335 0 return $ref;
1336 }
1337  
1338 sub _daemon_cmd_pass {
1339 0 ▶ my $self = shift;
Subroutine _daemon_cmd_pass: not called CC=3 SCAR=24.8
1340 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
1341 0 my $server = uc $self->server_name();
1342 0 my $ref = [['462']];
1343 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1344 0 return $ref;
1345 }
1346  
1347 sub _daemon_cmd_user {
1348 0 ▶ my $self = shift;
Subroutine _daemon_cmd_user: not called CC=3 SCAR=24.8
1349 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
1350 0 my $server = uc $self->server_name();
1351 0 my $ref = [['462']];
1352 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1353 0 return $ref;
1354 }
1355  
1356 sub _daemon_cmd_oper {
1357 3 ▶ my $self = shift;
Subroutine _daemon_cmd_oper: called CC=8 SCAR=21.6
1358 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
1359 3 my $server = $self->server_name();
1360 3 my $ref = [ ];
1361 3 my $args = [@_];
1362 3 my $count = @$args;
1363  
1364 SWITCH: {
1365 3 ▶ last SWITCH if $self->state_user_is_operator($nick);
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_user_is_operator($nick) 0 3 3
1366 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
1367 0 push @$ref, ['461', 'OPER'];
1368 0 last SWITCH;
1369 }
1370  
1371 3 my $result = $self->_state_o_line($nick, @$args);
1372 3 ▶ if (!$result || $result <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result or $result <= 0) 1 2 3
Condition66%2/3
not $result or $result <= 0
l!l&&r!l&&!r
102
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
1373 1 push @$ref, ['491'];
1374 1 last SWITCH;
1375 }
1376  
1377 2 $self->{stats}{ops}++;
1378 2 my $record = $self->{state}{users}{uc_irc($nick)};
1379 2 $record->{umode} .= 'o';
1380 2 $self->{state}{stats}{ops_online}++;
1381 2 push @$ref, {
1382 prefix => $server,
1383 command => '381',
1384 params => [$nick, 'You are now an IRC operator'],
1385 };
1386  
1387 2 my $reply = {
1388 prefix => $nick,
1389 command => 'MODE',
1390 params => [$nick, '+o'],
1391 };
1392  
1393 2 $self->send_output(
1394 $reply,
1395 $self->_state_connected_peers(),
1396 );
1397 2 $self->send_event(
1398 "daemon_umode",
1399 $self->state_user_full($nick),
1400 '+o',
1401 );
1402  
1403 2 my $route_id = $self->_state_user_route($nick);
1404 2 $self->{state}{localops}{$route_id} = time;
1405 2 $self->antiflood($route_id, 0);
1406 2 push @$ref, $reply;
1407 }
1408  
1409 3 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 0 3
1410 0 return $ref;
1411 }
1412  
1413 sub _daemon_cmd_die {
1414 1 ▶ my $self = shift;
Subroutine _daemon_cmd_die: called CC=4 SCAR=15.2
1415 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
1416 1 my $server = $self->server_name();
1417 1 my $ref = [ ];
1418  
1419 SWITCH: {
1420 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
1421 0 push @$ref, ['481'];
1422 0 last SWITCH;
1423 }
1424 1 $self->send_event("daemon_die", $nick);
1425 1 $self->shutdown();
1426 }
1427 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
1428 0 return $ref;
1429 }
1430  
1431 sub _daemon_cmd_rehash {
1432 1 ▶ my $self = shift;
Subroutine _daemon_cmd_rehash: called CC=4 SCAR=15.2
1433 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
1434 1 my $server = $self->server_name();
1435 1 my $ref = [ ];
1436  
1437 SWITCH: {
1438 1 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 1 1
1439 0 push @$ref, ['481'];
1440 0 last SWITCH;
1441 }
1442 1 $self->send_event("daemon_rehash", $nick);
1443 1 push @$ref, {
1444 prefix => $server,
1445 command => '383',
1446 params => [$nick, 'ircd.conf', 'Rehashing'],
1447 };
1448 }
1449 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
1450 0 return $ref;
1451 }
1452  
1453 sub _daemon_cmd_locops {
1454 0 ▶ my $self = shift;
Subroutine _daemon_cmd_locops: not called CC=5 SCAR=34.0
1455 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
1456 0 my $server = $self->server_name();
1457 0 my $ref = [ ];
1458 0 my $args = [@_];
1459 0 my $count = @$args;
1460  
1461 SWITCH: {
1462 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1463 0 push @$ref, ['481'];
1464 0 last SWITCH;
1465 }
1466 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1467 0 push @$ref, ['461', 'LOCOPS'];
1468 0 last SWITCH;
1469 }
1470 0 my $full = $self->state_user_full($nick);
1471 $self->send_output(
1472 {
1473 prefix => $full,
1474 command => 'WALLOPS',
1475 params => ['LOCOPS - ' . $args->[0]],
1476 },
1477 0 keys %{ $self->{state}{locops} },
1478 );
1479 0 $self->send_event("daemon_locops", $full, $args->[0]);
1480 }
1481  
1482 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1483 0 return $ref;
1484 }
1485  
1486 sub _daemon_cmd_wallops {
1487 0 ▶ my $self = shift;
Subroutine _daemon_cmd_wallops: not called CC=5 SCAR=34.0
1488 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
1489 0 my $server = $self->server_name();
1490 0 my $ref = [ ];
1491 0 my $args = [@_];
1492 0 my $count = @$args;
1493  
1494 SWITCH: {
1495 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1496 0 push @$ref, ['481'];
1497 0 last SWITCH;
1498 }
1499 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1500 0 push @$ref, ['461', 'WALLOPS'];
1501 0 last SWITCH;
1502 }
1503 0 my $full = $self->state_user_full($nick);
1504  
1505 0 $self->send_output(
1506 {
1507 prefix => $nick,
1508 command => 'WALLOPS',
1509 params => [$args->[0]],
1510 },
1511 $self->_state_connected_peers(),
1512 );
1513  
1514 $self->send_output(
1515 {
1516 prefix => $full,
1517 command => 'WALLOPS',
1518 params => ['OPERWALL - ' . $args->[0]],
1519 },
1520 0 keys %{ $self->{state}{operwall} },
1521 );
1522  
1523 0 $self->send_event("daemon_operwall", $full, $args->[0]);
1524 }
1525  
1526 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1527 0 return $ref;
1528 }
1529  
1530 sub _daemon_cmd_operwall {
1531 0 ▶ my $self = shift;
Subroutine _daemon_cmd_operwall: not called CC=5 SCAR=34.0
1532 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
1533 0 my $server = $self->server_name();
1534 0 my $ref = [ ];
1535 0 my $args = [@_];
1536 0 my $count = @$args;
1537  
1538 SWITCH: {
1539 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1540 0 push @$ref, ['481'];
1541 0 last SWITCH;
1542 }
1543 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1544 0 push @$ref, ['461', 'OPERWALL'];
1545 0 last SWITCH;
1546 }
1547 0 my $full = $self->state_user_full($nick);
1548  
1549 0 $self->send_output(
1550 {
1551 prefix => $nick,
1552 command => 'WALLOPS',
1553 params => [$args->[0]],
1554 },
1555 $self->_state_connected_peers(),
1556 );
1557  
1558 $self->send_output(
1559 {
1560 prefix => $full,
1561 command => 'WALLOPS',
1562 params => ['OPERWALL - ' . $args->[0]],
1563 },
1564 0 keys %{ $self->{state}{operwall} },
1565 );
1566  
1567 0 $self->send_event("daemon_operwall", $full, $args->[0]);
1568 }
1569  
1570 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1571 0 return $ref;
1572 }
1573  
1574 sub _daemon_cmd_connect {
1575 0 ▶ my $self = shift;
Subroutine _daemon_cmd_connect: not called CC=13 SCAR=52.0
1576 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
1577 0 my $server = $self->server_name();
1578 0 my $ref = [ ];
1579 0 my $args = [@_];
1580 0 my $count = @$args;
1581  
1582 SWITCH: {
1583 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1584 0 push @$ref, ['481'];
1585 0 last SWITCH;
1586 }
1587 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1588 0 push @$ref, ['461', 'CONNECT'];
1589 0 last SWITCH;
1590 }
1591 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
1592 0 push @$ref, ['402', $args->[2]];
1593 0 last SWITCH;
1594 }
1595 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
1596 0 $args->[2] = $self->_state_peer_name($args->[2]);
1597 0 $self->send_output(
1598 {
1599 prefix => $nick,
1600 command => 'CONNECT',
1601 params => $args,
1602 },
1603 $self->_state_peer_route($args->[2]),
1604 );
1605 0 last SWITCH;
1606 }
1607 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
1608 || $self->{config}{peers}{uc $args->[0]}{type} ne 'r') {
1609 0 push @$ref, {
1610 command => 'NOTICE',
1611 params => [
1612 $nick,
1613 "Connect: Host $args->[0] is not listed in ircd.conf",
1614 ],
1615 };
1616 0 last SWITCH;
1617 }
1618 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
1619 0 push @$ref, {
1620 command => 'NOTICE',
1621 params => [
1622 $nick,
1623 "Connect: Server $args->[0] already exists from $peer_name.",
1624 ],
1625 };
1626 0 last SWITCH;
1627 }
1628  
1629 0 my $connector = $self->{config}{peers}{uc $args->[0]};
1630 0 my $name = $connector->{name};
1631 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
1632 0 my $raddr = $connector->{raddress};
1633 0 $self->add_connector(
1634 remoteaddress => $raddr,
1635 remoteport => $rport,
1636 name => $name,
1637 );
1638 }
1639  
1640 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1641 0 return $ref;
1642 }
1643  
1644 sub _daemon_cmd_squit {
1645 0 ▶ my $self = shift;
Subroutine _daemon_cmd_squit: not called CC=9 SCAR=45.0
1646 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
1647 0 my $server = $self->server_name();
1648 0 my $ref = [ ];
1649 0 my $args = [@_];
1650 0 my $count = @$args;
1651  
1652 SWITCH: {
1653 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1654 0 push @$ref, ['481'];
1655 0 last SWITCH;
1656 }
1657 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
1658 0 push @$ref, ['461', 'SQUIT'];
1659 0 last SWITCH;
1660 }
1661 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
1662 || uc $server eq uc $args->[0]) {
1663 0 push @$ref, ['402', $args->[0]];
1664 0 last SWITCH;
1665 }
1666  
1667 0 my $peer = uc $args->[0];
1668 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
1669 0 $args->[0] = $self->_state_peer_name($peer);
1670 0 $args->[1] = $reason;
1671  
1672 0 ▶ if ( !grep { $_ eq $peer }
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $peer;} keys %{$self->{"state"}{"peers"}{uc $server}{"peers"};}) 0 0 0
1673 0 keys %{ $self->{state}{peers}{uc $server}{peers} }) {
1674 0 $self->send_output(
1675 {
1676 prefix => $nick,
1677 command => 'SQUIT',
1678 params => $args,
1679 },
1680 $self->_state_peer_route($args->[0]),
1681 );
1682 0 last SWITCH;
1683 }
1684  
1685 0 my $conn_id = $self->_state_peer_route($peer);
1686 0 $self->disconnect($conn_id, $reason);
1687 0 $self->send_output(
1688 {
1689 command => 'ERROR',
1690 params => [
1691 join ' ', 'Closing Link:',
1692 $self->_client_ip($conn_id), $args->[0], "($nick)"
1693 ],
1694 },
1695 $conn_id,
1696 );
1697 }
1698  
1699 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1700 0 return $ref;
1701 }
1702  
1703 sub _daemon_cmd_rkline {
1704 0 ▶ my $self = shift;
Subroutine _daemon_cmd_rkline: not called CC=25 SCAR=64.8
1705 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
1706 0 my $server = $self->server_name();
1707 0 my $ref = [ ];
1708 0 my $args = [@_];
1709 0 my $count = @$args;
1710 # RKLINE [time] <mask> [ON <server>] :[reason]
1711  
1712 SWITCH: {
1713 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1714 0 push @$ref, ['481'];
1715 0 last SWITCH;
1716 }
1717 0 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 0 0
Condition0%0/3
not $count or $count < 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table0%0/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
1718 0 push @$ref, ['461', 'RKLINE'];
1719 0 last SWITCH;
1720 }
1721 0 my $duration = 0;
1722 0 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 0 0 0
1723 0 $duration = shift @$args;
1724 0 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 0 0
1725 }
1726 0 my $mask = shift @$args;
1727 0 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 0 0
1728 0 push @$ref, ['461', 'RKLINE'];
1729 0 last SWITCH;
1730 }
1731 0 my ($user, $host) = split /\@/, $mask;
1732 0 ▶ if (!$user || !$host) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($user and $host) 0 0 0
Condition0%0/3
$user and $host
!ll&&!rl&&r
000
MC/DC0%0/2
$user and $host
$user $host
Truth table0%0/3
A and B
A= $userB= $host
ABresult
0X0
100
111
1733 0 last SWITCH;
1734 }
1735 0 my $full = $self->state_user_full($nick);
1736 0 my $us = 0;
1737 0 my $ucserver = uc $server;
1738  
1739 0 ▶ if ($args->[0] && uc $args->[0] eq 'ON' && @$args < 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq "ON" and @$args < 2) 0 0 0
Condition0%0/6
$args->[0] and uc $args->[0] eq "ON" and @$args < 2
!ll&&!rl&&r
000
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
000
MC/DC0%0/3
$args->[0] and uc $args->[0] eq "ON" and @$args < 2
$args->[0] uc $args->[0] eq "ON" @$args < 2
Truth table0%0/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= @$args < 2
ABCresult
0XX0
10X0
1100
1111
1740 0 push @$ref, ['461', 'RKLINE'];
1741 0 last SWITCH;
1742 }
1743 0 my ($target, $reason);
1744 0 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 0 0 0
Condition0%0/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
000
MC/DC0%0/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table0%0/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
1745 0 $target = shift @$args;
1746 0 ▶ $reason = shift @{ $args } || 'No Reason';
Condition0%0/2
shift @{$args;} || 'No Reason'
l!l
00
MC/DC0%0/1
shift @{$args;} || 'No Reason'
shift @{$args;}
Truth table0%0/2
A
A= shift @{$args;}
Aresult
11
00
1747 0 my %targets;
1748  
1749 0 for my $peer (keys %{ $self->{state}{peers} }) {
1750 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
1751 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
1752 0 $us = 1;
1753 }
1754 else {
1755 0 $targets{ $self->_state_peer_route($peer) }++;
1756 }
1757 }
1758 }
1759  
1760 $self->send_output(
1761 {
1762 prefix => $nick,
1763 command => 'RKLINE',
1764 params => [$target, $duration, $user, $host, $reason],
1765 colonify => 0,
1766 },
1767 0 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
1768 );
1769 }
1770 else {
1771 0 $us = 1;
1772 }
1773  
1774 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
1775 0 ▶ $target = $server if !$target;
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 0 0
1776 0 ▶ if (!$reason) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 0 0 0
1777 0 ▶ $reason = pop @$args || 'No Reason';
Condition0%0/2
pop @$args || 'No Reason'
l!l
00
MC/DC0%0/1
pop @$args || 'No Reason'
pop @$args
Truth table0%0/2
A
A= pop @$args
Aresult
11
00
1778 }
1779 $self->send_event(
1780 0 "daemon_rkline",
1781 $full,
1782 $target,
1783 $duration,
1784 $user,
1785 $host,
1786 $reason,
1787 );
1788  
1789 0 push @{ $self->{state}{rklines} }, {
1790 setby => $full,
1791 setat => time(),
1792 target => $target,
1793 duration => $duration,
1794 user => $user,
1795 host => $host,
1796 reason => $reason,
1797 };
1798  
1799 0 for ($self->_state_local_users_match_rkline($user, $host)) {
1800 0 $self->_terminate_conn_error($_, 'K-Lined');
1801 }
1802 }
1803 }
1804  
1805 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1806 0 return $ref;
1807 }
1808  
1809 sub _daemon_cmd_kline {
1810 0 ▶ my $self = shift;
Subroutine _daemon_cmd_kline: not called CC=25 SCAR=64.8
1811 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
1812 0 my $server = $self->server_name();
1813 0 my $ref = [ ];
1814 0 my $args = [@_];
1815 0 my $count = @$args;
1816 # KLINE [time] <nick|user@host> [ ON <server> ] :[reason]
1817  
1818 SWITCH: {
1819 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1820 0 push @$ref, ['481'];
1821 0 last SWITCH;
1822 }
1823 0 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 0 0
Condition0%0/3
not $count or $count < 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table0%0/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
1824 0 push @$ref, ['461', 'KLINE'];
1825 0 last SWITCH;
1826 }
1827 0 my $duration = 0;
1828 0 ▶ if ($args->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /^\d+$/) 0 0 0
1829 0 $duration = shift @$args;
1830 0 ▶ $duration = 14400 if $duration > 14400;
Branch: 1 branch
BranchTrueFalseTotal
if $duration > 14400 0 0 0
1831 }
1832 0 my $mask = shift @$args;
1833 0 ▶ if (!$mask) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mask) 0 0 0
1834 0 push @$ref, ['461', 'KLINE'];
1835 0 last SWITCH;
1836 }
1837 0 my ($user, $host);
1838 0 ▶ if ($mask !~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $mask =~ /\@/) { } 0 0 0
1839 0 ▶ if (my $rogue = $self->_state_user_full($mask)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $rogue = $self->_state_user_full($mask)) { } 0 0 0
1840 0 ($user, $host) = (split /[!\@]/, $rogue )[1..2];
1841 }
1842 else {
1843 0 push @$ref, ['401', $mask];
1844 0 last SWITCH;
1845 }
1846 }
1847 else {
1848 0 ($user, $host) = split /\@/, $mask;
1849 }
1850  
1851 0 my $full = $self->state_user_full($nick);
1852 0 my $us = 0;
1853 0 my $ucserver = uc $server;
1854 0 ▶ 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 0 0
Condition0%0/6
$args->[0] and uc $args->[0] eq "ON" and scalar @$args < 2
!ll&&!rl&&r
000
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
000
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 table0%0/4
A and B and C
A= $args->[0]B= uc $args->[0] eq "ON"C= scalar @$args < 2
ABCresult
0XX0
10X0
1100
1111
1855 && scalar @$args < 2) {
1856 0 push @$ref, ['461', 'KLINE'];
1857 0 last SWITCH;
1858 }
1859 0 my ($target, $reason);
1860 0 ▶ if ($args->[0] && uc $args->[0] eq 'ON') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] and uc $args->[0] eq 'ON') { } 0 0 0
Condition0%0/3
$args->[0] and uc $args->[0] eq "ON"
!ll&&!rl&&r
000
MC/DC0%0/2
$args->[0] and uc $args->[0] eq "ON"
$args->[0] uc $args->[0] eq "ON"
Truth table0%0/3
A and B
A= $args->[0]B= uc $args->[0] eq "ON"
ABresult
0X0
100
111
1861 0 $target = shift @$args;
1862 0 ▶ $reason = shift @$args || 'No Reason';
Condition0%0/2
shift @$args || 'No Reason'
l!l
00
MC/DC0%0/1
shift @$args || 'No Reason'
shift @$args
Truth table0%0/2
A
A= shift @$args
Aresult
11
00
1863 0 my %targets;
1864  
1865 0 for my $peer (keys %{ $self->{state}{peers} }) {
1866 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
1867 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
1868 0 $us = 1;
1869 }
1870 else {
1871 0 $targets{ $self->_state_peer_route($peer) }++;
1872 }
1873 }
1874 }
1875  
1876 $self->send_output(
1877 {
1878 prefix => $nick,
1879 command => 'KLINE',
1880 params => [
1881 $target,
1882 $duration,
1883 $user,
1884 $host,
1885 $reason,
1886 ],
1887 colonify => 0,
1888 },
1889 0 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
1890 );
1891 }
1892 else {
1893 0 $us = 1;
1894 }
1895  
1896 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
1897 0 ▶ $target = $server if !$target;
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 0 0
1898 0 ▶ if (!$reason) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reason) 0 0 0
1899 0 ▶ $reason = pop @$args || 'No Reason';
Condition0%0/2
pop @$args || 'No Reason'
l!l
00
MC/DC0%0/1
pop @$args || 'No Reason'
pop @$args
Truth table0%0/2
A
A= pop @$args
Aresult
11
00
1900 }
1901 $self->send_event(
1902 0 "daemon_kline",
1903 $full,
1904 $target,
1905 $duration,
1906 $user,
1907 $host,
1908 $reason,
1909 );
1910  
1911 0 push @{ $self->{state}{klines} }, {
1912 setby => $full,
1913 setat => time,
1914 target => $target,
1915 duration => $duration,
1916 user => $user,
1917 host => $host,
1918 reason => $reason,
1919 };
1920  
1921 0 for ($self->_state_local_users_match_gline($user, $host)) {
1922 0 $self->_terminate_conn_error($_, 'K-Lined');
1923 }
1924 }
1925 }
1926  
1927 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
1928 0 return $ref;
1929 }
1930  
1931 sub _daemon_cmd_unkline {
1932 0 ▶ my $self = shift;
Subroutine _daemon_cmd_unkline: not called CC=22 SCAR=62.3
1933 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
1934 0 my $server = $self->server_name();
1935 0 my $ref = [ ];
1936 0 my $args = [@_];
1937 0 my $count = @$args;
1938 # UNKLINE <user@host> [ ON <target_mask> ]
1939  
1940 SWITCH: {
1941 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
1942 0 push @$ref, ['481'];
1943 0 last SWITCH;
1944 }
1945 0 ▶ if (!$count || $count < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 1) 0 0 0
Condition0%0/3
not $count or $count < 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 1
not $count $count < 1
Truth table0%0/3
not(A) or B
A= not $countB= $count < 1
ABresult
1X1
011
000
1946 0 push @$ref, ['461', 'UNKLINE'];
1947 0 last SWITCH;
1948 }
1949 0 my ($user, $host);
1950 0 ▶ if ($args->[0] !~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $args->[0] =~ /\@/) { } 0 0 0
1951 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
1952 0 ($user, $host) = (split /[!\@]/, $rogue)[1..2]
1953 }
1954 else {
1955 0 push @$ref, ['401', $args->[0]];
1956 0 last SWITCH;
1957 }
1958 }
1959 else {
1960 0 ($user, $host) = split /\@/, $args->[0];
1961 }
1962  
1963 0 my $full = $self->state_user_full($nick);
1964 0 my $us = 0;
1965 0 my $ucserver = uc $server;
1966 0 ▶ 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 0 0
Condition0%0/6
$count > 1 and uc $args->[2] eq "ON" and $count < 3
!ll&&!rl&&r
000
$count > 1 and uc $args->[2] eq "ON"
!ll&&!rl&&r
000
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 table0%0/4
A and B and C
A= $count > 1B= uc $args->[2] eq "ON"C= $count < 3
ABCresult
0XX0
10X0
1100
1111
1967 0 push @$ref, ['461', 'UNKLINE'];
1968 0 last SWITCH;
1969 }
1970 0 ▶ 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 0 0
Condition0%0/6
$count > 1 and $args->[2] and uc $args->[2] eq "ON"
!ll&&!rl&&r
000
$count > 1 and $args->[2]
!ll&&!rl&&r
000
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 table0%0/4
A and B and C
A= $count > 1B= $args->[2]C= uc $args->[2] eq "ON"
ABCresult
0XX0
10X0
1100
1111
1971 0 my $target = $args->[2];
1972 0 my %targets;
1973 0 for my $peer (keys %{ $self->{state}{peers} }) {
1974 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
1975 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
1976 0 $us = 1;
1977 }
1978 else {
1979 0 $targets{ $self->_state_peer_route( $peer ) }++;
1980 }
1981 }
1982 }
1983  
1984 $self->send_output(
1985 {
1986 prefix => $nick,
1987 command => 'UNKLINE',
1988 params => [$target, $user, $host],
1989 colonify => 0,
1990 },
1991 0 grep { $self->_state_peer_capab($_, 'UNKLN') } keys %targets,
1992 );
1993 }
1994 else {
1995 0 $us = 1;
1996 }
1997 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
1998 0 ▶ my $target = $args->[3] || $server;
Condition0%0/3
$args->[3] || $server
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[3] || $server
$args->[3] $server
Truth table0%0/3
A || B
A= $args->[3]B= $server
ABresult
1X1
011
000
1999 0 $self->send_event(
2000 "daemon_unkline", $full, $target, $user, $host,
2001 );
2002 0 my $i = 0;
2003 0 for (@{ $self->{state}{klines} }) {
2004 0 ▶ if ($_->{user} eq $user && $_->{host} eq $host) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"user"} eq $user and $_->{"host"} eq $host) 0 0 0
Condition0%0/3
$_->{"user"} eq $user and $_->{"host"} eq $host
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{"user"} eq $user and $_->{"host"} eq $host
$_->{"user"} eq $user $_->{"host"} eq $host
Truth table0%0/3
A and B
A= $_->{"user"} eq $userB= $_->{"host"} eq $host
ABresult
0X0
100
111
2005 0 splice @{ $self->{state}{klines} }, $i, 1;
2006 0 last;
2007 }
2008 0 ++$i;
2009 }
2010 }
2011 }
2012  
2013 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2014 0 return $ref;
2015 }
2016  
2017 sub _daemon_cmd_gline {
2018 0 ▶ my $self = shift;
Subroutine _daemon_cmd_gline: not called CC=10 SCAR=47.0
2019 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
2020 0 my $server = $self->server_name();
2021 0 my $ref = [ ];
2022 0 my $args = [ @_ ];
2023 0 my $count = @$args;
2024 # :klanker GLINE * meep.com :Fuckers
2025  
2026 SWITCH: {
2027 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2028 0 push @$ref, ['481'];
2029 0 last SWITCH;
2030 }
2031 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
2032 0 push @$ref, ['461', 'GLINE'];
2033 0 last SWITCH;
2034 }
2035 0 ▶ if ($args->[0] !~ /\@/ && !$self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->[0] =~ /\@/ or $self->state_nick_exists($args->[0])) 0 0 0
Condition0%0/3
$args->[0] =~ /\@/ or $self->state_nick_exists($args->[0])
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[0] =~ /\@/ or $self->state_nick_exists($args->[0])
$args->[0] =~ /\@/ $self->state_nick_exists($args->[0])
Truth table0%0/3
A or B
A= $args->[0] =~ /\@/B= $self->state_nick_exists($args->[0])
ABresult
1X1
011
000
2036 0 push @$ref, ['401', $args->[0]];
2037 0 last SWITCH;
2038 }
2039 0 my ($user_part, $host_part);
2040 0 ▶ if ($args->[0] =~ /\@/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[0] =~ /\@/) { } 0 0 0
2041 0 ($user_part, $host_part)
2042 = (split /[!@]/, $self->state_user_full($args->[0]))[1..2];
2043 }
2044 else {
2045 0 ($user_part, $host_part) = split /\@/, $args->[0];
2046 }
2047 0 my $time = time;
2048 0 my $reason = join ' ', $args->[1], strftime('(%c)', localtime $time);
2049 0 my $full = $self->state_user_full($nick);
2050  
2051 0 push @{ $self->{state}{glines} }, {
2052 setby => $full,
2053 setat => time,
2054 user => $user_part,
2055 host => $host_part,
2056 reason => $reason,
2057 };
2058  
2059 $self->send_output(
2060 {
2061 prefix => $nick,
2062 command => 'GLINE',
2063 params => [$user_part, $host_part, $reason],
2064 colonify => 0,
2065 },
2066 0 grep { $self->_state_peer_capab($_, 'GLN') }
2067 $self->_state_connected_peers()
2068 );
2069  
2070 0 $self->send_event(
2071 "daemon_gline",
2072 $full,
2073 $user_part,
2074 $host_part,
2075 $reason,
2076 );
2077  
2078 0 for ($self->_state_local_users_match_gline($user_part, $host_part)) {
2079 0 $self->_terminate_conn_error($_, 'G-Lined');
2080 }
2081 }
2082  
2083 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2084 0 return $ref;
2085 }
2086  
2087 sub _daemon_cmd_kill {
2088 0 ▶ my $self = shift;
Subroutine _daemon_cmd_kill: not called CC=10 SCAR=47.0
2089 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
2090 0 my $server = $self->server_name();
2091 0 my $ref = [ ];
2092 0 my $args = [@_];
2093 0 my $count = @$args;
2094  
2095 SWITCH: {
2096 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
2097 0 push @$ref, ['481'];
2098 0 last SWITCH;
2099 }
2100 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2101 0 push @$ref, ['461', 'KILL'];
2102 0 last SWITCH;
2103 }
2104 0 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 0 0 0
2105 0 push @$ref, ['483'];
2106 0 last SWITCH;
2107 }
2108 0 ▶ if (!$self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($args->[0])) 0 0 0
2109 0 push @$ref, ['401', $args->[0]];
2110 0 last SWITCH;
2111 }
2112 0 my $target = $self->state_user_nick($args->[0]);
2113 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
2114 0 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 0 0 0
2115 0 my $route_id = $self->_state_user_route($target);
2116 0 $self->send_output(
2117 {
2118 prefix => $nick,
2119 command => 'KILL',
2120 params => [
2121 $target,
2122 join('!', $server, $nick )." ($comment)",
2123 ]
2124 },
2125 $self->_state_connected_peers(),
2126 );
2127  
2128 0 $self->send_output(
2129 {
2130 prefix => $self->state_user_full($nick),
2131 command => 'KILL',
2132 params => [$target, $comment],
2133 },
2134 $route_id,
2135 );
2136 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
2137 0 $self->call('del_spoofed_nick', $target, "Killed ($comment)");
2138 }
2139 else {
2140 0 $self->{state}{conns}{$route_id}{killed} = 1;
2141 0 $self->_terminate_conn_error($route_id, "Killed ($comment)");
2142 }
2143 }
2144 else {
2145 0 $self->{state}{users}{uc_irc($target)}{killed} = 1;
2146 0 $self->send_output(
2147 {
2148 prefix => $nick,
2149 command => 'KILL',
2150 params => [
2151 $target,
2152 join('!', $server, $nick )." ($comment)",
2153 ],
2154 },
2155 $self->_state_connected_peers(),
2156 );
2157 $self->send_output(
2158 0 @{ $self->_daemon_peer_quit(
2159 $target,
2160 "Killed ($nick ($comment))"
2161 )}
2162 );
2163 }
2164 }
2165  
2166 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2167 0 return $ref;
2168 }
2169  
2170 sub _daemon_cmd_nick {
2171 5 ▶ my $self = shift;
Subroutine _daemon_cmd_nick: called CC=15 SCAR=30.5
2172 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
2173 5 my $new = shift;
2174 5 my $server = uc $self->server_name();
2175 5 my $ref = [ ];
2176  
2177 SWITCH: {
2178 5 ▶ if (!$new) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($new) 0 5 5
2179 0 push @$ref, ['431'];
2180 0 last SWITCH;
2181 }
2182 5 my $nicklen = $self->server_config('NICKLEN');
2183 5 ▶ $new = substr($new, 0, $nicklen) if length($new) > $nicklen;
Branch: 1 branch
BranchTrueFalseTotal
if length $new > $nicklen 0 5 5
2184 5 ▶ if ($nick eq $new) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nick eq $new) 0 5 5
2185 0 last SWITCH;
2186 }
2187 5 ▶ if (!is_valid_nick_name($new)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_nick_name($new)) 0 5 5
2188 0 push @$ref, ['432', $new];
2189 0 last SWITCH;
2190 }
2191 5 my $unick = uc_irc($nick);
2192 5 my $unew = uc_irc($new);
2193 5 ▶ if ($self->state_nick_exists($new) && $unick ne $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($new) and $unick ne $unew) 0 5 5
Condition33%1/3
$self->state_nick_exists($new) and $unick ne $unew
!ll&&!rl&&r
500
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
2194 0 push @$ref, ['433', $new];
2195 0 last SWITCH;
2196 }
2197 5 my $full = $self->state_user_full($nick);
2198 5 my $record = $self->{state}{users}{$unick};
2199 5 my $common = { $nick => $record->{route_id} };
2200  
2201 5 for my $chan (keys %{ $record->{chans} }) {
2202 1 for my $user ($self->state_chan_list($chan)) {
2203 1 ▶ next if !$self->_state_is_local_user($user);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_is_local_user($user) 0 1 1
2204 1 $common->{$user} = $self->_state_user_route($user);
2205 }
2206 }
2207 5 ▶ if ($unick eq $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unick eq $unew) { } 0 5 5
2208 0 $record->{nick} = $new;
2209 0 $record->{ts} = time;
2210 }
2211 else {
2212 5 $record->{nick} = $new;
2213 5 $record->{ts} = time;
2214 # Remove from peoples accept lists
2215 5 for (keys %{ $record->{accepts} }) {
2216 0 delete $self->{state}{users}{$_}{accepts}{$unick};
2217 }
2218 5 delete $record->{accepts};
2219 5 delete $self->{state}{users}{$unick};
2220 5 $self->{state}{users}{$unew} = $record;
2221 5 delete $self->{state}{peers}{$server}{users}{$unick};
2222 5 $self->{state}{peers}{$server}{users}{$unew} = $record;
2223  
2224 5 for my $chan (keys %{ $record->{chans} }) {
2225 $self->{state}{chans}{$chan}{users}{$unew}
2226 1 = delete $self->{state}{chans}{$chan}{users}{$unick};
2227 }
2228 }
2229 5 my @peers = $self->_state_connected_peers();
2230 $self->send_output(
2231 {
2232 prefix => $nick,
2233 command => 'NICK',
2234 5 params => [$new, $record->{ts}],
2235 },
2236 @peers,
2237 );
2238  
2239 $self->send_output(
2240 {
2241 prefix => $full,
2242 command => 'NICK',
2243 params => [$new],
2244 },
2245 5 map{ $common->{$_} } keys %$common,
2246 );
2247 5 $self->send_event("daemon_nick", $full, $new);
2248 }
2249  
2250 5 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 5 0 5
2251 0 return $ref;
2252 }
2253  
2254 sub _daemon_cmd_away {
2255 0 ▶ my $self = shift;
Subroutine _daemon_cmd_away: not called CC=4 SCAR=30.0
2256 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
2257 0 my $msg = shift;
2258 0 my $server = $self->server_name();
2259 0 my $ref = [ ];
2260  
2261 SWITCH: {
2262 0 my $record = $self->{state}{users}{uc_irc($nick)};
2263 0 ▶ if (!$msg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 0 0 0
2264 0 delete $record->{away};
2265 0 $self->send_output(
2266 {
2267 prefix => $nick,
2268 command => 'AWAY',
2269 colonify => 0,
2270 },
2271 $self->_state_connected_peers(),
2272 );
2273 0 push @$ref, {
2274 prefix => $server,
2275 command => '305',
2276 params => ['You are no longer marked as being away'],
2277 };
2278 0 last SWITCH;
2279 }
2280  
2281 0 $record->{away} = $msg;
2282 0 $self->send_output(
2283 {
2284 prefix => $nick,
2285 command => 'AWAY',
2286 params => [$msg],
2287 colonify => 0,
2288 },
2289 $self->_state_connected_peers(),
2290 );
2291 0 push @$ref, {
2292 prefix => $server,
2293 command => '306',
2294 params => ['You have been marked as being away'],
2295 };
2296 }
2297  
2298 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2299 0 return $ref;
2300 }
2301  
2302 # Pseudo cmd for ISupport 005 numerics
2303 sub _daemon_cmd_isupport {
2304 16 ▶ my $self = shift;
Subroutine _daemon_cmd_isupport: called CC=5 SCAR=16.3
2305 16 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2306 16 my $server = $self->server_name();
2307 16 my $ref = [ ];
2308  
2309 push @$ref, {
2310 prefix => $server,
2311 command => '005',
2312 params => [
2313 $nick,
2314 join(' ', map {
2315 16 (defined $self->{config}{isupport}{$_}
2316 144 ▶ ? join '=', $_, $self->{config}{isupport}{$_}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'config'}{'isupport'}{$_} ? : 80 64 144
2317 : $_
2318 )
2319 } qw(CALLERID EXCEPTS INVEX MAXCHANNELS MAXBANS MAXTARGETS
2320 NICKLEN TOPICLEN KICKLEN)
2321 ),
2322 'are supported by this server',
2323 ],
2324 };
2325  
2326 push @$ref, {
2327 prefix => $server,
2328 command => '005',
2329 params => [
2330 $nick,
2331 join(' ', map {
2332 16 (defined $self->{config}{isupport}{$_}
2333 96 ▶ ? join '=', $_, $self->{config}{isupport}{$_}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'config'}{'isupport'}{$_} ? : 96 0 96
2334 : $_
2335 )
2336 } qw(CHANTYPES PREFIX CHANMODES NETWORK CASEMAPPING DEAF)
2337 ), 'are supported by this server',
2338 ],
2339 };
2340  
2341 16 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 16 16
2342 16 return $ref;
2343 }
2344  
2345 sub _daemon_cmd_info {
2346 0 ▶ my $self = shift;
Subroutine _daemon_cmd_info: not called CC=8 SCAR=42.8
2347 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
2348 0 my $target = shift;
2349 0 my $server = $self->server_name();
2350 0 my $ref = [ ];
2351  
2352 SWITCH: {
2353 0 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 0 0
Condition0%0/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
000
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table0%0/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
2354 0 push @$ref, ['402', $target];
2355 0 last SWITCH;
2356 }
2357 0 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 0 0
Condition0%0/3
$target and uc $server ne uc $target
!ll&&!rl&&r
000
MC/DC0%0/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table0%0/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
2358 0 $self->send_output(
2359 {
2360 prefix => $nick,
2361 command => 'INFO',
2362 params => [$self->_state_peer_name($target)],
2363 },
2364 $self->_state_peer_route($target),
2365 );
2366 0 last SWITCH;
2367 }
2368  
2369 0 for my $info (@{ $self->server_config('Info') }) {
2370 0 push @$ref, {
2371 prefix => $server,
2372 command => '371',
2373 params => [$nick, $info],
2374 };
2375 }
2376  
2377 0 push @$ref, {
2378 prefix => $server,
2379 command => '374',
2380 params => [$nick, 'End of /INFO list.'],
2381 };
2382 }
2383  
2384 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2385 0 return $ref;
2386 }
2387  
2388 sub _daemon_cmd_version {
2389 0 ▶ my $self = shift;
Subroutine _daemon_cmd_version: not called CC=8 SCAR=42.8
2390 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
2391 0 my $server = $self->server_name();
2392 0 my $ref = [ ];
2393 0 my $target = shift;
2394  
2395 SWITCH: {
2396 0 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 0 0
Condition0%0/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
000
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table0%0/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
2397 0 push @$ref, ['402', $target];
2398 0 last SWITCH;
2399 }
2400 0 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 0 0
Condition0%0/3
$target and uc $server ne uc $target
!ll&&!rl&&r
000
MC/DC0%0/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table0%0/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
2401 0 $self->send_output(
2402 {
2403 prefix => $nick,
2404 command => 'VERSION',
2405 params => [$self->_state_peer_name($target)],
2406 },
2407 $self->_state_peer_route($target)
2408 );
2409 0 last SWITCH;
2410 }
2411  
2412 0 push @$ref, {
2413 prefix => $server,
2414 command => '351',
2415 params => [
2416 $nick,
2417 $self->server_version(),
2418 $server,
2419 'eGHIMZ TS5ow',
2420 ],
2421 };
2422 0 push @$ref, $_ for @{ $self->_daemon_cmd_isupport($nick) };
2423 }
2424  
2425 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2426 0 return $ref;
2427 }
2428  
2429 sub _daemon_cmd_admin {
2430 0 ▶ my $self = shift;
Subroutine _daemon_cmd_admin: not called CC=7 SCAR=40.3
2431 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
2432 0 my $target = shift;
2433 0 my $server = $self->server_name();
2434 0 my $ref = [ ];
2435 0 my $admin = $self->server_config('Admin');
2436  
2437 SWITCH: {
2438 0 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 0 0
Condition0%0/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
000
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table0%0/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
2439 0 push @$ref, ['402', $target];
2440 0 last SWITCH;
2441 }
2442 0 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 0 0
Condition0%0/3
$target and uc $server ne uc $target
!ll&&!rl&&r
000
MC/DC0%0/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table0%0/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
2443 0 $self->send_output(
2444 {
2445 prefix => $nick,
2446 command => 'ADMIN',
2447 params => [$self->_state_peer_name($target)],
2448 },
2449 $self->_state_peer_route($target),
2450 );
2451 0 last SWITCH;
2452 }
2453  
2454 0 push @$ref, {
2455 prefix => $server,
2456 command => '256',
2457 params => [$nick, $server, 'Administrative Info'],
2458 };
2459  
2460 0 push @$ref, {
2461 prefix => $server,
2462 command => '257',
2463 params => [$nick, $admin->[0]],
2464 };
2465  
2466 0 push @$ref, {
2467 prefix => $server,
2468 command => '258',
2469 params => [$nick, $admin->[1]],
2470 };
2471  
2472 0 push @$ref, {
2473 prefix => $server,
2474 command => '259',
2475 params => [$nick, $admin->[2]],
2476 };
2477 }
2478  
2479 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2480 0 return $ref;
2481 }
2482  
2483 sub _daemon_cmd_summon {
2484 0 ▶ my $self = shift;
Subroutine _daemon_cmd_summon: not called CC=3 SCAR=24.8
2485 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
2486 0 my $server = $self->server_name();
2487 0 my $ref = [ ];
2488 0 push @$ref, '445';
2489 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2490 0 return $ref;
2491 }
2492  
2493 sub _daemon_cmd_time {
2494 1 ▶ my $self = shift;
Subroutine _daemon_cmd_time: called CC=7 SCAR=24.3
2495 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
2496 1 my $server = $self->server_name();
2497 1 my $target = shift;
2498 1 my $ref = [ ];
2499  
2500 SWITCH: {
2501 1 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 1 1
Condition33%1/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
100
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
2502 0 push @$ref, ['402', $target];
2503 0 last SWITCH;
2504 }
2505 1 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 1 1
Condition33%1/3
$target and uc $server ne uc $target
!ll&&!rl&&r
100
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
2506 0 $self->send_output(
2507 {
2508 prefix => $nick,
2509 command => 'TIME',
2510 params => [$self->_state_peer_name($target)],
2511 },
2512 $self->_state_peer_route($target),
2513 );
2514 0 last SWITCH;
2515 }
2516  
2517 1 push @$ref, {
2518 prefix => $server,
2519 command => '391',
2520 params => [
2521 $nick,
2522 $server,
2523 strftime("%A %B %e %Y -- %T %z", localtime),
2524 ],
2525 };
2526 }
2527  
2528 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
2529 0 return $ref;
2530 }
2531  
2532 sub _daemon_cmd_users {
2533 16 ▶ my $self = shift;
Subroutine _daemon_cmd_users: called CC=3 SCAR=11.2
2534 16 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2535 16 my $server = $self->server_name();
2536 16 my $ref = [ ];
2537 16 my $global = keys %{ $self->{state}{users} };
2538 16 my $local = keys %{ $self->{state}{peers}{uc $server}{users} };
2539  
2540 push @$ref, {
2541 prefix => $server,
2542 command => '265',
2543 params => [
2544 $nick,
2545 "Current local users: $local Max: "
2546 . $self->{state}{stats}{maxlocal},
2547 16 ],
2548 };
2549  
2550 push @$ref, {
2551 prefix => $server,
2552 command => '266',
2553 params => [
2554 $nick,
2555 "Current global users: $global Max: "
2556 . $self->{state}{stats}{maxglobal},
2557 16 ],
2558 };
2559  
2560 16 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 16 0 16
2561 0 return $ref;
2562 }
2563  
2564 sub _daemon_cmd_lusers {
2565 16 ▶ my $self = shift;
Subroutine _daemon_cmd_lusers: called CC=6 SCAR=18.0
2566 16 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2567 16 my $server = $self->server_name();
2568 16 my $ref = [ ];
2569 16 my $invisible = $self->{state}{stats}{invisible};
2570 16 my $users = keys(%{ $self->{state}{users} }) - $invisible;
2571 16 my $servers = keys %{ $self->{state}{peers} };
2572 16 my $chans = keys %{ $self->{state}{chans} };
2573 16 my $local = keys %{ $self->{state}{peers}{uc $server}{users} };
2574 16 my $peers = keys %{ $self->{state}{peers}{uc $server}{peers} };
2575 16 my $totalconns = $self->{state}{stats}{conns_cumlative};
2576 16 my $mlocal = $self->{state}{stats}{maxlocal};
2577 16 my $conns = $self->{state}{stats}{maxconns};
2578  
2579 16 push @$ref, {
2580 prefix => $server,
2581 command => '251',
2582 params => [
2583 $nick,
2584 "There are $users users and $invisible invisible on "
2585 . "$servers servers",
2586 ],
2587 };
2588  
2589 16 $servers--;
2590  
2591 push @$ref, {
2592 prefix => $server,
2593 command => '252',
2594 params => [
2595 $nick,
2596 $self->{state}{stats}{ops_online},
2597 "IRC Operators online",
2598 ]
2599 16 ▶ } if $self->{state}{stats}{ops_online};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"}{"stats"}{"ops_online"} 1 15 16
2600  
2601 16 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
if $chans 0 16 16
2602 prefix => $server,
2603 command => '254',
2604 params => [$nick, $chans, "channels formed"],
2605 } if $chans;
2606  
2607 16 push @$ref, {
2608 prefix => $server,
2609 command => '255',
2610 params => [$nick, "I have $local clients and $peers servers"],
2611 };
2612  
2613 16 push @$ref, $_ for $self->_daemon_cmd_users($nick);
2614  
2615 16 push @$ref, {
2616 prefix => $server,
2617 command => '250',
2618 params => [
2619 $nick, "Highest connection count: $conns ($mlocal clients) "
2620 . "($totalconns connections received)",
2621 ],
2622 };
2623  
2624 16 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 16 0 16
2625 0 return $ref;
2626 }
2627  
2628 sub _daemon_cmd_motd {
2629 16 ▶ my $self = shift;
Subroutine _daemon_cmd_motd: called CC=10 SCAR=30.7
2630 16 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2631 16 my $target = shift;
2632 16 my $server = $self->server_name();
2633 16 my $ref = [ ];
2634 16 my $motd = $self->server_config('MOTD');
2635  
2636 SWITCH: {
2637 16 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 16 16
Condition33%1/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
1600
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
2638 0 push @$ref, ['402', $target];
2639 0 last SWITCH;
2640 }
2641 16 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 16 16
Condition33%1/3
$target and uc $server ne uc $target
!ll&&!rl&&r
1600
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
2642 0 $self->send_output(
2643 {
2644 prefix => $nick,
2645 command => 'MOTD',
2646 params => [$self->_state_peer_name($target)],
2647 },
2648 $self->_state_peer_route($target),
2649 );
2650 0 last SWITCH;
2651 }
2652 16 ▶ if ($motd && ref $motd eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($motd and ref $motd eq 'ARRAY') { } 0 16 16
Condition33%1/3
$motd and ref $motd eq "ARRAY"
!ll&&!rl&&r
1600
MC/DC0%0/2
$motd and ref $motd eq "ARRAY"
$motd ref $motd eq "ARRAY"
Truth table33%1/3
A and B
A= $motdB= ref $motd eq "ARRAY"
ABresult
0X0
100
111
2653 0 push @$ref, {
2654 prefix => $server,
2655 command => '375',
2656 params => [$nick, "- $server Message of the day - "],
2657 };
2658 push @$ref, {
2659 prefix => $server,
2660 command => '372',
2661 params => [$nick, "- $_"]
2662 0 } for @$motd;
2663 0 push @$ref, {
2664 prefix => $server,
2665 command => '376',
2666 params => [$nick, "End of MOTD command"],
2667 };
2668 }
2669 else {
2670 16 push @$ref, '422';
2671 }
2672 }
2673  
2674 16 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 16 0 16
2675 0 return $ref;
2676 }
2677  
2678 sub _daemon_cmd_stats {
2679 0 ▶ my $self = shift;
Subroutine _daemon_cmd_stats: not called CC=14 SCAR=53.5
2680 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
2681 0 my $char = shift;
2682 0 my $target = shift;
2683 0 my $server = $self->server_name();
2684 0 my $ref = [ ];
2685  
2686 SWITCH: {
2687 0 ▶ if (!$char) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($char) 0 0 0
2688 0 push @$ref, ['461', 'STATS'];
2689 0 last SWITCH;
2690 }
2691 0 $char = substr $char, 0, 1;
2692 0 ▶ if ($char !~ /[ump]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($char =~ /[ump]/) 0 0 0
2693 0 push @$ref, {
2694 prefix => $server,
2695 command => '263',
2696 params => [
2697 $nick,
2698 'Server load is temporarily too heavy. '
2699 .'Please wait a while and try again.'
2700 ],
2701 };
2702 0 last SWITCH;
2703 }
2704 0 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 0 0
Condition0%0/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
000
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table0%0/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
2705 0 push @$ref, ['402', $target];
2706 0 last SWITCH;
2707 }
2708 0 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 0 0
Condition0%0/3
$target and uc $server ne uc $target
!ll&&!rl&&r
000
MC/DC0%0/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table0%0/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
2709 0 $self->send_output(
2710 {
2711 prefix => $nick,
2712 command => 'STATS',
2713 params => [
2714 $char,
2715 $self->_state_peer_name($target),
2716 ],
2717 },
2718 $self->_state_peer_route($target),
2719 );
2720 0 last SWITCH;
2721 }
2722  
2723 SWITCH2: {
2724 0 ▶ if ($char eq 'u') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "u") 0 0 0
2725 0 my $uptime = time - $self->server_config('created');
2726 0 my $days = int $uptime / 86400;
2727 0 my $remain = $uptime % 86400;
2728 0 my $hours = int $remain / 3600;
2729 0 $remain %= 3600;
2730 0 my $mins = int $remain / 60;
2731 0 $remain %= 60;
2732  
2733 0 push @$ref, {
2734 prefix => $server,
2735 command => '242',
2736 params => [
2737 $nick,
2738 sprintf("Server Up %d days, %2.2d:%2.2d:%2.2d",
2739 $days, $hours, $mins, $remain),
2740 ],
2741 };
2742  
2743 0 my $totalconns = $self->{state}{stats}{conns_cumlative};
2744 0 my $local = $self->{state}{stats}{maxlocal};
2745 0 my $conns = $self->{state}{stats}{maxconns};
2746  
2747 0 push @$ref, {
2748 prefix => $server,
2749 command => '250',
2750 params => [
2751 $nick,
2752 "Highest connection count: $conns ($local "
2753 ."clients) ($totalconns connections received)",
2754 ],
2755 };
2756 0 last SWITCH2;
2757 }
2758 0 ▶ if ($char eq 'm') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "m") 0 0 0
2759 0 my $cmds = $self->{state}{stats}{cmds};
2760 push @$ref, {
2761 prefix => $server,
2762 command => '212',
2763 params => [
2764 $nick,
2765 $_,
2766 $cmds->{$_}{local},
2767 $cmds->{$_}{bytes},
2768 $cmds->{$_}{remote},
2769 ],
2770 0 } for sort keys %$cmds;
2771 0 last SWITCH2;
2772 }
2773 0 ▶ if ($char eq 'p') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "p") 0 0 0
2774 0 my @ops = map { $self->_client_nickname( $_ ) }
2775 0 keys %{ $self->{state}{localops} };
2776 0 for my $op (sort @ops) {
2777 0 my $record = $self->{state}{users}{uc_irc($op)};
2778 push @$ref, {
2779 prefix => $server,
2780 command => '249',
2781 params => [
2782 $nick,
2783 sprintf("[O] %s (%s\@%s) Idle: %u",
2784 $record->{nick}, $record->{auth}{ident},
2785 $record->{auth}{hostname},
2786 0 time - $record->{idle_time}),
2787 ],
2788 };
2789 }
2790  
2791 0 push @$ref, {
2792 prefix => $server,
2793 command => '249',
2794 params => [$nick, scalar @ops . " OPER(s)"],
2795 };
2796 0 last SWITCH2;
2797 }
2798 }
2799  
2800 0 push @$ref, {
2801 prefix => $server,
2802 command => '219',
2803 params => [$nick, $char, 'End of /STATS report'],
2804 };
2805 }
2806  
2807 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2808 0 return $ref;
2809 }
2810  
2811 sub _daemon_cmd_userhost {
2812 0 ▶ my $self = shift;
Subroutine _daemon_cmd_userhost: not called CC=9 SCAR=45.0
2813 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
2814 0 my $server = $self->server_name();
2815 0 my $ref = [ ];
2816 0 my $str = '';
2817  
2818 0 for my $query (@_) {
2819 0 my ($proper, $userhost)
2820 = split /!/, $self->state_user_full($query);
2821 0 ▶ if ($proper && $userhost) {
Branch: 1 branch
BranchTrueFalseTotal
if ($proper and $userhost) 0 0 0
Condition0%0/3
$proper and $userhost
!ll&&!rl&&r
000
MC/DC0%0/2
$proper and $userhost
$proper $userhost
Truth table0%0/3
A and B
A= $properB= $userhost
ABresult
0X0
100
111
2822 0 ▶ $str = join(' ', $str, $proper
Branch: 2 branches
BranchTrueFalseTotal
$self->state_user_is_operator($proper) ? : 0 0 0
$self->_state_user_away($proper) ? : 0 0 0
2823 . ($self->state_user_is_operator($proper)
2824 ? '*'
2825 : ''
2826 ) . '=' . ($self->_state_user_away($proper)
2827 ? '-'
2828 : '+'
2829 ) . $userhost);
2830 }
2831 }
2832  
2833 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
$str ? : 0 0 0
2834 prefix => $server,
2835 command => '302',
2836 params => [$nick, ($str ? $str : ':')],
2837 };
2838  
2839 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2840 0 return $ref;
2841 }
2842  
2843 sub _daemon_cmd_ison {
2844 0 ▶ my $self = shift;
Subroutine _daemon_cmd_ison: not called CC=5 SCAR=34.0
2845 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
2846 0 my $server = $self->server_name();
2847 0 my $ref = [ ];
2848 0 my $args = [@_];
2849 0 my $count = @$args;
2850  
2851 SWITCH: {
2852 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2853 0 push @$ref, ['461', 'ISON'];
2854 0 last SWITCH;
2855 }
2856 0 my $string = '';
2857 $string = join ' ', map {
2858 $self->{state}{users}{uc_irc($_)}{nick}
2859 0 } grep { $self->state_nick_exists($_) } @$args;
2860  
2861 0 ▶ push @$ref, {
Branch: 1 branch
BranchTrueFalseTotal
$string =~ /\s+/ ? : 0 0 0
2862 prefix => $server,
2863 command => '303',
2864 params => [$nick, ($string =~ /\s+/ ? $string : ":$string")],
2865 };
2866 }
2867  
2868 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
2869 0 return $ref;
2870 }
2871  
2872 sub _daemon_cmd_list {
2873 2 ▶ my $self = shift;
Subroutine _daemon_cmd_list: called CC=26 SCAR=47.7
2874 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
2875 2 my $server = $self->server_name();
2876 2 my $ref = [ ];
2877 2 my $args = [@_];
2878 2 my $count = @$args;
2879  
2880 SWITCH: {
2881 2 my @chans;
2882 2 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
2883 0 @chans = map { $self->_state_chan_name($_) }
2884 0 keys %{ $self->{state}{chans} };
2885 }
2886 2 my $last = pop @$args;
2887 2 ▶ if ($count && $last !~ /^[#&]/ &&
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)) 0 2 2
Condition33%2/6
$count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)
!ll&&!rl&&r
200
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
020
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
2888 !$self->state_peer_exists($last)) {
2889 0 push @$ref, ['401', $last];
2890 0 last SWITCH;
2891 }
2892 2 ▶ if ($count && $last !~ /^[#&]/ && uc $last ne uc $server) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and uc $last ne uc $server) 0 2 2
Condition33%2/6
$count and not $last =~ /^[#&]/ and uc $last ne uc $server
!ll&&!rl&&r
200
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
020
MC/DC0%0/3
$count and not $last =~ /^[#&]/ and uc $last ne uc $server
$count not $last =~ /^[#&]/ uc $last ne uc $server
Truth table25%1/4
A and not(B) and C
A= $countB= not $last =~ /^[#&]/C= uc $last ne uc $server
ABCresult
0XX0
10X0
1100
1111
2893 0 $self->send_output(
2894 {
2895 prefix => $self->state_user_full($nick),
2896 command => 'LIST',
2897 params => [
2898 @$args,
2899 $self->_state_peer_name($last),
2900 ],
2901 }, $self->_state_peer_route($last),
2902 );
2903 0 last SWITCH;
2904 }
2905 2 ▶ if ($count && $last !~ /^[#&]/ && @$args == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and @$args == 0) 0 2 2
Condition33%2/6
$count and not $last =~ /^[#&]/ and @$args == 0
!ll&&!rl&&r
200
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
020
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
2906 0 @chans = map { $self->_state_chan_name($_) }
2907 0 keys %{ $self->{state}{chans} };
2908 }
2909 2 ▶ if ($count && $last !~ /^[#&]/ && @$args == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and @$args == 1) 0 2 2
Condition33%2/6
$count and not $last =~ /^[#&]/ and @$args == 1
!ll&&!rl&&r
200
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
020
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
2910 0 $last = pop @$args;
2911 }
2912 2 ▶ if ($count && $last =~ /^[#&]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and $last =~ /^[#&]/) 2 0 2
Condition33%1/3
$count and $last =~ /^[#&]/
!ll&&!rl&&r
002
MC/DC0%0/2
$count and $last =~ /^[#&]/
$count $last =~ /^[#&]/
Truth table33%1/3
A and B
A= $countB= $last =~ /^[#&]/
ABresult
0X0
100
111
2913 2 @chans = split /,/, $last;
2914 }
2915 2 push @$ref, {
2916 prefix => $server,
2917 command => '321',
2918 params => [$nick, 'Channel', 'Users Name'],
2919 };
2920  
2921 2 my $count = 0;
2922 2 INNER: for my $chan (@chans) {
2923 2 ▶ if (!is_valid_chan_name($chan)
Branch: 1 branch
BranchTrueFalseTotal
unless (is_valid_chan_name($chan) and $self->state_chan_exists($chan)) 0 2 2
Condition33%1/3
is_valid_chan_name($chan) and $self->state_chan_exists($chan)
!ll&&!rl&&r
002
MC/DC0%0/2
is_valid_chan_name($chan) and $self->state_chan_exists($chan)
is_valid_chan_name($chan) $self->state_chan_exists($chan)
Truth table33%1/3
A and B
A= is_valid_chan_name($chan)B= $self->state_chan_exists($chan)
ABresult
0X0
100
111
2924 || !$self->state_chan_exists($chan)) {
2925 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
2926 0 push @$ref, ['401', $chan];
2927 0 last INNER;
2928 }
2929 0 $count++;
2930 0 next INNER;
2931 }
2932 2 $count++;
2933 2 ▶ if ($self->state_chan_mode_set( $chan, 'p')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_mode_set($chan, "p") or $self->state_chan_mode_set($chan, "s") and not $self->state_is_chan_member($nick, $chan)) 0 2 2
Condition33%2/6
$self->state_chan_mode_set($chan, "p") or $self->state_chan_mode_set($chan, "s") and not $self->state_is_chan_member($nick, $chan)
l!l&&r!l&&!r
002
$self->state_chan_mode_set($chan, "s") and not $self->state_is_chan_member($nick, $chan)
!ll&&!rl&&r
200
MC/DC0%0/3
$self->state_chan_mode_set($chan, "p") or $self->state_chan_mode_set($chan, "s") and not $self->state_is_chan_member($nick, $chan)
$self->state_chan_mode_set($chan, "p") $self->state_chan_mode_set($chan, "s") not $self->state_is_chan_member($nick, $chan)
Truth table0%0/4
A or B and not(C)
A= $self->state_chan_mode_set($chan, "p")B= $self->state_chan_mode_set($chan, "s")C= not $self->state_is_chan_member($nick, $chan)
ABCresult
1XX1
0111
00X0
0100
2934 || $self->state_chan_mode_set($chan, 's')
2935 && !$self->state_is_chan_member($nick, $chan)) {
2936 0 next INNER;
2937 }
2938 2 my $record = $self->{state}{chans}{uc_irc($chan)};
2939 push @$ref, {
2940 prefix => $server,
2941 command => '322',
2942 params => [
2943 $nick,
2944 $record->{name},
2945 2 ▶ scalar keys %{ $record->{users} },
Branch: 1 branch
BranchTrueFalseTotal
defined $record->{'topic'} ? : 1 1 2
2946 (defined $record->{topic}
2947 2 ? $record->{topic}[0]
2948 : ''
2949 ),
2950 ],
2951 };
2952 }
2953  
2954 2 push @$ref, {
2955 prefix => $server,
2956 command => '323',
2957 params => [$nick, 'End of /LIST'],
2958 };
2959 }
2960  
2961 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 2 0 2
2962 0 return $ref;
2963 }
2964  
2965 sub _daemon_cmd_names {
2966 9 ▶ my $self = shift;
Subroutine _daemon_cmd_names: called CC=26 SCAR=43.7
2967 9 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
90
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
2968 9 my $server = $self->server_name();
2969 9 my $ref = [ ];
2970 9 my $args = [@_];
2971 9 my $count = @$args;
2972  
2973 SWITCH: {
2974 9 my (@chans, $query);
2975 9 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 9 9
2976 0 @chans = $self->state_user_chans($nick);
2977 0 $query = '*';
2978 }
2979 9 my $last = pop @$args;
2980 9 ▶ if ($count && $last !~ /^[#&]/
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)) 0 9 9
Condition33%2/6
$count and not $last =~ /^[#&]/ and not $self->state_peer_exists($last)
!ll&&!rl&&r
900
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
090
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
2981 && !$self->state_peer_exists($last)) {
2982 0 push @$ref, ['401', $last];
2983 0 last SWITCH;
2984 }
2985 9 ▶ if ($count && $last !~ /^[#&]/ & uc $last ne uc $server) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and !($last =~ /^[#&]/) & uc $last ne uc $server) 0 9 9
Condition33%1/3
$count and !($last =~ /^[#&]/) & uc $last ne uc $server
!ll&&!rl&&r
090
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
2986 0 $self->send_output(
2987 {
2988 prefix => $nick,
2989 command => 'NAMES',
2990 params => [@$args, $self->_state_peer_name($last)],
2991 },
2992 $self->_state_peer_route($last),
2993 );
2994 0 last SWITCH;
2995 }
2996 9 ▶ if ($count && $last !~ /^[#&]/ && @$args == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and @$args == 0) 0 9 9
Condition33%2/6
$count and not $last =~ /^[#&]/ and @$args == 0
!ll&&!rl&&r
900
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
090
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
2997 0 @chans = $self->state_user_chans($nick);
2998 0 $query = '*';
2999 }
3000 9 ▶ if ($count && $last !~ /^[#&]/ && @$args == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and not $last =~ /^[#&]/ and @$args == 1) 0 9 9
Condition33%2/6
$count and not $last =~ /^[#&]/ and @$args == 1
!ll&&!rl&&r
900
$count and not $last =~ /^[#&]/
!ll&&!rl&&r
090
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
3001 0 $last = pop @$args;
3002 }
3003 9 ▶ if ($count && $last =~ /^[#&]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count and $last =~ /^[#&]/) 9 0 9
Condition33%1/3
$count and $last =~ /^[#&]/
!ll&&!rl&&r
009
MC/DC0%0/2
$count and $last =~ /^[#&]/
$count $last =~ /^[#&]/
Truth table33%1/3
A and B
A= $countB= $last =~ /^[#&]/
ABresult
0X0
100
111
3004 my ($chan) = grep {
3005 9 ▶ $_ && $self->state_chan_exists($_)
Branch: 1 branch
BranchTrueFalseTotal
$_ and $self->state_chan_exists($_) and $self->state_is_chan_member($nick, $_) 9 0 9
Condition33%1/3
$_ and $self->state_chan_exists($_)
!ll&&!rl&&r
009
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
3006 && $self->state_is_chan_member($nick, $_)
3007 } split /,/, $last;
3008 9 @chans = ();
3009  
3010 9 ▶ if ($chan) {
Branch: 1 branch
BranchTrueFalseTotal
if ($chan) { } 9 0 9
3011 9 push @chans, $chan;
3012 9 $query = $self->_state_chan_name($chan);
3013 }
3014 else {
3015 0 $query = '*';
3016 }
3017 }
3018  
3019 9 for my $chan (@chans) {
3020 9 my $record = $self->{state}{chans}{uc_irc($chan)};
3021 9 my $type = '=';
3022 9 ▶ $type = '@' if $record->{mode} =~ /s/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /s/ 0 9 9
3023 9 ▶ $type = '*' if $record->{mode} =~ /p/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /p/ 0 9 9
3024 9 my $length = length($server)+3+length($chan)+length($nick)+7;
3025 9 my $buffer = '';
3026  
3027 9 for my $name (sort $self->state_chan_list_prefixed($record->{name})) {
3028 12 ▶ if (length(join ' ', $buffer, $name) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buffer, $name) + $length > 510) 0 12 12
3029 push @$ref, {
3030 prefix => $server,
3031 command => '353',
3032 0 params => [$nick, $type, $record->{name}, $buffer]
3033 };
3034 0 $buffer = $name;
3035 0 next;
3036 }
3037 12 ▶ if ($buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) { } 3 9 12
3038 3 $buffer = join ' ', $buffer, $name;
3039 }
3040 else {
3041 9 $buffer = $name;
3042 }
3043 }
3044 push @$ref, {
3045 prefix => $server,
3046 command => '353',
3047 9 params => [$nick, $type, $record->{name}, $buffer],
3048 };
3049 }
3050 9 push @$ref, {
3051 prefix => $server,
3052 command => '366',
3053 params => [$nick, $query, 'End of NAMES list'],
3054 };
3055 }
3056  
3057 9 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 9 0 9
3058 0 return $ref;
3059 }
3060  
3061 sub _daemon_cmd_whois {
3062 0 ▶ my $self = shift;
Subroutine _daemon_cmd_whois: not called CC=37 SCAR=72.5
3063 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
3064 0 my $server = $self->server_name();
3065 0 my $ref = [ ];
3066 0 my ($first, $second) = @_;
3067  
3068 SWITCH: {
3069 0 ▶ if (!$first && !$second) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($first or $second) 0 0 0
Condition0%0/3
$first or $second
l!l&&r!l&&!r
000
MC/DC0%0/2
$first or $second
$first $second
Truth table0%0/3
A or B
A= $firstB= $second
ABresult
1X1
011
000
3070 0 push @$ref, ['431'];
3071 0 last SWITCH;
3072 }
3073 0 ▶ if (!$second && $first) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $second and $first) 0 0 0
Condition0%0/3
not $second and $first
!ll&&!rl&&r
000
MC/DC0%0/2
not $second and $first
not $second $first
Truth table0%0/3
not(A) and B
A= not $secondB= $first
ABresult
0X0
100
111
3074 0 $second = (split /,/, $first)[0];
3075 0 $first = $server;
3076 }
3077 0 ▶ if ($first && $second) {
Branch: 1 branch
BranchTrueFalseTotal
if ($first and $second) 0 0 0
Condition0%0/3
$first and $second
!ll&&!rl&&r
000
MC/DC0%0/2
$first and $second
$first $second
Truth table0%0/3
A and B
A= $firstB= $second
ABresult
0X0
100
111
3078 0 $second = (split /,/, $second)[0];
3079 }
3080 0 ▶ 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)) 0 0 0
Condition0%0/3
uc_irc($first) eq uc_irc($second) and $self->state_nick_exists($second)
!ll&&!rl&&r
000
MC/DC0%0/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 table0%0/3
A and B
A= uc_irc($first) eq uc_irc($second)B= $self->state_nick_exists($second)
ABresult
0X0
100
111
3081 && $self->state_nick_exists($second)) {
3082 0 $first = $self->state_user_server($second);
3083 }
3084 0 my $query;
3085 my $target;
3086 0 ▶ $query = $first if !$second;
Branch: 1 branch
BranchTrueFalseTotal
unless $second 0 0 0
3087 0 ▶ $query = $second if $second;
Branch: 1 branch
BranchTrueFalseTotal
if $second 0 0 0
3088 0 ▶ $target = $first if $second && uc $first ne uc$server;
Branch: 1 branch
BranchTrueFalseTotal
if $second and uc $first ne uc $server 0 0 0
Condition0%0/3
$second and uc $first ne uc $server
!ll&&!rl&&r
000
MC/DC0%0/2
$second and uc $first ne uc $server
$second uc $first ne uc $server
Truth table0%0/3
A and B
A= $secondB= uc $first ne uc $server
ABresult
0X0
100
111
3089 0 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 0 0
Condition0%0/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
000
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table0%0/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
3090 0 push @$ref, ['402', $target];
3091 0 last SWITCH;
3092 }
3093 0 ▶ if ($target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target) 0 0 0
3094 0 $self->send_output(
3095 {
3096 prefix => $nick,
3097 command => 'WHOIS',
3098 params => [
3099 $self->_state_peer_name($target),
3100 $second,
3101 ],
3102 },
3103 $self->_state_peer_route($target),
3104 );
3105 0 last SWITCH;
3106 }
3107 # Okay we got here *phew*
3108 0 ▶ if (!$self->state_nick_exists($query)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->state_nick_exists($query)) { } 0 0 0
3109 0 push @$ref, ['401', $query];
3110 }
3111 else {
3112 0 my $record = $self->{state}{users}{uc_irc($query)};
3113 push @$ref, {
3114 prefix => $server,
3115 command => '311',
3116 params => [
3117 $nick,
3118 $record->{nick},
3119 $record->{auth}{ident},
3120 $record->{auth}{hostname},
3121 '*',
3122 $record->{ircname},
3123 0 ],
3124 };
3125 0 my @chans;
3126 0 LOOP: for my $chan (keys %{ $record->{chans} }) {
3127 0 ▶ if ($self->{state}{chans}{$chan}{mode} =~ /[ps]/
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ and not $self->state_is_chan_member($nick, $chan)) 0 0 0
Condition0%0/3
$self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ and not $self->state_is_chan_member($nick, $chan)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ and not $self->state_is_chan_member($nick, $chan)
$self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/ not $self->state_is_chan_member($nick, $chan)
Truth table0%0/3
A and not(B)
A= $self->{"state"}{"chans"}{$chan}{"mode"} =~ /[ps]/B= not $self->state_is_chan_member($nick, $chan)
ABresult
0X0
100
111
3128 && !$self->state_is_chan_member($nick, $chan)) {
3129 0 next LOOP;
3130 }
3131 0 my $prefix = '';
3132 0 ▶ $prefix .= '@' if $record->{chans}{$chan} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /o/ 0 0 0
3133 0 ▶ $prefix .= '%' if $record->{chans}{$chan} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /h/ 0 0 0
3134 0 ▶ $prefix .= '+' if $record->{chans}{$chan} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{$chan} =~ /v/ 0 0 0
3135 0 push @chans, $prefix . $self->{state}{chans}{$chan}{name};
3136 }
3137 0 ▶ if (@chans) {
Branch: 1 branch
BranchTrueFalseTotal
if (@chans) 0 0 0
3138 0 my $buffer = '';
3139 my $length = length($server) + 3 + length($nick)
3140 0 + length($record->{nick}) + 7;
3141  
3142 0 LOOP2: for my $chan (@chans) {
3143 0 ▶ if (length(join ' ', $buffer, $chan) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $buffer, $chan) + $length > 510) 0 0 0
3144 push @$ref, {
3145 prefix => $server,
3146 command => '319',
3147 0 params => [$nick, $record->{nick}, $buffer],
3148 };
3149 0 $buffer = $chan;
3150 0 next LOOP2;
3151 }
3152 0 ▶ if ($buffer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer) { } 0 0 0
3153 0 $buffer = join ' ', $buffer, $chan;
3154 }
3155 else {
3156 0 $buffer = $chan;
3157 }
3158 }
3159 push @$ref, {
3160 prefix => $server,
3161 command => '319',
3162 0 params => [$nick, $record->{nick}, $buffer],
3163 };
3164 }
3165 push @$ref, {
3166 prefix => $server,
3167 command => '312',
3168 params => [
3169 $nick,
3170 $record->{nick},
3171 $record->{server},
3172 0 $self->_state_peer_desc($record->{server}),
3173 ],
3174 };
3175 push @$ref, {
3176 prefix => $server,
3177 command => '301',
3178 params => [
3179 $nick,
3180 $record->{nick},
3181 $record->{away},
3182 ],
3183 0 ▶ } if $record->{type} eq 'c' && $record->{away};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"type"} eq "c" and $record->{"away"} 0 0 0
Condition0%0/3
$record->{"type"} eq "c" and $record->{"away"}
!ll&&!rl&&r
000
MC/DC0%0/2
$record->{"type"} eq "c" and $record->{"away"}
$record->{"type"} eq "c" $record->{"away"}
Truth table0%0/3
A and B
A= $record->{"type"} eq "c"B= $record->{"away"}
ABresult
0X0
100
111
3184 push @$ref, {
3185 prefix => $server,
3186 command => '313',
3187 params => [$nick, $record->{nick}, 'is an IRC Operator'],
3188 0 ▶ } if $record->{umode} && $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} and $record->{"umode"} =~ /o/ 0 0 0
Condition0%0/3
$record->{"umode"} and $record->{"umode"} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$record->{"umode"} and $record->{"umode"} =~ /o/
$record->{"umode"} $record->{"umode"} =~ /o/
Truth table0%0/3
A and B
A= $record->{"umode"}B= $record->{"umode"} =~ /o/
ABresult
0X0
100
111
3189 0 ▶ if ($record->{type} eq 'c'
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"type"} eq "c" and $self->server_config("whoisactually") || $self->state_user_is_operator($nick)) 0 0 0
Condition0%0/6
$record->{"type"} eq "c" and $self->server_config("whoisactually") || $self->state_user_is_operator($nick)
!ll&&!rl&&r
000
$self->server_config("whoisactually") or $self->state_user_is_operator($nick)
l!l&&r!l&&!r
000
MC/DC0%0/3
$record->{"type"} eq "c" and $self->server_config("whoisactually") || $self->state_user_is_operator($nick)
$record->{"type"} eq "c" $self->server_config("whoisactually") $self->state_user_is_operator($nick)
Truth table0%0/4
A and B or C
A= $record->{"type"} eq "c"B= $self->server_config("whoisactually")C= $self->state_user_is_operator($nick)
ABCresult
0XX0
1000
11X1
1011
3190 && ($self->server_config('whoisactually')
3191 or $self->state_user_is_operator($nick))) {
3192 push @$ref, {
3193 prefix => $server,
3194 command => '338',
3195 params => [
3196 $nick,
3197 $record->{nick},
3198 0 $record->{socket}[0],
3199 'actually using host',
3200 ],
3201 };
3202 }
3203 push @$ref, {
3204 prefix => $server,
3205 command => '317',
3206 params => [
3207 $nick,
3208 $record->{nick},
3209 time - $record->{idle_time},
3210 $record->{conn_time},
3211 'seconds idle, signon time',
3212 ],
3213 0 ▶ } if $record->{type} eq 'c';
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"type"} eq "c" 0 0 0
3214 }
3215 0 push @$ref, {
3216 prefix => $server,
3217 command => '318',
3218 params => [$nick, $query, 'End of /WHOIS list.'],
3219 };
3220 }
3221  
3222 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3223 0 return $ref;
3224 }
3225  
3226 sub _daemon_cmd_who {
3227 0 ▶ my $self = shift;
Subroutine _daemon_cmd_who: not called CC=16 SCAR=56.1
3228 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
3229 0 my ($who, $op_only) = @_;
3230 0 my $server = $self->server_name();
3231 0 my $ref = [ ];
3232 0 my $orig = $who;
3233  
3234 SWITCH: {
3235 0 ▶ if (!$who) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($who) 0 0 0
3236 0 push @$ref, ['461', 'WHO'];
3237 0 last SWITCH;
3238 }
3239 0 ▶ if ($self->state_chan_exists($who)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_chan_exists($who) and $self->state_is_chan_member($nick, $who)) 0 0 0
Condition0%0/3
$self->state_chan_exists($who) and $self->state_is_chan_member($nick, $who)
!ll&&!rl&&r
000
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 table0%0/3
A and B
A= $self->state_chan_exists($who)B= $self->state_is_chan_member($nick, $who)
ABresult
0X0
100
111
3240 && $self->state_is_chan_member($nick, $who)) {
3241 0 my $record = $self->{state}{chans}{uc_irc($who)};
3242 0 $who = $record->{name};
3243 0 for my $member (keys %{ $record->{users} }) {
3244 0 my $rpl_who = {
3245 prefix => $server,
3246 command => '352',
3247 params => [$nick, $who],
3248 };
3249 0 my $memrec = $self->{state}{users}{$member};
3250 0 push @{ $rpl_who->{params} }, $memrec->{auth}{ident};
3251 0 push @{ $rpl_who->{params} }, $memrec->{auth}{hostname};
3252 0 push @{ $rpl_who->{params} }, $memrec->{server};
3253 0 push @{ $rpl_who->{params} }, $memrec->{nick};
3254 0 ▶ my $status = ($memrec->{away} ? 'G' : 'H');
Branch: 1 branch
BranchTrueFalseTotal
$memrec->{'away'} ? : 0 0 0
3255 0 ▶ $status .= '*' if $memrec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $memrec->{"umode"} =~ /o/ 0 0 0
3256 0 ▶ $status .= '@' if $record->{users}{$member} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"users"}{$member} =~ /o/ 0 0 0
3257 0 ▶ $status .= '%' if $record->{users}{$member} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"users"}{$member} =~ /h/ 0 0 0
3258 $status .= '+' if $record->{users}{$member} !~ /o/
3259 0 ▶ and $record->{users}{$member} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if not $record->{"users"}{$member} =~ /o/ and $record->{"users"}{$member} =~ /v/ 0 0 0
Condition0%0/3
not $record->{"users"}{$member} =~ /o/ and $record->{"users"}{$member} =~ /v/
!ll&&!rl&&r
000
MC/DC0%0/2
not $record->{"users"}{$member} =~ /o/ and $record->{"users"}{$member} =~ /v/
not $record->{"users"}{$member} =~ /o/ $record->{"users"}{$member} =~ /v/
Truth table0%0/3
not(A) and B
A= not $record->{"users"}{$member} =~ /o/B= $record->{"users"}{$member} =~ /v/
ABresult
0X0
100
111
3260 0 push @{ $rpl_who->{params} }, $status;
3261 0 push @{ $rpl_who->{params} }, "$memrec->{hops} "
3262 0 . $memrec->{ircname};
3263 0 push @$ref, $rpl_who;
3264 }
3265 }
3266 0 ▶ if ($self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($who)) 0 0 0
3267 0 my $nickrec = $self->{state}{users}{uc_irc($who)};
3268 0 $who = $nickrec->{nick};
3269 0 my $rpl_who = {
3270 prefix => $server,
3271 command => '352',
3272 params => [$nick, '*'],
3273 };
3274 0 push @{ $rpl_who->{params} }, $nickrec->{auth}{ident};
3275 0 push @{ $rpl_who->{params} }, $nickrec->{auth}{hostname};
3276 0 push @{ $rpl_who->{params} }, $nickrec->{server};
3277 0 push @{ $rpl_who->{params} }, $nickrec->{nick};
3278 0 ▶ my $status = ($nickrec->{away} ? 'G' : 'H');
Branch: 1 branch
BranchTrueFalseTotal
$nickrec->{'away'} ? : 0 0 0
3279 0 ▶ $status .= '*' if $nickrec->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $nickrec->{"umode"} =~ /o/ 0 0 0
3280 0 push @{ $rpl_who->{params} }, $status;
3281 0 push @{ $rpl_who->{params} }, "$nickrec->{hops} "
3282 0 . $nickrec->{ircname};
3283 0 push @$ref, $rpl_who;
3284 }
3285 0 push @$ref, {
3286 prefix => $server,
3287 command => '315',
3288 params => [$nick, $orig, 'End of WHO list'],
3289 };
3290 }
3291  
3292 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3293 0 return $ref;
3294 }
3295  
3296 sub _daemon_cmd_mode {
3297 1 ▶ my $self = shift;
Subroutine _daemon_cmd_mode: called CC=91 SCAR=81.7
3298 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
3299 1 my $chan = shift;
3300 1 my $server = $self->server_name();
3301 1 my $maxmodes = $self->server_config('MODES');
3302 1 my $ref = [ ];
3303 1 my $args = [@_];
3304 1 my $count = @$args;
3305  
3306 SWITCH: {
3307 1 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 1 1
3308 0 push @$ref, ['403', $chan];
3309 0 last SWITCH;
3310 }
3311  
3312 1 my $record = $self->{state}{chans}{uc_irc($chan)};
3313 1 $chan = $record->{name};
3314  
3315 1 ▶ if (!$count && !$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count or $self->state_is_chan_member($nick, $chan)) 0 1 1
Condition33%1/3
$count or $self->state_is_chan_member($nick, $chan)
l!l&&r!l&&!r
100
MC/DC0%0/2
$count or $self->state_is_chan_member($nick, $chan)
$count $self->state_is_chan_member($nick, $chan)
Truth table33%1/3
A or B
A= $countB= $self->state_is_chan_member($nick, $chan)
ABresult
1X1
011
000
3316 push @$ref, {
3317 prefix => $server,
3318 command => '324',
3319 0 params => [$nick, $chan, '+' . $record->{mode}],
3320 colonify => 0,
3321 };
3322 push @$ref, {
3323 prefix => $server,
3324 command => '329',
3325 0 params => [$nick, $chan, $record->{ts}],
3326 colonify => 0,
3327 };
3328 0 last SWITCH;
3329 }
3330 1 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 1 1
3331 push @$ref, {
3332 prefix => $server,
3333 command => '324',
3334 params => [
3335 $nick,
3336 $chan,
3337 '+' . $record->{mode},
3338 ($record->{ckey} || ()),
3339 0 ▶ ($record->{climit} || ()),
Condition0%0/6
$record->{'ckey'} || ()
l!l&&r!l&&!r
000
$record->{'climit'} || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$record->{'ckey'} || ()
$record->{'ckey'} ()
MC/DC0%0/2
$record->{'climit'} || ()
$record->{'climit'} ()
Truth table0%0/3
A || B
A= $record->{'ckey'}B= ()
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $record->{'climit'}B= ()
ABresult
1X1
011
000
3340 ],
3341 colonify => 0,
3342 };
3343 push @$ref, {
3344 prefix => $server,
3345 command => '329',
3346 0 params => [$nick, $chan, $record->{ts}],
3347 colonify => 0,
3348 };
3349 0 last SWITCH;
3350 }
3351  
3352 1 my $unknown = 0;
3353 1 my $notop = 0;
3354 1 my $nick_is_op = $self->state_is_chan_op($nick, $chan);
3355 1 my $nick_is_hop = $self->state_is_chan_hop($nick, $chan);
3356 1 my $reply;
3357 my @reply_args;
3358 1 my $parsed_mode = parse_mode_line(@$args);
3359 1 my $mode_count = 0;
3360  
3361 1 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 1 1 2
3362 1 ▶ if ($mode !~ /[eIbklimnpstohv]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mode =~ /[eIbklimnpstohv]/) 0 1 1
3363 0 ▶ push @$ref, [
Branch: 1 branch
BranchTrueFalseTotal
unless $unknown 0 0 0
3364 '472',
3365 (split //, $mode)[1],
3366 $chan,
3367 ] if !$unknown;
3368 0 $unknown++;
3369 0 next;
3370 }
3371  
3372 1 my $arg;
3373 1 ▶ if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) 1 0 1
3374 1 $arg = shift @{ $parsed_mode->{args} };
3375 }
3376 1 ▶ if ($mode =~ /[-+]b/ && !defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[-+]b/ and not defined $arg) 0 1 1
Condition33%1/3
$mode =~ /[-+]b/ and not defined $arg
!ll&&!rl&&r
100
MC/DC0%0/2
$mode =~ /[-+]b/ and not defined $arg
$mode =~ /[-+]b/ not defined $arg
Truth table33%1/3
A and not(B)
A= $mode =~ /[-+]b/B= not defined $arg
ABresult
0X0
100
111
3377 push @$ref, {
3378 prefix => $server,
3379 command => '367',
3380 params => [
3381 $nick,
3382 $chan,
3383 0 @{ $record->{bans}{$_} },
3384 ]
3385 0 } for keys %{ $record->{bans} };
3386 0 push @$ref, {
3387 prefix => $server,
3388 command => '368',
3389 params => [$nick, $chan, 'End of Channel Ban List'],
3390 };
3391 0 next;
3392 }
3393 1 ▶ if (!$nick_is_op && !$nick_is_hop) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nick_is_op or $nick_is_hop) 0 1 1
Condition33%1/3
$nick_is_op or $nick_is_hop
l!l&&r!l&&!r
100
MC/DC0%0/2
$nick_is_op or $nick_is_hop
$nick_is_op $nick_is_hop
Truth table33%1/3
A or B
A= $nick_is_opB= $nick_is_hop
ABresult
1X1
011
000
3394 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
3395 0 $notop++;
3396 0 next;
3397 }
3398 1 ▶ if ($mode =~ /[-+]I/ && !defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[-+]I/ and not defined $arg) 0 1 1
Condition33%1/3
$mode =~ /[-+]I/ and not defined $arg
!ll&&!rl&&r
100
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
3399 push @$ref, {
3400 prefix => $server,
3401 command => '346',
3402 params => [
3403 $nick,
3404 $chan,
3405 0 @{ $record->{invex}{$_} },
3406 ],
3407 0 } for keys %{ $record->{invex} };
3408 0 push @$ref, {
3409 prefix => $server,
3410 command => '347',
3411 params => [$nick, $chan, 'End of Channel Invite List']
3412 };
3413 0 next;
3414 }
3415 1 ▶ if ($mode =~ /[-+]e/ && !defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /[-+]e/ and not defined $arg) 0 1 1
Condition33%1/3
$mode =~ /[-+]e/ and not defined $arg
!ll&&!rl&&r
100
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
3416 push @$ref, {
3417 prefix => $server,
3418 command => '348',
3419 0 params => [$nick, $chan, @{ $record->{excepts}{$_} } ]
3420 0 } for keys %{ $record->{excepts} };
3421 0 push @$ref, {
3422 prefix => $server,
3423 command => '349',
3424 params => [
3425 $nick,
3426 $chan,
3427 'End of Channel Exception List',
3428 ],
3429 };
3430 0 next;
3431 }
3432 1 ▶ 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 1 1
Condition33%2/6
not $nick_is_op and $nick_is_hop and $mode =~ /[op]/
!ll&&!rl&&r
100
not $nick_is_op and $nick_is_hop
!ll&&!rl&&r
100
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
3433 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
3434 0 $notop++;
3435 0 next;
3436 }
3437 1 ▶ 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 1 1
Condition33%3/9
not $nick_is_op and $nick_is_hop and $record->{"mode"} =~ /p/ and $mode =~ /h/
!ll&&!rl&&r
100
not $nick_is_op and $nick_is_hop and $record->{"mode"} =~ /p/
!ll&&!rl&&r
100
not $nick_is_op and $nick_is_hop
!ll&&!rl&&r
100
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
3438 && $mode =~ /h/) {
3439 0 ▶ push @$ref, ['482', $chan] if !$notop;
Branch: 1 branch
BranchTrueFalseTotal
unless $notop 0 0 0
3440 0 $notop++;
3441 0 next;
3442 }
3443 1 ▶ if (($mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/)
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/ and not defined $arg) 0 1 1
Condition33%2/6
$mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/ and not defined $arg
!ll&&!rl&&r
010
$mode =~ /^[-+][ohv]/ or $mode =~ /^\+[lk]/
l!l&&r!l&&!r
100
MC/DC0%0/3
$mode =~ /^[-+][ohv]/ || $mode =~ /^\+[lk]/ and not defined $arg
$mode =~ /^[-+][ohv]/ $mode =~ /^\+[lk]/ not defined $arg
Truth table20%1/5
A or B and not(C)
A= $mode =~ /^[-+][ohv]/B= $mode =~ /^\+[lk]/C= not defined $arg
ABCresult
00X0
1X00
0100
1X11
0111
3444 && !defined $arg) {
3445 0 next;
3446 }
3447 1 ▶ if ($mode =~ /^[-+][ohv]/ && !$self->state_nick_exists($arg)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^[-+][ohv]/ and not $self->state_nick_exists($arg)) 0 1 1
Condition33%1/3
$mode =~ /^[-+][ohv]/ and not $self->state_nick_exists($arg)
!ll&&!rl&&r
010
MC/DC0%0/2
$mode =~ /^[-+][ohv]/ and not $self->state_nick_exists($arg)
$mode =~ /^[-+][ohv]/ not $self->state_nick_exists($arg)
Truth table33%1/3
A and not(B)
A= $mode =~ /^[-+][ohv]/B= not $self->state_nick_exists($arg)
ABresult
0X0
100
111
3448 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3449 0 push @$ref, ['401', $arg];
3450 0 next;
3451 }
3452 1 ▶ if ($mode =~ /^[-+][ohv]/
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^[-+][ohv]/ and not $self->state_is_chan_member($arg, $chan)) 0 1 1
Condition33%1/3
$mode =~ /^[-+][ohv]/ and not $self->state_is_chan_member($arg, $chan)
!ll&&!rl&&r
010
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 table33%1/3
A and not(B)
A= $mode =~ /^[-+][ohv]/B= not $self->state_is_chan_member($arg, $chan)
ABresult
0X0
100
111
3453 && !$self->state_is_chan_member($arg, $chan)) {
3454 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3455 0 push @$ref, ['441', $chan, $self->state_user_nick($arg)];
3456 0 next;
3457 }
3458 1 ▶ if (my ($flag, $char) = $mode =~ /^([-+])([ohv])/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^([-+])([ohv])/) 1 0 1
3459 1 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 1 1
3460  
3461 1 ▶ if ($flag eq '+'
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "+" and not $record->{"users"}{uc_irc($arg)} =~ /$char/) 1 0 1
Condition33%1/3
$flag eq "+" and not $record->{"users"}{uc_irc($arg)} =~ /$char/
!ll&&!rl&&r
001
MC/DC0%0/2
$flag eq "+" and not $record->{"users"}{uc_irc($arg)} =~ /$char/
$flag eq "+" not $record->{"users"}{uc_irc($arg)} =~ /$char/
Truth table33%1/3
A and not(B)
A= $flag eq "+"B= not $record->{"users"}{uc_irc($arg)} =~ /$char/
ABresult
0X0
100
111
3462 && $record->{users}{uc_irc($arg)} !~ /$char/) {
3463 # Update user and chan record
3464 1 $arg = uc_irc($arg);
3465 1 ▶ if ($mode eq '+h' && $record->{users}{$arg} =~ /o/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "+h" and $record->{"users"}{$arg} =~ /o/) 0 1 1
Condition33%1/3
$mode eq "+h" and $record->{"users"}{$arg} =~ /o/
!ll&&!rl&&r
100
MC/DC0%0/2
$mode eq "+h" and $record->{"users"}{$arg} =~ /o/
$mode eq "+h" $record->{"users"}{$arg} =~ /o/
Truth table33%1/3
A and B
A= $mode eq "+h"B= $record->{"users"}{$arg} =~ /o/
ABresult
0X0
100
111
3466 0 next;
3467 }
3468 1 ▶ if ($char eq 'h' && $record->{users}{$arg} =~ /v/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "h" and $record->{"users"}{$arg} =~ /v/) 0 1 1
Condition33%1/3
$char eq "h" and $record->{"users"}{$arg} =~ /v/
!ll&&!rl&&r
100
MC/DC0%0/2
$char eq "h" and $record->{"users"}{$arg} =~ /v/
$char eq "h" $record->{"users"}{$arg} =~ /v/
Truth table33%1/3
A and B
A= $char eq "h"B= $record->{"users"}{$arg} =~ /v/
ABresult
0X0
100
111
3469 0 $record->{users}{$arg} =~ s/v//g;
3470 0 $reply .= '-v';
3471 0 push @reply_args, $self->state_user_nick($arg);
3472 }
3473 1 ▶ if ($char eq 'o' && $record->{users}{$arg} =~ /h/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o" and $record->{"users"}{$arg} =~ /h/) 0 1 1
Condition33%1/3
$char eq "o" and $record->{"users"}{$arg} =~ /h/
!ll&&!rl&&r
010
MC/DC0%0/2
$char eq "o" and $record->{"users"}{$arg} =~ /h/
$char eq "o" $record->{"users"}{$arg} =~ /h/
Truth table33%1/3
A and B
A= $char eq "o"B= $record->{"users"}{$arg} =~ /h/
ABresult
0X0
100
111
3474 0 $record->{users}{$arg} =~ s/h//g;
3475 0 $reply .= '-h';
3476 0 push @reply_args, $self->state_user_nick($arg);
3477 }
3478 $record->{users}{$arg} = join('', sort
3479 1 split //, $record->{users}{$arg} . $char);
3480 $self->{state}{users}{$arg}{chans}{uc_irc($chan)}
3481 1 = $record->{users}{$arg};
3482 1 $reply .= $mode;
3483 1 push @reply_args, $self->state_user_nick($arg);
3484 }
3485  
3486 1 ▶ if ($flag eq '-' && $record->{users}{uc_irc($arg)}
Branch: 1 branch
BranchTrueFalseTotal
if ($flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/) 0 1 1
Condition33%1/3
$flag eq "-" and $record->{"users"}{uc_irc($arg)} =~ /$char/
!ll&&!rl&&r
100
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
3487 =~ /$char/) {
3488 # Update user and chan record
3489 0 $arg = uc_irc($arg);
3490 0 $record->{users}{$arg} =~ s/$char//g;
3491 $self->{state}{users}{$arg}{chans}{uc_irc($chan)}
3492 0 = $record->{users}{$arg};
3493 0 $reply .= $mode;
3494 0 push @reply_args, $self->state_user_nick($arg);
3495 }
3496 1 next;
3497 }
3498 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
3499 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3500 0 $reply .= $mode;
3501 0 push @reply_args, $arg;
3502 0 ▶ if ($record->{mode} !~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /l/) 0 0 0
3503 $record->{mode} = join('', sort
3504 0 split //, $record->{mode} . 'l');
3505 }
3506 0 $record->{climit} = $arg;
3507 0 next;
3508 }
3509 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
3510 0 $record->{mode} =~ s/l//g;
3511 0 delete $record->{climit};
3512 0 $reply .= $mode;
3513 0 next;
3514 }
3515 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
3516 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3517 0 $reply .= $mode;
3518 0 push @reply_args, $arg;
3519 0 ▶ if ($record->{mode} !~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /k/) 0 0 0
3520 $record->{mode} = join('', sort
3521 0 split //, $record->{mode} . 'k');
3522 }
3523 0 $record->{ckey} = $arg;
3524 0 next;
3525 }
3526 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
3527 0 $reply .= $mode;
3528 0 push @reply_args, '*';
3529 0 $record->{mode} =~ s/k//g;
3530 0 delete $record->{ckey};
3531 0 next;
3532 }
3533 # Bans
3534 0 ▶ if (my ($flag) = $mode =~ /([-+])b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])b/) 0 0 0
3535 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3536 0 my $mask = normalize_mask($arg);
3537 0 my $umask = uc_irc $mask;
3538 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
3539 0 $record->{bans}{$umask}
3540 = [$mask, $self->state_user_full($nick), time];
3541 0 $reply .= $mode;
3542 0 push @reply_args, $mask;
3543 }
3544 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
3545 0 delete $record->{bans}{$umask};
3546 0 $reply .= $mode;
3547 0 push @reply_args, $mask;
3548 }
3549 0 next;
3550 }
3551 # Invex
3552 0 ▶ if (my ($flag) = $mode =~ /([-+])I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])I/) 0 0 0
3553 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3554 0 my $mask = normalize_mask( $arg );
3555 0 my $umask = uc_irc $mask;
3556  
3557 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
3558 0 $record->{invex}{$umask}
3559 = [$mask, $self->state_user_full($nick), time];
3560 0 $reply .= $mode;
3561 0 push @reply_args, $mask;
3562 }
3563 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
3564 0 delete $record->{invex}{$umask};
3565 0 $reply .= $mode;
3566 0 push @reply_args, $mask;
3567 }
3568 0 next;
3569 }
3570 # Exceptions
3571 0 ▶ if (my ($flag) = $mode =~ /([-+])e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /([-+])e/) 0 0 0
3572 0 ▶ next if ++$mode_count > $maxmodes;
Branch: 1 branch
BranchTrueFalseTotal
if ++$mode_count > $maxmodes 0 0 0
3573 0 my $mask = normalize_mask($arg);
3574 0 my $umask = uc_irc($mask);
3575  
3576 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
3577 0 $record->{excepts}{$umask}
3578 = [$mask, $self->state_user_full($nick), time];
3579 0 $reply .= $mode;
3580 0 push @reply_args, $mask;
3581 }
3582 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
3583 0 delete $record->{excepts}{$umask};
3584 0 $reply .= $mode;
3585 0 push @reply_args, $mask;
3586 }
3587 0 next;
3588 }
3589 # The rest should be argumentless.
3590 0 my ($flag, $char) = split //, $mode;
3591 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
3592 0 $reply .= $mode;
3593 $record->{mode} = join('', sort
3594 0 split //, $record->{mode} . $char);
3595 0 next;
3596 }
3597 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
3598 0 $reply .= $mode;
3599 0 $record->{mode} =~ s/$char//g;
3600 0 next;
3601 }
3602 } # while
3603  
3604 1 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 1 0 1
3605 1 $reply = unparse_mode_line($reply);
3606 1 my $output = {
3607 prefix => $self->state_user_full($nick),
3608 command => 'MODE',
3609 params => [$chan, $reply, @reply_args],
3610 colonify => 0,
3611 };
3612 1 $self->_send_output_to_channel($chan, $output);
3613 }
3614 } # SWITCH
3615  
3616 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
3617 0 return $ref;
3618 }
3619  
3620 sub _daemon_cmd_join {
3621 9 ▶ my $self = shift;
Subroutine _daemon_cmd_join: called CC=41 SCAR=51.1
3622 9 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
90
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
3623 9 my $server = $self->server_name();
3624 9 my $ref = [ ];
3625 9 my $args = [@_];
3626 9 my $count = @$args;
3627 9 my $route_id = $self->_state_user_route($nick);
3628 9 my $unick = uc_irc($nick);
3629  
3630 SWITCH: {
3631 9 my (@channels, @chankeys);
3632 9 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 9 9
3633 0 push @$ref, ['461', 'JOIN'];
3634 0 last SWITCH;
3635 }
3636  
3637 9 @channels = split /,/, $args->[0];
3638 9 ▶ @chankeys = split /,/, $args->[1] if $args->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[1] 0 9 9
3639 9 my $channel_length = $self->server_config('CHANNELLEN');
3640  
3641 9 LOOP: for my $channel (@channels) {
3642 9 my $uchannel = uc_irc($channel);
3643 9 ▶ if ($channel eq '0'
Branch: 1 branch
BranchTrueFalseTotal
if ($channel eq 0 and my(@chans) = $self->state_user_chans($nick)) 0 9 9
Condition33%1/3
$channel eq 0 and my(@chans) = $self->state_user_chans($nick)
!ll&&!rl&&r
900
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
3644 and my @chans = $self->state_user_chans($nick)) {
3645 $self->_send_output_to_client(
3646 $route_id,
3647 (ref $_ eq 'ARRAY' ? @$_ : $_),
3648 0 ▶ ) for map { $self->_daemon_cmd_part($nick, $_) } @chans;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
3649 0 next LOOP;
3650 }
3651 # Channel isn't valid
3652 9 ▶ if (!is_valid_chan_name($channel)
Branch: 1 branch
BranchTrueFalseTotal
if (not is_valid_chan_name($channel) or length $channel > $channel_length) 0 9 9
Condition33%1/3
not is_valid_chan_name($channel) or length $channel > $channel_length
l!l&&r!l&&!r
009
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
3653 || length $channel > $channel_length) {
3654 0 $self->_send_output_to_client(
3655 $route_id,
3656 '403',
3657 $channel,
3658 );
3659 0 next LOOP;
3660 }
3661 # Too many channels
3662 9 ▶ if ($self->state_user_chans($nick)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") and not $self->state_user_is_operator($nick)) 0 9 9
Condition33%1/3
$self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
900
MC/DC0%0/2
$self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") and not $self->state_user_is_operator($nick)
$self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS") not $self->state_user_is_operator($nick)
Truth table33%1/3
A and not(B)
A= $self->state_user_chans($nick) >= $self->server_config("MAXCHANNELS")B= not $self->state_user_is_operator($nick)
ABresult
0X0
100
111
3663 >= $self->server_config('MAXCHANNELS')
3664 && !$self->state_user_is_operator($nick)) {
3665 0 $self->_send_output_to_client(
3666 $route_id,
3667 '405',
3668 $channel,
3669 );
3670 0 next LOOP;
3671 }
3672 # Channel doesn't exist
3673 9 ▶ if (!$self->state_chan_exists($channel)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($channel)) 6 3 9
3674 6 my $record = {
3675 name => $channel,
3676 ts => time,
3677 mode => 'nt',
3678 users => { $unick => 'o' },
3679 };
3680 6 $self->{state}{chans}{$uchannel} = $record;
3681 6 $self->{state}{users}{$unick}{chans}{$uchannel} = 'o';
3682 6 my @peers = $self->_state_connected_peers();
3683 $self->send_output(
3684 {
3685 command => 'SJOIN',
3686 params => [
3687 $record->{ts},
3688 $channel,
3689 '+' . $record->{mode},
3690 6 ▶ '@' . $nick,
Branch: 1 branch
BranchTrueFalseTotal
unless $channel =~ /^&/ 6 0 6
3691 ],
3692 },
3693 @peers,
3694 ) if $channel !~ /^&/;
3695 6 my $output = {
3696 prefix => $self->state_user_full($nick),
3697 command => 'JOIN',
3698 params => [$channel],
3699 };
3700 6 $self->send_output($output, $route_id);
3701 $self->send_event(
3702 "daemon_join",
3703 $output->{prefix},
3704 6 $channel,
3705 );
3706 $self->send_output(
3707 {
3708 prefix => $server,
3709 command => 'MODE',
3710 6 params => [$channel, '+' . $record->{mode}],
3711 },
3712 $route_id,
3713 );
3714 $self->_send_output_to_client(
3715 $route_id,
3716 (ref $_ eq 'ARRAY' ? @$_ : $_),
3717 6 ▶ ) for $self->_daemon_cmd_names($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 12 12
3718 $self->_send_output_to_client(
3719 $route_id,
3720 (ref $_ eq 'ARRAY' ? @$_ : $_ ),
3721 6 ▶ ) for $self->_daemon_cmd_topic($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 6 6
3722 6 next LOOP;
3723 }
3724 # Numpty user is already on channel
3725 3 ▶ if ($self->state_is_chan_member($nick, $channel)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($nick, $channel)) 0 3 3
3726 0 next LOOP;
3727 }
3728 3 my $chanrec = $self->{state}{chans}{$uchannel};
3729 3 my $bypass;
3730 3 ▶ if ($self->state_user_is_operator($nick)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_user_is_operator($nick) and $self->{"config"}{"OPHACKS"}) 0 3 3
Condition66%2/3
$self->state_user_is_operator($nick) and $self->{"config"}{"OPHACKS"}
!ll&&!rl&&r
210
MC/DC0%0/2
$self->state_user_is_operator($nick) and $self->{"config"}{"OPHACKS"}
$self->state_user_is_operator($nick) $self->{"config"}{"OPHACKS"}
Truth table66%2/3
A and B
A= $self->state_user_is_operator($nick)B= $self->{"config"}{"OPHACKS"}
ABresult
0X0
100
111
3731 && $self->{config}{OPHACKS}) {
3732 0 $bypass = 1;
3733 }
3734 # Channel is full
3735 3 ▶ if (!$bypass && $chanrec->{mode} =~ /l/
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $chanrec->{"mode"} =~ /l/ and keys %$chanrec >= $chanrec->{"climit"}) 0 3 3
Condition33%2/6
not $bypass and $chanrec->{"mode"} =~ /l/ and keys %$chanrec >= $chanrec->{"climit"}
!ll&&!rl&&r
300
not $bypass and $chanrec->{"mode"} =~ /l/
!ll&&!rl&&r
030
MC/DC0%0/3
not $bypass and $chanrec->{"mode"} =~ /l/ and keys %$chanrec >= $chanrec->{"climit"}
not $bypass $chanrec->{"mode"} =~ /l/ keys %$chanrec >= $chanrec->{"climit"}
Truth table25%1/4
not(A) and B and C
A= not $bypassB= $chanrec->{"mode"} =~ /l/C= keys %$chanrec >= $chanrec->{"climit"}
ABCresult
0XX0
10X0
1100
1111
3736 && keys %$chanrec >= $chanrec->{climit}) {
3737 0 $self->_send_output_to_client($route_id, '471', $channel);
3738 0 next LOOP;
3739 }
3740 3 my $chankey;
3741 3 ▶ $chankey = shift @chankeys if $chanrec->{mode} =~ /k/;
Branch: 1 branch
BranchTrueFalseTotal
if $chanrec->{"mode"} =~ /k/ 0 3 3
3742 # Channel +k and no key or invalid key provided
3743 3 ▶ if (!$bypass && $chanrec->{mode} =~ /k/
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $chanrec->{"mode"} =~ /k/ and !$chankey || $chankey ne $chanrec->{"ckey"}) 0 3 3
Condition22%2/9
not $bypass and $chanrec->{"mode"} =~ /k/ and !$chankey || $chankey ne $chanrec->{"ckey"}
!ll&&!rl&&r
300
not $bypass and $chanrec->{"mode"} =~ /k/
!ll&&!rl&&r
030
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
3744 && (!$chankey || $chankey ne $chanrec->{ckey})) {
3745 0 $self->_send_output_to_client($route_id, '475', $channel);
3746 0 next LOOP;
3747 }
3748 # Channel +i and not INVEX
3749 3 ▶ if (!$bypass && $chanrec->{mode} =~ /i/
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $chanrec->{"mode"} =~ /i/ and not $self->_state_user_invited($nick, $channel)) 0 3 3
Condition33%2/6
not $bypass and $chanrec->{"mode"} =~ /i/ and not $self->_state_user_invited($nick, $channel)
!ll&&!rl&&r
300
not $bypass and $chanrec->{"mode"} =~ /i/
!ll&&!rl&&r
030
MC/DC0%0/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 table25%1/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
3750 && !$self->_state_user_invited($nick, $channel)) {
3751 0 $self->_send_output_to_client($route_id, '473', $channel);
3752 0 next LOOP;
3753 }
3754 # Channel +b and no exception
3755 3 ▶ if (!$bypass && $self->_state_user_banned($nick, $channel)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $bypass and $self->_state_user_banned($nick, $channel)) 0 3 3
Condition33%1/3
not $bypass and $self->_state_user_banned($nick, $channel)
!ll&&!rl&&r
030
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
3756 0 $self->_send_output_to_client($route_id, '474', $channel);
3757 0 next LOOP;
3758 }
3759 # JOIN the channel
3760 3 delete $self->{state}{users}{$unick}{invites}{$uchannel};
3761 # Add user
3762 3 $self->{state}{users}{$unick}{chans}{$uchannel} = '';
3763 3 $self->{state}{chans}{$uchannel}{users}{$unick} = '';
3764 # Send JOIN message to peers and local users.
3765 $self->send_output(
3766 {
3767 prefix => $server,
3768 command => 'SJOIN',
3769 3 ▶ params => [$chanrec->{ts}, $channel, '+', $nick],
Branch: 1 branch
BranchTrueFalseTotal
unless $channel =~ /^&/ 3 0 3
3770 },
3771 $self->_state_connected_peers(),
3772 ) if $channel !~ /^&/;
3773  
3774 3 my $output = {
3775 prefix => $self->state_user_full($nick),
3776 command => 'JOIN',
3777 params => [$channel],
3778 };
3779 3 $self->_send_output_to_client($route_id, $output);
3780 3 $self->_send_output_to_channel($channel, $output, $route_id);
3781  
3782 # Send NAMES and TOPIC to client
3783 $self->_send_output_to_client(
3784 $route_id,
3785 (ref $_ eq 'ARRAY' ? @$_ : $_),
3786 3 ▶ ) for $self->_daemon_cmd_names($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 6 6
3787 $self->_send_output_to_client(
3788 $route_id,
3789 (ref $_ eq 'ARRAY' ? @$_ : $_),
3790 3 ▶ ) for $self->_daemon_cmd_topic($nick, $channel);
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 3 3
3791 }
3792 }
3793  
3794 9 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 8 1 9
3795 1 return $ref;
3796 }
3797  
3798 sub _daemon_cmd_part {
3799 0 ▶ my $self = shift;
Subroutine _daemon_cmd_part: not called CC=8 SCAR=42.8
3800 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
3801 0 my $chan = shift;
3802 0 my $server = $self->server_name();
3803 0 my $ref = [ ];
3804 0 my $args = [@_];
3805 0 my $count = @$args;
3806  
3807 SWITCH: {
3808 0 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 0 0 0
3809 0 push @$ref, ['461', 'PART'];
3810 0 last SWITCH;
3811 }
3812 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
3813 0 push @$ref, ['403', $chan];
3814 0 last SWITCH;
3815 }
3816 0 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 0 0
3817 0 push @$ref, ['442', $chan];
3818 0 last SWITCH;
3819 }
3820 $self->_send_output_to_channel(
3821 0 ▶ $chan,
Condition0%0/3
$args->[0] || $nick
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[0] || $nick
$args->[0] $nick
Truth table0%0/3
A || B
A= $args->[0]B= $nick
ABresult
1X1
011
000
3822 {
3823 prefix => $self->state_user_full($nick),
3824 command => 'PART',
3825 params => [$chan, ($args->[0] || $nick)],
3826 },
3827 );
3828 0 $nick = uc_irc($nick);
3829 0 $chan = uc_irc($chan);
3830 0 delete $self->{state}{chans}{$chan}{users}{$nick};
3831 0 delete $self->{state}{users}{$nick}{chans}{$chan};
3832 0 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
3833 0 delete $self->{state}{chans}{$chan};
3834 }
3835 }
3836  
3837 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3838 0 return $ref;
3839 }
3840  
3841 sub _daemon_cmd_kick {
3842 0 ▶ my $self = shift;
Subroutine _daemon_cmd_kick: not called CC=11 SCAR=48.8
3843 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
3844 0 my $server = $self->server_name();
3845 0 my $ref = [ ];
3846 0 my $args = [@_];
3847 0 my $count = @$args;
3848  
3849 SWITCH: {
3850 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
3851 0 push @$ref, ['461', 'KICK'];
3852 0 last SWITCH;
3853 }
3854 0 my $chan = (split /,/, $args->[0])[0];
3855 0 my $who = (split /,/, $args->[1])[0];
3856 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
3857 0 push @$ref, ['403', $chan];
3858 0 last SWITCH;
3859 }
3860 0 $chan = $self->_state_chan_name($chan);
3861 0 ▶ if (!$self->state_nick_exists($who) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
3862 0 push @$ref, ['401', $who];
3863 0 last SWITCH;
3864 }
3865 0 $who = $self->state_user_nick($who);
3866 0 ▶ if (!$self->state_is_chan_op($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_op($nick, $chan)) 0 0 0
3867 0 push @$ref, ['482', $chan];
3868 0 last SWITCH;
3869 }
3870 0 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 0 0
3871 0 push @$ref, ['441', $who, $chan];
3872 0 last SWITCH;
3873 }
3874 0 ▶ my $comment = $args->[2] || $who;
Condition0%0/3
$args->[2] || $who
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[2] || $who
$args->[2] $who
Truth table0%0/3
A || B
A= $args->[2]B= $who
ABresult
1X1
011
000
3875 0 $self->_send_output_to_channel(
3876 $chan,
3877 {
3878 prefix => $self->state_user_full($nick),
3879 command => 'KICK',
3880 params => [$chan, $who, $comment],
3881 },
3882 );
3883 0 $who = uc_irc($who);
3884 0 $chan = uc_irc($chan);
3885 0 delete $self->{state}{chans}{$chan}{users}{$who};
3886 0 delete $self->{state}{users}{$who}{chans}{$chan};
3887 0 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
3888 0 delete $self->{state}{chans}{$chan};
3889 }
3890 }
3891  
3892 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3893 0 return $ref;
3894 }
3895  
3896 sub _daemon_cmd_remove {
3897 0 ▶ my $self = shift;
Subroutine _daemon_cmd_remove: not called CC=11 SCAR=48.8
3898 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
3899 0 my $server = $self->server_name();
3900 0 my $ref = [ ];
3901 0 my $args = [@_];
3902 0 my $count = @$args;
3903  
3904 SWITCH: {
3905 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
3906 0 push @$ref, ['461', 'REMOVE'];
3907 0 last SWITCH;
3908 }
3909 0 my $chan = (split /,/, $args->[0])[0];
3910 0 my $who = (split /,/, $args->[1])[0];
3911 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
3912 0 push @$ref, ['403', $chan];
3913 0 last SWITCH;
3914 }
3915 0 $chan = $self->_state_chan_name($chan);
3916 0 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
3917 0 push @$ref, ['401', $who];
3918 0 last SWITCH;
3919 }
3920 0 my $fullwho = $self->state_user_full($who);
3921 0 $who = (split /!/, $fullwho)[0];
3922 0 ▶ if (!$self->state_is_chan_op($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_op($nick, $chan)) 0 0 0
3923 0 push @$ref, ['482', $chan];
3924 0 last SWITCH;
3925 }
3926 0 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 0 0
3927 0 push @$ref, ['441', $who, $chan];
3928 0 last SWITCH;
3929 }
3930 0 my $comment = "Requested by $nick";
3931 0 ▶ $comment .= qq{ "$args->[2]"} if $args->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[2] 0 0 0
3932 0 $self->_send_output_to_channel(
3933 $chan,
3934 {
3935 prefix => $fullwho,
3936 command => 'PART',
3937 params => [$chan, $comment],
3938 },
3939 );
3940 0 $who = uc_irc($who);
3941 0 $chan = uc_irc($chan);
3942 0 delete $self->{state}{chans}{$chan}{users}{$who};
3943 0 delete $self->{state}{users}{$who}{chans}{$chan};
3944 0 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
3945 0 delete $self->{state}{chans}{$chan};
3946 }
3947 }
3948  
3949 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
3950 0 return $ref;
3951 }
3952  
3953 sub _daemon_cmd_invite {
3954 0 ▶ my $self = shift;
Subroutine _daemon_cmd_invite: not called CC=15 SCAR=54.8
3955 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
3956 0 my $server = $self->server_name();
3957 0 my $ref = [ ];
3958 0 my $args = [@_];
3959 0 my $count = @$args;
3960  
3961 SWITCH: {
3962 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
3963 0 push @$ref, ['461', 'INVITE'];
3964 0 last SWITCH;
3965 }
3966 0 my ($who, $chan) = @$args;
3967 0 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
3968 0 push @$ref, ['401', $who];
3969 0 last SWITCH;
3970 }
3971 0 $who = $self->state_user_nick($who);
3972 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
3973 0 push @$ref, ['403', $chan];
3974 0 last SWITCH;
3975 }
3976 0 $chan = $self->_state_chan_name($chan);
3977 0 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 0 0
3978 0 push @$ref, ['442', $chan];
3979 0 last SWITCH;
3980 }
3981 0 ▶ if ($self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_is_chan_member($who, $chan)) 0 0 0
3982 0 push @$ref, ['443', $who, $chan];
3983 0 last SWITCH;
3984 }
3985 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)) 0 0 0
Condition0%0/3
$self->state_chan_mode_set($chan, "i") and not $self->state_is_chan_op($nick, $chan)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->state_chan_mode_set($chan, "i") and not $self->state_is_chan_op($nick, $chan)
$self->state_chan_mode_set($chan, "i") not $self->state_is_chan_op($nick, $chan)
Truth table0%0/3
A and not(B)
A= $self->state_chan_mode_set($chan, "i")B= not $self->state_is_chan_op($nick, $chan)
ABresult
0X0
100
111
3986 && !$self->state_is_chan_op($nick, $chan)) {
3987 0 push @$ref, ['482', $chan];
3988 0 last SWITCH;
3989 }
3990 0 my $local;
3991 0 ▶ if ($self->_state_is_local_user($who)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($who)) 0 0 0
3992 0 my $record = $self->{state}{users}{uc_irc($who)};
3993 0 $record->{invites}{uc_irc($chan)} = time;
3994 0 $local = 1;
3995 }
3996 0 my $away = $self->_state_user_away_msg($who);
3997 0 my $route_id = $self->_state_user_route($who);
3998 0 my $output = {
3999 prefix => $self->state_user_full($nick),
4000 command => 'INVITE',
4001 params => [$who, $chan],
4002 colonify => 0,
4003 };
4004 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
4005 $self->send_event(
4006 "daemon_invite",
4007 $output->{prefix},
4008 0 @{ $output->{params} }
4009 );
4010 }
4011 else {
4012 0 ▶ if (!$local) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($local) 0 0 0
4013 0 $output->{prefix} = $nick;
4014 0 push @{ $output->{params} }, time;
4015 }
4016 0 $self->send_output($output, $route_id);
4017 }
4018 0 push @$ref, {
4019 prefix => $server,
4020 command => '341',
4021 params => [$chan, $who],
4022 };
4023 0 ▶ if (defined $away) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $away) 0 0 0
4024 0 push @$ref, {
4025 prefix => $server,
4026 command => '301',
4027 params => [$nick, $who, $away],
4028 };
4029 }
4030 }
4031  
4032 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4033 0 return $ref;
4034 }
4035  
4036 sub _daemon_cmd_umode {
4037 17 ▶ my $self = shift;
Subroutine _daemon_cmd_umode: called CC=25 SCAR=44.0
4038 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
4039 17 my $umode = shift;
4040 17 my $server = $self->server_name();
4041 17 my $ref = [ ];
4042 17 my $record = $self->{state}{users}{uc_irc($nick)};
4043  
4044 17 ▶ if (!$umode) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $umode) { } 1 16 17
4045 push @$ref, {
4046 prefix => $server,
4047 command => '221',
4048 1 params => [$nick, '+' . $record->{umode}],
4049 };
4050 }
4051 else {
4052 16 my $peer_ignore;
4053 16 my $parsed_mode = parse_mode_line($umode);
4054 16 my $route_id = $self->_state_user_route($nick);
4055 16 my $previous = $record->{umode};
4056  
4057 16 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 16 16 32
4058 16 ▶ next if $mode eq '+o';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+o" 0 16 16
4059 16 my ($action, $char) = split //, $mode;
4060 16 ▶ if ($action eq '+' && $record->{umode} !~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "+" and not $record->{"umode"} =~ /$char/) 16 0 16
Condition33%1/3
$action eq "+" and not $record->{"umode"} =~ /$char/
!ll&&!rl&&r
0016
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
4061 16 ▶ next if $char =~ /[wzl]a/ && $record->{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $char =~ /[wzl]a/ and not $record->{"umode"} =~ /o/ 0 16 16
Condition33%1/3
$char =~ /[wzl]a/ and not $record->{"umode"} =~ /o/
!ll&&!rl&&r
1600
MC/DC0%0/2
$char =~ /[wzl]a/ and not $record->{"umode"} =~ /o/
$char =~ /[wzl]a/ not $record->{"umode"} =~ /o/
Truth table33%1/3
A and not(B)
A= $char =~ /[wzl]a/B= not $record->{"umode"} =~ /o/
ABresult
0X0
100
111
4062 16 $record->{umode} .= $char;
4063 16 ▶ if ($char eq 'i') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "i") 16 0 16
4064 16 $self->{state}{stats}{invisible}++;
4065 16 $peer_ignore = delete $record->{_ignore_i_umode};
4066 }
4067 16 ▶ if ($char eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w") 0 16 16
4068 0 $self->{state}{wallops}{$route_id} = time;
4069 }
4070 16 ▶ if ($char eq 'z') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "z") 0 16 16
4071 0 $self->{state}{operwall}{$route_id} = time;
4072 }
4073 16 ▶ if ($char eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l") 0 16 16
4074 0 $self->{state}{locops}{$route_id} = time;
4075 }
4076 }
4077 16 ▶ if ($action eq '-' && $record->{umode} =~ /$char/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "-" and $record->{"umode"} =~ /$char/) 0 16 16
Condition33%1/3
$action eq "-" and $record->{"umode"} =~ /$char/
!ll&&!rl&&r
1600
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
4078 0 $record->{umode} =~ s/$char//g;
4079 0 ▶ $self->{state}{stats}{invisible}-- if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
4080  
4081 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
4082 0 $self->{state}{stats}{ops_online}--;
4083 0 delete $self->{state}{localops}{$route_id};
4084 0 $self->antiflood( $route_id, 1);
4085 }
4086 0 ▶ if ($char eq 'w') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "w") 0 0 0
4087 0 delete $self->{state}{wallops}{$route_id};
4088 }
4089 0 ▶ if ($char eq 'z') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "z") 0 0 0
4090 0 delete $self->{state}{operwall}{$route_id};
4091 }
4092 0 ▶ if ($char eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "l") 0 0 0
4093 0 delete $self->{state}{locops}{$route_id};
4094 }
4095 }
4096 }
4097  
4098 16 $record->{umode} = join '', sort split //, $record->{umode};
4099 16 my $peerprev = $previous;
4100 16 my $peerumode = $record->{umode};
4101 16 $peerprev =~ s/[^aiow]//g;
4102 16 $peerumode =~ s/[^aiow]//g;
4103 16 my $pset = gen_mode_change($peerprev, $peerumode);
4104 16 my $set = gen_mode_change($previous, $record->{umode});
4105 16 ▶ if ($pset && !$peer_ignore ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pset and not $peer_ignore) 0 16 16
Condition33%1/3
$pset and not $peer_ignore
!ll&&!rl&&r
0160
MC/DC0%0/2
$pset and not $peer_ignore
$pset not $peer_ignore
Truth table33%1/3
A and not(B)
A= $psetB= not $peer_ignore
ABresult
0X0
100
111
4106 0 my $hashref = {
4107 prefix => $nick,
4108 command => 'MODE',
4109 params => [$nick, $pset],
4110 };
4111 0 $self->send_output(
4112 $hashref,
4113 $self->_state_connected_peers(),
4114 );
4115 }
4116 16 ▶ if ($set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set) 16 0 16
4117 16 my $hashref = {
4118 prefix => $nick,
4119 command => 'MODE',
4120 params => [$nick, $set],
4121 };
4122 16 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
unless $peer_ignore 0 16 16
4123 "daemon_umode",
4124 $self->state_user_full($nick),
4125 $set
4126 ) if !$peer_ignore;
4127 16 push @$ref, $hashref;
4128 }
4129 }
4130  
4131 17 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 17 0 17
4132 0 return $ref;
4133 }
4134  
4135 sub _daemon_cmd_topic {
4136 11 ▶ my $self = shift;
Subroutine _daemon_cmd_topic: called CC=15 SCAR=34.4
4137 11 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
110
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
4138 11 my $server = $self->server_name();
4139 11 my $ref = [ ];
4140 11 my $args = [@_];
4141 11 my $count = @$args;
4142  
4143 SWITCH:{
4144 11 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 11 11
4145 0 push @$ref, ['461', 'TOPIC'];
4146 0 last SWITCH;
4147 }
4148 11 ▶ if (!$self->state_chan_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($args->[0])) 0 11 11
4149 0 push @$ref, ['403', $args->[0]];
4150 0 last SWITCH;
4151 }
4152 11 ▶ 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 11 11
Condition33%1/3
$self->state_chan_mode_set($args->[0], "s") and not $self->state_is_chan_member($nick, $args->[0])
!ll&&!rl&&r
1100
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
4153 && !$self->state_is_chan_member($nick, $args->[0])) {
4154 0 push @$ref, ['442', $args->[0]];
4155 0 last SWITCH;
4156 }
4157 11 my $chan_name = $self->_state_chan_name($args->[0]);
4158 11 ▶ if ($count == 1
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 1 and my $topic = $self->state_chan_topic($args->[0])) 0 11 11
Condition66%2/3
$count == 1 and my $topic = $self->state_chan_topic($args->[0])
!ll&&!rl&&r
290
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
4159 and my $topic = $self->state_chan_topic($args->[0])) {
4160 0 push @$ref, {
4161 prefix => $server,
4162 command => '332',
4163 params => [$nick, $chan_name, $topic->[0]],
4164 };
4165 push @$ref, {
4166 prefix => $server,
4167 command => '333',
4168 0 params => [$nick, $chan_name, @{ $topic }[1..2]],
4169 };
4170 0 last SWITCH;
4171 }
4172 11 ▶ if ($count == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 1) 9 2 11
4173 9 push @$ref, {
4174 prefix => $server,
4175 command => '331',
4176 params => [$nick, $chan_name, 'No topic is set'],
4177 };
4178 9 last SWITCH;
4179 }
4180 2 ▶ if (!$self->state_is_chan_member($nick, $args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $args->[0])) 0 2 2
4181 0 push @$ref, ['442', $args->[0]];
4182 0 last SWITCH;
4183 }
4184 2 ▶ 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 2 2
Condition33%1/3
$self->state_chan_mode_set($args->[0], "t") and not $self->state_is_chan_op($nick, $args->[0])
!ll&&!rl&&r
020
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
4185 && !$self->state_is_chan_op($nick, $args->[0])) {
4186 0 push @$ref, ['482', $args->[0]];
4187 0 last SWITCH;
4188 }
4189 2 my $record = $self->{state}{chans}{uc_irc($args->[0])};
4190 2 my $topic_length = $self->server_config('TOPICLEN');
4191 2 ▶ if (length $args->[0] > $topic_length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $args->[0] > $topic_length) 0 2 2
4192 0 $args->[1] = substr $args->[0], 0, $topic_length;
4193 }
4194 2 ▶ if ($args->[1] eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[1] eq '') { } 1 1 2
4195 1 delete $record->{topic};
4196 }
4197 else {
4198 $record->{topic} = [
4199 1 $args->[1],
4200 $self->state_user_full($nick),
4201 time,
4202 ];
4203 }
4204 2 $self->_send_output_to_channel(
4205 $args->[0],
4206 {
4207 prefix => $self->state_user_full($nick),
4208 command => 'TOPIC',
4209 params => [$chan_name, $args->[1]],
4210 },
4211 );
4212 }
4213  
4214 11 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 11 0 11
4215 0 return $ref;
4216 }
4217  
4218 sub _daemon_cmd_links {
4219 0 ▶ my $self = shift;
Subroutine _daemon_cmd_links: not called CC=8 SCAR=42.8
4220 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
4221 0 my $target = shift;
4222 0 my $server = $self->server_name();
4223 0 my $ref = [ ];
4224  
4225 SWITCH:{
4226 0 ▶ if ($target && !$self->state_peer_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and not $self->state_peer_exists($target)) 0 0 0
Condition0%0/3
$target and not $self->state_peer_exists($target)
!ll&&!rl&&r
000
MC/DC0%0/2
$target and not $self->state_peer_exists($target)
$target not $self->state_peer_exists($target)
Truth table0%0/3
A and not(B)
A= $targetB= not $self->state_peer_exists($target)
ABresult
0X0
100
111
4227 0 push @$ref, ['402', $target];
4228 0 last SWITCH;
4229 }
4230 0 ▶ if ($target && uc $server ne uc $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target and uc $server ne uc $target) 0 0 0
Condition0%0/3
$target and uc $server ne uc $target
!ll&&!rl&&r
000
MC/DC0%0/2
$target and uc $server ne uc $target
$target uc $server ne uc $target
Truth table0%0/3
A and B
A= $targetB= uc $server ne uc $target
ABresult
0X0
100
111
4231 0 $self->send_output(
4232 {
4233 prefix => $nick,
4234 command => 'LINKS',
4235 params => [$self->_state_peer_name($target)],
4236 },
4237 $self->_state_peer_route($target)
4238 );
4239 0 last SWITCH;
4240 }
4241  
4242 0 for ($self->_state_server_links($server, $server, $nick)) {
4243 0 push @$ref, $_;
4244 }
4245 0 push @$ref, {
4246 prefix => $server,
4247 command => '364',
4248 params => [
4249 $nick,
4250 $server,
4251 $server,
4252 join( ' ', '0', $self->server_config('serverdesc'))
4253 ],
4254 };
4255 0 push @$ref, {
4256 prefix => $server,
4257 command => '365',
4258 params => [$nick, '*', 'End of /LINKS list.'],
4259 };
4260 }
4261  
4262 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4263 0 return $ref;
4264 }
4265  
4266 sub _daemon_peer_squit {
4267 0 ▶ my $self = shift;
Subroutine _daemon_peer_squit: not called CC=13 SCAR=52.0
4268 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
4269 0 my $ref = [ ];
4270 0 my $args = [ @_ ];
4271 0 my $count = @$args;
4272 0 ▶ return if !$self->state_peer_exists($args->[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($args->[0]) 0 0 0
4273  
4274 SWITCH: {
4275 0 ▶ if ($peer_id ne $self->_state_peer_route($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer_id ne $self->_state_peer_route($args->[0])) 0 0 0
4276 0 $self->send_output(
4277 {
4278 command => 'SQUIT',
4279 params => $args,
4280 },
4281 $self->_state_peer_route($args->[0]),
4282 );
4283 0 last SWITCH;
4284 }
4285 0 ▶ if ($peer_id eq $self->_state_peer_route($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($peer_id eq $self->_state_peer_route($args->[0])) 0 0 0
4286 $self->send_output(
4287 {
4288 command => 'SQUIT',
4289 params => $args,
4290 },
4291 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
4292 );
4293 0 $self->send_event("daemon_squit", @$args);
4294 0 my $quit_msg = join ' ',
4295 $self->_state_peer_for_peer($args->[0]), $args->[0];
4296  
4297 0 for my $nick ($self->_state_server_squit($args->[0])) {
4298 0 my $output = {
4299 prefix => $self->state_user_full($nick),
4300 command => 'QUIT',
4301 params => [$quit_msg],
4302 };
4303 0 my $common = { };
4304 0 for my $uchan ($self->state_user_chans($nick)) {
4305 0 $uchan = uc_irc($uchan);
4306 0 delete $self->{state}{chans}{$uchan}{users}{$nick};
4307 0 for my $user ($self->state_chan_list($uchan)) {
4308 0 ▶ next if !$self->_state_is_local_user($user);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_is_local_user($user) 0 0 0
4309 0 $common->{$user} = $self->_state_user_route($user);
4310 }
4311 0 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 0 0 0
4312 0 delete $self->{state}{chans}{$uchan};
4313 }
4314 }
4315 0 $self->send_output($output, values %$common);
4316 $self->send_event(
4317 "daemon_quit",
4318 $output->{prefix},
4319 0 $output->{params}[0],
4320 );
4321 0 my $record = delete $self->{state}{users}{$nick};
4322 0 ▶ if ($record->{umode} =~ /o/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /o/) 0 0 0
4323 0 $self->{state}{stats}{ops_online}--;
4324 }
4325 0 ▶ if ($record->{umode} =~ /i/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"umode"} =~ /i/) 0 0 0
4326 0 $self->{state}{stats}{invisible}--;
4327 }
4328 }
4329 0 last SWITCH;
4330 }
4331 }
4332  
4333 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4334 0 return $ref;
4335 }
4336  
4337 sub _daemon_peer_rkline {
4338 0 ▶ my $self = shift;
Subroutine _daemon_peer_rkline: not called CC=11 SCAR=48.8
4339 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
4340 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
4341 0 my $server = $self->server_name();
4342 0 my $ref = [ ];
4343 0 my $args = [ @_ ];
4344 0 my $count = @$args;
4345 # :klanker RKLINE logserv.gumbynet.org.uk 600 ^m.*\ foo\.(com|uk|net)$ :Foo
4346  
4347 SWITCH: {
4348 0 ▶ if (!$count || $count < 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 5) 0 0 0
Condition0%0/3
not $count or $count < 5
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 5
not $count $count < 5
Truth table0%0/3
not(A) or B
A= not $countB= $count < 5
ABresult
1X1
011
000
4349 0 last SWITCH;
4350 }
4351 0 my $full = $self->state_user_full($nick);
4352 0 my $target = $args->[0];
4353 0 my $us = 0;
4354 0 my $ucserver = uc $server;
4355 0 my %targets;
4356 0 for my $peer (keys %{ $self->{state}{peers} }) {
4357 0 ▶ if (matches_mask( $target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
4358 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
4359 0 $us = 1;
4360 }
4361 else {
4362 0 $targets{$self->_state_peer_route($peer)}++;
4363 }
4364 }
4365 }
4366  
4367 0 delete $targets{$peer_id};
4368 $self->send_output(
4369 {
4370 prefix => $nick,
4371 command => 'RKLINE',
4372 params => $args,
4373 colonify => 0,
4374 },
4375 0 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
4376 );
4377  
4378 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
4379 0 $self->send_event("daemon_rkline", $full, @$args);
4380 0 push @{ $self->{state}{rklines} }, {
4381 setby => $full,
4382 setat => time,
4383 target => $args->[0],
4384 duration => $args->[1],
4385 user => $args->[2],
4386 host => $args->[3],
4387 reason => $args->[4],
4388 };
4389 $self->_terminate_conn_error($_, 'K-Lined')
4390 0 for $self->_state_local_users_match_rkline($args->[2], $args->[3]);
4391 }
4392 }
4393  
4394 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4395 0 return $ref;
4396 }
4397  
4398 sub _daemon_peer_kline {
4399 0 ▶ my $self = shift;
Subroutine _daemon_peer_kline: not called CC=11 SCAR=48.8
4400 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
4401 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
4402 0 my $server = $self->server_name();
4403 0 my $ref = [ ];
4404 0 my $args = [ @_ ];
4405 0 my $count = @$args;
4406  
4407 SWITCH: {
4408 0 ▶ if (!$count || $count < 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 5) 0 0 0
Condition0%0/3
not $count or $count < 5
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 5
not $count $count < 5
Truth table0%0/3
not(A) or B
A= not $countB= $count < 5
ABresult
1X1
011
000
4409 0 last SWITCH;
4410 }
4411 0 my $full = $self->state_user_full($nick);
4412 0 my $target = $args->[0];
4413 0 my $us = 0;
4414 0 my $ucserver = uc $server;
4415 0 my %targets;
4416  
4417 0 for my $peer (keys %{ $self->{state}{peers} }) {
4418 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
4419 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
4420 0 $us = 1;
4421 }
4422 else {
4423 0 $targets{$self->_state_peer_route($peer)}++;
4424 }
4425 }
4426 }
4427 0 delete $targets{$peer_id};
4428 $self->send_output(
4429 {
4430 prefix => $nick,
4431 command => 'KLINE',
4432 params => $args,
4433 colonify => 0,
4434 },
4435 0 grep { $self->_state_peer_capab($_, 'KLN') } keys %targets,
4436 );
4437 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
4438 0 $self->send_event("daemon_kline", $full, @$args);
4439 0 push @{ $self->{state}{klines} }, {
4440 setby => $full,
4441 setat => time(),
4442 target => $args->[0],
4443 duration => $args->[1],
4444 user => $args->[2],
4445 host => $args->[3],
4446 reason => $args->[4],
4447 };
4448 $self->_terminate_conn_error($_, 'K-Lined')
4449 0 for $self->_state_local_users_match_gline($args->[2], $args->[3]);
4450 }
4451 }
4452  
4453 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4454 0 return $ref;
4455 }
4456  
4457 sub _daemon_peer_unkline {
4458 0 ▶ my $self = shift;
Subroutine _daemon_peer_unkline: not called CC=13 SCAR=52.0
4459 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
4460 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
4461 0 my $server = $self->server_name();
4462 0 my $ref = [ ];
4463 0 my $args = [ @_ ];
4464 0 my $count = @$args;
4465  
4466 # :klanker UNKLINE logserv.gumbynet.org.uk * moos.loud.me.uk
4467 SWITCH: {
4468 0 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 0 0
Condition0%0/3
not $count or $count < 3
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table0%0/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
4469 0 last SWITCH;
4470 }
4471 0 my $full = $self->state_user_full($nick);
4472 0 my $target = $args->[0];
4473 0 my $us = 0;
4474 0 my $ucserver = uc $server;
4475 0 my %targets;
4476  
4477 0 for my $peer (keys %{ $self->{state}{peers} }) {
4478 0 ▶ if (matches_mask($target, $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($target, $peer)) 0 0 0
4479 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
4480 0 $us = 1;
4481 }
4482 else {
4483 0 $targets{$self->_state_peer_route($peer)}++;
4484 }
4485 }
4486 }
4487 0 delete $targets{$peer_id};
4488 $self->send_output(
4489 {
4490 prefix => $nick,
4491 command => 'UNKLINE',
4492 params => $args,
4493 colonify => 0,
4494 },
4495 0 grep { $self->_state_peer_capab($_, 'UNKLN') } keys %targets,
4496 );
4497  
4498 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
4499 0 $self->send_event("daemon_unkline", $full, @$args);
4500 0 my $i = 0;
4501 0 for (@{ $self->{state}{klines} }) {
4502 0 ▶ if ($_->{user} eq $args->[1] && $_->{host} eq $args->[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"user"} eq $args->[1] and $_->{"host"} eq $args->[2]) 0 0 0
Condition0%0/3
$_->{"user"} eq $args->[1] and $_->{"host"} eq $args->[2]
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{"user"} eq $args->[1] and $_->{"host"} eq $args->[2]
$_->{"user"} eq $args->[1] $_->{"host"} eq $args->[2]
Truth table0%0/3
A and B
A= $_->{"user"} eq $args->[1]B= $_->{"host"} eq $args->[2]
ABresult
0X0
100
111
4503 0 splice (@{ $self->{state}{klines} }, $i, 1);
4504 0 last;
4505 }
4506 0 ++$i;
4507 }
4508 }
4509 }
4510  
4511 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4512 0 return $ref;
4513 }
4514  
4515 sub _daemon_peer_gline {
4516 0 ▶ my $self = shift;
Subroutine _daemon_peer_gline: not called CC=8 SCAR=42.8
4517 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
4518 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
4519 0 my $server = $self->server_name();
4520 0 my $ref = [ ];
4521 0 my $args = [ @_ ];
4522 0 my $count = @$args;
4523  
4524 # :klanker GLINE * meep.com :Fuckers
4525 SWITCH: {
4526 0 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 0 0
Condition0%0/3
not $count or $count < 3
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table0%0/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
4527 0 last SWITCH;
4528 }
4529 0 my $full = $self->state_user_full($nick);
4530 0 push @{ $self->{state}{glines} }, {
4531 setby => $full,
4532 setat => time,
4533 user => $args->[0],
4534 host => $args->[1],
4535 reason => $args->[2],
4536 };
4537 $self->send_output(
4538 {
4539 prefix => $nick,
4540 command => 'GLINE',
4541 params => $args,
4542 colonify => 0,
4543 },
4544 0 ▶ grep { $_ ne $peer_id && $self->_state_peer_capab($_, 'GLN') }
Branch: 1 branch
BranchTrueFalseTotal
$_ ne $peer_id and $self->_state_peer_capab($_, "GLN") 0 0 0
4545 $self->_state_connected_peers(),
4546 );
4547 0 $self->send_event("daemon_gline", $full, @$args);
4548 $self->_terminate_conn_error($_, 'G-Lined')
4549 0 for $self->_state_local_users_match_gline($args->[0], $args->[1]);
4550 }
4551  
4552 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4553 0 return $ref;
4554 }
4555  
4556 sub _daemon_peer_wallops {
4557 0 ▶ my $self = shift;
Subroutine _daemon_peer_wallops: not called CC=6 SCAR=37.4
4558 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
4559 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
4560 0 my $ref = [ ];
4561 0 my $args = [ @_ ];
4562 0 my $count = @$args;
4563  
4564 SWITCH: {
4565 0 ▶ my $full = $self->state_user_full($prefix) || $prefix;
Condition0%0/3
$self->state_user_full($prefix) || $prefix
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->state_user_full($prefix) || $prefix
$self->state_user_full($prefix) $prefix
Truth table0%0/3
A || B
A= $self->state_user_full($prefix)B= $prefix
ABresult
1X1
011
000
4566 $self->send_output(
4567 {
4568 prefix => $prefix,
4569 command => 'WALLOPS',
4570 params => [$args->[0]],
4571 },
4572 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
4573 );
4574 0 ▶ if ($self->state_peer_exists($full)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($full)) { } 0 0 0
4575 $self->send_output(
4576 {
4577 prefix => $full,
4578 command => 'WALLOPS',
4579 params => ['OPERWALL - ' . $args->[0]],
4580 0 }, keys %{ $self->{state}{wallops} },
4581 );
4582 0 $self->send_event("daemon_wallops", $full, $args->[0]);
4583 }
4584 else {
4585 $self->send_output(
4586 {
4587 prefix => $full,
4588 command => 'WALLOPS',
4589 params => ['OPERWALL - ' . $args->[0]],
4590 },
4591 0 keys %{ $self->{state}{operwall} },
4592 );
4593 0 $self->send_event("daemon_operwall", $full, $args->[0]);
4594 }
4595 }
4596  
4597 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4598 0 return $ref;
4599 }
4600  
4601 sub _daemon_peer_operwall {
4602 0 ▶ my $self = shift;
Subroutine _daemon_peer_operwall: not called CC=6 SCAR=37.4
4603 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
4604 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
4605 0 my $ref = [ ];
4606 0 my $args = [ @_ ];
4607 0 my $count = @$args;
4608  
4609 SWITCH: {
4610 0 ▶ my $full = $self->state_user_full($prefix) || $prefix;
Condition0%0/3
$self->state_user_full($prefix) || $prefix
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->state_user_full($prefix) || $prefix
$self->state_user_full($prefix) $prefix
Truth table0%0/3
A || B
A= $self->state_user_full($prefix)B= $prefix
ABresult
1X1
011
000
4611 $self->send_output(
4612 {
4613 prefix => $prefix,
4614 command => 'WALLOPS',
4615 params => [$args->[0]],
4616 },
4617 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
4618 );
4619 0 ▶ if ($self->state_peer_exists($full)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($full)) { } 0 0 0
4620 $self->send_output(
4621 {
4622 prefix => $full,
4623 command => 'WALLOPS',
4624 params => ['OPERWALL - ' . $args->[0]],
4625 },
4626 0 keys %{ $self->{state}{wallops} },
4627 );
4628 0 $self->send_event("daemon_wallops", $full, $args->[0]);
4629 }
4630 else {
4631 $self->send_output(
4632 {
4633 prefix => $full,
4634 command => 'WALLOPS',
4635 params => ['OPERWALL - ' . $args->[0]],
4636 },
4637 0 keys %{ $self->{state}{operwall} },
4638 );
4639 0 $self->send_event("daemon_operwall", $full, $args->[0]);
4640 }
4641 }
4642  
4643 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4644 0 return $ref;
4645 }
4646  
4647 sub _daemon_peer_eob {
4648 2 ▶ my $self = shift;
Subroutine _daemon_peer_eob: called CC=4 SCAR=14.3
4649 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
4650 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
4651 2 my $ref = [ ];
4652 2 $self->send_event("daemon_eob", $peer);
4653 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
4654 2 return $ref;
4655 }
4656  
4657 sub _daemon_peer_kill {
4658 0 ▶ my $self = shift;
Subroutine _daemon_peer_kill: not called CC=8 SCAR=42.8
4659 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
4660 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
4661 0 my $server = $self->server_name();
4662 0 my $ref = [ ];
4663 0 my $args = [ @_ ];
4664 0 my $count = @$args;
4665  
4666 SWITCH: {
4667 0 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 0 0 0
4668 0 last SWITCH;
4669 }
4670 0 ▶ if (!$self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($args->[0])) 0 0 0
4671 0 last SWITCH;
4672 }
4673  
4674 0 my $target = $self->state_user_nick($args->[0]);
4675 0 my $comment = $args->[1];
4676 0 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 0 0 0
4677 0 my $route_id = $self->_state_user_route($target);
4678 $self->send_output(
4679 {
4680 prefix => $nick,
4681 command => 'KILL',
4682 params => [
4683 $target,
4684 join('!', $server, $comment),
4685 ],
4686 0 }, grep { $_ ne $peer_id } $self->_state_connected_peers()
4687 );
4688  
4689 0 $self->send_output(
4690 {
4691 prefix => $self->state_user_full($nick),
4692 command => 'KILL',
4693 params => [
4694 $target,
4695 join('!', $server, $comment),
4696 ],
4697 },
4698 $route_id,
4699 );
4700  
4701 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
4702 0 $self->call(
4703 'del_spoofed_nick',
4704 $target,
4705 "Killed ($comment)",
4706 );
4707 }
4708 else {
4709 0 $self->{state}{conns}{$route_id}{killed} = 1;
4710 0 $self->_terminate_conn_error(
4711 $route_id,
4712 "Killed ($comment)",
4713 );
4714 }
4715 }
4716 else {
4717 0 $self->{state}{users}{uc_irc($target)}{killed} = 1;
4718 $self->send_output(
4719 {
4720 prefix => $nick,
4721 command => 'KILL',
4722 params => [$target, join('!', $server, $comment)],
4723 },
4724 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
4725 );
4726 $self->send_output(
4727 0 @{ $self->_daemon_peer_quit(
4728 $target, "Killed ($nick ($comment))" ) },
4729 );
4730 }
4731 }
4732  
4733 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4734 0 return $ref;
4735 }
4736  
4737 sub _daemon_peer_svinfo {
4738 4 ▶ my $self = shift;
Subroutine _daemon_peer_svinfo: called CC=3 SCAR=11.1
4739 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
4740 4 my $ref = [ ];
4741 4 my $args = [ @_ ];
4742 4 my $count = @$args;
4743 4 $self->{state}{conns}{$peer_id}{svinfo} = $args;
4744 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
4745 4 return $ref;
4746 }
4747  
4748 sub _daemon_peer_ping {
4749 0 ▶ my $self = shift;
Subroutine _daemon_peer_ping: not called CC=8 SCAR=42.8
4750 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
4751 0 my $server = $self->server_name();
4752 0 my $ref = [ ];
4753 0 my $args = [ @_ ];
4754 0 my $count = @$args;
4755  
4756 SWITCH: {
4757 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
4758 0 last SWITCH;
4759 }
4760 0 ▶ if ($count >= 2 && uc $server ne uc $args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and uc $server ne uc $args->[1]) 0 0 0
Condition0%0/3
$count >= 2 and uc $server ne uc $args->[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$count >= 2 and uc $server ne uc $args->[1]
$count >= 2 uc $server ne uc $args->[1]
Truth table0%0/3
A and B
A= $count >= 2B= uc $server ne uc $args->[1]
ABresult
0X0
100
111
4761 0 ▶ $self->send_output(
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_peer_exists($args->[1]) 0 0 0
4762 {
4763 command => 'PING',
4764 params => $args,
4765 },
4766 $self->_state_peer_route($args->[1]),
4767 ) if $self->state_peer_exists($args->[1]);
4768 0 ▶ $self->send_output(
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_nick_exists($args->[1]) 0 0 0
4769 {
4770 command => 'PING',
4771 params => $args,
4772 },
4773 $self->_state_user_route($args->[1]),
4774 ) if $self->state_nick_exists($args->[1]);
4775 0 last SWITCH;
4776 }
4777 $self->send_output(
4778 {
4779 0 command => 'PONG',
4780 params => [$server, $args->[0]],
4781 },
4782 $peer_id,
4783 );
4784 }
4785  
4786 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4787 0 return $ref;
4788 }
4789  
4790 sub _daemon_peer_pong {
4791 0 ▶ my $self = shift;
Subroutine _daemon_peer_pong: not called CC=8 SCAR=42.8
4792 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
4793 0 my $ref = [ ];
4794 0 my $args = [ @_ ];
4795 0 my $count = @$args;
4796  
4797 SWITCH: {
4798 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
4799 0 last SWITCH;
4800 }
4801 0 ▶ if ($count >= 2 && uc $self->server_name() ne uc $args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count >= 2 and uc $self->server_name ne uc $args->[1]) 0 0 0
Condition0%0/3
$count >= 2 and uc $self->server_name ne uc $args->[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$count >= 2 and uc $self->server_name ne uc $args->[1]
$count >= 2 uc $self->server_name ne uc $args->[1]
Truth table0%0/3
A and B
A= $count >= 2B= uc $self->server_name ne uc $args->[1]
ABresult
0X0
100
111
4802 0 ▶ $self->send_output(
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_peer_exists($args->[1]) 0 0 0
4803 {
4804 command => 'PONG',
4805 params => $args,
4806 },
4807 $self->_state_peer_route($args->[1]),
4808 ) if $self->state_peer_exists($args->[1]);
4809 0 ▶ $self->send_output(
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_nick_exists($args->[1]) 0 0 0
4810 {
4811 command => 'PONG',
4812 params => $args,
4813 },
4814 $self->_state_user_route($args->[1]),
4815 ) if $self->state_nick_exists($args->[1]);
4816 0 last SWITCH;
4817 }
4818 0 delete $self->{state}{conns}{$peer_id}{pinged};
4819 }
4820  
4821 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4822 0 return $ref;
4823 }
4824  
4825 sub _daemon_peer_server {
4826 0 ▶ my $self = shift;
Subroutine _daemon_peer_server: not called CC=8 SCAR=42.8
4827 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
4828 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
4829 0 my $server = $self->server_name();
4830 0 my $ref = [ ];
4831 0 my $args = [ @_ ];
4832 0 my $count = @$args;
4833 0 my $peer = $self->{state}{conns}{$peer_id}{name};
4834  
4835 SWITCH: {
4836 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
4837 0 last SWITCH;
4838 }
4839 0 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 0 0 0
4840 0 $self->_terminate_conn_error($peer_id, 'Server exists');
4841 0 last SWITCH;
4842 }
4843 0 ▶ my $record = {
Condition0%0/2
$args->[2] || ''
l!l
00
MC/DC0%0/1
$args->[2] || ''
$args->[2]
Truth table0%0/2
A
A= $args->[2]
Aresult
11
00
4844 name => $args->[0],
4845 hops => $args->[1],
4846 desc => ( $args->[2] || '' ),
4847 route_id => $peer_id,
4848 type => 'r',
4849 peer => $prefix,
4850 peers => { },
4851 users => { },
4852 };
4853 0 my $uname = uc $record->{name};
4854 0 $self->{state}{peers}{$uname} = $record;
4855 0 $self->{state}{peers}{uc $prefix}{peers}{$uname} = $record;
4856 $self->send_output(
4857 {
4858 prefix => $prefix,
4859 command => 'SERVER',
4860 params => [
4861 $record->{name},
4862 $record->{hops} + 1,
4863 $record->{desc},
4864 ],
4865 },
4866 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
4867 );
4868 $self->send_event(
4869 "daemon_server",
4870 $record->{name},
4871 $prefix,
4872 $record->{hops},
4873 $record->{desc},
4874 0 );
4875 }
4876 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4877 0 return $ref;
4878 }
4879  
4880 sub _daemon_peer_quit {
4881 0 ▶ my $self = shift;
Subroutine _daemon_peer_quit: not called CC=15 SCAR=54.8
4882 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
4883 0 ▶ my $qmsg = shift || 'Client Quit';
Condition0%0/2
shift() || 'Client Quit'
l!l
00
MC/DC0%0/1
shift() || 'Client Quit'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4884 0 my $conn_id = shift;
4885 0 my $ref = [ ];
4886 0 my $full = $self->state_user_full($nick);
4887  
4888 0 $nick = uc_irc($nick);
4889 0 my $record = delete $self->{state}{users}{$nick};
4890 0 ▶ return $ref if !$record;
Branch: 1 branch
BranchTrueFalseTotal
unless $record 0 0 0
4891 $self->send_output(
4892 {
4893 prefix => $record->{nick},
4894 command => 'QUIT',
4895 params => [$qmsg],
4896 },
4897 0 ▶ grep { !$conn_id || $_ ne $conn_id }
Branch: 1 branch
BranchTrueFalseTotal
not $conn_id or $_ ne $conn_id 0 0 0
4898 $self->_state_connected_peers(),
4899 0 ▶ ) if !$record->{killed};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"killed"} 0 0 0
4900  
4901 0 push @$ref, {
4902 prefix => $full,
4903 command => 'QUIT',
4904 params => [$qmsg],
4905 };
4906  
4907 0 $self->send_event("daemon_quit", $full, $qmsg);
4908  
4909 # Remove for peoples accept lists
4910 delete $self->{state}{users}{$_}{accepts}{uc_irc($nick)}
4911 0 for keys %{ $record->{accepts} };
4912  
4913 # Okay, all 'local' users who share a common channel with user.
4914 0 my $common = { };
4915 0 for my $uchan (keys %{ $record->{chans} }) {
4916 0 delete $self->{state}{chans}{$uchan}{users}{$nick};
4917 0 for my $user ($self->state_chan_list($uchan)) {
4918 0 ▶ next if !$self->_state_is_local_user($user);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_is_local_user($user) 0 0 0
4919 0 $common->{$user} = $self->_state_user_route($user);
4920 }
4921 0 ▶ if (!keys %{ $self->{state}{chans}{$uchan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$uchan}{"users"};}) 0 0 0
4922 0 delete $self->{state}{chans}{$uchan};
4923 }
4924 }
4925  
4926 0 push @$ref, $common->{$_} for keys %$common;
4927 0 ▶ $self->{state}{stats}{ops_online}-- if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 0 0 0
4928 0 ▶ $self->{state}{stats}{invisible}-- if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 0 0 0
4929 0 delete $self->{state}{peers}{uc $record->{server}}{users}{$nick};
4930  
4931 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
4932 0 return $ref;
4933 }
4934  
4935 sub _daemon_peer_nick {
4936 4 ▶ my $self = shift;
Subroutine _daemon_peer_nick: called CC=28 SCAR=52.7
4937 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
4938 4 my $prefix = shift;
4939 4 my $server = $self->server_name();
4940 4 my $ref = [ ];
4941 4 my $args = [ @_ ];
4942 4 my $count = @$args;
4943 4 my $peer = $self->{state}{conns}{$peer_id}{name};
4944 4 my $nicklen = $self->server_config('NICKLEN');
4945  
4946 SWITCH: {
4947 4 ▶ if (!$count || $count < 8 && !$prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 8 and not $prefix) 0 4 4
Condition33%2/6
not $count or $count < 8 and not $prefix
l!l&&r!l&&!r
004
$count < 8 and not $prefix
!ll&&!rl&&r
400
MC/DC0%0/3
not $count or $count < 8 and not $prefix
not $count $count < 8 not $prefix
Truth table0%0/4
not(A) or B and not(C)
A= not $countB= $count < 8C= not $prefix
ABCresult
1XX1
0111
00X0
0100
4948 0 $self->_terminate_conn_error(
4949 $peer_id,
4950 'Not enough arguments to server command.',
4951 );
4952 0 last SWITCH;
4953 }
4954 4 ▶ if ($prefix && $self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix and $self->state_nick_exists($args->[0])) 0 4 4
Condition33%1/3
$prefix and $self->state_nick_exists($args->[0])
!ll&&!rl&&r
400
MC/DC0%0/2
$prefix and $self->state_nick_exists($args->[0])
$prefix $self->state_nick_exists($args->[0])
Truth table33%1/3
A and B
A= $prefixB= $self->state_nick_exists($args->[0])
ABresult
0X0
100
111
4955 0 $self->send_output(
4956 {
4957 prefix => $server,
4958 command => 'KILL',
4959 params => [$args->[0], "$server (Nick exists)"],
4960 },
4961 $peer_id,
4962 );
4963 0 my $unick = uc_irc($prefix);
4964 0 $self->{state}{users}{$unick}{nick_collision} = 1;
4965 0 $self->daemon_server_kill($prefix, 'Nick Collision', $peer_id);
4966 0 last SWITCH;
4967 }
4968 4 ▶ if ($prefix && length($args->[0]) > $nicklen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix and length $args->[0] > $nicklen) 0 4 4
Condition33%1/3
$prefix and length $args->[0] > $nicklen
!ll&&!rl&&r
400
MC/DC0%0/2
$prefix and length $args->[0] > $nicklen
$prefix length $args->[0] > $nicklen
Truth table33%1/3
A and B
A= $prefixB= length $args->[0] > $nicklen
ABresult
0X0
100
111
4969 0 $self->send_output(
4970 {
4971 prefix => $server,
4972 command => 'KILL',
4973 params => [$args->[0], "$server (Bad nickname)"],
4974 },
4975 $peer_id,
4976 );
4977 0 my $unick = uc_irc($prefix);
4978 0 $self->{state}{users}{$unick}{nick_collision} = 1;
4979 0 $self->daemon_server_kill($prefix, 'Nick Collision', $peer_id);
4980 0 last SWITCH;
4981 }
4982 4 ▶ if ($prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix) 0 4 4
4983 0 my $full = $self->state_user_full($prefix);
4984 0 my $unick = uc_irc($prefix);
4985 0 my $new = $args->[0];
4986 0 my $unew = uc_irc($new);
4987 0 ▶ my $ts = $args->[1] || time;
Condition0%0/3
$args->[1] || time
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[1] || time
$args->[1] time
Truth table0%0/3
A || B
A= $args->[1]B= time
ABresult
1X1
011
000
4988 0 my $record = $self->{state}{users}{$unick};
4989 0 my $server = uc $record->{server};
4990  
4991 0 ▶ if ($unick eq $unew) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unick eq $unew) { } 0 0 0
4992 0 $record->{nick} = $new;
4993 0 $record->{ts} = $ts;
4994 }
4995 else {
4996 0 $record->{nick} = $new;
4997 0 $record->{ts} = $ts;
4998 # Remove from peoples accept lists
4999 delete $self->{state}{users}{$_}{accepts}{$unick}
5000 0 for keys %{ $record->{accepts} };
5001 0 delete $record->{accepts};
5002 0 delete $self->{state}{users}{$unick};
5003 0 $self->{state}{users}{$unew} = $record;
5004 0 delete $self->{state}{peers}{$server}{users}{$unick};
5005 0 $self->{state}{peers}{$server}{users}{$unew} = $record;
5006  
5007 0 for my $chan (keys %{ $record->{chans} }) {
5008 $self->{state}{chans}{$chan}{users}{$unew}
5009 0 = delete $self->{state}{chans}{$chan}{users}{$unick};
5010 }
5011 }
5012 0 my $common = { };
5013 0 for my $chan (keys %{ $record->{chans} }) {
5014 0 for my $user ($self->state_chan_list($chan)) {
5015 0 ▶ next if !$self->_state_is_local_user($user);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_is_local_user($user) 0 0 0
5016 0 $common->{$user} = $self->_state_user_route($user);
5017 }
5018 }
5019 $self->send_output(
5020 {
5021 prefix => $prefix,
5022 command => 'NICK',
5023 params => $args,
5024 },
5025 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
5026 );
5027 $self->send_output(
5028 {
5029 prefix => $full,
5030 command => 'NICK',
5031 params => [$new],
5032 },
5033 0 map{ $common->{$_} } keys %{ $common },
5034 );
5035 0 $self->send_event("daemon_nick", $full, $new);
5036 0 last SWITCH;
5037 }
5038 4 ▶ if ($self->state_nick_exists($args->[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($args->[0]) and () = split(/!/, $self->state_user_full($args->[0]), 3)) 4 0 4
Condition33%1/3
$self->state_nick_exists($args->[0]) and () = split(/!/, $self->state_user_full($args->[0]), 3)
!ll&&!rl&&r
004
MC/DC0%0/2
$self->state_nick_exists($args->[0]) and () = split(/!/, $self->state_user_full($args->[0]), 3)
$self->state_nick_exists($args->[0]) () = split(/!/, $self->state_user_full($args->[0]), 3)
Truth table33%1/3
A and B
A= $self->state_nick_exists($args->[0])B= () = split(/!/, $self->state_user_full($args->[0]), 3)
ABresult
0X0
100
111
5039 and my ($nick, $userhost) = split /!/,
5040 $self->state_user_full($args->[0])) {
5041 4 my $unick = uc_irc $nick;
5042 4 my $incoming = join '@', @{ $args }[4..5];
5043 4 ▶ if ($userhost eq $incoming) {
Branch: 1 branch
BranchTrueFalseTotal
if ($userhost eq $incoming) { } 0 4 4
5044 0 my $ts = $self->{state}{users}{$unick}{ts};
5045 0 ▶ if ($args->[2] > $ts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2] > $ts) { } 0 0 0
5046 0 $self->{state}{users}{$unick}{nick_collision} = 1;
5047 0 $self->daemon_server_kill(
5048 $nick,
5049 'Nick Collision',
5050 $peer_id,
5051 );
5052 }
5053 else {
5054 0 last SWITCH;
5055 }
5056 }
5057 else {
5058 4 my $ts = $self->{state}{users}{$unick}{ts};
5059 4 ▶ if ($args->[2] < $ts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->[2] < $ts) { } 2 2 4
5060 2 $self->{state}{users}{$unick}{nick_collision} = 1;
5061 2 $self->daemon_server_kill(
5062 $nick,
5063 'Nick Collision',
5064 $peer_id,
5065 );
5066 }
5067 else {
5068 2 last SWITCH;
5069 }
5070 }
5071 }
5072 2 ▶ if (!$self->state_peer_exists($args->[6])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_peer_exists($args->[6])) 0 2 2
5073 0 last SWITCH;
5074 }
5075 2 ▶ if (length( $args->[0] ) > $nicklen) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $args->[0] > $nicklen) 0 2 2
5076 0 $self->send_output(
5077 {
5078 prefix => $server,
5079 command => 'KILL',
5080 params => [$args->[0], "$server (Bad nickname)"],
5081 },
5082 $peer_id,
5083 );
5084 0 last SWITCH;
5085 }
5086 2 my $unick = uc_irc($args->[0]);
5087 2 $args->[3] =~ s/^\+//g;
5088 2 ▶ my $record = {
Condition50%1/2
$args->[7] || ''
l!l
20
MC/DC0%0/1
$args->[7] || ''
$args->[7]
Truth table50%1/2
A
A= $args->[7]
Aresult
11
00
5089 nick => $args->[0],
5090 hops => $args->[1],
5091 ts => $args->[2],
5092 type => 'r',
5093 umode => $args->[3],
5094 auth => {
5095 ident => $args->[4],
5096 hostname => $args->[5],
5097 },
5098 route_id => $peer_id,
5099 server => $args->[6],
5100 ircname => ( $args->[7] || '' ),
5101 };
5102 2 $self->{state}{users}{ $unick } = $record;
5103 2 ▶ $self->{state}{stats}{ops_online}++ if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 0 2 2
5104 2 ▶ $self->{state}{stats}{invisible}++ if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 2 0 2
5105 2 $self->{state}{peers}{uc $record->{server}}{users}{$unick}
5106 = $record;
5107 2 $self->_state_update_stats();
5108 $self->send_output(
5109 {
5110 command => 'NICK',
5111 params => $args,
5112 },
5113 2 grep { $_ ne $peer_id } $self->_state_connected_peers(),
5114 );
5115 2 $self->send_event("daemon_nick", @$args);
5116 }
5117  
5118 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 4 4
5119 4 return $ref;
5120 }
5121  
5122 sub _daemon_peer_part {
5123 0 ▶ my $self = shift;
Subroutine _daemon_peer_part: not called CC=9 SCAR=45.0
5124 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
5125 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
5126 0 my $chan = shift;
5127 0 my $ref = [ ];
5128 0 my $args = [ @_ ];
5129 0 my $count = @$args;
5130  
5131 SWITCH: {
5132 0 ▶ if (!$chan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chan) 0 0 0
5133 0 last SWITCH;
5134 }
5135 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
5136 0 last SWITCH;
5137 }
5138 0 ▶ if (!$self->state_is_chan_member($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($nick, $chan)) 0 0 0
5139 0 last SWITCH;
5140 }
5141 $self->_send_output_to_channel(
5142 0 ▶ $chan, {
Condition0%0/3
$args->[0] || $nick
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[0] || $nick
$args->[0] $nick
Truth table0%0/3
A || B
A= $args->[0]B= $nick
ABresult
1X1
011
000
5143 prefix => $self->state_user_full($nick),
5144 command => 'PART',
5145 params => [$chan, ($args->[0] || $nick)],
5146 },
5147 $peer_id,
5148 );
5149 0 $nick = uc_irc($nick);
5150 0 $chan = uc_irc($chan);
5151 0 delete $self->{state}{chans}{$chan}{users}{$nick};
5152 0 delete $self->{state}{users}{$nick}{chans}{$chan};
5153 0 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
5154 0 delete $self->{state}{chans}{$chan};
5155 }
5156 }
5157  
5158 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5159 0 return $ref;
5160 }
5161  
5162 sub _daemon_peer_kick {
5163 0 ▶ my $self = shift;
Subroutine _daemon_peer_kick: not called CC=12 SCAR=50.5
5164 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
5165 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
5166 0 my $ref = [ ];
5167 0 my $args = [ @_ ];
5168 0 my $count = @$args;
5169  
5170 SWITCH: {
5171 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
5172 0 last SWITCH;
5173 }
5174 0 my $chan = (split /,/, $args->[0])[0];
5175 0 my $who = (split /,/, $args->[1])[0];
5176 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
5177 0 last SWITCH;
5178 }
5179 0 $chan = $self->_state_chan_name($chan);
5180 0 ▶ if ( !$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
5181 0 last SWITCH;
5182 }
5183 0 $who = $self->state_user_nick($who);
5184 0 ▶ if (!$self->state_is_chan_op($nick, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_op($nick, $chan)) 0 0 0
5185 0 last SWITCH;
5186 }
5187 0 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 0 0
5188 0 last SWITCH;
5189 }
5190 0 ▶ my $comment = $args->[2] || $who;
Condition0%0/3
$args->[2] || $who
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[2] || $who
$args->[2] $who
Truth table0%0/3
A || B
A= $args->[2]B= $who
ABresult
1X1
011
000
5191 0 $self->_send_output_to_channel(
5192 $chan, {
5193 prefix => $self->state_user_full($nick),
5194 command => 'KICK',
5195 params => [$chan, $who, $comment],
5196 },
5197 $peer_id,
5198 );
5199 0 $who = uc_irc($who);
5200 0 $chan = uc_irc($chan);
5201 0 delete $self->{state}{chans}{$chan}{users}{$who};
5202 0 delete $self->{state}{users}{$who}{chans}{$chan};
5203 0 ▶ if (! keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
5204 0 delete $self->{state}{chans}{$chan};
5205 }
5206 }
5207  
5208 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5209 0 return $ref;
5210 }
5211  
5212 sub _daemon_peer_sjoin {
5213 1 ▶ my $self = shift;
Subroutine _daemon_peer_sjoin: called CC=65 SCAR=64.6
5214 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
5215 1 my $prefix = shift;
5216 1 my $ref = [ ];
5217 1 my $args = [ @_ ];
5218 1 my $count = @$args;
5219 #my $peer = $self->{state}{conns}{$peer_id}{name};
5220  
5221 SWITCH: {
5222 1 ▶ if (!$count || $count < 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 4) 0 1 1
Condition33%1/3
not $count or $count < 4
l!l&&r!l&&!r
001
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
5223 0 last SWITCH;
5224 }
5225 1 my $ts = $args->[0];
5226 1 my $chan = $args->[1];
5227 1 my $nicks = pop @{ $args };
5228 1 my $ignore_modes = 0;
5229 1 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 1 1
5230 0 my $server = $self->server_name();
5231 0 my $chanrec = { name => $chan, ts => $ts };
5232 0 my @args = @{ $args }[2..$#{ $args }];
5233 0 my $cmode = shift @args;
5234 0 $cmode =~ s/^\+//g;
5235 0 $chanrec->{mode} = $cmode;
5236 0 for my $mode (split //, $cmode) {
5237 0 my $arg;
5238 0 ▶ $arg = shift @args if $mode =~ /[lk]/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /[lk]/ 0 0 0
5239 0 ▶ $chanrec->{climit} = $arg if $mode eq 'l';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "l" 0 0 0
5240 0 ▶ $chanrec->{ckey} = $arg if $mode eq 'k';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "k" 0 0 0
5241 }
5242 0 push @$args, $nicks;
5243 0 my $uchan = uc_irc($chanrec->{name});
5244 0 for my $nick (split /\s+/, $nicks) {
5245 0 my $umode = '';
5246 0 ▶ $umode .= 'o' if $nick =~ s/\@//g;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ s/\@//g 0 0 0
5247 0 ▶ $umode = 'h' if $nick =~ s/\%//g;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ s/\%//g 0 0 0
5248 0 ▶ $umode .= 'v' if $nick =~ s/\+//g;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ s/\+//g 0 0 0
5249 0 my $unick = uc_irc($nick);
5250 0 $chanrec->{users}{$unick} = $umode;
5251 0 $self->{state}{users}{$unick}{chans}{$uchan} = $umode;
5252  
5253 0 $self->send_event(
5254 "daemon_join",
5255 $self->state_user_full($nick),
5256 $chan,
5257 );
5258 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $umode 0 0 0
5259 "daemon_mode",
5260 $server,
5261 $chan,
5262 '+' . $umode,
5263 $nick,
5264 ) if $umode;
5265 }
5266 0 $self->{state}{chans}{$uchan} = $chanrec;
5267 $self->send_output(
5268 {
5269 prefix => $prefix,
5270 command => 'SJOIN',
5271 params => $args,
5272 },
5273 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
5274 );
5275 0 last SWITCH;
5276 }
5277 1 my $chanrec = $self->{state}{chans}{uc_irc($chan)};
5278 1 my @local_users = map { $self->_state_user_route($_) }
5279 1 grep { $self->_state_is_local_user($_) }
5280 1 keys %{ $chanrec->{users} };
5281  
5282 1 ▶ if ($ts < $chanrec->{ts}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ts < $chanrec->{'ts'}) { } 1 0 1
elsif ($ts > $chanrec->{'ts'}) { } 0 0 0
5283 # Incoming is older
5284 1 ▶ if ($nicks =~ /^\@/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nicks =~ /^\@/) { } 1 0 1
elsif (grep {/^\@/;} $self->state_chan_list_prefixed($chan)) { } 0 0 0
5285 # Remove all modes expect bans/invex/excepts
5286 # deop/dehalfop/devoice all existing users
5287 1 my @deop;
5288 my @deop_list;
5289 1 my $common = { };
5290  
5291 1 for my $user (keys %{ $chanrec->{users} }) {
5292 1 ▶ $common->{$user} = $self->_state_user_route($user)
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_is_local_user($user) 1 0 1
5293 if $self->_state_is_local_user($user);
5294 1 ▶ next if !$chanrec->{users}{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless $chanrec->{"users"}{$user} 0 1 1
5295 1 my $current = $chanrec->{users}{$user};
5296 1 my $proper = $self->state_user_nick($user);
5297 1 $chanrec->{users}{$user} = '';
5298 1 $self->{state}{users}{$user}{chans}{uc_irc($chanrec->{name})} = '';
5299 1 push @deop, "-$current";
5300 1 push @deop_list, $proper for split //, $current;
5301 }
5302  
5303 1 ▶ if (keys %$common && @deop) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$common and @deop) 1 0 1
Condition33%1/3
keys %$common and @deop
!ll&&!rl&&r
001
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
5304 1 my $server = $self->server_name();
5305 $self->send_event(
5306 "daemon_mode",
5307 $server,
5308 $chanrec->{name},
5309 1 unparse_mode_line(join '', @deop),
5310 @deop_list,
5311 );
5312 1 my @output_modes;
5313 1 my $length = length($server) + 4
5314 + length($chan) + 4;
5315 1 my @buffer = ('', '');
5316 1 for my $deop (@deop) {
5317 1 my $arg = shift @deop_list;
5318 1 my $mode_line = unparse_mode_line($buffer[0].$deop);
5319 1 ▶ if (length(join ' ', $mode_line, $buffer[1],
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", $mode_line, $buffer[1], $arg) + $length > 510) 0 1 1
5320 $arg) + $length > 510) {
5321 push @output_modes, {
5322 prefix => $server,
5323 command => 'MODE',
5324 colonify => 0,
5325 params => [
5326 $chanrec->{name},
5327 0 $buffer[0],
5328 split /\s+/,
5329 $buffer[1],
5330 ],
5331 };
5332 0 $buffer[0] = $deop;
5333 0 $buffer[1] = $arg;
5334 0 next;
5335 }
5336 1 $buffer[0] = $mode_line;
5337 1 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 1 1
5338 0 $buffer[1] = join ' ', $buffer[1], $arg;
5339 }
5340 else {
5341 1 $buffer[1] = $arg;
5342 }
5343 }
5344 push @output_modes, {
5345 prefix => $server,
5346 command => 'MODE',
5347 colonify => 0,
5348 params => [
5349 $chanrec->{name},
5350 1 $buffer[0],
5351 split /\s+/, $buffer[1],
5352 ],
5353 };
5354 $self->send_output($_, values %$common)
5355 1 for @output_modes;
5356 }
5357 1 my $origmode = $chanrec->{mode};
5358 1 my @args = @{ $args }[2..$#{ $args }];
5359 1 my $chanmode = shift @args;
5360 1 my $reply = '';
5361 1 my @reply_args;
5362  
5363 1 for my $mode (grep { $_ ne '+' } split //, $chanmode) {
5364 2 my $arg;
5365 2 ▶ $arg = shift @args if $mode =~ /[lk]/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /[lk]/ 0 2 2
5366 2 ▶ if ($mode eq 'l' && ($chanrec->{mode} !~ /l/
Branch: 3 branches
BranchTrueFalseTotal
if ($mode eq 'l' and !($chanrec->{'mode'} =~ /l/) || $arg ne $chanrec->{'climit'}) { } 0 2 2
elsif ($mode eq 'k' and !($chanrec->{'mode'} =~ /k/) || $arg ne $chanrec->{'ckey'}) { } 0 2 2
elsif (not $chanrec->{'mode'} =~ /$mode/) { } 0 2 2
Condition16%1/6
$mode eq "l" and !($chanrec->{"mode"} =~ /l/) || $arg ne $chanrec->{"climit"}
!ll&&!rl&&r
200
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
5367 || $arg ne $chanrec->{climit})) {
5368 0 $reply .= '+' . $mode;
5369 0 push @reply_args, $arg;
5370 0 ▶ if ($chanrec->{mode} !~ /$mode/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /$mode/) 0 0 0
5371 0 $chanrec->{mode} .= $mode;
5372 }
5373 $chanrec->{mode} = join '', sort split //,
5374 0 $chanrec->{mode};
5375 0 $chanrec->{climit} = $arg;
5376 }
5377 ▶ elsif ($mode eq 'k' && ($chanrec->{mode} !~ /k/
Condition16%1/6
$mode eq "k" and !($chanrec->{"mode"} =~ /k/) || $arg ne $chanrec->{"ckey"}
!ll&&!rl&&r
200
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
5378 || $arg ne $chanrec->{ckey})) {
5379 0 $reply .= '+' . $mode;
5380 0 push @reply_args, $arg;
5381 0 ▶ if ($chanrec->{mode} !~ /$mode/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($chanrec->{"mode"} =~ /$mode/) 0 0 0
5382 0 $chanrec->{mode} .= $mode;
5383 }
5384 $chanrec->{mode} = join '', sort split //,
5385 0 $chanrec->{mode};
5386 0 $chanrec->{ckey} = $arg;
5387 }
5388 elsif ($chanrec->{mode} !~ /$mode/) {
5389 0 $reply .= '+' . $mode;
5390 $chanrec->{mode} = join '', sort split //,
5391 0 $chanrec->{mode};
5392 }
5393 }
5394  
5395 1 ▶ if (keys %$common && ($reply || $origmode)) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$common and $reply || $origmode) 1 0 1
Condition33%2/6
keys %$common and $reply || $origmode
!ll&&!rl&&r
001
$reply or $origmode
l!l&&r!l&&!r
010
MC/DC0%0/3
keys %$common and $reply || $origmode
keys %$common $reply $origmode
Truth table25%1/4
A and B or C
A= keys %$commonB= $replyC= $origmode
ABCresult
0XX0
1000
11X1
1011
5396 1 ▶ $origmode = join '', grep { $chanmode !~ /$_/ }
Condition50%1/2
$origmode || ''
l!l
10
MC/DC0%0/1
$origmode || ''
$origmode
Truth table50%1/2
A
A= $origmode
Aresult
11
00
5397 split //, ($origmode || '');
5398 1 ▶ $chanrec->{mode} =~ s/[$origmode]//g if $origmode;
Branch: 1 branch
BranchTrueFalseTotal
if $origmode 0 1 1
5399 1 ▶ $reply = '-' . $origmode . $reply if $origmode;
Branch: 1 branch
BranchTrueFalseTotal
if $origmode 0 1 1
5400 1 ▶ if ($origmode && $origmode =~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($origmode and $origmode =~ /k/) 0 1 1
Condition33%1/3
$origmode and $origmode =~ /k/
!ll&&!rl&&r
100
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
5401 0 unshift @reply_args, '*';
5402 0 delete $chanrec->{ckey};
5403 }
5404 1 ▶ if ($origmode and $origmode =~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($origmode and $origmode =~ /l/) 0 1 1
Condition33%1/3
$origmode and $origmode =~ /l/
!ll&&!rl&&r
100
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
5405 0 delete $chanrec->{climit};
5406 }
5407 $self->send_output(
5408 {
5409 prefix => $self->server_name(),
5410 command => 'MODE',
5411 colonify => 0,
5412 params => [
5413 $chanrec->{name},
5414 1 ▶ unparse_mode_line($reply),
Branch: 1 branch
BranchTrueFalseTotal
if $reply 0 1 1
5415 @reply_args,
5416 ],
5417 },
5418 values %$common,
5419 ) if $reply;
5420 }
5421 # NOTICE HERE
5422 $self->send_output(
5423 {
5424 prefix => $self->server_name(),
5425 command => 'NOTICE',
5426 params => [
5427 $chanrec->{name},
5428 "*** Notice -- TS for " . $chanrec->{name}
5429 . " changed from " . $chanrec->{ts}
5430 1 . " to $ts",
5431 ],
5432 },
5433 @local_users,
5434 );
5435 1 $chanrec->{ts} = $ts;
5436 }
5437 0 elsif (grep { /^\@/ } $self->state_chan_list_prefixed($chan)) {
5438 0 $args->[0] = $chanrec->{ts};
5439 }
5440 else {
5441 # NOTICE HERE
5442 $self->send_output(
5443 {
5444 prefix => $self->server_name(),
5445 command => 'NOTICE',
5446 params => [
5447 $chanrec->{name},
5448 "*** Notice -- TS for " . $chanrec->{name}
5449 . " changed from " . $chanrec->{ts}
5450 0 . " to $ts",
5451 ],
5452 },
5453 @local_users,
5454 );
5455 0 $chanrec->{ts} = $ts;
5456 }
5457 }
5458 elsif ($ts > $chanrec->{ts}) {
5459 # Incoming is younger
5460 0 ▶ if ($nicks !~ /^\@/) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $nicks =~ /^\@/) { } 0 0 0
elsif (grep {/^\@/;} $self->state_chan_list_prefixed($chan)) { } 0 0 0
5461 0 $args->[0] = $chanrec->{ts};
5462 }
5463 0 elsif (grep { /^\@/ } $self->state_chan_list_prefixed($chan)) {
5464 0 ▶ pop @$args while $#{ $args } > 2;
Branch: 1 branch
BranchTrueFalseTotal
$#{$args;} > 2 and do { pop @$args } 0 0 0
5465 0 $args->[2] = '+';
5466 0 $args->[0] = $chanrec->{ts};
5467 0 $nicks = join ' ', map { my $s = $_; $s =~ s/[@%+]//g; $s; }
5468 split /\s+/, $nicks;
5469 }
5470 else {
5471 0 $chanrec->{ts} = $ts;
5472 }
5473 }
5474 # Propagate SJOIN to connected peers except the one that told us.
5475 1 push @$args, $nicks;
5476 $self->send_output(
5477 {
5478 prefix => $prefix,
5479 command => 'SJOIN',
5480 params => $args,
5481 },
5482 1 grep { $_ ne $peer_id } $self->_state_connected_peers(),
5483 );
5484 # Generate appropriate JOIN messages for all local
5485 # channel members
5486 1 my $uchan = uc_irc($chanrec->{name});
5487 #my @local_users = map { $self->_state_user_route($_) }
5488 # grep { $self->_state_is_local_user($_) }
5489 # keys %{ $chanrec->{users} };
5490 1 my $modes;
5491 my @mode_parms;
5492 1 for my $nick (split /\s+/, $nicks) {
5493 1 my $proper = $nick;
5494 1 $proper =~ s/[@%+]//g;
5495 1 $nick = uc_irc($nick);
5496 1 my $umode = '';
5497 1 my @op_list;
5498 1 ▶ $umode .= 'o' if $nick =~ s/\@//g;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ s/\@//g 1 0 1
5499 1 ▶ $umode = 'h' if $nick =~ s/\%//g;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ s/\%//g 0 1 1
5500 1 ▶ $umode .= 'v' if $nick =~ s/\+//g;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ s/\+//g 0 1 1
5501 1 $chanrec->{users}{$nick} = $umode;
5502 1 $self->{state}{users}{$nick}{chans}{$uchan} = $umode;
5503 1 push @op_list, $proper for split //, $umode;
5504 my $output = {
5505 prefix => $self->state_user_full($nick),
5506 command => 'JOIN',
5507 1 params => [$chanrec->{name}],
5508 };
5509 1 $self->send_output($output, @local_users);
5510 $self->send_event(
5511 "daemon_join",
5512 $output->{prefix},
5513 $chanrec->{name},
5514 1 );
5515 1 ▶ if ($umode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umode) 1 0 1
5516 1 $modes .= $umode;
5517 1 push @mode_parms, @op_list;
5518 }
5519 }
5520 1 ▶ if ($modes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modes) 1 0 1
5521 1 my $server = $self->server_name();
5522 $self->send_event(
5523 "daemon_mode",
5524 $server,
5525 $chanrec->{name},
5526 1 '+' . $modes,
5527 @mode_parms,
5528 );
5529 1 my @output_modes;
5530 1 my $length = length($server) + 4 + length($chan) + 4;
5531 1 my @buffer = ('+', '');
5532 1 for my $umode (split //, $modes) {
5533 1 my $arg = shift @mode_parms;
5534 1 ▶ if (length(join ' ', @buffer, $arg) + $length > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", @buffer, $arg) + $length > 510) 0 1 1
5535 push @output_modes, {
5536 prefix => $server,
5537 command => 'MODE',
5538 colonify => 0,
5539 params => [
5540 $chanrec->{name},
5541 0 $buffer[0],
5542 split /\s+/,
5543 $buffer[1],
5544 ],
5545 };
5546 0 $buffer[0] = "+$umode";
5547 0 $buffer[1] = $arg;
5548 0 next;
5549 }
5550 1 $buffer[0] .= $umode;
5551 1 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 1 1
5552 0 $buffer[1] = join ' ', $buffer[1], $arg;
5553 }
5554 else {
5555 1 $buffer[1] = $arg;
5556 }
5557 }
5558 push @output_modes, {
5559 prefix => $server,
5560 command => 'MODE',
5561 colonify => 0,
5562 params => [
5563 $chanrec->{name},
5564 1 $buffer[0],
5565 split /\s+/,
5566 $buffer[1],
5567 ],
5568 };
5569 $self->send_output($_, @local_users)
5570 1 for @output_modes;
5571 }
5572 }
5573  
5574 1 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 1 1
5575 1 return $ref;
5576 }
5577  
5578 sub _daemon_peer_mode {
5579 0 ▶ my $self = shift;
Subroutine _daemon_peer_mode: not called CC=55 SCAR=80.3
5580 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
5581 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
5582 0 my $chan = shift;
5583 0 my $server = $self->server_name();
5584 0 my $ref = [ ];
5585 0 my $args = [ @_ ];
5586 0 my $count = scalar @$args;
5587  
5588 SWITCH: {
5589 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
5590 0 last SWITCH;
5591 }
5592 0 my $record = $self->{state}{chans}{uc_irc($chan)};
5593 0 $chan = $record->{name};
5594 0 my $full;
5595 0 ▶ $full = $self->state_user_full($nick)
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_nick_exists($nick) 0 0 0
5596 if $self->state_nick_exists($nick);
5597 0 my $reply;
5598 my @reply_args;
5599 0 my $parsed_mode = parse_mode_line(@$args);
5600  
5601 0 ▶ while (my $mode = shift (@{ $parsed_mode->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 0 0 0
5602 0 my $arg;
5603 0 ▶ $arg = shift @{ $parsed_mode->{args} }
Branch: 1 branch
BranchTrueFalseTotal
if $mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/ 0 0 0
5604 if $mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/;
5605 0 ▶ if (my ($flag,$char) = $mode =~ /^(\+|-)([ohv])/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^(\+|-)([ohv])/) 0 0 0
5606 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
5607 && $record->{users}{uc_irc($arg)} !~ /$char/) {
5608 # Update user and chan record
5609 0 $arg = uc_irc($arg);
5610 next if $mode eq '+h'
5611 0 ▶ && $record->{users}{$arg} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+h" and $record->{"users"}{$arg} =~ /o/ 0 0 0
Condition0%0/3
$mode eq "+h" and $record->{"users"}{$arg} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$mode eq "+h" and $record->{"users"}{$arg} =~ /o/
$mode eq "+h" $record->{"users"}{$arg} =~ /o/
Truth table0%0/3
A and B
A= $mode eq "+h"B= $record->{"users"}{$arg} =~ /o/
ABresult
0X0
100
111
5612 0 ▶ if ($char eq 'h' && $record->{users}{$arg} =~ /v/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "h" and $record->{"users"}{$arg} =~ /v/) 0 0 0
Condition0%0/3
$char eq "h" and $record->{"users"}{$arg} =~ /v/
!ll&&!rl&&r
000
MC/DC0%0/2
$char eq "h" and $record->{"users"}{$arg} =~ /v/
$char eq "h" $record->{"users"}{$arg} =~ /v/
Truth table0%0/3
A and B
A= $char eq "h"B= $record->{"users"}{$arg} =~ /v/
ABresult
0X0
100
111
5613 0 $record->{users}{$arg} =~ s/v//g;
5614 0 $reply .= '-v';
5615 0 push @reply_args, $self->state_user_nick($arg);
5616 }
5617 0 ▶ if ($char eq 'o' && $record->{users}{$arg} =~ /h/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o" and $record->{"users"}{$arg} =~ /h/) 0 0 0
Condition0%0/3
$char eq "o" and $record->{"users"}{$arg} =~ /h/
!ll&&!rl&&r
000
MC/DC0%0/2
$char eq "o" and $record->{"users"}{$arg} =~ /h/
$char eq "o" $record->{"users"}{$arg} =~ /h/
Truth table0%0/3
A and B
A= $char eq "o"B= $record->{"users"}{$arg} =~ /h/
ABresult
0X0
100
111
5618 0 $record->{users}{$arg} =~ s/h//g;
5619 0 $reply .= '-h';
5620 0 push @reply_args, $self->state_user_nick($arg);
5621 }
5622 $record->{users}{$arg} = join('', sort split //,
5623 0 $record->{users}{$arg} . $char);
5624 $self->{state}{users}{$arg}{chans}{uc_irc($chan)}
5625 0 = $record->{users}{$arg};
5626 0 $reply .= "+$char";
5627 0 push @reply_args, $self->state_user_nick($arg);
5628 }
5629 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
5630 =~ /$char/) {
5631 # Update user and chan record
5632 0 $arg = uc_irc($arg);
5633 0 $record->{users}{$arg} =~ s/$char//g;
5634 $self->{state}{users}{$arg}{chans}{uc_irc($chan)}
5635 0 = $record->{users}{$arg};
5636 0 $reply .= "-$char";
5637 0 push @reply_args, $self->state_user_nick($arg);
5638 }
5639 0 next;
5640 }
5641 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
5642 $record->{mode} = join('', sort split //,
5643 0 ▶ $record->{mode} . 'l' ) if $record->{mode} !~ /l/;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"mode"} =~ /l/ 0 0 0
5644 0 $record->{climit} = $arg;
5645 0 $reply .= '+l';
5646 0 push @reply_args, $arg;
5647 0 next;
5648 }
5649 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
5650 0 $record->{mode} =~ s/l//g;
5651 0 delete $record->{climit};
5652 0 $reply .= '-l';
5653 0 next;
5654 }
5655 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
5656 $record->{mode} = join('', sort split //,
5657 0 ▶ $record->{mode} . 'k') if $record->{mode} !~ /k/;
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"mode"} =~ /k/ 0 0 0
5658 0 $record->{ckey} = $arg;
5659 0 $reply .= '+k';
5660 0 push @reply_args, $arg;
5661 0 next;
5662 }
5663 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
5664 0 $record->{mode} =~ s/k//g;
5665 0 delete $record->{ckey};
5666 0 $reply .= '-k';
5667 0 next;
5668 }
5669 # Bans
5670 0 ▶ if (my ($flag) = $mode =~ /(\+|-)b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)b/) 0 0 0
5671 0 my $mask = normalize_mask($arg);
5672 0 my $umask = uc_irc($mask);
5673 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
5674 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
5675 = [$mask, ($full || $server), time];
5676 0 $reply .= '+b';
5677 0 push @reply_args, $mask;
5678 }
5679 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
5680 0 delete $record->{bans}{$umask};
5681 0 $reply .= '-b';
5682 0 push @reply_args, $mask;
5683 }
5684 0 next;
5685 }
5686 # Invex
5687 0 ▶ if (my ($flag) = $mode =~ /(\+|-)I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)I/) 0 0 0
5688 0 my $mask = normalize_mask($arg);
5689 0 my $umask = uc_irc($mask);
5690 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
5691 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
5692 = [$mask, ($full || $server), time];
5693 0 $reply .= '+I';
5694 0 push @reply_args, $mask;
5695 }
5696 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
5697 0 delete $record->{invex}{$umask};
5698 0 $reply .= '-I';
5699 0 push @reply_args, $mask;
5700 }
5701 0 next;
5702 }
5703 # Exceptions
5704 0 ▶ if (my ($flag) = $mode =~ /(\+|-)e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)e/) 0 0 0
5705 0 my $mask = normalize_mask($arg);
5706 0 my $umask = uc_irc($mask);
5707 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
5708 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
5709 = [$mask, ($full || $server), time];
5710 0 $reply .= '+e';
5711 0 push @reply_args, $mask;
5712 }
5713 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
5714 0 delete $record->{excepts}{$umask};
5715 0 $reply .= '-e';
5716 0 push @reply_args, $mask;
5717 }
5718 0 next;
5719 }
5720 # The rest should be argumentless.
5721 0 my ($flag, $char) = split //, $mode;
5722 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
5723 $record->{mode} = join('', sort split //,
5724 0 $record->{mode} . $char);
5725 0 $reply .= "+$char";
5726 0 next;
5727 }
5728 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
5729 0 $record->{mode} =~ s/$char//g;
5730 0 $reply .= "-$char";
5731 0 next;
5732 }
5733 } # while
5734  
5735 0 unshift @$args, $record->{name};
5736 0 ▶ if ($reply) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 0 0 0
5737 0 my $parsed_line = unparse_mode_line($reply);
5738 $self->send_output(
5739 {
5740 prefix => $nick,
5741 command => 'MODE',
5742 colonify => 0,
5743 params => [
5744 $record->{name},
5745 $parsed_line,
5746 @reply_args,
5747 ],
5748 },
5749 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
5750 );
5751 $self->send_output(
5752 {
5753 prefix => ($full || $server),
5754 command => 'MODE',
5755 colonify => 0,
5756 params => [
5757 $record->{name},
5758 $parsed_line,
5759 @reply_args,
5760 ],
5761 },
5762 0 map { $self->_state_user_route($_) }
5763 0 grep { $self->_state_is_local_user($_) }
5764 0 ▶ keys %{ $record->{users} },
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
5765 );
5766 $self->send_event(
5767 "daemon_mode",
5768 ($full || $server),
5769 $record->{name},
5770 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
5771 @reply_args,
5772 );
5773 }
5774 } # SWITCH
5775  
5776 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5777 0 return $ref;
5778 }
5779  
5780 sub _daemon_peer_umode {
5781 0 ▶ my $self = shift;
Subroutine _daemon_peer_umode: not called CC=14 SCAR=53.5
5782 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
5783 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
5784 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
5785 0 my $umode = shift;
5786 0 my $server = $self->server_name();
5787 0 my $ref = [ ];
5788 0 my $record = $self->{state}{users}{uc_irc($nick)};
5789 0 my $parsed_mode = parse_mode_line($umode);
5790  
5791 0 ▶ while (my $mode = shift @{ $parsed_mode->{modes} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 0 0 0
5792 0 my ($action, $char) = split //, $mode;
5793 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
5794 0 $record->{umode} .= $char;
5795 0 ▶ $self->{state}{stats}{invisible}++ if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
5796 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
5797 0 $self->{state}{stats}{ops_online}++;
5798 }
5799 }
5800 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
5801 0 $record->{umode} =~ s/$char//g;
5802 0 ▶ $self->{state}{stats}{invisible}-- if $char eq 'i';
Branch: 1 branch
BranchTrueFalseTotal
if $char eq "i" 0 0 0
5803 0 ▶ if ($char eq 'o') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o") 0 0 0
5804 0 $self->{state}{stats}{ops_online}--;
5805 }
5806 }
5807 }
5808 $self->send_output(
5809 {
5810 prefix => $prefix,
5811 command => 'MODE',
5812 params => [$nick, $umode],
5813 },
5814 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
5815 );
5816 0 $self->send_event(
5817 "daemon_umode",
5818 $self->state_user_full($nick),
5819 $umode,
5820 );
5821  
5822 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
5823 0 return $ref;
5824 }
5825  
5826 sub _daemon_peer_message {
5827 0 ▶ my $self = shift;
Subroutine _daemon_peer_message: not called CC=82 SCAR=88.3
5828 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
5829 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
5830 0 ▶ my $type = 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
5831 0 my $ref = [ ];
5832 0 my $args = [ @_ ];
5833 0 my $count = @$args;
5834  
5835 SWITCH: {
5836 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
5837 0 push @$ref, ['461', $type];
5838 0 last SWITCH;
5839 }
5840 0 ▶ if ($count < 2 || !$args->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count < 2 or not $args->[1]) 0 0 0
Condition0%0/3
$count < 2 or not $args->[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$count < 2 or not $args->[1]
$count < 2 not $args->[1]
Truth table0%0/3
A or not(B)
A= $count < 2B= not $args->[1]
ABresult
1X1
011
000
5841 0 push @$ref, ['412'];
5842 0 last SWITCH;
5843 }
5844 0 my $targets = 0;
5845 0 my $max_targets = $self->server_config('MAXTARGETS');
5846 0 my $full = $self->state_user_full($nick);
5847 0 my $targs = $self->_state_parse_msg_targets($args->[0]);
5848  
5849 0 LOOP: for my $target (keys %$targs) {
5850 0 my $targ_type = shift @{ $targs->{$target} };
5851 0 ▶ 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 0 0
Condition0%0/3
$targ_type =~ /(server|host)mask/ and not $self->state_user_is_operator($nick)
!ll&&!rl&&r
000
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 table0%0/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $self->state_user_is_operator($nick)
ABresult
0X0
100
111
5852 && !$self->state_user_is_operator($nick)) {
5853 0 push @$ref, ['481'];
5854 0 next LOOP;
5855 }
5856 0 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./) 0 0 0
Condition0%0/3
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
!ll&&!rl&&r
000
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\./
$targ_type =~ /(server|host)mask/ not $targs->{$target}[0] =~ /\./
Truth table0%0/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $targs->{$target}[0] =~ /\./
ABresult
0X0
100
111
5857 && $targs->{$target}[0] !~ /\./) {
5858 0 push @$ref, ['413', $target];
5859 0 next LOOP;
5860 }
5861 0 ▶ if ($targ_type =~ /(server|host)mask/
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/) 0 0 0
Condition0%0/3
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/
!ll&&!rl&&r
000
MC/DC0%0/2
$targ_type =~ /(server|host)mask/ and not $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/
$targ_type =~ /(server|host)mask/ not $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/
Truth table0%0/3
A and not(B)
A= $targ_type =~ /(server|host)mask/B= not $targs->{$target}[0] =~ /\x2E.*[\x2A\x3F]+.*$/
ABresult
0X0
100
111
5862 && $targs->{$target}[0] !~ /\x2E.*[\x2A\x3F]+.*$/) {
5863 0 push @$ref, ['414', $target];
5864 0 next LOOP;
5865 }
5866 0 ▶ 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 0 0
Condition0%0/3
$targ_type eq "channel_ext" and not $self->state_chan_exists($targs->{$target}[1])
!ll&&!rl&&r
000
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 table0%0/3
A and not(B)
A= $targ_type eq "channel_ext"B= not $self->state_chan_exists($targs->{$target}[1])
ABresult
0X0
100
111
5867 && !$self->state_chan_exists($targs->{$target}[1])) {
5868 0 push @$ref, ['401', $targs->{$target}[1]];
5869 0 next LOOP;
5870 }
5871 0 ▶ if ($targ_type eq 'channel'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel" and not $self->state_chan_exists($target)) 0 0 0
Condition0%0/3
$targ_type eq "channel" and not $self->state_chan_exists($target)
!ll&&!rl&&r
000
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 table0%0/3
A and not(B)
A= $targ_type eq "channel"B= not $self->state_chan_exists($target)
ABresult
0X0
100
111
5872 && !$self->state_chan_exists($target)) {
5873 0 push @$ref, ['401', $target];
5874 0 next LOOP;
5875 }
5876 0 ▶ if ($targ_type eq 'nick'
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick" and not $self->state_nick_exists($target)) 0 0 0
Condition0%0/3
$targ_type eq "nick" and not $self->state_nick_exists($target)
!ll&&!rl&&r
000
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 table0%0/3
A and not(B)
A= $targ_type eq "nick"B= not $self->state_nick_exists($target)
ABresult
0X0
100
111
5877 && !$self->state_nick_exists($target)) {
5878 0 push @$ref, ['401', $target];
5879 0 next LOOP;
5880 }
5881 0 ▶ 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 0 0
Condition0%0/3
$targ_type eq "nick_ext" and not $self->state_peer_exists($targs->{$target}[1])
!ll&&!rl&&r
000
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 table0%0/3
A and not(B)
A= $targ_type eq "nick_ext"B= not $self->state_peer_exists($targs->{$target}[1])
ABresult
0X0
100
111
5882 && !$self->state_peer_exists($targs->{$target}[1])) {
5883 0 push @$ref, ['402', $targs->{$target}[1]];
5884 0 next LOOP;
5885 }
5886 0 $targets++;
5887 0 ▶ if ($targets > $max_targets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targets > $max_targets) 0 0 0
5888 0 push @$ref, ['407', $target];
5889 0 last SWITCH;
5890 }
5891 # $$whatever
5892 0 ▶ if ($targ_type eq 'servermask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "servermask") 0 0 0
5893 0 my $us = 0;
5894 0 my %targets;
5895 0 my $ucserver = uc $self->server_name();
5896 0 for my $peer (keys %{ $self->{state}{peers} }) {
5897 0 ▶ if (matches_mask($targs->{$target}[0], $peer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($targs->{$target}[0], $peer)) 0 0 0
5898 0 ▶ if ($ucserver eq $peer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ucserver eq $peer) { } 0 0 0
5899 0 $us = 1;
5900 }
5901 else {
5902 0 $targets{ $self->_state_peer_route($peer) }++;
5903 }
5904 }
5905 }
5906 0 delete $targets{$peer_id};
5907 0 $self->send_output(
5908 {
5909 prefix => $nick,
5910 command => $type,
5911 params => [$target, $args->[1]],
5912 },
5913 keys %targets,
5914 );
5915 0 ▶ if ($us) {
Branch: 1 branch
BranchTrueFalseTotal
if ($us) 0 0 0
5916 0 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
5917 0 my @local;
5918 0 my $spoofed = 0;
5919 0 for my $luser (values %$local) {
5920 0 ▶ if ($luser->{route_id} eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($luser->{'route_id'} eq 'spoofed') { } 0 0 0
5921 0 $spoofed = 1;
5922 }
5923 else {
5924 0 push @local, $luser->{route_id};
5925 }
5926 }
5927 $self->send_output(
5928 {
5929 0 prefix => $full,
5930 command => $type,
5931 params => [$target, $args->[1]],
5932 },
5933 @local,
5934 );
5935 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
5936 "daemon_" . lc $type,
5937 $full,
5938 $target,
5939 $args->[1],
5940 ) if $spoofed;
5941 }
5942 0 next LOOP;
5943 }
5944 # $#whatever
5945 0 ▶ if ($targ_type eq 'hostmask') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "hostmask") 0 0 0
5946 0 my $spoofed = 0;
5947 0 my %targets;
5948 my @local;
5949 0 HOST: for my $luser (values %{ $self->{state}{users} }) {
5950 next HOST if !matches_mask(
5951 0 ▶ $targs->{$target}[0], $luser->{auth}{hostname});
Branch: 1 branch
BranchTrueFalseTotal
unless matches_mask($targs->{$target}[0], $luser->{"auth"}{"hostname"}) 0 0 0
5952 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
5953 0 $spoofed = 1;
5954 }
5955 elsif ( $luser->{type} eq 'r') {
5956 0 $targets{$luser->{route_id}}++;
5957 }
5958 else {
5959 0 push @local, $luser->{route_id};
5960 }
5961 }
5962 0 delete $targets{$peer_id};
5963 0 $self->send_output(
5964 {
5965 prefix => $nick,
5966 command => $type,
5967 params => [$target, $args->[1]],
5968 },
5969 keys %targets,
5970 );
5971 0 $self->send_output(
5972 {
5973 prefix => $full,
5974 command => $type,
5975 params => [$target, $args->[1]],
5976 },
5977 @local,
5978 );
5979 0 ▶ $self->send_event(
Branch: 1 branch
BranchTrueFalseTotal
if $spoofed 0 0 0
5980 "daemon_" . lc $type,
5981 $full,
5982 $target,
5983 $args->[1],
5984 ) if $spoofed;
5985 0 next LOOP;
5986 }
5987 0 ▶ if ($targ_type eq 'nick_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "nick_ext") 0 0 0
5988 $targs->{$target}[1]
5989 0 = $self->_state_peer_name($targs->{$target}[1]);
5990 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
5991 && !$self->state_user_is_operator($nick)) {
5992 0 push @$ref, ['481'];
5993 0 next LOOP;
5994 }
5995 0 ▶ if ($targs->{$target}[1] ne $self->server_name()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targs->{$target}[1] ne $self->server_name) 0 0 0
5996 $self->send_output(
5997 {
5998 prefix => $nick,
5999 command => $type,
6000 params => [$target, $args->[1]],
6001 },
6002 0 $self->_state_peer_route($targs->{$target}[1]),
6003 );
6004 0 next LOOP;
6005 }
6006 0 ▶ if (uc $targs->{$target}[0] eq 'OPERS') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $targs->{$target}[0] eq "OPERS") 0 0 0
6007 0 ▶ if (!$self->state_user_is_operator($nick)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_user_is_operator($nick)) 0 0 0
6008 0 push @$ref, ['481'];
6009 0 next LOOP;
6010 }
6011 $self->send_output(
6012 {
6013 prefix => $full,
6014 command => $type,
6015 params => [$target, $args->[1]],
6016 },
6017 0 keys %{ $self->{state}{localops} },
6018 );
6019 0 next LOOP;
6020 }
6021  
6022 my @local = $self->_state_find_user_host(
6023 $targs->{$target}[0],
6024 0 $targs->{$target}[2],
6025 );
6026  
6027 0 ▶ if (@local == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@local == 1) { } 0 0 0
6028 0 my $ref = shift @local;
6029 0 ▶ if ($ref->[0] eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref->[0] eq 'spoofed') { } 0 0 0
6030 0 $self->send_event(
6031 "daemon_" . lc $type,
6032 $full,
6033 $ref->[1],
6034 $args->[1],
6035 );
6036 }
6037 else {
6038 0 $self->send_output(
6039 {
6040 prefix => $full,
6041 command => $type,
6042 params => [$target, $args->[1]],
6043 },
6044 $ref->[0],
6045 );
6046 }
6047 }
6048 else {
6049 0 push @$ref, ['407', $target];
6050 0 next LOOP;
6051 }
6052 }
6053 0 my $channel;
6054 my $status_msg;
6055 0 ▶ if ($targ_type eq 'channel') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel") 0 0 0
6056 0 $channel = $self->_state_chan_name($target);
6057 }
6058 0 ▶ if ($targ_type eq 'channel_ext') {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_type eq "channel_ext") 0 0 0
6059 0 $channel = $self->_state_chan_name($targs->{target}[1]);
6060 0 $status_msg = $targs->{target}[0];
6061 }
6062 0 ▶ if ($channel && $status_msg
Branch: 1 branch
BranchTrueFalseTotal
if ($channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)) 0 0 0
Condition0%0/6
$channel and $status_msg and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
000
$channel and $status_msg
!ll&&!rl&&r
000
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 table0%0/4
A and B and not(C)
A= $channelB= $status_msgC= not $self->state_user_chan_mode($nick, $channel)
ABCresult
0XX0
10X0
1100
1111
6063 && !$self->state_user_chan_mode($nick, $channel)) {
6064 0 push @$ref, ['482', $target];
6065 0 next LOOP;
6066 }
6067 0 ▶ 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 0 0
Condition0%0/6
$channel and $self->state_chan_mode_set($channel, "n") and not $self->state_is_chan_member($nick, $channel)
!ll&&!rl&&r
000
$channel and $self->state_chan_mode_set($channel, "n")
!ll&&!rl&&r
000
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 table0%0/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
6068 && !$self->state_is_chan_member($nick, $channel)) {
6069 0 push @$ref, ['404', $channel];
6070 0 next LOOP;
6071 }
6072 0 ▶ 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 0 0
Condition0%0/6
$channel and $self->state_chan_mode_set($channel, "m") and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
000
$channel and $self->state_chan_mode_set($channel, "m")
!ll&&!rl&&r
000
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 table0%0/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
6073 && !$self->state_user_chan_mode($nick, $channel)) {
6074 0 push @$ref, ['404', $channel];
6075 0 next LOOP;
6076 }
6077 0 ▶ 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 0 0
Condition0%0/6
$channel and $self->_state_user_banned($nick, $channel) and not $self->state_user_chan_mode($nick, $channel)
!ll&&!rl&&r
000
$channel and $self->_state_user_banned($nick, $channel)
!ll&&!rl&&r
000
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 table0%0/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
6078 && !$self->state_user_chan_mode($nick, $channel)) {
6079 0 push @$ref, ['404', $channel];
6080 0 next LOOP;
6081 }
6082 0 ▶ if ($channel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($channel) 0 0 0
6083 0 my $common = { };
6084 0 ▶ my $msg = {
Branch: 1 branch
BranchTrueFalseTotal
$status_msg ? : 0 0 0
6085 command => $type,
6086 params => [
6087 ($status_msg ? $target : $channel),
6088 $args->[1],
6089 ],
6090 };
6091 0 for my $member ($self->state_chan_list($channel, $status_msg)) {
6092 0 ▶ next if $self->_state_user_is_deaf($member);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_is_deaf($member) 0 0 0
6093 0 $common->{ $self->_state_user_route($member) }++;
6094 }
6095 0 delete $common->{$peer_id};
6096 0 for my $route_id (keys %$common) {
6097 0 $msg->{prefix} = $nick;
6098 0 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 0 0 0
6099 0 $msg->{prefix} = $full;
6100 }
6101 0 ▶ if ($route_id ne 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id ne 'spoofed') { } 0 0 0
6102 0 $self->send_output($msg, $route_id);
6103 }
6104 else {
6105 0 ▶ my $tmsg = $type eq 'PRIVMSG'
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'PRIVMSG' ? : 0 0 0
6106 ? 'public'
6107 : 'notice';
6108 0 $self->send_event(
6109 "daemon_$tmsg",
6110 $full,
6111 $channel,
6112 $args->[1],
6113 );
6114 }
6115 }
6116 0 next LOOP;
6117 }
6118 0 my $server = $self->server_name();
6119 0 ▶ if ($self->state_nick_exists($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_nick_exists($target)) 0 0 0
6120 0 $target = $self->state_user_nick($target);
6121 0 ▶ if (my $away = $self->_state_user_away_msg($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $away = $self->_state_user_away_msg($target)) 0 0 0
6122 0 push @$ref, {
6123 prefix => $server,
6124 command => '301',
6125 params => [$nick, $target, $away],
6126 };
6127 }
6128 0 my $targ_umode = $self->state_user_umode($target);
6129 # Target user has CALLERID on
6130 0 ▶ if ($targ_umode && $targ_umode =~ /[Gg]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targ_umode and $targ_umode =~ /[Gg]/) 0 0 0
Condition0%0/3
$targ_umode and $targ_umode =~ /[Gg]/
!ll&&!rl&&r
000
MC/DC0%0/2
$targ_umode and $targ_umode =~ /[Gg]/
$targ_umode $targ_umode =~ /[Gg]/
Truth table0%0/3
A and B
A= $targ_umodeB= $targ_umode =~ /[Gg]/
ABresult
0X0
100
111
6131 0 my $targ_rec = $self->{state}{users}{uc_irc($target) };
6132 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
6133 !$self->state_users_share_chan($target, $nick)
6134 || !$targ_rec->{accepts}{uc_irc($nick)}))
6135 || ($targ_umode =~ /g/
6136 && !$targ_rec->{accepts}{uc_irc($nick)})) {
6137 0 push @$ref, {
6138 prefix => $server,
6139 command => '716',
6140 params => [
6141 $nick,
6142 $target,
6143 'is in +g mode (server side ignore)',
6144 ],
6145 };
6146 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
6147 || (time - $targ_rec->{last_caller} ) >= 60) {
6148 0 my ($n, $uh) = split /!/,
6149 $self->state_user_full($nick);
6150 $self->send_output(
6151 {
6152 prefix => $server,
6153 command => '718',
6154 params => [
6155 $target,
6156 "$n\[$uh\]",
6157 'is messaging you, and you are umode +g.'
6158 ],
6159 },
6160 $targ_rec->{route_id},
6161 0 ▶ ) if $targ_rec->{route_id} ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $targ_rec->{"route_id"} ne "spoofed" 0 0 0
6162 0 push @$ref, {
6163 prefix => $server,
6164 command => '717',
6165 params => [
6166 $nick,
6167 $target,
6168 'has been informed that you messaged them.',
6169 ],
6170 };
6171 }
6172 0 $targ_rec->{last_caller} = time();
6173 0 next LOOP;
6174 }
6175 }
6176 0 my $msg = {
6177 prefix => $nick,
6178 command => $type,
6179 params => [$target, $args->[1]],
6180 };
6181 0 my $route_id = $self->_state_user_route($target);
6182 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
6183 0 $msg->{prefix} = $full;
6184 0 $self->send_event(
6185 "daemon_" . lc $type,
6186 $full,
6187 $target,
6188 $args->[1],
6189 );
6190 }
6191 else {
6192 0 ▶ if ($self->_connection_is_client($route_id)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_connection_is_client($route_id)) 0 0 0
6193 0 $msg->{prefix} = $full;
6194 }
6195 0 $self->send_output($msg, $route_id);
6196 }
6197 0 next LOOP;
6198 }
6199 }
6200 }
6201  
6202 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
6203 0 return $ref;
6204 }
6205  
6206 sub _daemon_peer_topic {
6207 0 ▶ my $self = shift;
Subroutine _daemon_peer_topic: not called CC=6 SCAR=37.4
6208 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
6209 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
6210 0 my $server = $self->server_name();
6211 0 my $ref = [ ];
6212 0 my $args = [ @_ ];
6213 0 my $count = @$args;
6214  
6215 SWITCH:{
6216 0 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 0 0
6217 0 last SWITCH;
6218 }
6219 0 ▶ if (!$self->state_chan_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($args->[0])) 0 0 0
6220 0 last SWITCH;
6221 }
6222 0 my $chan_name = $self->_state_chan_name($args->[0]);
6223 0 my $record = $self->{state}{chans}{uc_irc($args->[0])};
6224 $record->{topic}
6225 0 = [$args->[1], $self->state_user_full($nick), time];
6226 0 $self->_send_output_to_channel(
6227 $args->[0],
6228 {
6229 prefix => $self->state_user_full($nick),
6230 command => 'TOPIC',
6231 params => [$chan_name, $args->[1]],
6232 },
6233 $peer_id,
6234 );
6235 }
6236  
6237 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
6238 0 return $ref;
6239 }
6240  
6241 sub _daemon_peer_invite {
6242 0 ▶ my $self = shift;
Subroutine _daemon_peer_invite: not called CC=9 SCAR=45.0
6243 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
6244 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
6245 0 my $server = $self->server_name();
6246 0 my $ref = [ ];
6247 0 my $args = [ @_ ];
6248 0 my $count = @$args;
6249  
6250 SWITCH: {
6251 0 ▶ if (!$count || $count < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count or $count < 3) 0 0 0
Condition0%0/3
not $count or $count < 3
l!l&&r!l&&!r
000
MC/DC0%0/2
not $count or $count < 3
not $count $count < 3
Truth table0%0/3
not(A) or B
A= not $countB= $count < 3
ABresult
1X1
011
000
6252 0 last SWITCH;
6253 }
6254 0 my ($who, $chan) = @$args;
6255 0 $who = $self->state_user_nick($who);
6256 0 $chan = $self->_state_chan_name($chan);
6257 0 my $local;
6258 0 ▶ if ($self->_state_is_local_user($who)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($who)) 0 0 0
6259 0 my $record = $self->{state}{users}{uc_irc($who)};
6260 0 $record->{invites}{uc_irc($chan)} = time;
6261 0 $local = 1;
6262 }
6263 0 my $route_id = $self->_state_user_route($who);
6264 0 my $output = {
6265 prefix => $self->state_user_full($nick),
6266 command => 'INVITE',
6267 params => [$who, $chan],
6268 colonify => 0,
6269 };
6270 0 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 0 0 0
6271 $self->send_event(
6272 "daemon_invite",
6273 $output->{prefix},
6274 0 @{ $output->{params} },
6275 );
6276 }
6277 else {
6278 0 ▶ if (!$local) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($local) 0 0 0
6279 0 $output->{prefix} = $nick;
6280 0 push @{ $output->{params} }, $args->[2];
6281 }
6282 0 $self->send_output($output, $route_id);
6283 }
6284 }
6285  
6286 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
6287 0 return $ref;
6288 }
6289  
6290 sub _daemon_peer_away {
6291 0 ▶ my $self = shift;
Subroutine _daemon_peer_away: not called CC=5 SCAR=34.0
6292 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
6293 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
6294 0 my $msg = shift;
6295 0 my $server = $self->server_name();
6296 0 my $ref = [ ];
6297  
6298 SWITCH: {
6299 0 my $record = $self->{state}{users}{uc_irc($nick)};
6300 0 ▶ if (!$msg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msg) 0 0 0
6301 0 delete $record->{away};
6302 $self->send_output(
6303 {
6304 prefix => $nick,
6305 command => 'AWAY',
6306 colonify => 0,
6307 },
6308 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
6309 );
6310 0 last SWITCH;
6311 }
6312 0 $record->{away} = $msg;
6313 $self->send_output(
6314 {
6315 prefix => $nick,
6316 command => 'AWAY',
6317 params => [$msg],
6318 colonify => 0,
6319 },
6320 0 grep { $_ ne $peer_id } $self->_state_connected_peers(),
6321 );
6322 }
6323  
6324 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
6325 0 return $ref;
6326 }
6327  
6328 sub _state_create {
6329 20 ▶ my $self = shift;
Subroutine _state_create: called CC=1 SCAR=0.0
6330  
6331 20 $self->_state_delete();
6332  
6333 # Connection specific tables
6334 20 $self->{state}{conns} = { };
6335  
6336 # IRC State specific
6337 20 $self->{state}{users} = { };
6338 20 $self->{state}{peers} = { };
6339 20 $self->{state}{chans} = { };
6340  
6341 # Register ourselves as a peer.
6342 $self->{state}{peers}{uc $self->server_name()} = {
6343 name => $self->server_name(),
6344 hops => 0,
6345 desc => $self->{config}{SERVERDESC},
6346 20 };
6347  
6348 $self->{state}{stats} = {
6349 20 maxconns => 0,
6350 maxlocal => 0,
6351 maxglobal => 0,
6352 ops_online => 0,
6353 invisible => 0,
6354 cmds => { },
6355 };
6356  
6357 20 return 1;
6358 }
6359  
6360 sub _state_delete {
6361 20 ▶ my $self = shift;
Subroutine _state_delete: called CC=1 SCAR=0.0
6362 20 delete $self->{state};
6363 20 return 1;
6364 }
6365  
6366 sub _state_update_stats {
6367 26 ▶ my $self = shift;
Subroutine _state_update_stats: called CC=3 SCAR=11.0
6368 26 my $server = $self->server_name();
6369 26 my $global = keys %{ $self->{state}{users} };
6370 26 my $local = keys %{ $self->{state}{peers}{uc $server}{users} };
6371  
6372 $self->{state}{stats}{maxglobal}
6373 26 ▶ = $global if $global > $self->{state}{stats}{maxglobal};
Branch: 1 branch
BranchTrueFalseTotal
if $global > $self->{"state"}{"stats"}{"maxglobal"} 24 2 26
6374 $self->{state}{stats}{maxlocal}
6375 26 ▶ = $local if $local > $self->{state}{stats}{maxlocal};
Branch: 1 branch
BranchTrueFalseTotal
if $local > $self->{"state"}{"stats"}{"maxlocal"} 24 2 26
6376 26 return 1;
6377 }
6378  
6379 sub _state_conn_stats {
6380 23 ▶ my $self = shift;
Subroutine _state_conn_stats: called CC=2 SCAR=6.9
6381  
6382 23 $self->{state}{stats}{conns_cumlative}++;
6383 23 my $conns = keys %{ $self->{state}{conns} };
6384 $self->{state}{stats}{maxconns} = $conns
6385 23 ▶ if $conns > $self->{state}{stats}{maxconns};
Branch: 1 branch
BranchTrueFalseTotal
if $conns > $self->{"state"}{"stats"}{"maxconns"} 22 1 23
6386 23 return 1;
6387 }
6388  
6389 sub _state_cmd_stat {
6390 147 ▶ my $self = shift;
Subroutine _state_cmd_stat: called CC=6 SCAR=17.9
6391 147 ▶ my $cmd = shift || return;
Condition50%1/2
shift() || (return)
l!l
1470
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6392 147 ▶ my $line = shift || return;
Condition100%2/2
shift() || (return)
l!l
9948
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
6393 99 my $remote = shift;
6394 99 ▶ my $record = $self->{state}{stats}{cmds}{$cmd} || {
Condition100%2/2
$self->{'state'}{'stats'}{'cmds'}{$cmd} || {'remote', 0, 'local', 0, 'bytes', 0}
l!l
2574
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
6395 remote => 0,
6396 local => 0,
6397 bytes => 0,
6398 };
6399  
6400 99 ▶ $record->{local}++ if !$remote;
Branch: 1 branch
BranchTrueFalseTotal
unless $remote 89 10 99
6401 99 ▶ $record->{remote}++ if $remote;
Branch: 1 branch
BranchTrueFalseTotal
if $remote 10 89 99
6402 99 $record->{bytes} += length $line;
6403 99 $self->{state}{stats}{cmds}{$cmd} = $record;
6404 99 return 1;
6405 }
6406  
6407 sub _state_find_user_host {
6408 0 ▶ my $self = shift;
Subroutine _state_find_user_host: not called CC=6 SCAR=37.4
6409 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
6410 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
6411 0 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
6412 0 my @conns;
6413 0 for my $user (values %$local) {
6414 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
6415 && matches_mask($luser, $user->{auth}{ident})) {
6416 0 push @conns, [$user->{route_id}, $user->{nick}];
6417 }
6418 }
6419  
6420 0 return @conns;
6421 }
6422  
6423 sub _state_local_users_match_rkline {
6424 0 ▶ my $self = shift;
Subroutine _state_local_users_match_rkline: not called CC=10 SCAR=47.0
6425 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
6426 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
6427 0 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
6428 0 my @conns;
6429  
6430 0 for my $user (values %$local) {
6431 0 ▶ next if $user->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"route_id"} eq "spoofed" 0 0 0
6432 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
6433 0 ▶ if (($user->{socket}[0] =~ /$host/
Branch: 1 branch
BranchTrueFalseTotal
if ($user->{"socket"}[0] =~ /$host/ || $user->{"auth"}{"hostname"} =~ /$host/ and $user->{"auth"}{"ident"} =~ /$luser/) 0 0 0
Condition0%0/6
$user->{"socket"}[0] =~ /$host/ || $user->{"auth"}{"hostname"} =~ /$host/ and $user->{"auth"}{"ident"} =~ /$luser/
!ll&&!rl&&r
000
$user->{"socket"}[0] =~ /$host/ or $user->{"auth"}{"hostname"} =~ /$host/
l!l&&r!l&&!r
000
MC/DC0%0/3
$user->{"socket"}[0] =~ /$host/ || $user->{"auth"}{"hostname"} =~ /$host/ and $user->{"auth"}{"ident"} =~ /$luser/
$user->{"socket"}[0] =~ /$host/ $user->{"auth"}{"hostname"} =~ /$host/ $user->{"auth"}{"ident"} =~ /$luser/
Truth table0%0/5
A or B and C
A= $user->{"socket"}[0] =~ /$host/B= $user->{"auth"}{"hostname"} =~ /$host/C= $user->{"auth"}{"ident"} =~ /$luser/
ABCresult
00X0
1X00
0100
1X11
0111
6434 || $user->{auth}{hostname} =~ /$host/)
6435 && $user->{auth}{ident} =~ /$luser/) {
6436 0 push @conns, $user->{route_id};
6437 }
6438 }
6439 0 return @conns;
6440 }
6441  
6442 sub _state_local_users_match_gline {
6443 0 ▶ my $self = shift;
Subroutine _state_local_users_match_gline: not called CC=17 SCAR=57.2
6444 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
6445 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
6446 0 my $local = $self->{state}{peers}{uc $self->server_name()}{users};
6447 0 my @conns;
6448  
6449 0 ▶ if (my $netmask = Net::Netmask->new2($host)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $netmask = 'Net::Netmask'->new2($host)) { } 0 0 0
6450 0 for my $user (values %$local) {
6451 0 ▶ next if $user->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"route_id"} eq "spoofed" 0 0 0
6452 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
6453 0 ▶ if ($netmask->match($user->{socket}[0])
Branch: 1 branch
BranchTrueFalseTotal
if ($netmask->match($user->{"socket"}[0]) and matches_mask($luser, $user->{"auth"}{"ident"})) 0 0 0
Condition0%0/3
$netmask->match($user->{"socket"}[0]) and matches_mask($luser, $user->{"auth"}{"ident"})
!ll&&!rl&&r
000
MC/DC0%0/2
$netmask->match($user->{"socket"}[0]) and matches_mask($luser, $user->{"auth"}{"ident"})
$netmask->match($user->{"socket"}[0]) matches_mask($luser, $user->{"auth"}{"ident"})
Truth table0%0/3
A and B
A= $netmask->match($user->{"socket"}[0])B= matches_mask($luser, $user->{"auth"}{"ident"})
ABresult
0X0
100
111
6454 && matches_mask($luser, $user->{auth}{ident})) {
6455 0 push @conns, $user->{route_id};
6456 }
6457 }
6458 }
6459 else {
6460 0 for my $user (values %$local) {
6461 0 ▶ next if $user->{route_id} eq 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $user->{"route_id"} eq "spoofed" 0 0 0
6462 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
6463  
6464 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
6465 || matches_mask($host, $user->{auth}{hostname}))
6466 && matches_mask($luser, $user->{auth}{ident})) {
6467 0 push @conns, $user->{route_id};
6468 }
6469 }
6470 }
6471  
6472 0 return @conns;
6473 }
6474  
6475 sub _state_user_matches_rkline {
6476 16 ▶ my $self = shift;
Subroutine _state_user_matches_rkline: called CC=8 SCAR=28.9
6477 16 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6478 16 my $record = $self->{state}{conns}{$conn_id};
6479 16 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition33%1/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
0160
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table33%1/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
6480 16 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition50%1/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
016
MC/DC0%0/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table50%1/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
6481 16 my $ip = $record->{socket}[0];
6482  
6483 16 for my $gline (@{ $self->{state}{rklines} }) {
6484 0 ▶ if (($host =~ /$gline->{host}/ || $ip =~ /$gline->{host}/)
Branch: 1 branch
BranchTrueFalseTotal
if ($host =~ /$gline->{"host"}/ || $ip =~ /$gline->{"host"}/ and $user =~ /$gline->{"user"}/) 0 0 0
Condition0%0/6
$host =~ /$gline->{"host"}/ || $ip =~ /$gline->{"host"}/ and $user =~ /$gline->{"user"}/
!ll&&!rl&&r
000
$host =~ /$gline->{"host"}/ or $ip =~ /$gline->{"host"}/
l!l&&r!l&&!r
000
MC/DC0%0/3
$host =~ /$gline->{"host"}/ || $ip =~ /$gline->{"host"}/ and $user =~ /$gline->{"user"}/
$host =~ /$gline->{"host"}/ $ip =~ /$gline->{"host"}/ $user =~ /$gline->{"user"}/
Truth table0%0/5
A or B and C
A= $host =~ /$gline->{"host"}/B= $ip =~ /$gline->{"host"}/C= $user =~ /$gline->{"user"}/
ABCresult
00X0
1X00
0100
1X11
0111
6485 && $user =~ /$gline->{user}/) {
6486 0 return 1;
6487 }
6488 }
6489 16 return 0;
6490 }
6491  
6492 sub _state_user_matches_kline {
6493 16 ▶ my $self = shift;
Subroutine _state_user_matches_kline: called CC=11 SCAR=38.1
6494 16 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6495 16 my $record = $self->{state}{conns}{$conn_id};
6496 16 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition33%1/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
0160
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table33%1/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
6497 16 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition50%1/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
016
MC/DC0%0/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table50%1/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
6498 16 my $ip = $record->{socket}[0];
6499  
6500 16 for my $gline (@{ $self->{state}{klines} }) {
6501 0 ▶ if (my $netmask = Net::Netmask->new2($gline->{host})) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $netmask = 'Net::Netmask'->new2($gline->{'host'})) { } 0 0 0
elsif (matches_mask($gline->{'host'}, $host) || matches_mask($gline->{'host'}, $ip) and matches_mask($gline->{'user'}, $user)) { } 0 0 0
6502 0 ▶ if ($netmask->match($ip)
Branch: 1 branch
BranchTrueFalseTotal
if ($netmask->match($ip) and matches_mask($gline->{"user"}, $user)) 0 0 0
Condition0%0/3
$netmask->match($ip) and matches_mask($gline->{"user"}, $user)
!ll&&!rl&&r
000
MC/DC0%0/2
$netmask->match($ip) and matches_mask($gline->{"user"}, $user)
$netmask->match($ip) matches_mask($gline->{"user"}, $user)
Truth table0%0/3
A and B
A= $netmask->match($ip)B= matches_mask($gline->{"user"}, $user)
ABresult
0X0
100
111
6503 && matches_mask($gline->{user}, $user)) {
6504 0 return 1;
6505 }
6506 }
6507 ▶ elsif ((matches_mask($gline->{host}, $host)
Condition0%0/6
matches_mask($gline->{"host"}, $host) || matches_mask($gline->{"host"}, $ip) and matches_mask($gline->{"user"}, $user)
!ll&&!rl&&r
000
matches_mask($gline->{"host"}, $host) or matches_mask($gline->{"host"}, $ip)
l!l&&r!l&&!r
000
MC/DC0%0/3
matches_mask($gline->{"host"}, $host) || matches_mask($gline->{"host"}, $ip) and matches_mask($gline->{"user"}, $user)
matches_mask($gline->{"host"}, $host) matches_mask($gline->{"host"}, $ip) matches_mask($gline->{"user"}, $user)
Truth table0%0/5
A or B and C
A= matches_mask($gline->{"host"}, $host)B= matches_mask($gline->{"host"}, $ip)C= matches_mask($gline->{"user"}, $user)
ABCresult
00X0
1X00
0100
1X11
0111
6508 || matches_mask($gline->{host}, $ip))
6509 && matches_mask($gline->{user}, $user)) {
6510 0 return 1;
6511 }
6512 }
6513  
6514 16 return 0;
6515 }
6516  
6517 sub _state_user_matches_gline {
6518 16 ▶ my $self = shift;
Subroutine _state_user_matches_gline: called CC=11 SCAR=38.1
6519 16 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6520 16 my $record = $self->{state}{conns}{$conn_id};
6521 16 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition33%1/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
0160
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table33%1/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
6522 16 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition50%1/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
016
MC/DC0%0/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table50%1/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
6523 16 my $ip = $record->{socket}[0];
6524  
6525 16 for my $gline (@{ $self->{state}{glines} }) {
6526 0 ▶ if (my $netmask = Net::Netmask->new2($gline->{host})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $netmask = "Net::Netmask"->new2($gline->{"host"})) 0 0 0
6527 0 ▶ if ($netmask->match($ip)
Branch: 2 branches
BranchTrueFalseTotal
if ($netmask->match($ip) and matches_mask($gline->{'user'}, $user)) { } 0 0 0
elsif (matches_mask($gline->{'host'}, $host) || matches_mask($gline->{'host'}, $ip) and matches_mask($gline->{'user'}, $user)) { } 0 0 0
Condition0%0/3
$netmask->match($ip) and matches_mask($gline->{"user"}, $user)
!ll&&!rl&&r
000
MC/DC0%0/2
$netmask->match($ip) and matches_mask($gline->{"user"}, $user)
$netmask->match($ip) matches_mask($gline->{"user"}, $user)
Truth table0%0/3
A and B
A= $netmask->match($ip)B= matches_mask($gline->{"user"}, $user)
ABresult
0X0
100
111
6528 && matches_mask($gline->{user}, $user)) {
6529 0 return 1;
6530 }
6531 ▶ elsif ((matches_mask($gline->{host}, $host)
Condition0%0/6
matches_mask($gline->{"host"}, $host) || matches_mask($gline->{"host"}, $ip) and matches_mask($gline->{"user"}, $user)
!ll&&!rl&&r
000
matches_mask($gline->{"host"}, $host) or matches_mask($gline->{"host"}, $ip)
l!l&&r!l&&!r
000
MC/DC0%0/3
matches_mask($gline->{"host"}, $host) || matches_mask($gline->{"host"}, $ip) and matches_mask($gline->{"user"}, $user)
matches_mask($gline->{"host"}, $host) matches_mask($gline->{"host"}, $ip) matches_mask($gline->{"user"}, $user)
Truth table0%0/5
A or B and C
A= matches_mask($gline->{"host"}, $host)B= matches_mask($gline->{"host"}, $ip)C= matches_mask($gline->{"user"}, $user)
ABCresult
00X0
1X00
0100
1X11
0111
6532 || matches_mask($gline->{host}, $ip))
6533 && matches_mask($gline->{user}, $user)) {
6534 0 return 1;
6535 }
6536 }
6537 }
6538  
6539 16 return 0;
6540 }
6541  
6542 sub _state_auth_client_conn {
6543 18 ▶ my $self = shift;
Subroutine _state_auth_client_conn: called CC=15 SCAR=36.9
6544 18 ▶ my $conn_id = 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
6545  
6546 18 ▶ if (!$self->{config}{auth} || !@{ $self->{config}{auth} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}) 16 2 18
Condition66%2/3
$self->{"config"}{"auth"} and @{$self->{"config"}{"auth"};}
!ll&&!rl&&r
1602
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
6547 16 return 1;
6548 }
6549 2 my $record = $self->{state}{conns}{$conn_id};
6550 2 ▶ my $host = $record->{auth}{hostname} || $record->{socket}[0];
Condition33%1/3
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
l!l&&r!l&&!r
020
MC/DC0%0/2
$record->{'auth'}{'hostname'} || $record->{'socket'}[0]
$record->{'auth'}{'hostname'} $record->{'socket'}[0]
Truth table33%1/3
A || B
A= $record->{'auth'}{'hostname'}B= $record->{'socket'}[0]
ABresult
1X1
011
000
6551 2 ▶ my $user = $record->{auth}{ident} || "~" . $record->{user};
Condition50%1/2
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
l!l
02
MC/DC0%0/1
$record->{'auth'}{'ident'} || '~' . $record->{'user'}
$record->{'auth'}{'ident'}
Truth table50%1/2
A
A= $record->{'auth'}{'ident'}
Aresult
11
00
6552 2 my $uh = join '@', $user, $host;
6553 2 my $ui = join '@', $user, $record->{socket}[0];
6554  
6555 2 for my $auth (@{ $self->{config}{auth} }) {
6556 2 ▶ if (matches_mask($auth->{mask}, $uh)
Branch: 1 branch
BranchTrueFalseTotal
if (matches_mask($auth->{"mask"}, $uh) or matches_mask($auth->{"mask"}, $ui)) 2 0 2
Condition33%1/3
matches_mask($auth->{"mask"}, $uh) or matches_mask($auth->{"mask"}, $ui)
l!l&&r!l&&!r
200
MC/DC0%0/2
matches_mask($auth->{"mask"}, $uh) or matches_mask($auth->{"mask"}, $ui)
matches_mask($auth->{"mask"}, $uh) matches_mask($auth->{"mask"}, $ui)
Truth table33%1/3
A or B
A= matches_mask($auth->{"mask"}, $uh)B= matches_mask($auth->{"mask"}, $ui)
ABresult
1X1
011
000
6557 || matches_mask($auth->{mask}, $ui)) {
6558 2 ▶ if ($auth->{password} && (!$record->{pass}
Branch: 1 branch
BranchTrueFalseTotal
if ($auth->{"password"} and !$record->{"pass"} || $auth->{"password"} ne $record->{"pass"}) 2 0 2
Condition33%2/6
$auth->{"password"} and !$record->{"pass"} || $auth->{"password"} ne $record->{"pass"}
!ll&&!rl&&r
020
not $record->{"pass"} or $auth->{"password"} ne $record->{"pass"}
l!l&&r!l&&!r
200
MC/DC0%0/3
$auth->{"password"} and !$record->{"pass"} || $auth->{"password"} ne $record->{"pass"}
$auth->{"password"} not $record->{"pass"} $auth->{"password"} ne $record->{"pass"}
Truth table0%0/4
A and not(B) or C
A= $auth->{"password"}B= not $record->{"pass"}C= $auth->{"password"} ne $record->{"pass"}
ABCresult
0XX0
1000
11X1
1011
6559 || $auth->{password} ne $record->{pass})) {
6560 2 return 0;
6561 }
6562 0 ▶ $record->{auth}{hostname} = $auth->{spoof} if $auth->{spoof};
Branch: 1 branch
BranchTrueFalseTotal
if $auth->{"spoof"} 0 0 0
6563  
6564 0 ▶ if (!$record->{auth}{ident} && $auth->{no_tilde}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $record->{"auth"}{"ident"} and $auth->{"no_tilde"}) 0 0 0
Condition0%0/3
not $record->{"auth"}{"ident"} and $auth->{"no_tilde"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $record->{"auth"}{"ident"} and $auth->{"no_tilde"}
not $record->{"auth"}{"ident"} $auth->{"no_tilde"}
Truth table0%0/3
not(A) and B
A= not $record->{"auth"}{"ident"}B= $auth->{"no_tilde"}
ABresult
0X0
100
111
6565 0 $record->{auth}{ident} = $record->{user};
6566 }
6567 0 return 1;
6568 }
6569 }
6570  
6571 0 return 0;
6572 }
6573  
6574 sub _state_auth_peer_conn {
6575 4 ▶ my $self = shift;
Subroutine _state_auth_peer_conn: called CC=14 SCAR=34.9
6576 4 my ($conn_id, $name, $pass) = @_;
6577  
6578 4 ▶ if (!$conn_id || !$self->_connection_exists($conn_id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conn_id and $self->_connection_exists($conn_id)) 0 4 4
Condition33%1/3
$conn_id and $self->_connection_exists($conn_id)
!ll&&!rl&&r
004
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
6579 0 return;
6580 }
6581  
6582 4 ▶ return if !$name || !$pass;
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $pass 0 4 4
Condition33%1/3
$name and $pass
!ll&&!rl&&r
004
MC/DC0%0/2
$name and $pass
$name $pass
Truth table33%1/3
A and B
A= $nameB= $pass
ABresult
0X0
100
111
6583 4 my $peers = $self->{config}{peers};
6584 4 ▶ if (!$peers->{uc $name} || $peers->{uc $name}{pass} ne $pass) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $$peers{uc $name} or $$peers{uc $name}{"pass"} ne $pass) 0 4 4
Condition33%1/3
not $$peers{uc $name} or $$peers{uc $name}{"pass"} ne $pass
l!l&&r!l&&!r
004
MC/DC0%0/2
not $$peers{uc $name} or $$peers{uc $name}{"pass"} ne $pass
not $$peers{uc $name} $$peers{uc $name}{"pass"} ne $pass
Truth table33%1/3
not(A) or B
A= not $$peers{uc $name}B= $$peers{uc $name}{"pass"} ne $pass
ABresult
1X1
011
000
6585 0 return 0;
6586 }
6587  
6588 4 my $conn = $self->{state}{conns}{$conn_id};
6589 4 ▶ if (!$peers->{uc $name}{ipmask} && $conn->{socket}[0] =~ /^127\./) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $$peers{uc $name}{"ipmask"} and $conn->{"socket"}[0] =~ /^127\./) 2 2 4
Condition66%2/3
not $$peers{uc $name}{"ipmask"} and $conn->{"socket"}[0] =~ /^127\./
!ll&&!rl&&r
202
MC/DC50%1/2
not $$peers{uc $name}{"ipmask"} and $conn->{"socket"}[0] =~ /^127\./
not $$peers{uc $name}{"ipmask"} $conn->{"socket"}[0] =~ /^127\./
Truth table66%2/3
not(A) and B
A= not $$peers{uc $name}{"ipmask"}B= $conn->{"socket"}[0] =~ /^127\./
ABresult
0X0
100
111
6590 2 return 1;
6591 }
6592 2 ▶ return 0 if !$peers->{uc $name}{ipmask};
Branch: 1 branch
BranchTrueFalseTotal
unless $$peers{uc $name}{"ipmask"} 0 2 2
6593 2 my $client_ip = $conn->{socket}[0];
6594  
6595 2 ▶ if (ref $peers->{uc $name}{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$peers{uc $name}{"ipmask"} eq "ARRAY") 0 2 2
6596 0 for my $block (grep { $_->isa('Net::Netmask') }
6597 0 @{ $peers->{uc $name}{ipmask} }) {
6598 0 ▶ return 1 if $block->match($client_ip);
Branch: 1 branch
BranchTrueFalseTotal
if $block->match($client_ip) 0 0 0
6599 }
6600 }
6601  
6602 return 1 if matches_mask(
6603 '*!*@'.$peers->{uc $name}{ipmask},
6604 2 ▶ "*!*\@$client_ip",
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask('*!*@' . $$peers{uc $name}{"ipmask"}, "*!*\@$client_ip") 2 0 2
6605 );
6606  
6607 0 return 0;
6608 }
6609  
6610 sub _state_send_credentials {
6611 4 ▶ my $self = shift;
Subroutine _state_send_credentials: called CC=6 SCAR=18.2
6612 4 ▶ my $conn_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
6613 4 ▶ my $name = 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
6614 4 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4 4
6615 4 ▶ return if !$self->{config}{peers}{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"config"}{"peers"}{uc $name} 0 4 4
6616  
6617 4 my $peer = $self->{config}{peers}{uc $name};
6618 $self->send_output(
6619 {
6620 command => 'PASS',
6621 4 params => [$peer->{rpass}, 'TS'],
6622 },
6623 $conn_id,
6624 );
6625  
6626 $self->send_output(
6627 {
6628 command => 'CAPAB',
6629 params => [
6630 4 ▶ join (' ', @{ $self->{config}{capab} },
Branch: 1 branch
BranchTrueFalseTotal
$peer->{'zip'} ? : 2 2 4
6631 4 ($peer->{zip} ? 'ZIP' : ())
6632 ),
6633 ],
6634 },
6635 $conn_id,
6636 );
6637  
6638 4 my $rec = $self->{state}{peers}{uc $self->server_name()};
6639 $self->send_output(
6640 {
6641 command => 'SERVER',
6642 4 params => [$rec->{name}, $rec->{hops} + 1, $rec->{desc}],
6643 },
6644 $conn_id,
6645 );
6646  
6647 4 $self->send_output(
6648 {
6649 command => 'SVINFO',
6650 params => [5, 5, 0, time],
6651 },
6652 $conn_id,
6653 );
6654  
6655 4 $self->{state}{conns}{$conn_id}{zip} = $peer->{zip};
6656 4 return 1;
6657 }
6658  
6659 sub _state_send_burst {
6660 4 ▶ my $self = shift;
Subroutine _state_send_burst: called CC=19 SCAR=44.9
6661 4 ▶ my $conn_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
6662 4 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4 4
6663 4 my $server = $self->server_name();
6664 4 my $conn = $self->{state}{conns}{$conn_id};
6665 4 my $burst = grep { /^EOB$/i } @{ $conn->{capab} };
6666 4 my $invex = grep { /^IE$/i } @{ $conn->{capab} };
6667 4 my $excepts = grep { /^EX$/i } @{ $conn->{capab} };
6668 4 my %map = qw(bans b excepts e invex I);
6669 4 my @lists = qw(bans);
6670 4 ▶ push @lists, 'excepts' if $excepts;
Branch: 1 branch
BranchTrueFalseTotal
if $excepts 4 0 4
6671 4 ▶ push @lists, 'invex' if $invex;
Branch: 1 branch
BranchTrueFalseTotal
if $invex 4 0 4
6672  
6673 # Send SERVER burst
6674 4 for ($self->_state_server_burst($server, $conn->{name})) {
6675 0 $self->send_output($_, $conn_id );
6676 }
6677  
6678 # Send NICK burst
6679 4 for my $nick (keys %{ $self->{state}{users} }) {
6680 4 my $record = $self->{state}{users}{$nick};
6681 4 ▶ next if $record->{route_id} eq $conn_id;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"route_id"} eq $conn_id 0 4 4
6682  
6683 4 my $umode_fixed = $record->{umode};
6684 4 $umode_fixed =~ s/[^aiow]//g;
6685 my $arrayref = [
6686 $record->{nick},
6687 $record->{hops} + 1,
6688 $record->{ts},
6689 '+' . $umode_fixed,
6690 $record->{auth}{ident},
6691 $record->{auth}{hostname},
6692 $record->{server}, $record->{ircname},
6693 4 ];
6694 4 $self->send_output(
6695 {
6696 command => 'NICK',
6697 params => $arrayref,
6698 },
6699 $conn_id,
6700 );
6701 }
6702  
6703 # Send SJOIN+MODE burst
6704 4 for my $chan (keys %{ $self->{state}{chans} }) {
6705 0 ▶ next if $chan =~ /^\&/;
Branch: 1 branch
BranchTrueFalseTotal
if $chan =~ /^\&/ 0 0 0
6706 0 my $chanrec = $self->{state}{chans}{$chan};
6707 0 my @nicks = map { $_->[1] }
6708 0 sort { $a->[0] cmp $b->[0] }
6709 0 map { my $w = $_; $w =~ tr/@%+/ABC/; [$w, $_] }
6710 $self->state_chan_list_prefixed($chan);
6711  
6712 my $arrayref2 = [
6713 $chanrec->{ts},
6714 $chanrec->{name},
6715 '+' . $chanrec->{mode},
6716 ($chanrec->{ckey} || ()),
6717 0 ▶ ($chanrec->{climit} || ()),
Condition0%0/6
$chanrec->{'ckey'} || ()
l!l&&r!l&&!r
000
$chanrec->{'climit'} || ()
l!l&&r!l&&!r
000
MC/DC0%0/2
$chanrec->{'ckey'} || ()
$chanrec->{'ckey'} ()
MC/DC0%0/2
$chanrec->{'climit'} || ()
$chanrec->{'climit'} ()
Truth table0%0/3
A || B
A= $chanrec->{'ckey'}B= ()
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $chanrec->{'climit'}B= ()
ABresult
1X1
011
000
6718 join ' ', @nicks,
6719 ];
6720  
6721 0 $self->send_output(
6722 {
6723 prefix => $server,
6724 command => 'SJOIN',
6725 params => $arrayref2,
6726 },
6727 $conn_id,
6728 );
6729  
6730 # TODO: MODE burst
6731 # Banlist|Exceptions|Invex
6732 0 my @output_modes;
6733 0 OUTER: for my $type (@lists) {
6734 0 my $length = length($server) + 4 + length($chan) + 4;
6735 0 my @buffer = ( '', '' );
6736 0 INNER: for my $thing (keys %{ $chanrec->{$type} }) {
6737 0 $thing = $chanrec->{$type}{$thing}[0];
6738 0 ▶ if (length(join ' ', @buffer, $thing)+$length+1 > 510) {
Branch: 1 branch
BranchTrueFalseTotal
if (length(join " ", @buffer, $thing) + $length + 1 > 510) 0 0 0
6739 0 $buffer[0] = '+' . $buffer[0];
6740 push @output_modes, {
6741 prefix => $server,
6742 command => 'MODE',
6743 colonify => 0,
6744 params => [
6745 $chanrec->{name},
6746 0 $buffer[0],
6747 split /\s+/, $buffer[1],
6748 ],
6749 };
6750 0 $buffer[0] = '+' . $map{$type};
6751 0 $buffer[1] = $thing;
6752 0 next INNER;
6753 }
6754  
6755 0 ▶ if ($buffer[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buffer[1]) { } 0 0 0
6756 0 $buffer[0] .= $map{$type};
6757 0 $buffer[1] = join ' ', $buffer[1], $thing;
6758 }
6759 else {
6760 0 $buffer[0] = '+' . $map{$type};
6761 0 $buffer[1] = $thing;
6762 }
6763 }
6764  
6765 push @output_modes, {
6766 prefix => $server,
6767 command => 'MODE',
6768 colonify => 0,
6769 params => [
6770 $chanrec->{name},
6771 0 ▶ $buffer[0],
Branch: 1 branch
BranchTrueFalseTotal
if $buffer[0] 0 0 0
6772 split /\s+/, $buffer[1],
6773 ],
6774 } if $buffer[0];
6775 }
6776 0 $self->send_output($_, $conn_id) for @output_modes;
6777 }
6778  
6779 $self->send_output(
6780 {
6781 4 ▶ prefix => $server,
Branch: 1 branch
BranchTrueFalseTotal
if $burst 4 0 4
6782 command => 'EOB',
6783 },
6784 $conn_id,
6785 ) if $burst;
6786  
6787 4 return 1;
6788 }
6789  
6790 sub _state_server_burst {
6791 4 ▶ my $self = shift;
Subroutine _state_server_burst: called CC=9 SCAR=26.0
6792 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
6793 4 ▶ my $targ = 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
6794 4 ▶ if (!$self->state_peer_exists( $peer )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_peer_exists($peer) and $self->state_peer_exists($targ)) 0 4 4
Condition33%1/3
$self->state_peer_exists($peer) and $self->state_peer_exists($targ)
!ll&&!rl&&r
004
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
6795 || !$self->state_peer_exists($targ)) {
6796 }
6797  
6798 4 my $ref = [ ];
6799 4 $peer = $self->_state_peer_name($peer);
6800 4 my $upeer = uc $peer;
6801 4 my $utarg = uc $targ;
6802  
6803 4 for my $server (keys %{ $self->{state}{peers}{$upeer}{peers} }) {
6804 4 ▶ next if $server eq $utarg;
Branch: 1 branch
BranchTrueFalseTotal
if $server eq $utarg 4 0 4
6805 0 my $rec = $self->{state}{peers}{$server};
6806 push @$ref, {
6807 prefix => $peer,
6808 command => 'SERVER',
6809 0 params => [$rec->{name}, $rec->{hops} + 1, $rec->{desc}],
6810 };
6811 0 push @$ref, $_ for $self->_state_server_burst($rec->{name}, $targ);
6812 }
6813  
6814 4 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 4 0 4
6815 0 return $ref;
6816 }
6817  
6818 sub _state_server_links {
6819 0 ▶ my $self = shift;
Subroutine _state_server_links: not called CC=8 SCAR=42.8
6820 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
6821 0 ▶ my $orig = 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
6822 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
6823 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
6824  
6825 0 my $ref = [ ];
6826 0 $peer = $self->_state_peer_name($peer);
6827 0 my $upeer = uc $peer;
6828  
6829 0 for my $server (keys %{ $self->{state}{peers}{$upeer}{peers} }) {
6830 0 my $rec = $self->{state}{peers}{$server};
6831 0 for ($self->_state_server_links($rec->{name}, $orig, $nick)) {
6832 0 push @$ref, $_;
6833 }
6834 push @$ref, {
6835 prefix => $orig,
6836 command => '364',
6837 params => [
6838 $nick,
6839 $rec->{name},
6840 $peer,
6841 0 join( ' ', $rec->{hops}, $rec->{desc}),
6842 ],
6843 };
6844 }
6845  
6846 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
6847 0 return $ref;
6848 }
6849  
6850 sub _state_peer_for_peer {
6851 0 ▶ my $self = shift;
Subroutine _state_peer_for_peer: not called CC=3 SCAR=24.8
6852 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
6853 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
6854 0 $peer = uc $peer;
6855 0 return $self->{state}{peers}{$peer}{peer};
6856 }
6857  
6858 sub _state_server_squit {
6859 0 ▶ my $self = shift;
Subroutine _state_server_squit: not called CC=7 SCAR=40.3
6860 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
6861 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
6862 0 my $ref = [ ];
6863 0 my $upeer = uc $peer;
6864 0 push @$ref, $_ for keys %{ $self->{state}{peers}{$upeer}{users} };
6865  
6866 0 for my $server (keys %{ $self->{state}{peers}{$upeer}{peers} }) {
6867 0 push @$ref, $_ for $self->_state_server_squit($server);
6868 }
6869  
6870 0 delete $self->{state}{peers}{$upeer};
6871 0 delete $self->{state}{peers}{uc $self->server_name()}{peers}{$upeer};
6872 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
6873 0 return $ref;
6874 }
6875  
6876 sub _state_register_peer {
6877 4 ▶ my $self = shift;
Subroutine _state_register_peer: called CC=4 SCAR=13.9
6878 4 ▶ my $conn_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
6879 4 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 4 4
6880 4 my $server = $self->server_name();
6881 4 my $record = $self->{state}{conns}{$conn_id};
6882  
6883 4 ▶ if (!$record->{cntr}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"cntr"}) 2 2 4
6884 2 $self->_state_send_credentials($conn_id, $record->{name});
6885 }
6886  
6887 4 $record->{burst} = $record->{registered} = 1;
6888 4 $record->{type} = 'p';
6889 4 $record->{route_id} = $conn_id;
6890 4 $record->{peer} = $server;
6891 4 $record->{users} = { };
6892 4 $record->{peers} = { };
6893 4 $self->{state}{peers}{uc $server}{peers}{uc $record->{name}} = $record;
6894 4 $self->{state}{peers}{ uc $record->{name} } = $record;
6895 4 $self->antiflood($conn_id, 0);
6896 $self->send_output(
6897 {
6898 prefix => $server,
6899 command => 'SERVER',
6900 params => [
6901 $record->{name},
6902 $record->{hops} + 1,
6903 $record->{desc},
6904 ],
6905 },
6906 4 grep { $_ ne $conn_id } $self->_state_connected_peers(),
6907 );
6908  
6909 $self->send_event(
6910 "daemon_server",
6911 $record->{name},
6912 $server,
6913 $record->{hops},
6914 $record->{desc},
6915 4 );
6916  
6917 4 return 1;
6918 }
6919  
6920 sub _state_register_client {
6921 16 ▶ my $self = shift;
Subroutine _state_register_client: called CC=8 SCAR=22.0
6922 16 ▶ my $conn_id = shift || return;
Condition50%1/2
shift() || (return)
l!l
160
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6923 16 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 0 16 16
6924  
6925 16 my $record = $self->{state}{conns}{$conn_id};
6926 16 $record->{ts} = $record->{idle_time} = $record->{conn_time} = time;
6927 16 $record->{_ignore_i_umode} = 1;
6928 16 $record->{server} = $self->server_name();
6929 16 $record->{hops} = 0;
6930 16 $record->{route_id} = $conn_id;
6931 16 $record->{umode} = '';
6932  
6933 16 ▶ if (!$record->{auth}{ident}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"auth"}{"ident"}) 16 0 16
6934 16 $record->{auth}{ident} = '~' . $record->{user};
6935 }
6936  
6937 16 ▶ 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\./) 16 0 16
Condition33%2/6
$record->{"auth"}{"hostname"} eq "localhost" or not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^127\./
l!l&&r!l&&!r
0160
not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^127\./
!ll&&!rl&&r
0016
MC/DC0%0/3
$record->{"auth"}{"hostname"} eq "localhost" or not $record->{"auth"}{"hostname"} and $record->{"socket"}[0] =~ /^127\./
$record->{"auth"}{"hostname"} eq "localhost" not $record->{"auth"}{"hostname"} $record->{"socket"}[0] =~ /^127\./
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\./
ABCresult
1XX1
0111
00X0
0100
6938 !$record->{auth}{hostname} && $record->{socket}[0] =~ /^127\./) {
6939 16 $record->{auth}{hostname} = $self->server_name();
6940 }
6941  
6942 16 ▶ if (!$record->{auth}{hostname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"auth"}{"hostname"}) 0 16 16
6943 0 $record->{auth}{hostname} = $record->{socket}[0];
6944 }
6945  
6946 16 $self->{state}{users}{uc_irc($record->{nick})} = $record;
6947 16 $self->{state}{peers}{uc $record->{server}}{users}{uc_irc($record->{nick})} = $record;
6948  
6949 my $arrayref = [
6950 $record->{nick},
6951 $record->{hops} + 1,
6952 $record->{ts}, '+i',
6953 $record->{auth}{ident},
6954 $record->{auth}{hostname},
6955 $record->{server},
6956 $record->{ircname},
6957 16 ];
6958 16 delete $self->{state}{pending}{uc_irc($record->{nick})};
6959 16 $self->send_output(
6960 {
6961 command => 'NICK',
6962 params => $arrayref,
6963 },
6964 $self->_state_connected_peers(),
6965 );
6966 16 $self->send_event("daemon_nick", @$arrayref);
6967 16 $self->_state_update_stats();
6968 16 return 1;
6969 }
6970  
6971 sub state_nicks {
6972 0 ▶ my $self = shift;
Subroutine state_nicks: not called CC=1 SCAR=6.9
Pod documented
6973 0 return map { $self->{state}{users}{$_}{nick} }
6974 0 keys %{ $self->{state}{users} };
6975 }
6976  
6977 sub state_nick_exists {
6978 267 ▶ my $self = shift;
Subroutine state_nick_exists: called CC=4 SCAR=14.0
Pod documented
6979 267 ▶ my $nick = shift || return 1;
Condition50%1/2
shift() || (return 1)
l!l
2670
MC/DC0%0/1
shift() || (return 1)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6980 267 $nick = uc_irc($nick);
6981  
6982 267 ▶ if (!defined $self->{state}{users}{$nick}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}) 32 235 267
Condition66%2/3
defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}
l!l&&r!l&&!r
235032
MC/DC50%1/2
defined $self->{"state"}{"users"}{$nick} or defined $self->{"state"}{"pending"}{$nick}
defined $self->{"state"}{"users"}{$nick} defined $self->{"state"}{"pending"}{$nick}
Truth table66%2/3
A or B
A= defined $self->{"state"}{"users"}{$nick}B= defined $self->{"state"}{"pending"}{$nick}
ABresult
1X1
011
000
6983 && !defined $self->{state}{pending}{$nick}) {
6984 32 return 0;
6985 }
6986 235 return 1;
6987 }
6988  
6989 sub state_chans {
6990 0 ▶ my $self = shift;
Subroutine state_chans: not called CC=1 SCAR=6.9
Pod documented
6991 0 return map { $self->{state}{chans}{$_}{name} }
6992 0 keys %{ $self->{state}{chans} };
6993 }
6994  
6995 sub state_chan_exists {
6996 144 ▶ my $self = shift;
Subroutine state_chan_exists: called CC=3 SCAR=11.0
Pod documented
6997 144 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
1440
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
6998 144 ▶ return 0 if !defined $self->{state}{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"chans"}{uc_irc($chan)} 6 138 144
6999 138 return 1;
7000 }
7001  
7002 sub state_peers {
7003 0 ▶ my $self = shift;
Subroutine state_peers: not called CC=1 SCAR=6.9
Pod documented
7004 0 return map { $self->{state}{peers}{$_}{name} }
7005 0 keys %{ $self->{state}{peers} };
7006 }
7007  
7008 sub state_peer_exists {
7009 20 ▶ my $self = shift;
Subroutine state_peer_exists: called CC=3 SCAR=11.0
Pod documented
7010 20 ▶ my $peer = 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
7011 20 ▶ return 0 if !defined $self->{state}{peers}{uc $peer};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"state"}{"peers"}{uc $peer} 6 14 20
7012 14 return 1;
7013 }
7014  
7015 sub _state_peer_name {
7016 4 ▶ my $self = shift;
Subroutine _state_peer_name: called CC=3 SCAR=11.4
7017 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
7018 4 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 4 4
7019 4 return $self->{state}{peers}{uc $peer}{name};
7020 }
7021  
7022 sub _state_peer_desc {
7023 0 ▶ my $self = shift;
Subroutine _state_peer_desc: not called CC=3 SCAR=24.8
7024 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
7025 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
7026 0 return $self->{state}{peers}{uc $peer}{desc};
7027 }
7028  
7029 sub _state_peer_capab {
7030 0 ▶ my $self = shift;
Subroutine _state_peer_capab: not called CC=4 SCAR=30.0
7031 0 ▶ my $conn_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
7032 0 ▶ my $capab = 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
7033 0 $capab = uc $capab;
7034 0 ▶ return if !$self->_connection_is_peer($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_is_peer($conn_id) 0 0 0
7035 0 my $conn = $self->{state}{conns}{$conn_id};
7036 0 return scalar grep { $_ eq $capab } @{ $conn->{capab} };
7037 }
7038  
7039 sub state_user_full {
7040 48 ▶ my $self = shift;
Subroutine state_user_full: called CC=3 SCAR=11.3
Pod documented
7041 48 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
480
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7042 48 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 48 48
7043 48 my $record = $self->{state}{users}{uc_irc($nick)};
7044 return $record->{nick} . '!' . $record->{auth}{ident}
7045 48 . '@' . $record->{auth}{hostname};
7046 }
7047  
7048 sub state_user_nick {
7049 9 ▶ my $self = shift;
Subroutine state_user_nick: called CC=3 SCAR=11.4
Pod documented
7050 9 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
90
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7051 9 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 9 9
7052 9 return $self->{state}{users}{uc_irc($nick)}{nick};
7053 }
7054  
7055 sub _state_user_ip {
7056 2 ▶ my $self = shift;
Subroutine _state_user_ip: called CC=4 SCAR=15.2
7057 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
7058 2 ▶ 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 2 2
Condition33%1/3
$self->state_nick_exists($nick) and $self->_state_is_local_user($nick)
!ll&&!rl&&r
002
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
7059 || !$self->_state_is_local_user($nick);
7060 2 my $record = $self->{state}{users}{uc_irc($nick)};
7061 2 return $record->{socket}[0];
7062 }
7063  
7064 sub _state_user_away {
7065 0 ▶ my $self = shift;
Subroutine _state_user_away: not called CC=4 SCAR=30.0
7066 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
7067 0 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 0 0
7068 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
7069 0 return 0;
7070 }
7071  
7072 sub _state_user_away_msg {
7073 3 ▶ my $self = shift;
Subroutine _state_user_away_msg: called CC=3 SCAR=11.4
7074 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
7075 3 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 3 3
7076 3 return $self->{state}{users}{uc_irc($nick)}{away};
7077 }
7078  
7079 sub state_user_umode {
7080 3 ▶ my $self = shift;
Subroutine state_user_umode: called CC=3 SCAR=11.4
Pod documented
7081 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
7082 3 ▶ return if! $self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 3 3
7083 3 return $self->{state}{users}{uc_irc($nick)}{umode};
7084 }
7085  
7086 sub state_user_is_operator {
7087 14 ▶ my $self = shift;
Subroutine state_user_is_operator: called CC=4 SCAR=14.1
Pod documented
7088 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
7089 14 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 14 14
7090 14 ▶ return 0 if $self->{state}{users}{uc_irc($nick)}{umode} !~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"users"}{uc_irc($nick)}{"umode"} =~ /o/ 5 9 14
7091 9 return 1;
7092 }
7093  
7094 sub _state_user_is_deaf {
7095 2 ▶ my $self = shift;
Subroutine _state_user_is_deaf: called CC=4 SCAR=15.6
7096 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
7097 2 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 2 2
7098 2 ▶ return 0 if $self->{state}{users}{uc_irc($nick)}{umode} !~ /D/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"users"}{uc_irc($nick)}{"umode"} =~ /D/ 2 0 2
7099 0 return 1;
7100 }
7101  
7102 sub state_user_chans {
7103 9 ▶ my $self = shift;
Subroutine state_user_chans: called CC=3 SCAR=11.2
Pod documented
7104 9 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
90
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7105 9 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 9 9
7106 9 my $record = $self->{state}{users}{uc_irc($nick)};
7107 2 return map { $self->{state}{chans}{$_}{name} }
7108 9 keys %{ $record->{chans} };
7109 }
7110  
7111 sub _state_user_route {
7112 57 ▶ my $self = shift;
Subroutine _state_user_route: called CC=3 SCAR=11.3
7113 57 ▶ my $nick = shift || return;
Condition50%1/2
shift() || (return)
l!l
570
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7114 57 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 57 57
7115 57 my $record = $self->{state}{users}{uc_irc($nick)};
7116 57 return $record->{route_id};
7117 }
7118  
7119 sub state_user_server {
7120 0 ▶ my $self = shift;
Subroutine state_user_server: not called CC=3 SCAR=24.8
Pod documented
7121 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
7122 0 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 0 0
7123 0 my $record = $self->{state}{users}{uc_irc($nick)};
7124 0 return $record->{server};
7125 }
7126  
7127 sub _state_peer_route {
7128 0 ▶ my $self = shift;
Subroutine _state_peer_route: not called CC=3 SCAR=24.8
7129 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
7130 0 ▶ return if !$self->state_peer_exists($peer);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_peer_exists($peer) 0 0 0
7131 0 my $record = $self->{state}{peers}{uc $peer};
7132 0 return $record->{route_id};
7133 }
7134  
7135 sub _state_connected_peers {
7136 67 ▶ my $self = shift;
Subroutine _state_connected_peers: called CC=2 SCAR=7.0
7137 67 my $server = uc $self->server_name();
7138 67 ▶ return if !keys %{ $self->{state}{peers} } > 1;
Branch: 1 branch
BranchTrueFalseTotal
if !keys(%{$$self{"state"}{"peers"};}) > 1 0 67 67
7139 67 my $record = $self->{state}{peers}{$server};
7140 8 return map { $record->{peers}{$_}{route_id} }
7141 67 keys %{ $record->{peers} };
7142 }
7143  
7144 sub state_chan_list {
7145 14 ▶ my $self = shift;
Subroutine state_chan_list: called CC=6 SCAR=24.5
Pod documented
7146 14 ▶ my $chan = 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
7147 14 ▶ my $status_msg = shift || '';
Condition50%1/2
shift() || ''
l!l
014
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7148 14 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 14 14
7149  
7150 14 $status_msg =~ s/[^@%+]//g;
7151 14 my $record = $self->{state}{chans}{uc_irc($chan)};
7152 16 return map { $self->{state}{users}{$_}{nick} }
7153 14 ▶ keys %{ $record->{users} } if !$status_msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $status_msg 14 0 14
7154  
7155 0 my %map = qw(o 3 h 2 v 1);
7156 0 my %sym = qw(@ 3 % 2 + 1);
7157 0 my $lowest = (sort map { $sym{$_} } split //, $status_msg)[0];
7158  
7159 0 return map { $self->{state}{users}{$_}{nick} }
7160 grep {
7161 0 $record->{users}{ $_ } and (reverse sort map { $map{$_} }
7162 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
7163 0 } keys %{ $record->{users} };
7164 }
7165  
7166 sub state_chan_list_prefixed {
7167 9 ▶ my $self = shift;
Subroutine state_chan_list_prefixed: called CC=8 SCAR=22.3
Pod documented
7168 9 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
90
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7169 9 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 9 9
7170 9 my $record = $self->{state}{chans}{uc_irc($chan)};
7171  
7172 return map {
7173 12 my $n = $self->{state}{users}{$_}{nick};
7174 12 my $m = $record->{users}{$_};
7175 12 my $p = '';
7176 12 ▶ $p = '@' if $m =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /o/ 9 3 12
7177 12 ▶ $p = '%' if $m =~ /h/ && !$p;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /h/ and not $p 0 12 12
Condition33%1/3
$m =~ /h/ and not $p
!ll&&!rl&&r
1200
MC/DC0%0/2
$m =~ /h/ and not $p
$m =~ /h/ not $p
Truth table33%1/3
A and not(B)
A= $m =~ /h/B= not $p
ABresult
0X0
100
111
7178 12 ▶ $p = '+' if $m =~ /v/ && !$p;
Branch: 1 branch
BranchTrueFalseTotal
if $m =~ /v/ and not $p 0 12 12
Condition33%1/3
$m =~ /v/ and not $p
!ll&&!rl&&r
1200
MC/DC0%0/2
$m =~ /v/ and not $p
$m =~ /v/ not $p
Truth table33%1/3
A and not(B)
A= $m =~ /v/B= not $p
ABresult
0X0
100
111
7179 12 $p . $n;
7180 9 } keys %{ $record->{users} };
7181 }
7182  
7183 sub _state_chan_timestamp {
7184 1 ▶ my $self = shift;
Subroutine _state_chan_timestamp: called CC=3 SCAR=11.4
7185 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
7186 1 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 1 1
7187 1 return $self->{state}{chans}{uc_irc($chan)}{ts};
7188 }
7189  
7190 sub state_chan_topic {
7191 9 ▶ my $self = shift;
Subroutine state_chan_topic: called CC=4 SCAR=15.9
Pod documented
7192 9 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
90
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7193 9 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 9 9
7194 9 my $record = $self->{state}{chans}{uc_irc($chan)};
7195 9 ▶ return if !$record->{topic};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"topic"} 9 0 9
7196 0 return [@{ $record->{topic} }];
7197 }
7198  
7199 sub _state_is_local_user {
7200 20 ▶ my $self = shift;
Subroutine _state_is_local_user: called CC=4 SCAR=15.2
7201 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
7202 20 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 20 20
7203 20 my $record = $self->{state}{peers}{uc $self->server_name()};
7204 20 ▶ return 1 if defined $record->{users}{uc_irc($nick)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"users"}{uc_irc($nick)} 20 0 20
7205 0 return 0;
7206 }
7207  
7208 sub _state_chan_name {
7209 22 ▶ my $self = shift;
Subroutine _state_chan_name: called CC=3 SCAR=11.4
7210 22 ▶ my $chan = 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
7211 22 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 22 22
7212 22 return $self->{state}{chans}{uc_irc($chan)}{name};
7213 }
7214  
7215 sub state_chan_mode_set {
7216 19 ▶ my $self = shift;
Subroutine state_chan_mode_set: called CC=6 SCAR=18.5
Pod documented
7217 19 ▶ my $chan = shift || return;
Condition50%1/2
shift() || (return)
l!l
190
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7218 19 ▶ my $mode = shift || return;
Condition50%1/2
shift() || (return)
l!l
190
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7219 19 ▶ return if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 19 19
7220  
7221 19 $mode =~ s/[^a-zA-Z]+//g;
7222 19 ▶ $mode = (split //, $mode )[0] if length $mode > 1;
Branch: 1 branch
BranchTrueFalseTotal
if length $mode > 1 0 19 19
7223 19 my $record = $self->{state}{chans}{uc_irc($chan)};
7224 19 ▶ return 1 if $record->{mode} =~ /$mode/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"mode"} =~ /$mode/ 3 16 19
7225 16 return 0;
7226 }
7227  
7228 sub _state_user_invited {
7229 0 ▶ my $self = shift;
Subroutine _state_user_invited: not called CC=7 SCAR=40.3
7230 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
7231 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
7232 0 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 0 0
7233 0 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 0 0
7234 0 my $nickrec = $self->{state}{users}{uc_irc($nick)};
7235 0 ▶ return 1 if $nickrec->{invites}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if $nickrec->{"invites"}{uc_irc($chan)} 0 0 0
7236 # Check if user matches INVEX
7237 0 ▶ 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 0 0
7238 0 return 0;
7239 }
7240  
7241 sub _state_user_banned {
7242 4 ▶ my $self = shift;
Subroutine _state_user_banned: called CC=5 SCAR=20.9
7243 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
7244 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
7245 4 ▶ return 0 if !$self->_state_user_matches_list($nick, $chan, 'bans');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_state_user_matches_list($nick, $chan, "bans") 4 0 4
7246 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
7247 0 return 0;
7248 }
7249  
7250 sub _state_user_matches_list {
7251 4 ▶ my $self = shift;
Subroutine _state_user_matches_list: called CC=8 SCAR=23.4
7252 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
7253 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
7254 4 ▶ my $list = shift || 'bans';
Condition50%1/2
shift() || 'bans'
l!l
40
MC/DC0%0/1
shift() || 'bans'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7255 4 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 4 4
7256 4 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 4 4
7257 4 my $full = $self->state_user_full($nick);
7258 4 my $record = $self->{state}{chans}{uc_irc($chan)};
7259  
7260 4 for my $mask (keys %{ $record->{$list} }) {
7261 0 ▶ return 1 if matches_mask($mask, $full);
Branch: 1 branch
BranchTrueFalseTotal
if matches_mask($mask, $full) 0 0 0
7262 }
7263 4 return 0;
7264 }
7265  
7266 sub state_is_chan_member {
7267 23 ▶ my $self = shift;
Subroutine state_is_chan_member: called CC=6 SCAR=18.6
Pod documented
7268 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
7269 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
7270 23 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 23 23
7271 23 ▶ return 0 if !$self->state_chan_exists($chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($chan) 0 23 23
7272 23 my $record = $self->{state}{users}{uc_irc($nick)};
7273 23 ▶ return 1 if defined $record->{chans}{uc_irc($chan)};
Branch: 1 branch
BranchTrueFalseTotal
if defined $record->{"chans"}{uc_irc($chan)} 19 4 23
7274 4 return 0;
7275 }
7276  
7277 sub state_user_chan_mode {
7278 0 ▶ my $self = shift;
Subroutine state_user_chan_mode: not called CC=4 SCAR=30.0
Pod documented
7279 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
7280 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
7281 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
7282 0 return $self->{state}{users}{uc_irc($nick)}{chans}{uc_irc($chan)};
7283 }
7284  
7285 sub state_is_chan_op {
7286 5 ▶ my $self = shift;
Subroutine state_is_chan_op: called CC=7 SCAR=26.4
Pod documented
7287 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
7288 5 ▶ my $chan = 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
7289 5 ▶ return if !$self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($nick, $chan) 0 5 5
7290 5 my $record = $self->{state}{users}{uc_irc($nick)};
7291 5 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /o/ 5 0 5
7292 0 ▶ return 1 if $self->{config}{OPHACKS} && $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"config"}{"OPHACKS"} and $record->{"umode"} =~ /o/ 0 0 0
Condition0%0/3
$self->{"config"}{"OPHACKS"} and $record->{"umode"} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"config"}{"OPHACKS"} and $record->{"umode"} =~ /o/
$self->{"config"}{"OPHACKS"} $record->{"umode"} =~ /o/
Truth table0%0/3
A and B
A= $self->{"config"}{"OPHACKS"}B= $record->{"umode"} =~ /o/
ABresult
0X0
100
111
7293 0 return 0;
7294 }
7295  
7296 sub state_is_chan_hop {
7297 1 ▶ my $self = shift;
Subroutine state_is_chan_hop: called CC=5 SCAR=17.0
Pod documented
7298 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
7299 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
7300 1 ▶ return if !$self->state_is_chan_member($nick, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($nick, $chan) 0 1 1
7301 1 my $record = $self->{state}{users}{uc_irc($nick)};
7302 1 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /h/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /h/ 0 1 1
7303 1 return 0;
7304 }
7305  
7306 sub state_has_chan_voice {
7307 0 ▶ my $self = shift;
Subroutine state_has_chan_voice: not called CC=5 SCAR=34.0
Pod documented
7308 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
7309 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
7310 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
7311 0 my $record = $self->{state}{users}{uc_irc($nick)};
7312 0 ▶ return 1 if $record->{chans}{uc_irc($chan)} =~ /v/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"chans"}{uc_irc($chan)} =~ /v/ 0 0 0
7313 0 return 0;
7314 }
7315  
7316 sub _state_o_line {
7317 3 ▶ my $self = shift;
Subroutine _state_o_line: called CC=16 SCAR=40.7
7318 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
7319 3 my ($user, $pass) = @_;
7320 3 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 3 3
7321 3 ▶ return if !$user || !$pass;
Branch: 1 branch
BranchTrueFalseTotal
unless $user and $pass 0 3 3
Condition33%1/3
$user and $pass
!ll&&!rl&&r
003
MC/DC0%0/2
$user and $pass
$user $pass
Truth table33%1/3
A and B
A= $userB= $pass
ABresult
0X0
100
111
7322  
7323 3 my $ops = $self->{config}{ops};
7324 3 ▶ return if !$ops->{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless $ops->{$user} 1 2 3
7325 2 ▶ return -1 if !chkpasswd ($pass, $ops->{$user}{password});
Branch: 1 branch
BranchTrueFalseTotal
unless chkpasswd($pass, $ops->{$user}{"password"}) 0 2 2
7326  
7327 2 my $client_ip = $self->_state_user_ip($nick);
7328 2 ▶ return if !$client_ip;
Branch: 1 branch
BranchTrueFalseTotal
unless $client_ip 0 2 2
7329 2 ▶ if (!$ops->{$user}{ipmask} && ($client_ip && $client_ip =~ /^127\./)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^127\./)) 2 0 2
Condition33%2/6
not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^127\./)
!ll&&!rl&&r
002
$client_ip and $client_ip =~ /^127\./
!ll&&!rl&&r
002
MC/DC0%0/3
not $ops->{$user}{"ipmask"} and ($client_ip and $client_ip =~ /^127\./)
not $ops->{$user}{"ipmask"} $client_ip $client_ip =~ /^127\./
Truth table25%1/4
not(A) and B and C
A= not $ops->{$user}{"ipmask"}B= $client_ipC= $client_ip =~ /^127\./
ABCresult
0XX0
10X0
1100
1111
7330 2 return 1;
7331 }
7332 0 ▶ return 0 if !$ops->{$user}{ipmask};
Branch: 1 branch
BranchTrueFalseTotal
unless $ops->{$user}{"ipmask"} 0 0 0
7333  
7334 0 ▶ if (ref $ops->{$user}{ipmask} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ops->{$user}{"ipmask"} eq "ARRAY") 0 0 0
7335 0 for my $block (grep { $_->isa('Net::Netmask') } @{ $ops->{$user}{ipmask} }) {
7336 0 ▶ return 1 if $block->match($client_ip);
Branch: 1 branch
BranchTrueFalseTotal
if $block->match($client_ip) 0 0 0
7337 }
7338 }
7339 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
7340 0 return 0;
7341 }
7342  
7343 sub _state_users_share_chan {
7344 0 ▶ my $self = shift;
Subroutine _state_users_share_chan: not called CC=7 SCAR=40.3
7345 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
7346 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
7347 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
7348 || !$self->state_nick_exists($nick2);
7349 0 my $rec1 = $self->{state}{users}{uc_irc($nick1)};
7350 0 my $rec2 = $self->{state}{users}{uc_irc($nick2)};
7351 0 for my $chan (keys %{ $rec1->{chans} }) {
7352 0 ▶ return 1 if $rec2->{chans}{$chan};
Branch: 1 branch
BranchTrueFalseTotal
if $rec2->{"chans"}{$chan} 0 0 0
7353 }
7354 0 return 0;
7355 }
7356  
7357 sub _state_parse_msg_targets {
7358 4 ▶ my $self = shift;
Subroutine _state_parse_msg_targets: called CC=9 SCAR=28.7
7359 4 ▶ my $targets = 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
7360 4 my %results;
7361  
7362 4 for my $target (split /,/, $targets) {
7363 4 ▶ if ($target =~ /^[#&]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^[#&]/) 1 3 4
7364 1 $results{$target} = ['channel'];
7365 1 next;
7366 }
7367 3 ▶ if ($target =~ /^([@%+]+)([#&].+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^([\@%+]+)([#&].+)$/) 0 3 3
7368 0 $results{$target} = ['channel_ext', $1, $2];
7369 0 next;
7370 }
7371 3 ▶ if ( $target =~ /^\${2}(.+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^\${2}(.+)$/) 0 3 3
7372 0 $results{$target} = ['servermask', $1];
7373 0 next;
7374 }
7375 3 ▶ if ( $target =~ /^\$#(.+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /^\$#(.+)$/) 0 3 3
7376 0 $results{$target} = ['hostmask', $1];
7377 0 next;
7378 }
7379 3 ▶ if ($target =~ /@/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target =~ /@/) 0 3 3
7380 0 my ($nick, $server) = split /@/, $target, 2;
7381 0 my $host;
7382 0 ▶ ($nick, $host) = split ( /%/, $nick, 2 ) if $nick =~ /%/;
Branch: 1 branch
BranchTrueFalseTotal
if $nick =~ /%/ 0 0 0
7383 0 $results{$target} = ['nick_ext', $nick, $server, $host];
7384 0 next;
7385 }
7386 3 $results{$target} = ['nick'];
7387 }
7388  
7389 4 return \%results;
7390 }
7391  
7392 sub server_name {
7393 570 ▶ return $_[0]->server_config('ServerName');
Subroutine server_name: called CC=1 SCAR=0.0
Pod documented
7394 }
7395  
7396 sub server_version {
7397 16 ▶ return $_[0]->server_config('Version');
Subroutine server_version: called CC=1 SCAR=0.0
Pod documented
7398 }
7399  
7400 sub server_created {
7401 16 ▶ 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
7402 localtime($_[0]->server_config('created')));
7403 }
7404  
7405 sub _client_nickname {
7406 443 ▶ my $self = shift;
Subroutine _client_nickname: called CC=3 SCAR=11.0
7407 443 ▶ my $wheel_id = $_[0] || return;
Condition50%1/2
$_[0] || (return)
l!l
4430
MC/DC0%0/1
$_[0] || (return)
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
7408 443 ▶ return '*' if !$self->{state}{conns}{$wheel_id}{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"state"}{"conns"}{$wheel_id}{"nick"} 81 362 443
7409 362 return $self->{state}{conns}{$wheel_id}{nick};
7410 }
7411  
7412  
7413 sub _client_ip {
7414 12 ▶ my $self = shift;
Subroutine _client_ip: called CC=2 SCAR=7.1
7415 12 ▶ my $wheel_id = shift || return '';
Condition50%1/2
shift() || (return '')
l!l
120
MC/DC0%0/1
shift() || (return '')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7416 12 return $self->{state}{conns}{$wheel_id}{socket}[0];
7417 }
7418  
7419 sub server_config {
7420 686 ▶ my $self = shift;
Subroutine server_config: called CC=2 SCAR=7.1
Pod documented
7421 686 ▶ my $value = shift || return;
Condition50%1/2
shift() || (return)
l!l
6860
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7422 686 return $self->{config}{uc $value};
7423 }
7424  
7425 sub configure {
7426 20 ▶ my $self = shift;
Subroutine configure: called CC=20 SCAR=36.2
Pod documented
7427 20 ▶ my $opts = ref $_[0] eq 'HASH' ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 4 16 20
7428 20 $opts->{uc $_} = delete $opts->{$_} for keys %$opts;
7429  
7430 my %defaults = (
7431 CREATED => time(),
7432 CASEMAPPING => 'rfc1459',
7433 SERVERNAME => 'poco.server.irc',
7434 SERVERDESC => 'Poco? POCO? POCO!',
7435 20 VERSION => do {
7436 20 ▶ no strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
7437 20 ▶ ref($self) . '-' . (defined $VERSION ? $VERSION : 'dev-git');
Branch: 1 branch
BranchTrueFalseTotal
defined $VERSION ? : 20 0 20
7438 },
7439 NETWORK => 'poconet',
7440 HOSTLEN => 63,
7441 NICKLEN => 9,
7442 USERLEN => 10,
7443 REALLEN => 50,
7444 KICKLEN => 120,
7445 TOPICLEN => 80,
7446 AWAYLEN => 160,
7447 CHANNELLEN => 50,
7448 PASSWDLEN => 20,
7449 KEYLEN => 23,
7450 MAXCHANNELS => 15,
7451 MAXACCEPT => 20,
7452 MODES => 4,
7453 MAXTARGETS => 4,
7454 MAXBANS => 25,
7455 MAXBANLENGTH => 1024,
7456 AUTH => 1,
7457 ANTIFLOOD => 1,
7458 WHOISACTUALLY => 1,
7459 OPHACKS => 0,
7460 );
7461 20 $self->{config}{$_} = $defaults{$_} for keys %defaults;
7462  
7463 20 for my $opt (qw(HOSTLEN NICKLEN USERLEN REALLEN TOPICLEN CHANNELLEN
7464 PASSWDLEN KEYLEN MAXCHANNELS MAXACCEPT MODES MAXTARGETS MAXBANS)) {
7465 260 my $new = delete $opts->{$opt};
7466 260 ▶ if (defined $new && $new > $self->{config}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new and $new > $self->{"config"}{$opt}) 0 260 260
Condition33%1/3
defined $new and $new > $self->{"config"}{$opt}
!ll&&!rl&&r
26000
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
7467 0 $self->{config}{$opt} = $new;
7468 }
7469 }
7470  
7471 20 for my $opt (qw(KICKLEN AWAYLEN)) {
7472 40 my $new = delete $opts->{$opt};
7473 40 ▶ if (defined $new && $new < $self->{config}{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new and $new < $self->{"config"}{$opt}) 0 40 40
Condition33%1/3
defined $new and $new < $self->{"config"}{$opt}
!ll&&!rl&&r
4000
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
7474 0 $self->{config}{$opt} = $new;
7475 }
7476 }
7477  
7478 20 for my $opt (keys %$opts) {
7479 4 ▶ $self->{config}{$opt} = $opts->{$opt} if defined $opts->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$opt} 4 0 4
7480 }
7481  
7482 $self->{config}{BANLEN}
7483 20 = sum(@{ $self->{config} }{qw(NICKLEN USERLEN HOSTLEN)}, 3);
7484 $self->{config}{USERHOST_REPLYLEN}
7485 20 = sum(@{ $self->{config} }{qw(NICKLEN USERLEN HOSTLEN)}, 5);
7486  
7487 20 $self->{config}{SERVERNAME} =~ s/[^a-zA-Z0-9\-.]//g;
7488 20 ▶ if ($self->{config}{SERVERNAME} !~ /\./) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"}{"SERVERNAME"} =~ /\./) 0 20 20
7489 0 $self->{config}{SERVERNAME} .= '.';
7490 }
7491  
7492 20 ▶ 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
2000
not defined $self->{"config"}{"ADMIN"} or ref $self->{"config"}{"ADMIN"} ne "ARRAY"
l!l&&r!l&&!r
2000
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
7493 || ref $self->{config}{ADMIN} ne 'ARRAY'
7494 0 || @{ $self->{config}{ADMIN} } != 3) {
7495 20 $self->{config}{ADMIN} = [];
7496 20 $self->{config}{ADMIN}[0] = 'Somewhere, Somewhere, Somewhere';
7497 20 $self->{config}{ADMIN}[1] = 'Some Institution';
7498 20 $self->{config}{ADMIN}[2] = 'someone@somewhere';
7499 }
7500  
7501 20 ▶ 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
2000
not defined $self->{"config"}{"INFO"} or ref $self->{"config"}{"INFO"} ne "ARRAY"
l!l&&r!l&&!r
2000
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
7502 || ref $self->{config}{INFO} ne 'ARRAY'
7503 0 || !@{ $self->{config}{INFO} } == 1) {
7504 20 $self->{config}{INFO} = [split /\n/, <<'EOF'];
7505 # POE::Component::Server::IRC
7506 #
7507 # Author: Chris "BinGOs" Williams
7508 #
7509 # Filter-IRCD Written by Hachi
7510 #
7511 # This module may be used, modified, and distributed under the same
7512 # terms as Perl itself. Please see the license that came with your Perl
7513 # distribution for details.
7514 #
7515 EOF
7516 }
7517  
7518 $self->{Error_Codes} = {
7519 20 401 => [1, "No such nick/channel"],
7520 402 => [1, "No such server"],
7521 403 => [1, "No such channel"],
7522 404 => [1, "Cannot send to channel"],
7523 405 => [1, "You have joined too many channels"],
7524 406 => [1, "There was no such nickname"],
7525 407 => [1, "Too many targets"],
7526 408 => [1, "No such service"],
7527 409 => [1, "No origin specified"],
7528 411 => [0, "No recipient given (%s)"],
7529 412 => [0, "No text to send"],
7530 413 => [1, "No toplevel domain specified"],
7531 414 => [1, "Wildcard in toplevel domain"],
7532 415 => [1, "Bad server/host mask"],
7533 421 => [1, "Unknown command"],
7534 422 => [0, "MOTD File is missing"],
7535 423 => [1, "No administrative info available"],
7536 424 => [1, "File error doing % on %"],
7537 431 => [1, "No nickname given"],
7538 432 => [1, "Erroneous nickname"],
7539 433 => [1, "Nickname is already in use"],
7540 436 => [1, "Nickname collision KILL from %s\@%s"],
7541 437 => [1, "Nick/channel is temporarily unavailable"],
7542 441 => [1, "They aren\'t on that channel"],
7543 442 => [1, "You\'re not on that channel"],
7544 443 => [2, "is already on channel"],
7545 444 => [1, "User not logged in"],
7546 445 => [0, "SUMMON has been disabled"],
7547 446 => [0, "USERS has been disabled"],
7548 451 => [0, "You have not registered"],
7549 461 => [1, "Not enough parameters"],
7550 462 => [0, "Unauthorised command (already registered)"],
7551 463 => [0, "Your host isn\'t among the privileged"],
7552 464 => [0, "Password mismatch"],
7553 465 => [0, "You are banned from this server"],
7554 466 => [0, "You will be banned from this server"],
7555 467 => [1, "Channel key already set"],
7556 471 => [1, "Cannot join channel (+l)"],
7557 472 => [1, "is unknown mode char to me for %s"],
7558 473 => [1, "Cannot join channel (+i)"],
7559 474 => [1, "Cannot join channel (+b)"],
7560 475 => [1, "Cannot join channel (+k)"],
7561 476 => [1, "Bad Channel Mask"],
7562 477 => [1, "Channel doesn\'t support modes"],
7563 478 => [2, "Channel list is full"],
7564 481 => [0, "Permission Denied- You\'re not an IRC operator"],
7565 482 => [1, "You\'re not channel operator"],
7566 483 => [0, "You can\'t kill a server!"],
7567 484 => [0, "Your connection is restricted!"],
7568 485 => [0, "You\'re not the original channel operator"],
7569 491 => [0, "No O-lines for your host"],
7570 501 => [0, "Unknown MODE flag"],
7571 502 => [0, "Cannot change mode for other users"],
7572 };
7573  
7574 $self->{config}{isupport} = {
7575 INVEX => undef,
7576 EXCEPT => undef,
7577 CALLERID => undef,
7578 CHANTYPES => '#&',
7579 PREFIX => '(ohv)@%+',
7580 CHANMODES => 'eIb,k,l,imnpst',
7581 STATUSMSG => '@%+',
7582 DEAF => 'D',
7583 MAXLIST => 'beI:' . $self->{config}{MAXBANS},
7584 20 map { ($_, $self->{config}{$_}) }
7585 qw(MAXCHANNELS MAXTARGETS NICKLEN TOPICLEN KICKLEN CASEMAPPING
7586 NETWORK MODES AWAYLEN),
7587 };
7588  
7589 20 $self->{config}{capab} = [qw(QS EX CHW IE HOPS UNKLN KLN GLN EOB)];
7590  
7591 20 return 1;
7592 }
7593  
7594 sub _send_output_to_client {
7595 332 ▶ my $self = shift;
Subroutine _send_output_to_client: called CC=10 SCAR=23.7
7596 332 ▶ my $wheel_id = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
3320
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7597 332 my $nick = $self->_client_nickname($wheel_id);
7598 332 ▶ $nick = shift if $self->_connection_is_peer($wheel_id);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_connection_is_peer($wheel_id) 0 332 332
7599 332 ▶ my $err = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
3320
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
7600 332 ▶ return if !$self->_connection_exists($wheel_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($wheel_id) 0 332 332
7601  
7602 SWITCH: {
7603 332 ▶ if (ref $err eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $err eq "HASH") 238 94 332
7604 238 $self->send_output($err, $wheel_id);
7605 238 last SWITCH;
7606 }
7607 94 ▶ if (defined $self->{Error_Codes}{$err}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"Error_Codes"}{$err}) 94 0 94
7608 94 my $input = {
7609 command => $err,
7610 prefix => $self->server_name(),
7611 params => [$nick],
7612 };
7613 94 ▶ if ($self->{Error_Codes}{$err}[0] > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Error_Codes"}{$err}[0] > 0) 1 93 94
7614 1 ▶ for (my $i = 1; $i <= $self->{Error_Codes}{$err}[0]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $self->{"Error_Codes"}{$err}[0]) 1 1 2
7615 1 push @{ $input->{params} }, shift;
7616 }
7617 }
7618 94 ▶ if ($self->{Error_Codes}{$err}[1] =~ /%/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'Error_Codes'}{$err}[1] =~ /%/) { } 0 94 94
7619 0 push @{ $input->{params} },
7620 0 sprintf($self->{Error_Codes}{$err}[1], @_);
7621 }
7622 else {
7623 94 push @{ $input->{params} }, $self->{Error_Codes}{$err}[1];
7624 }
7625 94 $self->send_output($input, $wheel_id);
7626 }
7627 }
7628  
7629 332 return 1;
7630 }
7631  
7632 sub _send_output_to_channel {
7633 6 ▶ my $self = shift;
Subroutine _send_output_to_channel: called CC=11 SCAR=26.6
7634 6 ▶ my $channel = 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
7635 6 ▶ my $output = 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
7636 6 ▶ my $conn_id = shift || '';
Condition100%2/2
shift() || ''
l!l
33
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
7637 6 ▶ return if !$self->state_chan_exists($channel);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_chan_exists($channel) 0 6 6
7638  
7639 # Get conn_ids for each of our peers.
7640 6 my $ref = [ ];
7641 6 my $peers = { };
7642 6 $peers->{$_}++ for $self->_state_connected_peers();
7643 6 ▶ delete $peers->{$conn_id} if $conn_id;
Branch: 1 branch
BranchTrueFalseTotal
if $conn_id 3 3 6
7644 push @$ref, $self->_state_user_route($_)
7645 6 for grep { $self->_state_is_local_user($_) }
7646 $self->state_chan_list($channel);
7647 6 @$ref = grep { $_ ne $conn_id } @$ref;
7648  
7649 6 ▶ if ($channel !~ /^\&/ && scalar keys %$peers
Branch: 1 branch
BranchTrueFalseTotal
if (not $channel =~ /^\&/ and scalar keys %$peers and $output->{"command"} ne "JOIN") 0 6 6
Condition40%2/5
not $channel =~ /^\&/ and scalar keys %$peers and $output->{"command"} ne "JOIN"
!ll&&!rl&&r
600
not $channel =~ /^\&/ and scalar keys %$peers
!ll
06
MC/DC0%0/2
not $channel =~ /^\&/ and scalar keys %$peers and $output->{"command"} ne "JOIN"
not $channel =~ /^\&/ $output->{"command"} ne "JOIN"
Truth table0%0/3
not(A) and B
A= not $channel =~ /^\&/B= $output->{"command"} ne "JOIN"
ABresult
0X0
100
111
7650 && $output->{command} ne 'JOIN') {
7651 0 my $full = $output->{prefix};
7652 0 my $nick = (split /!/, $full)[0];
7653 0 my $output2 = { %$output };
7654 0 $output2->{prefix} = $nick;
7655 0 $self->send_output($output2, keys %$peers);
7656 }
7657  
7658 6 $self->send_output($output, @$ref);
7659 $self->send_event(
7660 "daemon_" . lc $output->{command},
7661 $output->{prefix},
7662 6 @{ $output->{params} },
7663 );
7664 6 return 1;
7665 }
7666  
7667 sub add_operator {
7668 2 ▶ my $self = shift;
Subroutine add_operator: called CC=5 SCAR=18.0
Pod documented
7669 2 my $ref;
7670 2 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 2 0 2
7671 2 $ref = $_[0];
7672 }
7673 else {
7674 0 $ref = { @_ };
7675 }
7676 2 $ref->{lc $_} = delete $ref->{$_} for keys %$ref;
7677  
7678 2 ▶ if (!defined $ref->{username} || !defined $ref->{password}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ref->{"username"} and defined $ref->{"password"}) 0 2 2
Condition33%1/3
defined $ref->{"username"} and defined $ref->{"password"}
!ll&&!rl&&r
002
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
7679 0 warn "Not enough parameters\n";
7680 0 return;
7681 }
7682  
7683 2 my $record = $self->{state}{peers}{uc $self->server_name()};
7684 2 my $user = delete $ref->{username};
7685 2 $self->{config}{ops}{$user} = $ref;
7686 2 return 1;
7687 }
7688  
7689 sub del_operator {
7690 0 ▶ my $self = shift;
Subroutine del_operator: not called CC=3 SCAR=24.8
Pod documented
7691 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
7692 0 ▶ return if !defined $self->{config}{ops}{$user};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{"ops"}{$user} 0 0 0
7693 0 delete $self->{config}{ops}{$user};
7694 0 return;
7695 }
7696  
7697 sub add_auth {
7698 1 ▶ my $self = shift;
Subroutine add_auth: called CC=4 SCAR=15.0
Pod documented
7699 1 my $parms;
7700 1 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 1 1
7701 0 $parms = $_[0];
7702 }
7703 else {
7704 1 $parms = { @_ };
7705 }
7706 1 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
7707  
7708 1 ▶ if (!$parms->{mask}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parms->{"mask"}) 0 1 1
7709 0 warn "Not enough parameters specified\n";
7710 0 return;
7711 }
7712 1 push @{ $self->{config}{auth} }, $parms;
7713 1 return 1;
7714 }
7715  
7716 sub del_auth {
7717 0 ▶ my $self = shift;
Subroutine del_auth: not called CC=4 SCAR=30.0
Pod documented
7718 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
7719 0 my $i = 0;
7720  
7721 0 for (@{ $self->{config}{auth} }) {
7722 0 ▶ if ($_->{mask} eq $mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"mask"} eq $mask) 0 0 0
7723 0 splice( @{ $self->{config}{auth} }, $i, 1 );
7724 0 last;
7725 }
7726 0 ++$i;
7727 }
7728 0 return;
7729 }
7730  
7731 sub add_peer {
7732 4 ▶ my $self = shift;
Subroutine add_peer: called CC=16 SCAR=30.6
Pod documented
7733 4 my $parms;
7734 4 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 4 4
7735 0 $parms = $_[0];
7736 }
7737 else {
7738 4 $parms = { @_ };
7739 }
7740 4 $parms->{lc $_} = delete $parms->{$_} for keys %$parms;
7741  
7742 4 ▶ if (!defined $parms->{name} || !defined $parms->{pass}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}) 0 4 4
Condition33%2/6
defined $parms->{"name"} and defined $parms->{"pass"} and defined $parms->{"rpass"}
!ll&&!rl&&r
004
defined $parms->{"name"} and defined $parms->{"pass"}
!ll&&!rl&&r
004
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
7743 || !defined $parms->{rpass}) {
7744 0 croak((caller(0))[3].": Not enough parameters specified\n");
7745 0 return;
7746 }
7747  
7748 4 ▶ $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" 2 2 4
Condition66%2/3
not $parms->{"type"} or lc $parms->{"type"} ne "r"
l!l&&r!l&&!r
022
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
7749 4 $parms->{type} = lc $parms->{type};
7750 4 ▶ $parms->{rport} = 6667 if $parms->{type} eq 'r' && !$parms->{rport};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"type"} eq "r" and not $parms->{"rport"} 0 4 4
Condition66%2/3
$parms->{"type"} eq "r" and not $parms->{"rport"}
!ll&&!rl&&r
220
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
7751  
7752 4 for (qw(sockport sockaddr)) {
7753 8 ▶ $parms->{ $_ } = '*' if !$parms->{ $_ };
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{$_} 8 0 8
7754 }
7755  
7756 4 ▶ $parms->{ipmask} = $parms->{raddress} if $parms->{raddress};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"raddress"} 2 2 4
7757 4 ▶ $parms->{zip} = 0 if !$parms->{zip};
Branch: 1 branch
BranchTrueFalseTotal
unless $parms->{"zip"} 2 2 4
7758 4 my $name = $parms->{name};
7759 4 $self->{config}{peers}{uc $name} = $parms;
7760 $self->add_connector(
7761 remoteaddress => $parms->{raddress},
7762 remoteport => $parms->{rport},
7763 name => $name,
7764 4 ▶ ) if $parms->{type} eq 'r' && $parms->{auto};
Branch: 1 branch
BranchTrueFalseTotal
if $parms->{"type"} eq "r" and $parms->{"auto"} 2 2 4
Condition66%2/3
$parms->{"type"} eq "r" and $parms->{"auto"}
!ll&&!rl&&r
202
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
7765  
7766 4 return 1;
7767 }
7768  
7769 sub del_peer {
7770 0 ▶ my $self = shift;
Subroutine del_peer: not called CC=3 SCAR=24.8
Pod documented
7771 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
7772 0 ▶ return if !defined $self->{config}{peers}{uc $name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{"peers"}{uc $name} 0 0 0
7773 0 delete $self->{config}{peers}{uc $name};
7774 0 return;
7775 }
7776  
7777 sub _terminate_conn_error {
7778 14 ▶ my $self = shift;
Subroutine _terminate_conn_error: called CC=5 SCAR=16.1
7779 14 ▶ my $conn_id = 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
7780 14 my $msg = shift;
7781 14 ▶ return if !$self->_connection_exists($conn_id);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_connection_exists($conn_id) 2 12 14
7782  
7783 12 $self->disconnect($conn_id, $msg);
7784 12 $self->send_output(
7785 {
7786 command => 'ERROR',
7787 params => [
7788 'Closing Link: ' . $self->_client_ip($conn_id)
7789 . ' (' . $msg . ')',
7790 ],
7791 },
7792 $conn_id,
7793 );
7794  
7795 12 ▶ while (my ($nick, $id) = each %{ $self->{state}{pending} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"state"}{"pending"};}) 1 11 12
7796 1 ▶ if ($id == $conn_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id == $conn_id) 1 0 1
7797 1 delete $self->{state}{pending}{$nick};
7798 1 last;
7799 }
7800 }
7801  
7802 12 return 1;
7803 }
7804  
7805 sub daemon_server_kill {
7806 2 ▶ my $self = shift;
Subroutine daemon_server_kill: called CC=11 SCAR=30.3
Pod documented
7807 2 my $server = $self->server_name();
7808 2 my $ref = [ ];
7809 2 my $args = [ @_ ];
7810 2 my $count = @$args;
7811  
7812 SWITCH: {
7813 2 ▶ if (!$count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 0 2 2
7814 0 last SWITCH;
7815 }
7816 2 ▶ if ($self->state_peer_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->state_peer_exists($args->[0])) 0 2 2
7817 0 last SWITCH;
7818 }
7819 2 ▶ if (!$self->state_nick_exists($args->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($args->[0])) 0 2 2
7820 0 last SWITCH;
7821 }
7822  
7823 2 my $target = $self->state_user_nick($args->[0]);
7824 2 ▶ my $comment = $args->[1] || '<No reason given>';
Condition50%1/2
$args->[1] || '<No reason given>'
l!l
20
MC/DC0%0/1
$args->[1] || '<No reason given>'
$args->[1]
Truth table50%1/2
A
A= $args->[1]
Aresult
11
00
7825 2 ▶ my $conn_id = ($args->[2] && $self->_connection_exists($args->[2])
Branch: 1 branch
BranchTrueFalseTotal
$args->[2] && $self->_connection_exists($args->[2]) ? : 2 0 2
Condition33%1/3
$args->[2] and $self->_connection_exists($args->[2])
!ll&&!rl&&r
002
MC/DC0%0/2
$args->[2] and $self->_connection_exists($args->[2])
$args->[2] $self->_connection_exists($args->[2])
Truth table33%1/3
A and B
A= $args->[2]B= $self->_connection_exists($args->[2])
ABresult
0X0
100
111
7826 ? $args->[2]
7827 : '');
7828  
7829 2 ▶ if ($self->_state_is_local_user($target)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_state_is_local_user($target)) { } 2 0 2
7830 2 my $route_id = $self->_state_user_route($target);
7831 2 $self->send_output(
7832 {
7833 prefix => $server,
7834 command => 'KILL',
7835 params => [$target, $comment],
7836 },
7837 $route_id,
7838 );
7839 2 $self->_terminate_conn_error(
7840 $route_id,
7841 "Killed ($server ($comment))",
7842 );
7843 2 ▶ if ($route_id eq 'spoofed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($route_id eq 'spoofed') { } 2 0 2
7844 2 $self->call(
7845 'del_spoofed_nick',
7846 $target,
7847 "Killed ($server ($comment))",
7848 );
7849 }
7850 else {
7851 0 $self->{state}{conns}{$route_id}{killed} = 1;
7852 0 $self->_terminate_conn_error(
7853 $route_id,
7854 "Killed ($server ($comment))",
7855 );
7856 }
7857 }
7858 else {
7859 0 $self->{state}{users}{uc_irc($target)}{killed} = 1;
7860 $self->send_output(
7861 {
7862 prefix => $server,
7863 command => 'KILL',
7864 params => [$target, "$server ($comment)"],
7865 },
7866 0 ▶ grep { !$conn_id || $_ ne $conn_id }
Branch: 1 branch
BranchTrueFalseTotal
not $conn_id or $_ ne $conn_id 0 0 0
7867 $self->_state_connected_peers(),
7868 );
7869 $self->send_output(
7870 0 @{ $self->_daemon_peer_quit(
7871 $target,
7872 "Killed ($server ($comment))"
7873 ) });
7874 }
7875 }
7876  
7877 2 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 2 2
7878 2 return $ref;
7879 }
7880  
7881 sub daemon_server_mode {
7882 0 ▶ my $self = shift;
Subroutine daemon_server_mode: not called CC=51 SCAR=78.8
Pod documented
7883 0 my $chan = shift;
7884 0 my $server = $self->server_name();
7885 0 my $ref = [ ];
7886 0 my $args = [ @_ ];
7887 0 my $count = @$args;
7888  
7889 SWITCH: {
7890 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
7891 0 last SWITCH;
7892 }
7893 0 my $record = $self->{state}{chans}{uc_irc($chan)};
7894 0 $chan = $record->{name};
7895 0 my $full = $server;
7896 0 my $parsed_mode = parse_mode_line(@$args);
7897  
7898 0 ▶ while(my $mode = shift (@{ $parsed_mode->{modes} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mode = shift @{$$parsed_mode{"modes"};}) 0 0 0
7899 0 my $arg;
7900 0 ▶ if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode =~ /^(\+[ohvklbIe]|-[ohvbIe])/) 0 0 0
7901 0 $arg = shift @{ $parsed_mode->{args} };
7902 }
7903 0 ▶ if (my ($flag, $char) = $mode =~ /^(\+|-)([ohv])/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $mode =~ /^(\+|-)([ohv])/) 0 0 0
7904 0 ▶ next if !$self->state_is_chan_member($arg, $chan);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_is_chan_member($arg, $chan) 0 0 0
7905 0 ▶ if ($flag eq '+' && $record->{users}{uc_irc($arg)} !~ /$char/) {
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
7906 # Update user and chan record
7907 0 $arg = uc_irc $arg;
7908 0 ▶ next if $mode eq '+h' && $record->{users}{$arg} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+h" and $record->{"users"}{$arg} =~ /o/ 0 0 0
Condition0%0/3
$mode eq "+h" and $record->{"users"}{$arg} =~ /o/
!ll&&!rl&&r
000
MC/DC0%0/2
$mode eq "+h" and $record->{"users"}{$arg} =~ /o/
$mode eq "+h" $record->{"users"}{$arg} =~ /o/
Truth table0%0/3
A and B
A= $mode eq "+h"B= $record->{"users"}{$arg} =~ /o/
ABresult
0X0
100
111
7909 0 ▶ if ($char eq 'h' && $record->{users}{$arg} =~ /v/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "h" and $record->{"users"}{$arg} =~ /v/) 0 0 0
Condition0%0/3
$char eq "h" and $record->{"users"}{$arg} =~ /v/
!ll&&!rl&&r
000
MC/DC0%0/2
$char eq "h" and $record->{"users"}{$arg} =~ /v/
$char eq "h" $record->{"users"}{$arg} =~ /v/
Truth table0%0/3
A and B
A= $char eq "h"B= $record->{"users"}{$arg} =~ /v/
ABresult
0X0
100
111
7910 0 $record->{users}{$arg} =~ s/v//g;
7911 }
7912 0 ▶ if ($char eq 'o' && $record->{users}{$arg} =~ /h/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "o" and $record->{"users"}{$arg} =~ /h/) 0 0 0
Condition0%0/3
$char eq "o" and $record->{"users"}{$arg} =~ /h/
!ll&&!rl&&r
000
MC/DC0%0/2
$char eq "o" and $record->{"users"}{$arg} =~ /h/
$char eq "o" $record->{"users"}{$arg} =~ /h/
Truth table0%0/3
A and B
A= $char eq "o"B= $record->{"users"}{$arg} =~ /h/
ABresult
0X0
100
111
7913 0 $record->{users}{$arg} =~ s/h//g;
7914 }
7915 $record->{users}{$arg} = join('', sort split //,
7916 0 $record->{users}{$arg} . $char);
7917 $self->{state}{users}{$arg}{chans}{uc_irc($chan)}
7918 0 = $record->{users}{$arg};
7919 }
7920 0 ▶ if ($flag eq '-' && $record->{users}{uc_irc($arg)} =~ /$char/) {
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
7921 # Update user and chan record
7922 0 $arg = uc_irc($arg);
7923 0 $record->{users}{$arg} =~ s/$char//g;
7924 $self->{state}{users}{$arg}{chans}{uc_irc($chan)}
7925 0 = $record->{users}{$arg};
7926 }
7927 0 next;
7928 }
7929 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
7930 0 ▶ if ($record->{mode} !~ /l/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /l/) 0 0 0
7931 $record->{mode} = join('', sort split //,
7932 0 $record->{mode} . 'l');
7933 }
7934 0 $record->{climit} = $arg;
7935 0 next;
7936 }
7937 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
7938 0 $record->{mode} =~ s/l//g;
7939 0 delete $record->{climit};
7940 0 next;
7941 }
7942 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
7943 0 ▶ if ($record->{mode} !~ /k/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->{"mode"} =~ /k/) 0 0 0
7944 $record->{mode} = join('', sort split //,
7945 0 $record->{mode} . 'k');
7946 }
7947 0 $record->{ckey} = $arg;
7948 0 next;
7949 }
7950 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
7951 0 $record->{mode} =~ s/k//g;
7952 0 delete $record->{ckey};
7953 0 next;
7954 }
7955 # Bans
7956 0 ▶ if (my ($flag) = $mode =~ /(\+|-)b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)b/) 0 0 0
7957 0 my $mask = normalize_mask($arg);
7958 0 my $umask = uc_irc($mask);
7959 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
7960 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
7961 = [$mask, ($full || $server), time];
7962 }
7963 0 ▶ if ($flag eq '-' and $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
7964 0 delete $record->{bans}{$umask};
7965 }
7966 0 next;
7967 }
7968 # Invex
7969 0 ▶ if (my ($flag) = $mode =~ /(\+|-)I/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)I/) 0 0 0
7970 0 my $mask = normalize_mask($arg);
7971 0 my $umask = uc_irc($mask);
7972 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
7973 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
7974 = [$mask, ($full || $server), time];
7975 }
7976 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
7977 0 delete $record->{invex}{$umask};
7978 }
7979 0 next;
7980 }
7981 # Exceptions
7982 0 ▶ if (my ($flag) = $mode =~ /(\+|-)e/) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($flag) = $mode =~ /(\+|-)e/) 0 0 0
7983 0 my $mask = normalize_mask($arg);
7984 0 my $umask = uc_irc($mask);
7985 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
7986 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
7987 = [$mask, ($full || $server), time];
7988 }
7989 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
7990 0 delete $record->{excepts}{$umask};
7991 }
7992 0 next;
7993 }
7994 # The rest should be argumentless.
7995 0 my ($flag, $char) = split //, $mode;
7996 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
7997 $record->{mode} = join('', sort split //,
7998 0 $record->{mode} . $char);
7999 0 next;
8000 }
8001 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
8002 0 $record->{mode} =~ s/$char//g;
8003 0 next;
8004 }
8005 } # while
8006  
8007 0 unshift @$args, $record->{name};
8008 0 $self->send_output(
8009 {
8010 prefix => $server,
8011 command => 'MODE',
8012 params => $args,
8013 colonify => 0,
8014 },
8015 $self->_state_connected_peers(),
8016 );
8017 $self->send_output(
8018 {
8019 prefix => ($full || $server),
8020 command => 'MODE',
8021 params => $args,
8022 colonify => 0,
8023 },
8024 0 map { $self->_state_user_route($_) }
8025 0 grep { $self->_state_is_local_user($_) }
8026 0 ▶ keys %{ $record->{users} },
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
8027 );
8028 0 $self->send_event("daemon_mode", $server, @$args);
8029 } # SWITCH
8030  
8031 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
8032 0 return $ref;
8033 }
8034  
8035 sub daemon_server_kick {
8036 0 ▶ my $self = shift;
Subroutine daemon_server_kick: not called CC=9 SCAR=45.0
Pod documented
8037 0 my $server = $self->server_name();
8038 0 my $ref = [ ];
8039 0 my $args = [ @_ ];
8040 0 my $count = @$args;
8041  
8042 SWITCH: {
8043 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
8044 0 last SWITCH;
8045 }
8046 0 my $chan = (split /,/, $args->[0])[0];
8047 0 my $who = (split /,/, $args->[1])[0];
8048 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
8049 0 last SWITCH;
8050 }
8051 0 $chan = $self->_state_chan_name($chan);
8052 0 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
8053 0 last SWITCH;
8054 }
8055 0 $who = $self->state_user_nick($who);
8056 0 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 0 0
8057 0 last SWITCH;
8058 }
8059 0 ▶ my $comment = $args->[2] || $who;
Condition0%0/3
$args->[2] || $who
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->[2] || $who
$args->[2] $who
Truth table0%0/3
A || B
A= $args->[2]B= $who
ABresult
1X1
011
000
8060 0 $self->_send_output_to_channel(
8061 $chan,
8062 {
8063 prefix => $server,
8064 command => 'KICK',
8065 params => [$chan, $who, $comment],
8066 },
8067 );
8068 0 $who = uc_irc($who);
8069 0 $chan = uc_irc($chan);
8070 0 delete $self->{state}{chans}{$chan}{users}{$who};
8071 0 delete $self->{state}{users}{$who}{chans}{$chan};
8072 0 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
8073 0 delete $self->{state}{chans}{$chan};
8074 }
8075 }
8076  
8077 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
8078 0 return $ref;
8079 }
8080  
8081 sub daemon_server_remove {
8082 0 ▶ my $self = shift;
Subroutine daemon_server_remove: not called CC=9 SCAR=45.0
Pod documented
8083 0 my $server = $self->server_name();
8084 0 my $ref = [ ];
8085 0 my $args = [ @_ ];
8086 0 my $count = @$args;
8087  
8088 SWITCH: {
8089 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
8090 0 last SWITCH;
8091 }
8092 0 my $chan = (split /,/, $args->[0])[0];
8093 0 my $who = (split /,/, $args->[1])[0];
8094 0 ▶ if (!$self->state_chan_exists($chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_chan_exists($chan)) 0 0 0
8095 0 last SWITCH;
8096 }
8097 0 $chan = $self->_state_chan_name($chan);
8098 0 ▶ if (!$self->state_nick_exists($who)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_nick_exists($who)) 0 0 0
8099 0 last SWITCH;
8100 }
8101 0 my $fullwho = $self->state_user_full($who);
8102 0 $who = (split /!/, $who)[0];
8103 0 ▶ if (!$self->state_is_chan_member($who, $chan)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->state_is_chan_member($who, $chan)) 0 0 0
8104 0 last SWITCH;
8105 }
8106 0 my $comment = 'Enforced PART';
8107 0 ▶ $comment .= " \"$args->[2]\"" if $args->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $args->[2] 0 0 0
8108 0 $self->_send_output_to_channel(
8109 $chan,
8110 {
8111 prefix => $fullwho,
8112 command => 'PART',
8113 params => [$chan, $comment],
8114 },
8115 );
8116 0 $who = uc_irc($who);
8117 0 $chan = uc_irc($chan);
8118 0 delete $self->{state}{chans}{$chan}{users}{$who};
8119 0 delete $self->{state}{users}{$who}{chans}{$chan};
8120 0 ▶ if (!keys %{ $self->{state}{chans}{$chan}{users} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %{$$self{"state"}{"chans"}{$chan}{"users"};}) 0 0 0
8121 0 delete $self->{state}{chans}{$chan};
8122 }
8123 }
8124  
8125 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
8126 0 return $ref;
8127 }
8128  
8129 sub daemon_server_wallops {
8130 0 ▶ my $self = shift;
Subroutine daemon_server_wallops: not called CC=3 SCAR=24.8
Pod documented
8131 0 my $server = $self->server_name();
8132 0 my $ref = [ ];
8133 0 my $args = [ @_ ];
8134 0 my $count = @$args;
8135  
8136 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
8137 $self->send_output(
8138 {
8139 prefix => $server,
8140 command => 'WALLOPS',
8141 params => [$args->[0]],
8142 },
8143 $self->_state_connected_peers(),
8144 0 keys %{ $self->{state}{operwall} },
8145 );
8146 0 $self->send_event("daemon_wallops", $server, $args->[0]);
8147 }
8148  
8149 0 ▶ return @$ref if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
8150 0 return $ref;
8151 }
8152  
8153 sub add_spoofed_nick {
8154 8 ▶ my ($kernel, $self) = @_[KERNEL, OBJECT];
Subroutine add_spoofed_nick: called CC=12 SCAR=25.5
Pod documented
8155 8 my $ref;
8156 8 ▶ if (ref $_[ARG0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[10] eq 'HASH') { } 8 0 8
8157 8 $ref = $_[ARG0];
8158 }
8159 else {
8160 0 $ref = { @_[ARG0..$#_] };
8161 }
8162  
8163 8 $ref->{ lc $_ } = delete $ref->{$_} for keys %$ref;
8164 8 ▶ return if !$ref->{nick};
Branch: 1 branch
BranchTrueFalseTotal
unless $ref->{"nick"} 0 8 8
8165 8 ▶ return if $self->state_nick_exists($ref->{nick});
Branch: 1 branch
BranchTrueFalseTotal
if $self->state_nick_exists($ref->{"nick"}) 0 8 8
8166 8 my $record = $ref;
8167 8 ▶ $record->{ts} = time if !$record->{ts};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"ts"} 4 4 8
8168 8 $record->{type} = 's';
8169 8 $record->{server} = $self->server_name();
8170 8 $record->{hops} = 0;
8171 8 $record->{route_id} = 'spoofed';
8172 8 ▶ $record->{umode} = 'i' if !$record->{umode};
Branch: 1 branch
BranchTrueFalseTotal
unless $record->{"umode"} 0 8 8
8173 8 ▶ if (!defined $record->{ircname}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record->{"ircname"}) 2 6 8
8174 2 $record->{ircname} = "* I'm too lame to read the documentation *";
8175 }
8176 8 ▶ $self->{state}{stats}{invisible}++ if $record->{umode} =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /i/ 6 2 8
8177 8 ▶ $self->{state}{stats}{ops_online}++ if $record->{umode} =~ /o/;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"umode"} =~ /o/ 3 5 8
8178 8 $record->{idle_time} = $record->{conn_time} = $record->{ts};
8179 8 ▶ $record->{auth}{ident} = delete $record->{user} || $record->{nick};
Condition33%1/3
delete $record->{'user'} || $record->{'nick'}
l!l&&r!l&&!r
080
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
8180 $record->{auth}{hostname} = delete $record->{hostname}
8181 8 ▶ || $self->server_name();
Condition33%1/3
delete $record->{'hostname'} || $self->server_name
l!l&&r!l&&!r
080
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
8182 8 $self->{state}{users}{uc_irc($record->{nick})} = $record;
8183 8 $self->{state}{peers}{uc $record->{server}}{users}{uc_irc($record->{nick})} = $record;
8184  
8185 my $arrayref = [
8186 $record->{nick},
8187 $record->{hops} + 1,
8188 $record->{ts},
8189 '+' . $record->{umode},
8190 $record->{auth}{ident},
8191 $record->{auth}{hostname},
8192 $record->{server},
8193 $record->{ircname},
8194 8 ];
8195  
8196 8 $self->send_output(
8197 {
8198 command => 'NICK',
8199 params => $arrayref,
8200 },
8201 $self->_state_connected_peers(),
8202 );
8203 8 $self->send_event("daemon_nick", @$arrayref);
8204 8 $self->_state_update_stats();
8205 8 return;
8206 }
8207  
8208 sub del_spoofed_nick {
8209 5 ▶ my ($kernel, $self, $nick) = @_[KERNEL, OBJECT, ARG0];
Subroutine del_spoofed_nick: called CC=4 SCAR=14.0
Pod documented
8210 5 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 5 5
8211 5 ▶ return if $self->_state_user_route($nick) ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_route($nick) ne "spoofed" 0 5 5
8212  
8213 5 ▶ my $message = $_[ARG1] || 'Client Quit';
Condition100%2/2
$_[11] || 'Client Quit'
l!l
23
MC/DC100%1/1
$_[11] || 'Client Quit'
$_[11]
Truth table100%2/2
A
A= $_[11]
Aresult
11
00
8214 $self->send_output(
8215 5 @{ $self->_daemon_cmd_quit($nick, qq{"$message"}) },
8216 qq{"$message"},
8217 );
8218 5 return;
8219 }
8220  
8221 sub _spoofed_command {
8222 2 ▶ my ($kernel, $self, $state, $nick) = @_[KERNEL, OBJECT, STATE, ARG0];
Subroutine _spoofed_command: called CC=9 SCAR=24.3
8223 2 ▶ return if !$self->state_nick_exists($nick);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state_nick_exists($nick) 0 2 2
8224 2 ▶ return if $self->_state_user_route($nick) ne 'spoofed';
Branch: 1 branch
BranchTrueFalseTotal
if $self->_state_user_route($nick) ne "spoofed" 0 2 2
8225  
8226 2 $nick = $self->state_user_nick($nick);
8227 2 $state =~ s/daemon_cmd_//;
8228 2 my $command = "_daemon_cmd_" . $state;
8229  
8230 2 ▶ if ($state =~ /^(privmsg|notice)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($state =~ /^(privmsg|notice)$/) { } 0 2 2
elsif ($state eq 'sjoin') { } 1 1 2
8231 0 my $type = uc $1;
8232 0 $self->_daemon_cmd_message($nick, $type, @_[ARG1 .. $#_]);
8233 0 return;
8234 }
8235 elsif ($state eq 'sjoin') {
8236 1 my $chan = $_[ARG1];
8237 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
8238 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
8239 1 $chan = $self->_state_chan_name($chan);
8240 1 my $ts = $self->_state_chan_timestamp($chan) - 10;
8241 1 $self->_daemon_peer_sjoin(
8242 'spoofed',
8243 $self->server_name(),
8244 $ts,
8245 $chan,
8246 '+nt',
8247 '@' . $nick,
8248 );
8249 1 return;
8250 }
8251  
8252 1 ▶ $self->$command($nick, @_[ARG1 .. $#_]) if $self->can($command);
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($command) 1 0 1
8253 1 return;
8254 }
8255  
8256 20 1;
8257  
8258 =encoding utf8
8259  
8260 =head1 NAME
8261  
8262 POE::Component::Server::IRC - A fully event-driven networkable IRC server daemon module.
8263  
8264 =head1 SYNOPSIS
8265  
8266 # A fairly simple example:
8267 use strict;
8268 use warnings;
8269 use POE qw(Component::Server::IRC);
8270  
8271 my %config = (
8272 servername => 'simple.poco.server.irc',
8273 nicklen => 15,
8274 network => 'SimpleNET'
8275 );
8276  
8277 my $pocosi = POE::Component::Server::IRC->spawn( config => \%config );
8278  
8279 POE::Session->create(
8280 package_states => [
8281 'main' => [qw(_start _default)],
8282 ],
8283 heap => { ircd => $pocosi },
8284 );
8285  
8286 $poe_kernel->run();
8287  
8288 sub _start {
8289 my ($kernel, $heap) = @_[KERNEL, HEAP];
8290  
8291 $heap->{ircd}->yield('register', 'all');
8292  
8293 # Anyone connecting from the loopback gets spoofed hostname
8294 $heap->{ircd}->add_auth(
8295 mask => '*@localhost',
8296 spoof => 'm33p.com',
8297 no_tilde => 1,
8298 );
8299  
8300 # We have to add an auth as we have specified one above.
8301 $heap->{ircd}->add_auth(mask => '*@*');
8302  
8303 # Start a listener on the 'standard' IRC port.
8304 $heap->{ircd}->add_listener(port => 6667);
8305  
8306 # Add an operator who can connect from localhost
8307 $heap->{ircd}->add_operator(
8308 {
8309 username => 'moo',
8310 password => 'fishdont',
8311 }
8312 );
8313 }
8314  
8315 sub _default {
8316 my ($event, $args) = @_[ARG0 .. $#_];
8317  
8318 print "$event: ";
8319 for my $arg (@$args) {
8320 if (ref($arg) eq 'ARRAY') {
8321 print "[", join ( ", ", @$arg ), "] ";
8322 }
8323 elsif (ref($arg) eq 'HASH') {
8324 print "{", join ( ", ", %$arg ), "} ";
8325 }
8326 else {
8327 print "'$arg' ";
8328 }
8329 }
8330  
8331 print "\n";
8332 }
8333  
8334 =head1 DESCRIPTION
8335  
8336 POE::Component::Server::IRC is a POE component which implements an IRC
8337 server (also referred to as an IRC daemon or IRCd). It should be compliant
8338 with the pertient IRC RFCs and is based on reverse engineering Hybrid IRCd
8339 behaviour with regards to interactions with IRC clients and other IRC
8340 servers.
8341  
8342 Yes, that's right. POE::Component::Server::IRC is capable of linking to
8343 foreign IRC networks. It supports the TS5 server to server protocol and
8344 has been tested with linking to Hybrid-7 based networks. It should in
8345 theory work with any TS5-based IRC network.
8346  
8347 POE::Component::Server::IRC also has a services API, which enables one to
8348 extend the IRCd to create IRC Services. This is fully event-driven (of
8349 course =]). There is also a Plugin system, similar to that sported by
8350 L<POE::Component::IRC|POE::Component::IRC>.
8351  
8352 B<Note:> This is a subclass of
8353 L<POE::Component::Server::IRC::Backend|POE::Component::IRC::Server::Backend>.
8354 You should read its documentation too.
8355  
8356 =head1 CONSTRUCTOR
8357  
8358 =head2 C<spawn>
8359  
8360 Returns a new instance of the component. Takes the following parameters:
8361  
8362 =over 4
8363  
8364 =item * B<'config'>, a hashref of configuration options, see the
8365 L<C<configure>|/configure> method for details.
8366  
8367 =back
8368  
8369 Any other parameters will be passed along to
8370 L<POE::Component::Server::IRC::Backend|POE::Component::Server::IRC::Backend>'s
8371 L<C<create>|POE::Component::Server::IRC::Backend/create> method.
8372  
8373 If the component is spawned from within another session then that session
8374 will automagically be registered with the component to receive events and
8375 be sent an L<C<ircd_registered>|POE::Component::IRC::Server::Backend/ircd_registered>
8376 event.
8377  
8378 =head1 METHODS
8379  
8380 =head2 Information
8381  
8382 =head3 C<server_name>
8383  
8384 No arguments, returns the name of the ircd.
8385  
8386 =head3 C<server_version>
8387  
8388 No arguments, returns the software version of the ircd.
8389  
8390 =head3 C<server_created>
8391  
8392 No arguments, returns a string signifying when the ircd was created.
8393  
8394 =head3 C<server_config>
8395  
8396 Takes one argument, the server configuration value to query.
8397  
8398 =head2 Configuration
8399  
8400 These methods provide mechanisms for configuring and controlling the IRCd
8401 component.
8402  
8403 =head3 C<configure>
8404  
8405 Configures your new shiny IRCd.
8406  
8407 Takes a number of parameters:
8408  
8409 =over 4
8410  
8411 =item * B<'servername'>, a name to bless your shiny new IRCd with,
8412 defaults to 'poco.server.irc';
8413  
8414 =item * B<'serverdesc'>, a description for your IRCd, defaults to
8415 'Poco? POCO? POCO!';
8416  
8417 =item * B<'network'>, the name of the IRC network you will be creating,
8418 defaults to 'poconet';
8419  
8420 =item * B<'nicklen'>, the max length of nicknames to support, defaults
8421 to 9. B<Note>: the nicklen must be the same on all servers on your IRC
8422 network;
8423  
8424 =item * B<'maxtargets'>, max number of targets a user can send
8425 PRIVMSG/NOTICE's to, defaults to 4;
8426  
8427 =item * B<'maxchannels'>, max number of channels users may join, defaults
8428 to 15;
8429  
8430 =item * B<'version'>, change the server version that is reported;
8431  
8432 =item * B<'admin'>, an arrayref consisting of the 3 lines that will be
8433 returned by ADMIN;
8434  
8435 =item * B<'info'>, an arrayref consisting of lines to be returned by INFO;
8436  
8437 =item * B<'ophacks'>, set to true to enable oper hacks. Default is false;
8438  
8439 =item * B<'whoisactually'>, setting this to a false value means that only
8440 opers can see 338. Defaults to true;
8441  
8442 =back
8443  
8444 =head3 C<add_auth>
8445  
8446 By default the IRCd allows any user to connect to the server without a
8447 password. Configuring auths enables you to control who can connect and
8448 set passwords required to connect.
8449  
8450 Takes the following parameters:
8451  
8452 =over 4
8453  
8454 =item * B<'mask'>, a user@host or user@ipaddress mask to match against,
8455 mandatory;
8456  
8457 =item * B<'password'>, if specified, any client matching the mask must
8458 provide this to connect;
8459  
8460 =item * B<'spoof'>, if specified, any client matching the mask will have
8461 their hostname changed to this;
8462  
8463 =item * B<'no_tilde'>, if specified, the '~' prefix is removed from their
8464 username;
8465  
8466 =back
8467  
8468 Auth masks are processed in order of addition.
8469  
8470 If auth masks have been defined, then a connecting user *must* match one
8471 of the masks in order to be authorised to connect. This is a feature >;)
8472  
8473 =head3 C<del_auth>
8474  
8475 Takes a single argument, the mask to remove.
8476  
8477 =head3 C<add_operator>
8478  
8479 This adds an O line to the IRCd. Takes a number of parameters:
8480  
8481 =over 4
8482  
8483 =item * B<'username'>, the username of the IRC oper, mandatory;
8484  
8485 =item * B<'password'>, the password, mandatory;
8486  
8487 =item * B<'ipmask'>, either a scalar ipmask or an arrayref of Net::Netmask
8488 objects;
8489  
8490 =back
8491  
8492 A scalar ipmask can contain '*' to match any number of characters or '?' to
8493 match one character. If no 'ipmask' is provided, operators are only allowed
8494 to OPER from the loopback interface.
8495  
8496 B<'password'> can be either plain-text, L<C<crypt>|crypt>'d or unix/apache
8497 md5. See the C<mkpasswd> function in
8498 L<POE::Component::Server::IRC::Common|POE::Component::Server::IRC::Common>
8499 for how to generate passwords.
8500  
8501 =head3 C<del_operator>
8502  
8503 Takes a single argument, the username to remove.
8504  
8505 =head3 C<add_peer>
8506  
8507 Adds peer servers that we will allow to connect to us and who we will
8508 connect to. Takes the following parameters:
8509  
8510 =over 4
8511  
8512 =item * B<'name'>, the name of the server. This is the IRC name, not
8513 hostname, mandatory;
8514  
8515 =item * B<'pass'>, the password they must supply to us, mandatory;
8516  
8517 =item * B<'rpass'>, the password we need to supply to them, mandatory;
8518  
8519 =item * B<'type'>, the type of server, 'c' for a connecting server, 'r'
8520 for one that we will connect to;
8521  
8522 =item * B<'raddress'>, the remote address to connect to, implies 'type'
8523 eq 'r';
8524  
8525 =item * B<'rport'>, the remote port to connect to, default is 6667;
8526  
8527 =item * B<'ipmask'>, either a scalar ipmask or an arrayref of Net::Netmask
8528 objects;
8529  
8530 =item * B<'auto'>, if set to true value will automatically connect to
8531 remote server if type is 'r';
8532  
8533 =item * B<'zip'>, set to a true value to enable ziplink support. This must
8534 be done on both ends of the connection. Requires
8535 L<POE::Filter::Zlib::Stream|POE::Filter::Zlib::Stream>;
8536  
8537 =back
8538  
8539 =head3 C<del_peer>
8540  
8541 Takes a single argument, the peer to remove. This does not disconnect the
8542 said peer if it is currently connected.
8543  
8544 =head2 State queries
8545  
8546 The following methods allow you to query state information regarding
8547 nicknames, channels, and peers.
8548  
8549 =head3 C<state_nicks>
8550  
8551 Takes no arguments, returns a list of all nicknames in the state.
8552  
8553 =head3 C<state_chans>
8554  
8555 Takes no arguments, returns a list of all channels in the state.
8556  
8557 =head3 C<state_peers>
8558  
8559 Takes no arguments, returns a list of all irc servers in the state.
8560  
8561 =head3 C<state_nick_exists>
8562  
8563 Takes one argument, a nickname, returns true or false dependent on whether
8564 the given nickname exists or not.
8565  
8566 =head3 C<state_chan_exists>
8567  
8568 Takes one argument, a channel name, returns true or false dependent on
8569 whether the given channel exists or not.
8570  
8571 =head3 C<state_peer_exists>
8572  
8573 Takes one argument, a peer server name, returns true or false dependent
8574 on whether the given peer exists or not.
8575  
8576 =head3 C<state_user_full>
8577  
8578 Takes one argument, a nickname, returns that users full nick!user@host
8579 if they exist, undef if they don't.
8580  
8581 =head3 C<state_user_nick>
8582  
8583 Takes one argument, a nickname, returns the proper nickname for that user.
8584 Returns undef if the nick doesn't exist.
8585  
8586 =head3 C<state_user_umode>
8587  
8588 Takes one argument, a nickname, returns that users mode setting.
8589  
8590 =head3 C<state_user_is_operator>
8591  
8592 Takes one argument, a nickname, returns true or false dependent on whether
8593 the given nickname is an IRC operator or not.
8594  
8595 =head3 C<state_user_chans>
8596  
8597 Takes one argument, a nickname, returns a list of channels that that nick
8598 is a member of.
8599  
8600 =head3 C<state_user_server>
8601  
8602 Takes one argument, a nickname, returns the name of the peer server that
8603 that user is connected from.
8604  
8605 =head3 C<state_chan_list>
8606  
8607 Takes one argument, a channel name, returns a list of the member nicks on
8608 that channel.
8609  
8610 =head3 C<state_chan_list_prefixed>
8611  
8612 Takes one argument, a channel name, returns a list of the member nicks on
8613 that channel, nicknames will be prefixed with @%+ if they are +o +h or +v,
8614 respectively.
8615  
8616 =head3 C<state_chan_topic>
8617  
8618 Takes one argument, a channel name, returns undef if no topic is set on
8619 that channel, or an arrayref consisting of the topic, who set it and the
8620 time they set it.
8621  
8622 =head3 C<state_chan_mode_set>
8623  
8624 Takes two arguments, a channel name and a channel mode character. Returns
8625 true if that channel mode is set, false otherwise.
8626  
8627 =head3 C<state_is_chan_member>
8628  
8629 Takes two arguments, a nick and a channel name. Returns true if that nick
8630 is on channel, false otherwise.
8631  
8632 =head3 C<state_user_chan_mode>
8633  
8634 Takes two arguments, a nick and a channel name. Returns that nicks status
8635 (+ohv or '') on that channel.
8636  
8637 =head3 C<state_is_chan_op>
8638  
8639 Takes two arguments, a nick and a channel name. Returns true if that nick
8640 is an channel operator, false otherwise.
8641  
8642 =head3 C<state_is_chan_hop>
8643  
8644 Takes two arguments, a nick and a channel name. Returns true if that nick
8645 is an channel half-operator, false otherwise.
8646  
8647 =head3 C<state_has_chan_voice>
8648  
8649 Takes two arguments, a nick and a channel name. Returns true if that nick
8650 has channel voice, false otherwise.
8651  
8652 =head2 Server actions
8653  
8654 =head3 C<daemon_server_kill>
8655  
8656 Takes two arguments, a nickname and a comment (which is optional); Issues
8657 a SERVER KILL of the given nick;
8658  
8659 =head3 C<daemon_server_mode>
8660  
8661 First argument is a channel name, remaining arguments are channel modes
8662 and their parameters to apply.
8663  
8664 =head3 C<daemon_server_kick>
8665  
8666 Takes two arguments that are mandatory and an optional one: channel name,
8667 nickname of the user to kick and a pithy comment.
8668  
8669 =head3 C<daemon_server_remove>
8670  
8671 Takes two arguments that are mandatory and an optional one: channel name,
8672 nickname of the user to remove and a pithy comment.
8673  
8674 =head3 C<daemon_server_wallops>
8675  
8676 Takes one argument, the message text to send.
8677  
8678 =head1 INPUT EVENTS
8679  
8680 These are POE events that can be sent to the component.
8681  
8682 =head2 C<add_spoofed_nick>
8683  
8684 Takes a single argument a hashref which should have the following keys:
8685  
8686 =over 4
8687  
8688 =item * B<'nick'>, the nickname to add, mandatory;
8689  
8690 =item * B<'user'>, the ident you want the nick to have, defaults to the
8691 same as the nick;
8692  
8693 =item * B<'hostname'>, the hostname, defaults to the server name;
8694  
8695 =item * B<'umode'>, specify whether this is to be an IRCop etc, defaults
8696 to 'i';
8697  
8698 =item * B<'ts'>, unixtime, default is time(), best not to meddle;
8699  
8700 =back
8701  
8702 B<Note:> spoofed nicks are currently only really functional for use as IRC
8703 services.
8704  
8705 =head2 C<del_spoofed_nick>
8706  
8707 Takes a single mandatory argument, the spoofed nickname to remove.
8708 Optionally, you may specify a quit message for the spoofed nick.
8709  
8710 =head2 Spoofed nick commands
8711  
8712 The following input events are for the benefit of spoofed nicks. All
8713 require a nickname of a spoofed nick as the first argument.
8714  
8715 =head3 C<daemon_cmd_join>
8716  
8717 Takes two arguments, a spoofed nick and a channel name to join.
8718  
8719 =head3 C<daemon_cmd_part>
8720  
8721 Takes two arguments, a spoofed nick and a channel name to part from.
8722  
8723 =head3 C<daemon_cmd_mode>
8724  
8725 Takes at least three arguments, a spoofed nick, a channel and a channel
8726 mode to apply. Additional arguments are parameters for the channel modes.
8727  
8728 =head3 C<daemon_cmd_kick>
8729  
8730 Takes at least three arguments, a spoofed nick, a channel name and the
8731 nickname of a user to kick from that channel. You may supply a fourth
8732 argument which will be the kick comment.
8733  
8734 =head3 C<daemon_cmd_topic>
8735  
8736 Takes three arguments, a spoofed nick, a channel name and the topic to
8737 set on that channel. If the third argument is an empty string then the
8738 channel topic will be unset.
8739  
8740 =head3 C<daemon_cmd_nick>
8741  
8742 Takes two arguments, a spoofed nick and a new nickname to change to.
8743  
8744 =head3 C<daemon_cmd_gline>
8745  
8746 Takes three arguments, a spoofed nick, a user@host mask to gline and a
8747 reason for the gline.
8748  
8749 =head3 C<daemon_cmd_kline>
8750  
8751 Takes a number of arguments depending on where the KLINE is to be applied
8752 and for how long:
8753  
8754 To set a permanent KLINE:
8755  
8756 $ircd->yield(
8757 'daemon_cmd_kline',
8758 $spoofed_nick,
8759 $nick || $user_host_mask,
8760 $reason,
8761 );
8762  
8763 To set a temporary 10 minute KLINE:
8764  
8765 $ircd->yield(
8766 'daemon_cmd_kline',
8767 $spoofed_nick,
8768 10,
8769 $nick || $user_host_mask,
8770 $reason,
8771 );
8772  
8773 To set a temporary 10 minute KLINE on all servers:
8774  
8775 $ircd->yield(
8776 'daemon_cmd_kline',
8777 $spoofed_nick,
8778 10,
8779 $nick || $user_host_mask,
8780 'on',
8781 '*',
8782 $reason,
8783 );
8784  
8785 =head3 C<daemon_cmd_unkline>
8786  
8787 Removes a KLINE as indicated by the user@host mask supplied.
8788  
8789 To remove a KLINE:
8790  
8791 $ircd->yield(
8792 'daemon_cmd_unkline',
8793 $spoofed_nick,
8794 $user_host_mask,
8795 );
8796  
8797 To remove a KLINE from all servers:
8798  
8799 $ircd->yield(
8800 'daemon_cmd_unkline',
8801 $spoofed_nick,
8802 $user_host_mask,
8803 'on',
8804 '*',
8805 );
8806  
8807 =head3 C<daemon_cmd_rkline>
8808  
8809 Used to set a regex based KLINE. The regex given must be based on a
8810 user@host mask.
8811  
8812 To set a permanent RKLINE:
8813  
8814 $ircd->yield(
8815 'daemon_cmd_rkline',
8816 $spoofed_nick,
8817 '^.*$@^(yahoo|google|microsoft)\.com$',
8818 $reason,
8819 );
8820  
8821 To set a temporary 10 minute RKLINE:
8822  
8823 $ircd->yield(
8824 'daemon_cmd_rkline',
8825 $spoofed_nick,
8826 10,
8827 '^.*$@^(yahoo|google|microsoft)\.com$',
8828 $reason,
8829 );
8830  
8831 To set a temporary 10 minute RKLINE on all servers:
8832  
8833 $ircd->yield(
8834 'daemon_cmd_kline',
8835 $spoofed_nick,
8836 10,
8837 '^.*$@^(yahoo|google|microsoft)\.com$',
8838 'on',
8839 '*',
8840 $reason,
8841 );
8842  
8843 =head3 C<daemon_cmd_sjoin>
8844  
8845 Takes two arguments a spoofed nickname and an existing channel name. This
8846 command will then manipulate the channel timestamp to clear all modes on
8847 that channel, including existing channel operators, reset the channel mode
8848 to '+nt', the spoofed nick will then join the channel and gain channel ops.
8849  
8850 =head3 C<daemon_cmd_privmsg>
8851  
8852 Takes three arguments, a spoofed nickname, a target (which can be a
8853 nickname or a channel name) and whatever text you wish to send.
8854  
8855 =head3 C<daemon_cmd_notice>
8856  
8857 Takes three arguments, a spoofed nickname, a target (which can be a
8858 nickname or a channel name) and whatever text you wish to send.
8859  
8860 =head3 C<daemon_cmd_locops>
8861  
8862 Takes two arguments, a spoofed nickname and the text message to send to
8863 local operators.
8864  
8865 =head3 C<daemon_cmd_wallops>
8866  
8867 Takes two arguments, a spoofed nickname and the text message to send to
8868 all operators.
8869  
8870 =head3 C<daemon_cmd_operwall>
8871  
8872 Takes two arguments, a spoofed nickname and the text message to send to
8873 all operators.
8874  
8875 =head1 OUTPUT EVENTS
8876  
8877 =head2 C<ircd_daemon_error>
8878  
8879 =over
8880  
8881 =item Emitted: when we fail to register with a peer;
8882  
8883 =item Target: all plugins and registered sessions;
8884  
8885 =item Args:
8886  
8887 =over 4
8888  
8889 =item * C<ARG0>, the connection id;
8890  
8891 =item * C<ARG1>, the server name;
8892  
8893 =item * C<ARG2>, the reason;
8894  
8895 =back
8896  
8897 =back
8898  
8899 =head2 C<ircd_daemon_server>
8900  
8901 =over
8902  
8903 =item Emitted: when a server is introduced onto the network;
8904  
8905 =item Target: all plugins and registered sessions;
8906  
8907 =item Args:
8908  
8909 =over 4
8910  
8911 =item * C<ARG0>, the server name;
8912  
8913 =item * C<ARG1>, the name of the server that is introducing them;
8914  
8915 =item * C<ARG2>, the hop count;
8916  
8917 =item * C<ARG3>, the server description;
8918  
8919 =back
8920  
8921 =back
8922  
8923 =head2 C<ircd_daemon_squit>
8924  
8925 =over
8926  
8927 =item Emitted: when a server quits the network;
8928  
8929 =item Target: all plugins and registered sessions;
8930  
8931 =item Args:
8932  
8933 =over 4
8934  
8935 =item * C<ARG0>, the server name;
8936  
8937 =back
8938  
8939 =back
8940  
8941 =head2 C<ircd_daemon_nick>
8942  
8943 =over
8944  
8945 =item Emitted: when a user is introduced onto the network or changes their
8946 nickname
8947  
8948 =item Target: all plugins and registered sessions;
8949  
8950 =item Args (new user):
8951  
8952 =over 4
8953  
8954 =item * C<ARG0>, the nickname;
8955  
8956 =item * C<ARG1>, the hop count;
8957  
8958 =item * C<ARG2>, the time stamp (TS);
8959  
8960 =item * C<ARG3>, the user mode;
8961  
8962 =item * C<ARG4>, the ident;
8963  
8964 =item * C<ARG5>, the hostname;
8965  
8966 =item * C<ARG6>, the server name;
8967  
8968 =item * C<ARG7>, the real name;
8969  
8970 =back
8971  
8972 =item Args (nick change):
8973  
8974 =over 4
8975  
8976 =item * C<ARG0>, the full nick!user@host;
8977  
8978 =item * C<ARG1>, the new nickname;
8979  
8980 =back
8981  
8982 =back
8983  
8984 =head2 C<ircd_daemon_umode>
8985  
8986 =over
8987  
8988 =item Emitted: when a user changes their user mode;
8989  
8990 =item Target: all plugins and registered sessions;
8991  
8992 =item Args:
8993  
8994 =over 4
8995  
8996 =item * C<ARG0>, the full nick!user@host;
8997  
8998 =item * C<ARG1>, the user mode change;
8999  
9000 =back
9001  
9002 =back
9003  
9004 =head2 C<ircd_daemon_quit>
9005  
9006 =over
9007  
9008 =item Emitted: when a user quits or the server they are on squits;
9009  
9010 =item Target: all plugins and registered sessions;
9011  
9012 =item Args:
9013  
9014 =over 4
9015  
9016 =item * C<ARG0>, the full nick!user@host;
9017  
9018 =item * C<ARG1>, the quit message;
9019  
9020 =back
9021  
9022 =back
9023  
9024 =head2 C<ircd_daemon_join>
9025  
9026 =over
9027  
9028 =item Emitted: when a user joins a channel
9029  
9030 =item Target: all plugins and registered sessions;
9031  
9032 =item Args:
9033  
9034 =over 4
9035  
9036 =item * C<ARG0>, the full nick!user@host;
9037  
9038 =item * C<ARG1>, the channel name;
9039  
9040 =back
9041  
9042 =back
9043  
9044 =head2 C<ircd_daemon_part>
9045  
9046 =over
9047  
9048 =item Emitted: when a user parts a channel;
9049  
9050 =item Target: all plugins and registered sessions;
9051  
9052 =item Args:
9053  
9054 =over 4
9055  
9056 =item * C<ARG0>, the full nick!user@host;
9057  
9058 =item * C<ARG1>, the channel name;
9059  
9060 =item * C<ARG2>, the part message;
9061  
9062 =back
9063  
9064 =back
9065  
9066 =head2 C<ircd_daemon_kick>
9067  
9068 =over
9069  
9070 =item Emitted: when a user is kicked from a channel;
9071  
9072 =item Target: all plugins and registered sessions;
9073  
9074 =item Args:
9075  
9076 =over 4
9077  
9078 =item * C<ARG0>, the full nick!user@host of the kicker;
9079  
9080 =item * C<ARG1>, the channel name;
9081  
9082 =item * C<ARG2>, the nick of the kicked user;
9083  
9084 =item * C<ARG3>, the kick message;
9085  
9086 =back
9087  
9088 =back
9089  
9090 =head2 C<ircd_daemon_mode>
9091  
9092 =over
9093  
9094 =item Emitted: when a channel mode is changed;
9095  
9096 =item Target: all plugins and registered sessions;
9097  
9098 =item Args:
9099  
9100 =over 4
9101  
9102 =item * C<ARG0>, the full nick!user@host or server name;
9103  
9104 =item * C<ARG1>, the channel name;
9105  
9106 =item * C<ARG2..$#_>, the modes and their arguments;
9107  
9108 =back
9109  
9110 =back
9111  
9112 =head2 C<ircd_daemon_topic>
9113  
9114 =over
9115  
9116 =item Emitted: when a channel topic is changed
9117  
9118 =item Target: all plugins and registered sessions;
9119  
9120 =item Args:
9121  
9122 =over 4
9123  
9124 =item * C<ARG0>, the full nick!user@host of the changer;
9125  
9126 =item * C<ARG1>, the channel name;
9127  
9128 =item * C<ARG2>, the new topic;
9129  
9130 =back
9131  
9132 =back
9133  
9134 =head2 C<ircd_daemon_public>
9135  
9136 =over
9137  
9138 =item Emitted: when a channel message is sent (a spoofed nick must be in
9139 the channel)
9140  
9141 =item Target: all plugins and registered sessions;
9142  
9143 =item Args:
9144  
9145 =over 4
9146  
9147 =item * C<ARG0>, the full nick!user@host of the sender;
9148  
9149 =item * C<ARG1>, the channel name;
9150  
9151 =item * C<ARG2>, the message;
9152  
9153 =back
9154  
9155 =back
9156  
9157 =head2 C<ircd_daemon_privmsg>
9158  
9159 =over
9160  
9161 =item Emitted: when someone sends a private message to a spoofed nick
9162  
9163 =item Target: all plugins and registered sessions;
9164  
9165 =item Args:
9166  
9167 =over 4
9168  
9169 =item * C<ARG0>, the full nick!user@host of the sender;
9170  
9171 =item * C<ARG1>, the spoofed nick targeted;
9172  
9173 =item * C<ARG2>, the message;
9174  
9175 =back
9176  
9177 =back
9178  
9179 =head2 C<ircd_daemon_notice>
9180  
9181 =over
9182  
9183 =item Emitted: when someone sends a notice to a spoofed nick or channel
9184  
9185 =item Target: all plugins and registered sessions;
9186  
9187 =item Args:
9188  
9189 =over 4
9190  
9191 =item * C<ARG0>, the full nick!user@host of the sender;
9192  
9193 =item * C<ARG1>, the spoofed nick targeted or channel spoofed nick is in;
9194  
9195 =item * C<ARG2>, the message;
9196  
9197 =back
9198  
9199 =back
9200  
9201 =head2 C<ircd_daemon_invite>
9202  
9203 =over
9204  
9205 =item Emitted: when someone invites a spoofed nick to a channel;
9206  
9207 =item Target: all plugins and registered sessions;
9208  
9209 =item Args:
9210  
9211 =over 4
9212  
9213 =item * C<ARG0>, the full nick!user@host of the inviter;
9214  
9215 =item * C<ARG1>, the spoofed nick being invited;
9216  
9217 =item * C<ARG2>, the channel being invited to;
9218  
9219 =back
9220  
9221 =back
9222  
9223 =head2 C<ircd_daemon_rehash>
9224  
9225 =over
9226  
9227 =item Emitted: when an oper issues a REHASH command;
9228  
9229 =item Target: all plugins and registered sessions;
9230  
9231 =item Args:
9232  
9233 =over 4
9234  
9235 =item * C<ARG0>, the full nick!user@host of the oper;
9236  
9237 =back
9238  
9239 =back
9240  
9241 =head2 C<ircd_daemon_die>
9242  
9243 =over
9244  
9245 =item Emitted: when an oper issues a DIE command;
9246  
9247 =item Target: all plugins and registered sessions;
9248  
9249 =item Args:
9250  
9251 =over 4
9252  
9253 =item * C<ARG0>, the full nick!user@host of the oper;
9254  
9255 =back
9256  
9257 =back
9258  
9259 B<Note:> the component will shutdown, this is a feature;
9260  
9261 =head2 C<ircd_daemon_gline>
9262  
9263 =over
9264  
9265 =item Emitted: when an oper issues a GLINE command;
9266  
9267 =item Target: all plugins and registered sessions;
9268  
9269 =item Args:
9270  
9271 =over 4
9272  
9273 =item * C<ARG0>, the full nick!user@host;
9274  
9275 =item * C<ARG1>, the user mask;
9276  
9277 =item * C<ARG2>, the host mask;
9278  
9279 =item * C<ARG3>, the reason;
9280  
9281 =back
9282  
9283 =back
9284  
9285 =head2 C<ircd_daemon_kline>
9286  
9287 =over
9288  
9289 =item Emitted: when an oper issues a KLINE command;
9290  
9291 =item Target: all plugins and registered sessions;
9292  
9293 =item Args:
9294  
9295 =over 4
9296  
9297 =item * C<ARG0>, the full nick!user@host;
9298  
9299 =item * C<ARG1>, the target for the KLINE;
9300  
9301 =item * C<ARG2>, the duration in seconds;
9302  
9303 =item * C<ARG3>, the user mask;
9304  
9305 =item * C<ARG4>, the host mask;
9306  
9307 =item * C<ARG5>, the reason;
9308  
9309 =back
9310  
9311 =back
9312  
9313 =head2 C<ircd_daemon_rkline>
9314  
9315 =over
9316  
9317 =item Emitted: when an oper issues an RKLINE command;
9318  
9319 =item Target: all plugins and registered sessions;
9320  
9321 =item Args:
9322  
9323 =over 4
9324  
9325 =item * C<ARG0>, the full nick!user@host;
9326  
9327 =item * C<ARG1>, the target for the RKLINE;
9328  
9329 =item * C<ARG2>, the duration in seconds;
9330  
9331 =item * C<ARG3>, the user mask;
9332  
9333 =item * C<ARG4>, the host mask;
9334  
9335 =item * C<ARG5>, the reason;
9336  
9337 =back
9338  
9339 =back
9340  
9341 =head2 C<ircd_daemon_unkline>
9342  
9343 =over
9344  
9345 =item Emitted: when an oper issues an UNKLINE command;
9346  
9347 =item Target: all plugins and registered sessions;
9348  
9349 =item Args:
9350  
9351 =over 4
9352  
9353 =item * C<ARG0>, the full nick!user@host;
9354  
9355 =item * C<ARG1>, the target for the UNKLINE;
9356  
9357 =item * C<ARG2>, the user mask;
9358  
9359 =item * C<ARG3>, the host mask;
9360  
9361 =back
9362  
9363 =back
9364  
9365 =head2 C<ircd_daemon_locops>
9366  
9367 =over
9368  
9369 =item Emitted: when an oper issues a LOCOPS command;
9370  
9371 =item Target: all plugins and registered sessions;
9372  
9373 =item Args:
9374  
9375 =over 4
9376  
9377 =item * C<ARG0>, the full nick!user@host;
9378  
9379 =item * C<ARG1>, the locops message;
9380  
9381 =back
9382  
9383 =back
9384  
9385 =head2 C<ircd_daemon_operwall>
9386  
9387 =over
9388  
9389 =item Emitted: when an oper issues a WALLOPS or OPERWALL command;
9390  
9391 =item Target: all plugins and registered sessions;
9392  
9393 =item Args:
9394  
9395 =over 4
9396  
9397 =item * C<ARG0>, the full nick!user@host;
9398  
9399 =item * C<ARG1>, the wallops or operwall message;
9400  
9401 =back
9402  
9403 =back
9404  
9405 =head2 C<ircd_daemon_wallops>
9406  
9407 =over
9408  
9409 =item Emitted: when a server issues a WALLOPS;
9410  
9411 =item Target: all plugins and registered sessions;
9412  
9413 =item Args:
9414  
9415 =over 4
9416  
9417 =item * C<ARG0>, the server name;
9418  
9419 =item * C<ARG1>, the wallops message;
9420  
9421 =back
9422  
9423 =back
9424  
9425 =head1 BUGS
9426  
9427 A few have turned up in the past and they are sure to again. Please use
9428 L<http://rt.cpan.org/> to report any. Alternatively, email the current
9429 maintainer.
9430  
9431 =head1 DEVELOPMENT
9432  
9433 You can find the latest source on github:
9434 L<http://github.com/bingos/poe-component-server-irc>
9435  
9436 The project's developers usually hang out in the C<#poe> IRC channel on
9437 irc.perl.org. Do drop us a line.
9438  
9439 =head1 MAINTAINER
9440  
9441 Hinrik E<Ouml>rn SigurE<eth>sson <hinrik.sig@gmail.com>
9442  
9443 =head1 AUTHOR
9444  
9445 Chris 'BinGOs' Williams
9446  
9447 =head1 LICENSE
9448  
9449 Copyright C<(c)> Chris Williams
9450  
9451 This module may be used, modified, and distributed under the same terms as
9452 Perl itself. Please see the license that came with your Perl distribution
9453 for details.
9454  
9455 =head1 KUDOS
9456  
9457 Rocco Caputo for creating POE.
9458  
9459 Buu for pestering me when I started to procrastinate =]
9460  
9461 =head1 SEE ALSO
9462  
9463 L<POE|POE> L<http://poe.perl.org/>
9464  
9465 L<POE::Component::Server::IRC::Backend|POE::Component::IRC::Server::Backend>
9466  
9467 L<Net::Netmask|Net::Netmask>
9468  
9469 Hybrid IRCD L<http://ircd-hybrid.com/>
9470  
9471 TSOra L<http://www.idolnet.org/docs/README.TSora>
9472  
9473 RFC 2810 L<http://www.faqs.org/rfcs/rfc2810.html>
9474  
9475 RFC 2811 L<http://www.faqs.org/rfcs/rfc2811.html>
9476  
9477 RFC 2812 L<http://www.faqs.org/rfcs/rfc2812.html>
9478  
9479 RFC 2813 L<http://www.faqs.org/rfcs/rfc2813.html>
9480  
9481 =cut
↑ Summary IRC/Plugin/OperServ.pm »