Backend/Connect.pm

filter: Statementstmt 79.0% 34 / 43 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.0% 12 / 15 Podpod 100% 3 / 3 totaltotal 56.3% 49 / 87 SCAR 28.3
CC
9
Cov
54%
ssl_object
20.0
ssl_cipher
20.0
get_socket
12.0
CRAP 16.9
↑ Summary Backend/Role/CheckAvail.pm »
1 package POEx::IRC::Backend::Connect;
2 1 $POEx::IRC::Backend::Connect::VERSION = '0.030001';
3 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Types::Standard -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 with 'POEx::IRC::Backend::Role::Socket',
9 'POEx::IRC::Backend::Role::CheckAvail';
10  
11  
12 has alarm_id => (
13 ## Idle alarm ID.
14 lazy => 1,
15 is => 'rw',
16 predicate => 'has_alarm_id',
17 1 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
18 1 );
19  
20 has compressed => (
21 ## zlib filter added.
22 lazy => 1,
23 is => 'rwp',
24 isa => Bool,
25 writer => 'set_compressed',
26 1 ▶ default => sub { !!0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
27 1 );
28  
29 has idle => (
30 ## Idle delay.
31 lazy => 1,
32 is => 'ro',
33 isa => StrictNum,
34 1 ▶ default => sub { 180 },
Subroutine __ANON__: called CC=1 SCAR=0.0
35 1 );
36  
37 has is_client => (
38 lazy => 1,
39 is => 'rw',
40 isa => Bool,
41 1 ▶ default => sub { !!0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
42 1 );
43  
44 has is_peer => (
45 lazy => 1,
46 is => 'rw',
47 isa => Bool,
48 1 ▶ default => sub { !!0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
49 1 );
50  
51 has is_disconnecting => (
52 ## Bool or string (disconnect message)
53 is => 'rw',
54 isa => (Bool | Str),
55 1 ▶ default => sub { !!0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
56 1 );
57  
58 has is_pending_compress => (
59 ## Wheel needs zlib filter after a socket flush.
60 is => 'rw',
61 isa => Bool,
62 1 ▶ default => sub { !!0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
63 1 );
64  
65 1 has peeraddr => (
66 required => 1,
67 isa => Str,
68 is => 'ro',
69 writer => 'set_peeraddr',
70 );
71  
72 1 has peerport => (
73 required => 1,
74 is => 'ro',
75 writer => 'set_peerport',
76 );
77  
78 has ping_pending => (
79 lazy => 1,
80 is => 'rw',
81 1 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
82 1 );
83  
84 has seen => (
85 ## TS of last activity on this Connect.
86 lazy => 1,
87 is => 'rw',
88 1 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
89 1 );
90  
91 1 has sockaddr => (
92 required => 1,
93 isa => Str,
94 is => 'ro',
95 writer => 'set_sockaddr',
96 );
97  
98 1 has sockport => (
99 required => 1,
100 is => 'ro',
101 writer => 'set_sockport',
102 );
103  
104  
105 sub ssl_object {
106 0 ▶ my ($self) = @_;
Subroutine ssl_object: not called CC=4 SCAR=30.0
Pod documented
107 return undef
108 0 ▶ unless $self->ssl
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ssl and $self->has_ssl_support and $self->has_wheel 0 0 0
Condition0%0/6
$self->ssl and $self->has_ssl_support and $self->has_wheel
!ll&&!rl&&r
000
$self->ssl and $self->has_ssl_support
!ll&&!rl&&r
000
MC/DC0%0/3
$self->ssl and $self->has_ssl_support and $self->has_wheel
$self->ssl $self->has_ssl_support $self->has_wheel
Truth table0%0/4
A and B and C
A= $self->sslB= $self->has_ssl_supportC= $self->has_wheel
ABCresult
0XX0
10X0
1100
1111
109 and $self->has_ssl_support
110 and $self->has_wheel;
111  
112 0 POE::Component::SSLify::SSLify_GetSSL( $self->wheel->get_output_handle )
113 }
114  
115 sub ssl_cipher {
116 0 ▶ my ($self) = @_;
Subroutine ssl_cipher: not called CC=4 SCAR=30.0
Pod documented
117 0 ▶ return ''
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ssl and $self->has_ssl_support and $self->has_wheel 0 0 0
Condition0%0/6
$self->ssl and $self->has_ssl_support and $self->has_wheel
!ll&&!rl&&r
000
$self->ssl and $self->has_ssl_support
!ll&&!rl&&r
000
MC/DC0%0/3
$self->ssl and $self->has_ssl_support and $self->has_wheel
$self->ssl $self->has_ssl_support $self->has_wheel
Truth table0%0/4
A and B and C
A= $self->sslB= $self->has_ssl_supportC= $self->has_wheel
ABCresult
0XX0
10X0
1100
1111
118 unless $self->ssl
119 and $self->has_ssl_support
120 and $self->has_wheel;
121  
122 0 POE::Component::SSLify::SSLify_GetCipher( $self->wheel->get_output_handle )
123 }
124  
125 sub get_socket {
126 0 ▶ my ($self) = @_;
Subroutine get_socket: not called CC=3 SCAR=24.8
Pod documented
127 0 ▶ return undef unless $self->has_wheel;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_wheel 0 0 0
128 0 ▶ $self->ssl ?
Branch: 1 branch
BranchTrueFalseTotal
$self->ssl ? : 0 0 0
129 POE::Component::SSLify::SSLify_GetSocket( $self->wheel->get_output_handle )
130 : $self->wheel->get_output_handle
131 }
132  
133  
134 1 1;
135  
136 =pod
137  
138 =for Pod::Coverage has_\w+ set_\w+
139  
140 =head1 NAME
141  
142 POEx::IRC::Backend::Connect - A connected IRC socket
143  
144 =head1 SYNOPSIS
145  
146 Typically created by L<POEx::IRC::Backend> to represent an established
147 connection.
148  
149 =head1 DESCRIPTION
150  
151 These objects contain details regarding connected socket
152 L<POE::Wheel::ReadWrite> wheels managed by
153 L<POEx::IRC::Backend>.
154  
155 =head2 CONSUMES
156  
157 This class consumes the following roles:
158  
159 L<POEx::IRC::Backend::Role::HasWheel>
160  
161 L<POEx::IRC::Backend::Role::Socket>
162  
163 =head2 ATTRIBUTES
164  
165 =head3 alarm_id
166  
167 Connected socket wheels normally have a POE alarm ID attached for an idle
168 timer.
169  
170 Predicate: C<has_alarm_id>
171  
172 B<rw> attribute.
173  
174 =head3 compressed
175  
176 Boolean true if the Zlib filter has been added.
177  
178 See also: L<POEx::IRC::Backend/set_compressed_link>
179  
180 =head3 set_compressed
181  
182 Change the boolean value of the L</compressed> attrib.
183  
184 =head3 idle
185  
186 Idle time used for connection check alarms.
187  
188 See also: L</ping_pending>, L<POEx::IRC::Backend/ircsock_connection_idle>
189  
190 =head3 is_disconnecting
191  
192 Boolean false if the Connect is not in a disconnecting state; if it is
193 true, it is the disconnect message:
194  
195 $obj->is_disconnecting("Client quit")
196  
197 B<rw> attribute.
198  
199 See also: L<POEx::IRC::Backend/disconnect>
200  
201 =head3 is_client
202  
203 Boolean true if the connection wheel has been marked as a client.
204  
205 B<rw> attribute.
206  
207 =head3 is_peer
208  
209 Boolean true if the connection wheel has been marked as a peer.
210  
211 B<rw> attribute.
212  
213 =head3 is_pending_compress
214  
215 Primarily for internal use; boolean true if the Wheel needs a Zlib filter on
216 next buffer flush.
217  
218 B<rw> attribute.
219  
220 =head3 ping_pending
221  
222 The C<ping_pending> attribute can be used to manage standard IRC
223 PING/PONG heartbeating; a server can call C<< $conn->ping_pending(1) >> upon
224 dispatching a PING to a client (because of an C<ircsock_connection_idle>
225 event, for example) and C<< $conn->ping_pending(0) >> when a
226 response is received.
227  
228 If C<< $conn->ping_pending >> is true on the next C<ircsock_connection_idle>,
229 the client can be considered to have timed out and your server-side C<Backend>
230 can issue a disconnect; this emulates standard IRCD behavior.
231  
232 B<rw> attribute.
233  
234 See also: L<POEx::IRC::Backend/ircsock_connection_idle>
235  
236 =head3 peeraddr
237  
238 The remote peer address.
239  
240 Writer: C<set_peeraddr>
241  
242 =head3 peerport
243  
244 The remote peer port.
245  
246 Writer: C<set_peerport>
247  
248 =head3 seen
249  
250 Timestamp of last socket activity; updated by L<POEx::IRC::Backend> when
251 traffic is seen from this Connect.
252  
253 B<rw> attribute.
254  
255 =head3 sockaddr
256  
257 Our socket address.
258  
259 Writer: C<set_sockaddr>
260  
261 =head3 sockport
262  
263 Our socket port.
264  
265 Writer: C<set_sockport>
266  
267 =head2 METHODS
268  
269 =head3 get_socket
270  
271 Returns the actual underlying socket handle, or undef if one is not open.
272  
273 If this is a SSLified socket, the real handle is retrieved via
274 L<POE::Component::SSLify/SSLify_GetSocket>.
275  
276 =head3 ssl_cipher
277  
278 Returns the cipher in use by calling
279 L<POE::Component::SSLify/SSLify_GetCipher>, or the empty string if this is not
280 an SSLified connection.
281  
282 =head3 ssl_object
283  
284 Returns the underlying L<Net::SSLeay> object via
285 L<POE::Component::SSLify/SSLify_GetSSL>, or undef if this is not an SSLified
286 connection.
287  
288 =head1 AUTHOR
289  
290 Jon Portnoy <avenj@cobaltirc.org>
291  
292 =cut
↑ Summary Backend/Role/CheckAvail.pm »