File Coverage

blib/lib/POEx/IRC/Backend/Connect.pm
Criterion Covered Total %
statement 12 21 57.1
branch 0 8 0.0
condition 0 12 0.0
subroutine 4 7 57.1
pod 3 3 100.0
total 19 51 37.2


line stmt bran cond sub pod time code
1             package POEx::IRC::Backend::Connect;
2             $POEx::IRC::Backend::Connect::VERSION = '0.030003';
3 1     1   19426 use strictures 2;
  1         1714  
  1         36  
4 1     1   726 use Types::Standard -all;
  1         69989  
  1         15  
5              
6              
7 1     1   37299 use Moo; use MooX::TypeTiny;
  1     1   15357  
  1         7  
  1         2783  
  1         225  
  1         8  
8             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             default => sub { 0 },
18             );
19              
20             has compressed => (
21             ## zlib filter added.
22             lazy => 1,
23             is => 'rwp',
24             isa => Bool,
25             writer => 'set_compressed',
26             default => sub { !!0 },
27             );
28              
29             has idle => (
30             ## Idle delay.
31             lazy => 1,
32             is => 'ro',
33             isa => StrictNum,
34             default => sub { 180 },
35             );
36              
37             has is_client => (
38             lazy => 1,
39             is => 'rw',
40             isa => Bool,
41             default => sub { !!0 },
42             );
43              
44             has is_peer => (
45             lazy => 1,
46             is => 'rw',
47             isa => Bool,
48             default => sub { !!0 },
49             );
50              
51             has is_disconnecting => (
52             ## Bool or string (disconnect message)
53             is => 'rw',
54             isa => (Bool | Str),
55             default => sub { !!0 },
56             );
57              
58             has is_pending_compress => (
59             ## Wheel needs zlib filter after a socket flush.
60             is => 'rw',
61             isa => Bool,
62             default => sub { !!0 },
63             );
64              
65             has peeraddr => (
66             required => 1,
67             isa => Str,
68             is => 'ro',
69             writer => 'set_peeraddr',
70             );
71              
72             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             default => sub { 0 },
82             );
83              
84             has seen => (
85             ## TS of last activity on this Connect.
86             lazy => 1,
87             is => 'rw',
88             default => sub { 0 },
89             );
90              
91             has sockaddr => (
92             required => 1,
93             isa => Str,
94             is => 'ro',
95             writer => 'set_sockaddr',
96             );
97              
98             has sockport => (
99             required => 1,
100             is => 'ro',
101             writer => 'set_sockport',
102             );
103              
104              
105             sub ssl_object {
106 0     0 1   my ($self) = @_;
107             return undef
108 0 0 0       unless $self->ssl
      0        
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     0 1   my ($self) = @_;
117 0 0 0       return ''
      0        
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     0 1   my ($self) = @_;
127 0 0         return undef unless $self->has_wheel;
128 0 0         $self->ssl ?
129             POE::Component::SSLify::SSLify_GetSocket( $self->wheel->get_output_handle )
130             : $self->wheel->get_output_handle
131             }
132              
133              
134             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 DESCRIPTION
145              
146             These objects contain details regarding connected socket
147             L wheels managed by L.
148              
149             These objects are typically created by a successfully connected
150             L or an accepted connection to a
151             L.
152              
153             =head2 CONSUMES
154              
155             This class consumes the following roles:
156              
157             L
158              
159             L
160              
161             =head2 ATTRIBUTES
162              
163             =head3 alarm_id
164              
165             Connected socket wheels normally have a POE alarm ID attached for an idle
166             timer.
167              
168             Predicate: C
169              
170             B attribute.
171              
172             =head3 compressed
173              
174             Boolean true if the Zlib filter has been added.
175              
176             See also: L
177              
178             =head3 set_compressed
179              
180             Change the boolean value of the L attrib.
181              
182             =head3 idle
183              
184             Idle time used for connection check alarms.
185              
186             See also: L, L
187              
188             =head3 is_disconnecting
189              
190             Boolean false if the Connect is not in a disconnecting state; if it is
191             true, it is the disconnect message (for use by higher-level layers):
192              
193             $obj->is_disconnecting("Client quit")
194              
195             B attribute.
196              
197             See also: L
198              
199             =head3 is_client
200              
201             Boolean true if the connection wheel has been marked as a client; for use by
202             higher-level layers to help tag Connects.
203              
204             B attribute.
205              
206             =head3 is_peer
207              
208             Boolean true if the connection wheel has been marked as a peer; for use by
209             higher-level layers to help tag Connects.
210              
211             B 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 attribute.
219              
220             =head3 ping_pending
221              
222             The C 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
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,
229             the client can be considered to have timed out and your server-side C
230             can issue a disconnect; this emulates standard IRCD behavior.
231              
232             B attribute.
233              
234             See also: L
235              
236             =head3 peeraddr
237              
238             The remote peer address.
239              
240             Writer: C
241              
242             =head3 peerport
243              
244             The remote peer port.
245              
246             Writer: C
247              
248             =head3 seen
249              
250             Timestamp of last socket activity; updated by L when
251             traffic is seen from this Connect.
252              
253             B attribute.
254              
255             =head3 sockaddr
256              
257             Our socket address.
258              
259             Writer: C
260              
261             =head3 sockport
262              
263             Our socket port.
264              
265             Writer: C
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.
275              
276             =head3 ssl_cipher
277              
278             Returns the cipher in use by calling
279             L, or the empty string if this is not
280             an SSLified connection.
281              
282             =head3 ssl_object
283              
284             Returns the underlying L object via
285             L, or undef if this is not an SSLified
286             connection.
287              
288             =head1 AUTHOR
289              
290             Jon Portnoy
291              
292             =cut