| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package POEx::IRC::Backend::Connect; | 
| 2 |  |  |  |  |  |  | $POEx::IRC::Backend::Connect::VERSION = '0.030001'; | 
| 3 | 3 |  |  | 3 |  | 25017 | use strictures 2; | 
|  | 3 |  |  |  |  | 2011 |  | 
|  | 3 |  |  |  |  | 143 |  | 
| 4 | 3 |  |  | 3 |  | 1572 | use Types::Standard -all; | 
|  | 3 |  |  |  |  | 89117 |  | 
|  | 3 |  |  |  |  | 42 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 3 |  |  | 3 |  | 112034 | use Moo; | 
|  | 3 |  |  |  |  | 15254 |  | 
|  | 3 |  |  |  |  | 28 |  | 
| 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 | 3 |  |  | 3 | 1 | 995 | my ($self) = @_; | 
| 107 |  |  |  |  |  |  | return undef | 
| 108 | 3 | 50 | 66 |  |  | 29 | unless $self->ssl | 
|  |  |  | 66 |  |  |  |  | 
| 109 |  |  |  |  |  |  | and $self->has_ssl_support | 
| 110 |  |  |  |  |  |  | and $self->has_wheel; | 
| 111 |  |  |  |  |  |  |  | 
| 112 | 2 |  |  |  |  | 11 | POE::Component::SSLify::SSLify_GetSSL( $self->wheel->get_output_handle ) | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | sub ssl_cipher { | 
| 116 | 2 |  |  | 2 | 1 | 1622 | my ($self) = @_; | 
| 117 | 2 | 50 | 66 |  |  | 24 | return '' | 
|  |  |  | 66 |  |  |  |  | 
| 118 |  |  |  |  |  |  | unless $self->ssl | 
| 119 |  |  |  |  |  |  | and $self->has_ssl_support | 
| 120 |  |  |  |  |  |  | and $self->has_wheel; | 
| 121 |  |  |  |  |  |  |  | 
| 122 | 1 |  |  |  |  | 6 | POE::Component::SSLify::SSLify_GetCipher( $self->wheel->get_output_handle ) | 
| 123 |  |  |  |  |  |  | } | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | sub get_socket { | 
| 126 | 2 |  |  | 2 | 1 | 773 | my ($self) = @_; | 
| 127 | 2 | 50 |  |  |  | 11 | return undef unless $self->has_wheel; | 
| 128 | 2 | 100 |  |  |  | 17 | $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 SYNOPSIS | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | Typically created by L to represent an established | 
| 147 |  |  |  |  |  |  | connection. | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | These objects contain details regarding connected socket | 
| 152 |  |  |  |  |  |  | L wheels managed by | 
| 153 |  |  |  |  |  |  | L. | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | =head2 CONSUMES | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | This class consumes the following roles: | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | L | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | L | 
| 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 | 
| 171 |  |  |  |  |  |  |  | 
| 172 |  |  |  |  |  |  | B attribute. | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | =head3 compressed | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | Boolean true if the Zlib filter has been added. | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | See also: L | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =head3 set_compressed | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | Change the boolean value of the L attrib. | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | =head3 idle | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | Idle time used for connection check alarms. | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | See also: L, L | 
| 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 attribute. | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | See also: L | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | =head3 is_client | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | Boolean true if the connection wheel has been marked as a client. | 
| 204 |  |  |  |  |  |  |  | 
| 205 |  |  |  |  |  |  | B attribute. | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | =head3 is_peer | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | Boolean true if the connection wheel has been marked as a peer. | 
| 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 |