| 1 | package POEx::IRC::Backend; | ||||||||||||||||||||||||||||||||||||
| 2 | 1 | $POEx::IRC::Backend::VERSION = '0.030002'; | |||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use IRC::Message::Object (); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Net::IP::Minimal 'ip_is_ipv6'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||
| 12 | 1 | use POE qw/ | |||||||||||||||||||||||||||||||||||
| 13 | Wheel::ReadWrite | ||||||||||||||||||||||||||||||||||||
| 14 | Wheel::SocketFactory | ||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||
| 16 | Filter::Stackable | ||||||||||||||||||||||||||||||||||||
| 17 | Filter::IRCv3 | ||||||||||||||||||||||||||||||||||||
| 18 | Filter::Line | ||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | /; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||
| 21 | 1 | use Socket qw/ | |||||||||||||||||||||||||||||||||||
| 22 | AF_INET AF_INET6 | ||||||||||||||||||||||||||||||||||||
| 23 | pack_sockaddr_in | ||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||
| 25 | getnameinfo | ||||||||||||||||||||||||||||||||||||
| 26 | NI_NUMERICHOST | ||||||||||||||||||||||||||||||||||||
| 27 | NI_NUMERICSERV | ||||||||||||||||||||||||||||||||||||
| 28 | NIx_NOSERV | ||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | /; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use Types::Standard -all; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use Types::TypeTiny -all; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use POEx::IRC::Backend::Connect; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use POEx::IRC::Backend::Connector; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use POEx::IRC::Backend::Listener; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | sub RUNNING_IN_HELL () { $^O =~ /(cygwin|MSWin32)/ } | ||||||||||||||||||||||||||||||||||
|
Subroutine
RUNNING_IN_HELL: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | sub get_unpacked_addr { | ||||||||||||||||||||||||||||||||||||
| 44 | 5 | ▶ | my ($sock_packed, %params) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
get_unpacked_addr: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 45 | my ($err, $addr, $port) = getnameinfo $sock_packed, | ||||||||||||||||||||||||||||||||||||
| 46 | NI_NUMERICHOST | NI_NUMERICSERV, | ||||||||||||||||||||||||||||||||||||
| 47 | 5 | ▶ | ( $params{noserv} ? NIx_NOSERV : () ); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 48 | 5 | ▶ | croak $err if $err; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 49 | 5 | ▶ | $params{noserv} ? $addr : ($addr, $port) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | use Moo 2; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 54 | 1 | with 'POEx::IRC::Backend::Role::CheckAvail'; | |||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||
| 57 | 1 | has session_id => ( | |||||||||||||||||||||||||||||||||||
| 58 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||
| 59 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 60 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 61 | writer => '_set_session_id', | ||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||
| 64 | 1 | has controller => ( | |||||||||||||||||||||||||||||||||||
| 65 | ## Session ID for controller session | ||||||||||||||||||||||||||||||||||||
| 66 | ## Typically set by 'register' event, though it doesn't have to be: | ||||||||||||||||||||||||||||||||||||
| 67 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 69 | writer => '_set_controller', | ||||||||||||||||||||||||||||||||||||
| 70 | predicate => 'has_controller', | ||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||
| 73 | has filter_irc => ( | ||||||||||||||||||||||||||||||||||||
| 74 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 75 | isa => InstanceOf['POE::Filter'], | ||||||||||||||||||||||||||||||||||||
| 76 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | default => sub { POE::Filter::IRCv3->new }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 78 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||
| 80 | has filter_line => ( | ||||||||||||||||||||||||||||||||||||
| 81 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 82 | isa => InstanceOf['POE::Filter'], | ||||||||||||||||||||||||||||||||||||
| 83 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 84 | default => sub { | ||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | POE::Filter::Line->new( | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 86 | InputRegexp => '\015?\012', | ||||||||||||||||||||||||||||||||||||
| 87 | OutputLiteral => "\015\012", | ||||||||||||||||||||||||||||||||||||
| 88 | ) | ||||||||||||||||||||||||||||||||||||
| 89 | }, | ||||||||||||||||||||||||||||||||||||
| 90 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||
| 92 | has filter => ( | ||||||||||||||||||||||||||||||||||||
| 93 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 94 | isa => InstanceOf['POE::Filter'], | ||||||||||||||||||||||||||||||||||||
| 95 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 96 | default => sub { | ||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 98 | 1 | POE::Filter::Stackable->new( | |||||||||||||||||||||||||||||||||||
| 99 | Filters => [ $self->filter_line, $self->filter_irc ], | ||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||
| 101 | }, | ||||||||||||||||||||||||||||||||||||
| 102 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||
| 104 | has listeners => ( | ||||||||||||||||||||||||||||||||||||
| 105 | ## POEx::IRC::Backend::Listener objs | ||||||||||||||||||||||||||||||||||||
| 106 | ## These are listeners for a particular port. | ||||||||||||||||||||||||||||||||||||
| 107 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||
| 108 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 109 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||
| 110 | writer => '_set_listeners', | ||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | default => sub { +{} }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 112 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||
| 114 | has connectors => ( | ||||||||||||||||||||||||||||||||||||
| 115 | ## POEx::IRC::Backend::Connector objs | ||||||||||||||||||||||||||||||||||||
| 116 | ## These are outgoing (peer) connectors. | ||||||||||||||||||||||||||||||||||||
| 117 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||
| 118 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 119 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||
| 120 | writer => '_set_connectors', | ||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | default => sub { +{} }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 122 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||
| 124 | has wheels => ( | ||||||||||||||||||||||||||||||||||||
| 125 | ## POEx::IRC::Backend::Connect objs | ||||||||||||||||||||||||||||||||||||
| 126 | ## These are our connected wheels. | ||||||||||||||||||||||||||||||||||||
| 127 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||
| 128 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 129 | isa => HashRef, | ||||||||||||||||||||||||||||||||||||
| 130 | writer => '_set_wheels', | ||||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | default => sub { +{} }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 132 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||
| 134 | has ssl_context => ( | ||||||||||||||||||||||||||||||||||||
| 135 | lazy => 1, | ||||||||||||||||||||||||||||||||||||
| 136 | is => 'ro', | ||||||||||||||||||||||||||||||||||||
| 137 | writer => '_set_ssl_context', | ||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | default => sub { undef }, | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 139 | 1 | ); | |||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||
| 142 | sub spawn { | ||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=6 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 144 | 1 | my $ssl_opts = delete $args{ssl_opts}; | |||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | my $self = blessed $class ? $class : $class->new(%args); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | POE::Session->create( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 148 | object_states => [ | ||||||||||||||||||||||||||||||||||||
| 149 | $self => { | ||||||||||||||||||||||||||||||||||||
| 150 | _start => '_start', | ||||||||||||||||||||||||||||||||||||
| 151 | _stop => '_stop', | ||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||
| 153 | register => '_register_controller', | ||||||||||||||||||||||||||||||||||||
| 154 | shutdown => '_shutdown', | ||||||||||||||||||||||||||||||||||||
| 155 | create_connector => '_create_connector', | ||||||||||||||||||||||||||||||||||||
| 156 | create_listener => '_create_listener', | ||||||||||||||||||||||||||||||||||||
| 157 | remove_listener => '_remove_listener', | ||||||||||||||||||||||||||||||||||||
| 158 | send => '_send', | ||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||
| 160 | _accept_conn_v4 => '_accept_conn', | ||||||||||||||||||||||||||||||||||||
| 161 | _accept_conn_v6 => '_accept_conn', | ||||||||||||||||||||||||||||||||||||
| 162 | _accept_fail => '_accept_fail', | ||||||||||||||||||||||||||||||||||||
| 163 | _idle_alarm => '_idle_alarm', | ||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||
| 165 | _connector_up_v4 => '_connector_up', | ||||||||||||||||||||||||||||||||||||
| 166 | _connector_up_v6 => '_connector_up', | ||||||||||||||||||||||||||||||||||||
| 167 | _connector_failed => '_connector_failed', | ||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||
| 169 | _ircsock_input => '_ircsock_input', | ||||||||||||||||||||||||||||||||||||
| 170 | _ircsock_error => '_ircsock_error', | ||||||||||||||||||||||||||||||||||||
| 171 | _ircsock_flushed => '_ircsock_flushed', | ||||||||||||||||||||||||||||||||||||
| 172 | }, | ||||||||||||||||||||||||||||||||||||
| 173 | ], | ||||||||||||||||||||||||||||||||||||
| 174 | ) or confess "Failed to spawn POE::Session"; | ||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | if (defined $ssl_opts) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | confess "expected ssl_opts to be an ARRAY but got $ssl_opts" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 178 | unless ref $ssl_opts eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $ssl_err; | |||||||||||||||||||||||||||||||||||
| 180 | try { | ||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | die "Failed to load POE::Component::SSLify" unless $self->has_ssl_support; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->_set_ssl_context( | |||||||||||||||||||||||||||||||||||
| 183 | POE::Component::SSLify::SSLify_ContextCreate( @$ssl_opts ) | ||||||||||||||||||||||||||||||||||||
| 184 | ); | ||||||||||||||||||||||||||||||||||||
| 185 | 0 | 1 | |||||||||||||||||||||||||||||||||||
| 186 | } catch { | ||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $ssl_err = $_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 188 | undef | ||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | } or confess "SSLify failure: $ssl_err"; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||
| 192 | $self | ||||||||||||||||||||||||||||||||||||
| 193 | 1 | } | |||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||
| 195 | sub _start { | ||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | my ($kernel, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 197 | 1 | $self->_set_session_id( $_[SESSION]->ID ); | |||||||||||||||||||||||||||||||||||
| 198 | 1 | $kernel->refcount_increment( $self->session_id, "IRCD Running" ); | |||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||
| 201 | ▶ | sub _stop {} | |||||||||||||||||||||||||||||||||||
|
Subroutine
_stop: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||
| 203 | sub shutdown { | ||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 205 | 0 | $poe_kernel->post( $self->session_id => shutdown => @_ ) | |||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||
| 208 | sub _shutdown { | ||||||||||||||||||||||||||||||||||||
| 209 | 1 | ▶ | my ($kernel, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||
| 211 | 1 | $kernel->refcount_decrement( $self->session_id => "IRCD Running" ); | |||||||||||||||||||||||||||||||||||
| 212 | 1 | $kernel->refcount_decrement( $self->controller => "IRCD Running" ); | |||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||
| 214 | ## _disconnected should also clear our alarms. | ||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->_disconnected($_, "Server shutdown") for keys %{ $self->wheels }; | |||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||
| 217 | 1 | for my $attr (map {; '_set_'.$_ } qw/ listeners connectors wheels /) { | |||||||||||||||||||||||||||||||||||
| 218 | 3 | $self->$attr(+{}) | |||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||
| 222 | sub _register_controller { | ||||||||||||||||||||||||||||||||||||
| 223 | 1 | ▶ | my ($kernel, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_register_controller: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | $kernel->refcount_decrement( $self->controller => "IRCD Running" ) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 226 | if $self->has_controller; | ||||||||||||||||||||||||||||||||||||
| 227 | 1 | $self->_set_controller( $_[SENDER]->ID ); | |||||||||||||||||||||||||||||||||||
| 228 | 1 | $kernel->refcount_increment( $self->controller => "IRCD Running" ); | |||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||
| 230 | 1 | $kernel->post( $self->controller => ircsock_registered => $self ); | |||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||
| 233 | sub _idle_alarm { | ||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my ($kernel, $self, $w_id) = @_[KERNEL, OBJECT, ARG0]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_idle_alarm: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $this_conn = $self->wheels->{$w_id} || return; | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->wheels->{$w_id} || (return)
MC/DC0%0/1
$self->wheels->{$w_id} || (return)
$self->wheels->{$w_id}
Truth table0%0/2
A
A= $self->wheels->{$w_id}
| |||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||
| 237 | 0 | $kernel->post( $self->controller => ircsock_connection_idle => $this_conn ); | |||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||
| 239 | 0 | $this_conn->alarm_id( | |||||||||||||||||||||||||||||||||||
| 240 | $kernel->delay_set( _idle_alarm => $this_conn->idle, $w_id ) | ||||||||||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||
| 244 | sub create_listener { | ||||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
create_listener: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 246 | 1 | $poe_kernel->post( $self->session_id => create_listener => @_ ); | |||||||||||||||||||||||||||||||||||
| 247 | 1 | $self | |||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||
| 250 | sub _create_listener { | ||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | my ($kernel, $self, %args) = @_[KERNEL, OBJECT, ARG0 .. $#_]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_create_listener: called CC=12 SCAR=28.5
| |||||||||||||||||||||||||||||||||||||
| 252 | 1 | $args{lc $_} = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | my $bindaddr = delete $args{bindaddr} || '0.0.0.0'; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'bindaddr'} || '0.0.0.0'
MC/DC0%0/1
delete $args{'bindaddr'} || '0.0.0.0'
delete $args{'bindaddr'}
Truth table50%1/2
A
A= delete $args{'bindaddr'}
| |||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | my $bindport = delete $args{port} || 0; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'port'} || 0
MC/DC0%0/1
delete $args{'port'} || 0
delete $args{'port'}
Truth table50%1/2
A
A= delete $args{'port'}
| |||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | my $protocol = ( delete $args{ipv6} || ip_is_ipv6($bindaddr) ) ? 6 : 4; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
delete $args{"ipv6"} or ip_is_ipv6($bindaddr)
MC/DC0%0/2
delete $args{"ipv6"} or ip_is_ipv6($bindaddr)
delete $args{"ipv6"}
ip_is_ipv6($bindaddr)
Truth table33%1/3
A or B
A= delete $args{"ipv6"}B= ip_is_ipv6($bindaddr)
| |||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | my $wheel = POE::Wheel::SocketFactory->new( | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 260 | SocketDomain => ($protocol == 6 ? AF_INET6 : AF_INET), | ||||||||||||||||||||||||||||||||||||
| 261 | BindAddress => $bindaddr, | ||||||||||||||||||||||||||||||||||||
| 262 | BindPort => $bindport, | ||||||||||||||||||||||||||||||||||||
| 263 | SuccessEvent => | ||||||||||||||||||||||||||||||||||||
| 264 | ( $protocol == 6 ? '_accept_conn_v6' : '_accept_conn_v4' ), | ||||||||||||||||||||||||||||||||||||
| 265 | FailureEvent => '_accept_fail', | ||||||||||||||||||||||||||||||||||||
| 266 | Reuse => 1, | ||||||||||||||||||||||||||||||||||||
| 267 | ); | ||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||
| 269 | 1 | my $id = $wheel->ID; | |||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||
| 271 | my $listener = POEx::IRC::Backend::Listener->new( | ||||||||||||||||||||||||||||||||||||
| 272 | protocol => $protocol, | ||||||||||||||||||||||||||||||||||||
| 273 | wheel => $wheel, | ||||||||||||||||||||||||||||||||||||
| 274 | addr => $bindaddr, | ||||||||||||||||||||||||||||||||||||
| 275 | port => $bindport, | ||||||||||||||||||||||||||||||||||||
| 276 | idle => ( delete($args{idle}) || 180 ), | ||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | ssl => ( delete($args{ssl}) || 0 ), | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
delete $args{'idle'} || 180
delete $args{'ssl'} || 0
MC/DC0%0/1
delete $args{'idle'} || 180
delete $args{'idle'}
MC/DC0%0/1
delete $args{'ssl'} || 0
delete $args{'ssl'}
Truth table50%1/2
A
A= delete $args{'idle'}
Truth table50%1/2
A
A= delete $args{'ssl'}
| |||||||||||||||||||||||||||||||||||||
| 278 | ( keys %args ? (args => \%args) : () ), | ||||||||||||||||||||||||||||||||||||
| 279 | ); | ||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||
| 281 | 1 | $self->listeners->{$id} = $listener; | |||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||
| 283 | ## Real bound port/addr | ||||||||||||||||||||||||||||||||||||
| 284 | 1 | my (undef, $port) = get_unpacked_addr( $wheel->getsockname ); | |||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | $listener->set_port($port) if $port; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||
| 287 | 1 | $kernel->post( $self->controller => ircsock_listener_created => $listener ) | |||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||
| 290 | sub remove_listener { | ||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
remove_listener: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 292 | 1 | $poe_kernel->post( $self->session_id => remove_listener => @_ ); | |||||||||||||||||||||||||||||||||||
| 293 | 1 | $self | |||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||
| 296 | sub _remove_listener { | ||||||||||||||||||||||||||||||||||||
| 297 | 1 | ▶ | my ($kernel, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_listener: called CC=14 SCAR=40.0
| |||||||||||||||||||||||||||||||||||||
| 298 | 1 | my %args = @_[ARG0 .. $#_]; | |||||||||||||||||||||||||||||||||||
| 299 | 1 | $args{lc $_} = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||
| 301 | 1 | ▶ | if (defined $args{listener} && $self->listeners->{ $args{listener} }) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"listener"} and $self->listeners->{$args{"listener"}}
MC/DC0%0/2
defined $args{"listener"} and $self->listeners->{$args{"listener"}}
defined $args{"listener"}
$self->listeners->{$args{"listener"}}
Truth table33%1/3
A and B
A= defined $args{"listener"}B= $self->listeners->{$args{"listener"}}
| |||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $listener = delete $self->listeners->{ $args{listener} }; | |||||||||||||||||||||||||||||||||||
| 303 | 0 | $listener->clear_wheel; | |||||||||||||||||||||||||||||||||||
| 304 | 0 | $kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 305 | ircsock_listener_removed => $listener | ||||||||||||||||||||||||||||||||||||
| 306 | ); | ||||||||||||||||||||||||||||||||||||
| 307 | return | ||||||||||||||||||||||||||||||||||||
| 308 | 0 | } | |||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||
| 310 | 1 | my @removed; | |||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||
| 312 | 1 | LISTENER: for my $id (keys %{ $self->listeners }) { | |||||||||||||||||||||||||||||||||||
| 313 | 1 | my $listener = $self->listeners->{$id}; | |||||||||||||||||||||||||||||||||||
| 314 | 1 | ▶ | if (defined $args{port} && defined $args{addr}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
defined $args{"port"} and defined $args{"addr"}
MC/DC0%0/2
defined $args{"port"} and defined $args{"addr"}
defined $args{"port"}
defined $args{"addr"}
Truth table33%1/3
A and B
A= defined $args{"port"}B= defined $args{"addr"}
| |||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ($args{addr} eq $listener->addr && $args{port} eq $listener->port) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"addr"} eq $listener->addr and $args{"port"} eq $listener->port
MC/DC0%0/2
$args{"addr"} eq $listener->addr and $args{"port"} eq $listener->port
$args{"addr"} eq $listener->addr
$args{"port"} eq $listener->port
Truth table0%0/3
A and B
A= $args{"addr"} eq $listener->addrB= $args{"port"} eq $listener->port
| |||||||||||||||||||||||||||||||||||||
| 316 | 0 | delete $self->listeners->{$id}; | |||||||||||||||||||||||||||||||||||
| 317 | 0 | push @removed, $listener; | |||||||||||||||||||||||||||||||||||
| 318 | next LISTENER | ||||||||||||||||||||||||||||||||||||
| 319 | 0 | } | |||||||||||||||||||||||||||||||||||
| 320 | ▶ | } elsif (defined $args{addr} && $args{addr} eq $listener->addr) { | |||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $args{"addr"} and $args{"addr"} eq $listener->addr
MC/DC0%0/2
defined $args{"addr"} and $args{"addr"} eq $listener->addr
defined $args{"addr"}
$args{"addr"} eq $listener->addr
Truth table33%1/3
A and B
A= defined $args{"addr"}B= $args{"addr"} eq $listener->addr
| |||||||||||||||||||||||||||||||||||||
| 321 | 1 | delete $self->listeners->{$id}; | |||||||||||||||||||||||||||||||||||
| 322 | 1 | push @removed, $listener; | |||||||||||||||||||||||||||||||||||
| 323 | ▶ | } elsif (defined $args{port} && $args{port} eq $listener->port) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $args{"port"} and $args{"port"} eq $listener->port
MC/DC0%0/2
defined $args{"port"} and $args{"port"} eq $listener->port
defined $args{"port"}
$args{"port"} eq $listener->port
Truth table0%0/3
A and B
A= defined $args{"port"}B= $args{"port"} eq $listener->port
| |||||||||||||||||||||||||||||||||||||
| 324 | 0 | delete $self->listeners->{$id}; | |||||||||||||||||||||||||||||||||||
| 325 | 0 | push @removed, $listener; | |||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||
| 329 | 1 | for my $listener (@removed) { | |||||||||||||||||||||||||||||||||||
| 330 | 1 | $listener->clear_wheel; | |||||||||||||||||||||||||||||||||||
| 331 | 1 | $kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 332 | ircsock_listener_removed => $listener | ||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||
| 337 | sub _accept_fail { | ||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my ($kernel, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_fail: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||
| 339 | 0 | my ($op, $errnum, $errstr, $listener_id) = @_[ARG0 .. ARG3]; | |||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $listener = delete $self->listeners->{$listener_id}; | |||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($listener) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 343 | 0 | $listener->clear_wheel; | |||||||||||||||||||||||||||||||||||
| 344 | 0 | $kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 345 | ircsock_listener_failure => $listener, $op, $errnum, $errstr | ||||||||||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||
| 350 | sub _accept_conn { | ||||||||||||||||||||||||||||||||||||
| 351 | ## Accepted connection to a listener. | ||||||||||||||||||||||||||||||||||||
| 352 | 1 | ▶ | my ($self, $sock, $p_addr, $p_port, $listener_id) = @_[OBJECT, ARG0 .. ARG3]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_conn: called CC=7 SCAR=25.3
| |||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||
| 354 | 1 | ▶ | my ($protocol, $un_p_addr) = $_[STATE] eq '_accept_conn_v6' ? | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 355 | ( 6, $p_addr ) | ||||||||||||||||||||||||||||||||||||
| 356 | : ( 4, | ||||||||||||||||||||||||||||||||||||
| 357 | get_unpacked_addr( pack_sockaddr_in($p_port, $p_addr), noserv => 1 ) | ||||||||||||||||||||||||||||||||||||
| 358 | ) | ||||||||||||||||||||||||||||||||||||
| 359 | ; | ||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||
| 361 | 1 | my $listener = $self->listeners->{$listener_id}; | |||||||||||||||||||||||||||||||||||
| 362 | 1 | my $using_ssl = $listener->ssl; | |||||||||||||||||||||||||||||||||||
| 363 | 1 | ▶ | if ($using_ssl) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 364 | try { | ||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | die "Failed to load POE::Component::SSLify" unless $self->has_ssl_support; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 366 | 0 | $sock = POE::Component::SSLify::Server_SSLify($sock, $self->ssl_context); | |||||||||||||||||||||||||||||||||||
| 367 | } catch { | ||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | warn "Could not SSLify (server) socket: $_"; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 369 | undef | ||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | } or return; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||
| 373 | 1 | my $wheel = POE::Wheel::ReadWrite->new( | |||||||||||||||||||||||||||||||||||
| 374 | Handle => $sock, | ||||||||||||||||||||||||||||||||||||
| 375 | Filter => $self->filter, | ||||||||||||||||||||||||||||||||||||
| 376 | InputEvent => '_ircsock_input', | ||||||||||||||||||||||||||||||||||||
| 377 | ErrorEvent => '_ircsock_error', | ||||||||||||||||||||||||||||||||||||
| 378 | FlushedEvent => '_ircsock_flushed', | ||||||||||||||||||||||||||||||||||||
| 379 | ); | ||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||
| 381 | 1 | ▶ | unless ($wheel) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 382 | 0 | warn "Wheel creation failure in _accept_conn"; | |||||||||||||||||||||||||||||||||||
| 383 | return | ||||||||||||||||||||||||||||||||||||
| 384 | 0 | } | |||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||
| 386 | 1 | ▶ | my ($sockaddr, $sockport) = get_unpacked_addr( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 387 | getsockname( | ||||||||||||||||||||||||||||||||||||
| 388 | $using_ssl ? POE::Component::SSLify::SSLify_GetSocket($sock) : $sock | ||||||||||||||||||||||||||||||||||||
| 389 | ) | ||||||||||||||||||||||||||||||||||||
| 390 | ); | ||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||
| 392 | 1 | my $w_id = $wheel->ID; | |||||||||||||||||||||||||||||||||||
| 393 | 1 | ▶ | my $this_conn = $self->wheels->{$w_id} = | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 394 | POEx::IRC::Backend::Connect->new( | ||||||||||||||||||||||||||||||||||||
| 395 | ($listener->has_args ? (args => $listener->args) : () ), | ||||||||||||||||||||||||||||||||||||
| 396 | protocol => $protocol, | ||||||||||||||||||||||||||||||||||||
| 397 | wheel => $wheel, | ||||||||||||||||||||||||||||||||||||
| 398 | peeraddr => $un_p_addr, | ||||||||||||||||||||||||||||||||||||
| 399 | peerport => $p_port, | ||||||||||||||||||||||||||||||||||||
| 400 | sockaddr => $sockaddr, | ||||||||||||||||||||||||||||||||||||
| 401 | sockport => $sockport, | ||||||||||||||||||||||||||||||||||||
| 402 | seen => time, | ||||||||||||||||||||||||||||||||||||
| 403 | idle => $listener->idle, | ||||||||||||||||||||||||||||||||||||
| 404 | ssl => $using_ssl, | ||||||||||||||||||||||||||||||||||||
| 405 | ); | ||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||
| 407 | 1 | $this_conn->alarm_id( | |||||||||||||||||||||||||||||||||||
| 408 | $poe_kernel->delay_set( _idle_alarm => $this_conn->idle, $w_id ) | ||||||||||||||||||||||||||||||||||||
| 409 | ); | ||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||
| 411 | 1 | $poe_kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 412 | ircsock_listener_open => $this_conn, $listener | ||||||||||||||||||||||||||||||||||||
| 413 | ); | ||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||
| 416 | sub create_connector { | ||||||||||||||||||||||||||||||||||||
| 417 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
create_connector: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 418 | 1 | $poe_kernel->post( $self->session_id => create_connector => @_ ); | |||||||||||||||||||||||||||||||||||
| 419 | 1 | $self | |||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||
| 422 | sub _create_connector { | ||||||||||||||||||||||||||||||||||||
| 423 | ## Connector; try to spawn socket <-> remote peer | ||||||||||||||||||||||||||||||||||||
| 424 | ## remoteaddr => | ||||||||||||||||||||||||||||||||||||
| 425 | ## remoteport => | ||||||||||||||||||||||||||||||||||||
| 426 | ## [optional] | ||||||||||||||||||||||||||||||||||||
| 427 | ## bindaddr => | ||||||||||||||||||||||||||||||||||||
| 428 | ## ipv6 => | ||||||||||||||||||||||||||||||||||||
| 429 | ## ssl => | ||||||||||||||||||||||||||||||||||||
| 430 | ## ... other args get added to ->args() | ||||||||||||||||||||||||||||||||||||
| 431 | 1 | ▶ | my (undef, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_create_connector: called CC=14 SCAR=32.4
| |||||||||||||||||||||||||||||||||||||
| 432 | 1 | my %args = @_[ARG0 .. $#_]; | |||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||
| 434 | 1 | $args{lc $_} = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||
| 436 | 1 | my $remote_addr = delete $args{remoteaddr}; | |||||||||||||||||||||||||||||||||||
| 437 | 1 | my $remote_port = delete $args{remoteport}; | |||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||
| 439 | 1 | ▶ | die "create_connector expects a remoteaddr and remoteport\n" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $remote_addr and defined $remote_port
MC/DC0%0/2
defined $remote_addr and defined $remote_port
defined $remote_addr
defined $remote_port
Truth table33%1/3
A and B
A= defined $remote_addrB= defined $remote_port
| |||||||||||||||||||||||||||||||||||||
| 440 | unless defined $remote_addr and defined $remote_port; | ||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||
| 442 | my $protocol = | ||||||||||||||||||||||||||||||||||||
| 443 | delete $args{ipv6} ? 6 | ||||||||||||||||||||||||||||||||||||
| 444 | : ip_is_ipv6($remote_addr) ? 6 | ||||||||||||||||||||||||||||||||||||
| 445 | 1 | ▶ | : ( $args{bindaddr} && ip_is_ipv6($args{bindaddr}) ) ? 6 | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$args{"bindaddr"} and ip_is_ipv6($args{"bindaddr"})
MC/DC0%0/2
$args{"bindaddr"} and ip_is_ipv6($args{"bindaddr"})
$args{"bindaddr"}
ip_is_ipv6($args{"bindaddr"})
Truth table33%1/3
A and B
A= $args{"bindaddr"}B= ip_is_ipv6($args{"bindaddr"})
| |||||||||||||||||||||||||||||||||||||
| 446 | : 4; | ||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||
| 448 | my $wheel = POE::Wheel::SocketFactory->new( | ||||||||||||||||||||||||||||||||||||
| 449 | SocketDomain => ($protocol == 6 ? AF_INET6 : AF_INET), | ||||||||||||||||||||||||||||||||||||
| 450 | SocketProtocol => 'tcp', | ||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||
| 452 | RemoteAddress => $remote_addr, | ||||||||||||||||||||||||||||||||||||
| 453 | RemotePort => $remote_port, | ||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||
| 455 | FailureEvent => '_connector_failed', | ||||||||||||||||||||||||||||||||||||
| 456 | SuccessEvent => | ||||||||||||||||||||||||||||||||||||
| 457 | ( $protocol == 6 ? '_connector_up_v6' : '_connector_up_v4' ), | ||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||
| 459 | ( | ||||||||||||||||||||||||||||||||||||
| 460 | defined $args{bindaddr} ? | ||||||||||||||||||||||||||||||||||||
| 461 | 1 | ▶ | ( BindAddress => delete $args{bindaddr} ) : () | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 462 | ), | ||||||||||||||||||||||||||||||||||||
| 463 | ); | ||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||
| 465 | 1 | my $id = $wheel->ID; | |||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||
| 467 | $self->connectors->{$id} = POEx::IRC::Backend::Connector->new( | ||||||||||||||||||||||||||||||||||||
| 468 | wheel => $wheel, | ||||||||||||||||||||||||||||||||||||
| 469 | addr => $remote_addr, | ||||||||||||||||||||||||||||||||||||
| 470 | port => $remote_port, | ||||||||||||||||||||||||||||||||||||
| 471 | protocol => $protocol, | ||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||
| 473 | (defined $args{ssl} ? | ||||||||||||||||||||||||||||||||||||
| 474 | (ssl => delete $args{ssl}) : () ), | ||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||
| 476 | (defined $args{bindaddr} ? | ||||||||||||||||||||||||||||||||||||
| 477 | 1 | ▶ | (bindaddr => delete $args{bindaddr}) : () ), | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||
| 479 | ## Attach any extra args to Connector->args() | ||||||||||||||||||||||||||||||||||||
| 480 | (keys %args ? | ||||||||||||||||||||||||||||||||||||
| 481 | (args => \%args) : () ), | ||||||||||||||||||||||||||||||||||||
| 482 | ); | ||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||
| 486 | sub _connector_up { | ||||||||||||||||||||||||||||||||||||
| 487 | 1 | ▶ | my ($kernel, $self, $sock, $p_addr, $p_port, $c_id) | ||||||||||||||||||||||||||||||||||
|
Subroutine
_connector_up: called CC=7 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||
| 488 | = @_[KERNEL, OBJECT, ARG0 .. ARG3]; | ||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||
| 490 | 1 | my ($protocol, $un_p_addr); | |||||||||||||||||||||||||||||||||||
| 491 | 1 | ▶ | if ($_[STATE] eq '_connector_up_v6') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 492 | 0 | $protocol = 6; | |||||||||||||||||||||||||||||||||||
| 493 | 0 | $un_p_addr = $p_addr; | |||||||||||||||||||||||||||||||||||
| 494 | } else { | ||||||||||||||||||||||||||||||||||||
| 495 | 1 | $protocol = 4; | |||||||||||||||||||||||||||||||||||
| 496 | 1 | $un_p_addr = get_unpacked_addr( | |||||||||||||||||||||||||||||||||||
| 497 | pack_sockaddr_in($p_port, $p_addr), noserv => 1 | ||||||||||||||||||||||||||||||||||||
| 498 | ); | ||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||
| 501 | ## No need to try to connect out any more; remove from connectors pool: | ||||||||||||||||||||||||||||||||||||
| 502 | 1 | my $ct = delete $self->connectors->{$c_id}; | |||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||
| 504 | 1 | my $using_ssl; | |||||||||||||||||||||||||||||||||||
| 505 | 1 | ▶ | if ( $ct->ssl ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 506 | try { | ||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | die "Failed to load POE::Component::SSLify" unless $self->has_ssl_support; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 508 | 0 | $sock = POE::Component::SSLify::Client_SSLify( | |||||||||||||||||||||||||||||||||||
| 509 | $sock, undef, undef, $self->ssl_context | ||||||||||||||||||||||||||||||||||||
| 510 | ); | ||||||||||||||||||||||||||||||||||||
| 511 | 0 | $using_ssl = 1 | |||||||||||||||||||||||||||||||||||
| 512 | } catch { | ||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | warn "Could not SSLify (client) socket: $_\n"; | ||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 514 | undef | ||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | } or return; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||
| 518 | 1 | my $wheel = POE::Wheel::ReadWrite->new( | |||||||||||||||||||||||||||||||||||
| 519 | Handle => $sock, | ||||||||||||||||||||||||||||||||||||
| 520 | InputEvent => '_ircsock_input', | ||||||||||||||||||||||||||||||||||||
| 521 | ErrorEvent => '_ircsock_error', | ||||||||||||||||||||||||||||||||||||
| 522 | FlushedEvent => '_ircsock_flushed', | ||||||||||||||||||||||||||||||||||||
| 523 | Filter => POE::Filter::Stackable->new( | ||||||||||||||||||||||||||||||||||||
| 524 | Filters => [ $self->filter ], | ||||||||||||||||||||||||||||||||||||
| 525 | ) | ||||||||||||||||||||||||||||||||||||
| 526 | ); | ||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||
| 528 | 1 | ▶ | unless ($wheel) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 529 | 0 | warn "Wheel creation failure in _connector_up"; | |||||||||||||||||||||||||||||||||||
| 530 | return | ||||||||||||||||||||||||||||||||||||
| 531 | 0 | } | |||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||
| 533 | 1 | ▶ | my ($sockaddr, $sockport) = get_unpacked_addr( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 534 | getsockname( | ||||||||||||||||||||||||||||||||||||
| 535 | $using_ssl ? POE::Component::SSLify::SSLify_GetSocket($sock) : $sock | ||||||||||||||||||||||||||||||||||||
| 536 | ) | ||||||||||||||||||||||||||||||||||||
| 537 | ); | ||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||
| 539 | 1 | ▶ | my $this_conn = POEx::IRC::Backend::Connect->new( | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 540 | ($ct->has_args ? (args => $ct->args) : () ), | ||||||||||||||||||||||||||||||||||||
| 541 | protocol => $protocol, | ||||||||||||||||||||||||||||||||||||
| 542 | wheel => $wheel, | ||||||||||||||||||||||||||||||||||||
| 543 | peeraddr => $un_p_addr, | ||||||||||||||||||||||||||||||||||||
| 544 | peerport => $p_port, | ||||||||||||||||||||||||||||||||||||
| 545 | sockaddr => $sockaddr, | ||||||||||||||||||||||||||||||||||||
| 546 | sockport => $sockport, | ||||||||||||||||||||||||||||||||||||
| 547 | seen => time, | ||||||||||||||||||||||||||||||||||||
| 548 | ssl => $using_ssl, | ||||||||||||||||||||||||||||||||||||
| 549 | ); | ||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||
| 551 | 1 | $self->wheels->{ $wheel->ID } = $this_conn; | |||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||
| 553 | 1 | $kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 554 | ircsock_connector_open => $this_conn | ||||||||||||||||||||||||||||||||||||
| 555 | ); | ||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||
| 558 | sub _connector_failed { | ||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | my ($kernel, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_connector_failed: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 560 | 0 | my ($op, $errno, $errstr, $c_id) = @_[ARG0 .. ARG3]; | |||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $ct = delete $self->connectors->{$c_id}; | |||||||||||||||||||||||||||||||||||
| 563 | 0 | $ct->clear_wheel; | |||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||
| 565 | 0 | $kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 566 | ircsock_connector_failure => $ct, $op, $errno, $errstr | ||||||||||||||||||||||||||||||||||||
| 567 | ); | ||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||
| 570 | ## _ircsock_* handlers talk to endpoints via listeners/connectors | ||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||
| 572 | sub _ircsock_input { | ||||||||||||||||||||||||||||||||||||
| 573 | # ($input, $w_id) = @_[ARG0, ARG1]; | ||||||||||||||||||||||||||||||||||||
| 574 | 3 | ▶ | my $this_conn = $_[OBJECT]->wheels->{ $_[ARG1] }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_ircsock_input: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 575 | 3 | $this_conn->seen( time ); | |||||||||||||||||||||||||||||||||||
| 576 | 3 | ▶ | $poe_kernel->delay_adjust( $this_conn->alarm_id, $this_conn->idle ) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 577 | if $this_conn->has_alarm_id; | ||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||
| 579 | $poe_kernel->post( $_[OBJECT]->controller => | ||||||||||||||||||||||||||||||||||||
| 580 | 3 | ircsock_input => $this_conn, IRC::Message::Object->new(%{ $_[ARG0] }) | |||||||||||||||||||||||||||||||||||
| 581 | ); | ||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||
| 584 | sub _ircsock_error { | ||||||||||||||||||||||||||||||||||||
| 585 | ## Lost someone. | ||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | my (undef, $self) = @_[KERNEL, OBJECT]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_ircsock_error: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||
| 587 | 0 | my ($errstr, $w_id) = @_[ARG2, ARG3]; | |||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | my $this_conn = $self->wheels->{$w_id} || return; | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->wheels->{$w_id} || (return)
MC/DC0%0/1
$self->wheels->{$w_id} || (return)
$self->wheels->{$w_id}
Truth table0%0/2
A
A= $self->wheels->{$w_id}
| |||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | $self->_disconnected( | ||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$errstr || $this_conn->is_disconnecting
MC/DC0%0/2
$errstr || $this_conn->is_disconnecting
$errstr
$this_conn->is_disconnecting
Truth table0%0/3
A || B
A= $errstrB= $this_conn->is_disconnecting
| |||||||||||||||||||||||||||||||||||||
| 592 | $w_id, | ||||||||||||||||||||||||||||||||||||
| 593 | $errstr || $this_conn->is_disconnecting | ||||||||||||||||||||||||||||||||||||
| 594 | ); | ||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||
| 597 | sub _ircsock_flushed { | ||||||||||||||||||||||||||||||||||||
| 598 | ## Socket's been flushed; we may have something to do. | ||||||||||||||||||||||||||||||||||||
| 599 | 2 | ▶ | my ($self, $w_id) = @_[OBJECT, ARG0]; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_ircsock_flushed: called CC=4 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||
| 601 | 2 | ▶ | my $this_conn = $self->wheels->{$w_id} || return; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->wheels->{$w_id} || (return)
MC/DC0%0/1
$self->wheels->{$w_id} || (return)
$self->wheels->{$w_id}
Truth table50%1/2
A
A= $self->wheels->{$w_id}
| |||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||
| 603 | 2 | ▶ | if ($this_conn->is_disconnecting) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 604 | 0 | return $self->_disconnected( $w_id, $this_conn->is_disconnecting ) | |||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||
| 607 | 2 | ▶ | if ($this_conn->is_pending_compress) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 608 | 0 | return $self->set_compressed_link_now($w_id) | |||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||
| 612 | sub _send { | ||||||||||||||||||||||||||||||||||||
| 613 | ## POE bridge to send() | ||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | $_[OBJECT]->send(@_[ARG0 .. $#_ ]); | ||||||||||||||||||||||||||||||||||
|
Subroutine
_send: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||
| 617 | ## Methods. | ||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||
| 619 | sub send { | ||||||||||||||||||||||||||||||||||||
| 620 | ## ->send(HASH, ID [, ID .. ]) | ||||||||||||||||||||||||||||||||||||
| 621 | 3 | ▶ | my ($self, $out, @ids) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||
| 623 | 3 | ▶ | if (blessed $out && $out->isa('IRC::Message::Object')) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($out) and $out->isa("IRC::Message::Object")
MC/DC50%1/2
builtin::blessed($out) and $out->isa("IRC::Message::Object")
builtin::blessed($out)
$out->isa("IRC::Message::Object")
Truth table66%2/3
A and B
A= builtin::blessed($out)B= $out->isa("IRC::Message::Object")
| |||||||||||||||||||||||||||||||||||||
| 624 | # breaks encapsulation for performance reasons: | ||||||||||||||||||||||||||||||||||||
| 625 | $out = +{ | ||||||||||||||||||||||||||||||||||||
| 626 | command => $out->command, | ||||||||||||||||||||||||||||||||||||
| 627 | ( | ||||||||||||||||||||||||||||||||||||
| 628 | 2 | ▶ | map {; exists $out->{$_} ? ($_ => $out->{$_}) : () } | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 629 | qw/ colonify prefix params tags / | ||||||||||||||||||||||||||||||||||||
| 630 | ), | ||||||||||||||||||||||||||||||||||||
| 631 | }; | ||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||
| 634 | confess | ||||||||||||||||||||||||||||||||||||
| 635 | 3 | ▶ | "send() takes a HASH or IRC::Message::Object and a list of connection IDs" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $out eq "HASH" and @ids
MC/DC0%0/2
ref $out eq "HASH" and @ids
ref $out eq "HASH"
@ids
Truth table33%1/3
A and B
A= ref $out eq "HASH"B= @ids
| |||||||||||||||||||||||||||||||||||||
| 636 | unless ref $out eq 'HASH' and @ids; | ||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||
| 638 | 3 | TARGET: for my $target (@ids) { | |||||||||||||||||||||||||||||||||||
| 639 | # FIXME tests/docs wrt passing in Connect objs | ||||||||||||||||||||||||||||||||||||
| 640 | 3 | ▶ | $target = $target->wheel_id if blessed $target; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 641 | 3 | ▶ | ($self->wheels->{$target} || next TARGET)->wheel->put($out) | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->wheels->{$target} || (next TARGET)
MC/DC0%0/1
$self->wheels->{$target} || (next TARGET)
$self->wheels->{$target}
Truth table50%1/2
A
A= $self->wheels->{$target}
| |||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||
| 644 | $self | ||||||||||||||||||||||||||||||||||||
| 645 | 3 | } | |||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||
| 647 | sub disconnect { | ||||||||||||||||||||||||||||||||||||
| 648 | # Mark a wheel for disconnection at next flush. | ||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | my ($self, $w_id, $str) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | $w_id = $w_id->wheel_id if blessed $w_id; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | confess "disconnect() needs an (extant) wheel ID or Connect object" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 652 | unless defined $w_id; | ||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||
| 654 | # Application code should probably check $conn->has_wheel before trying to | ||||||||||||||||||||||||||||||||||||
| 655 | # call a ->disconnect, but if not, it's hard to determine if we were passed | ||||||||||||||||||||||||||||||||||||
| 656 | # junk or just racing against an already-gone wheel: | ||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | unless (defined $self->wheels->{$w_id}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 658 | 0 | carp "Attempting to disconnect() unknown wheel '$w_id'\n", | |||||||||||||||||||||||||||||||||||
| 659 | " This warning may be spurious. Your wheel may have died of natural causes.\n", | ||||||||||||||||||||||||||||||||||||
| 660 | " Try checking '\$conn->has_wheel' before calling disconnect()." ; | ||||||||||||||||||||||||||||||||||||
| 661 | return | ||||||||||||||||||||||||||||||||||||
| 662 | 0 | } | |||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | $self->wheels->{$w_id}->is_disconnecting($str // "Client disconnect"); | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$str // "Client disconnect"
MC/DC0%0/1
$str // "Client disconnect"
$str
Truth table0%0/2
A
A= $str
| |||||||||||||||||||||||||||||||||||||
| 665 | 0 | $self | |||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||
| 668 | sub disconnect_now { | ||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | my ($self, $w_id, $str) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect_now: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | $w_id = $w_id->wheel_id if blessed $w_id; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | confess "disconnect_now needs an (extant) wheel ID or Connect object" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 672 | unless defined $w_id; | ||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | unless (defined $self->wheels->{$w_id}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 675 | 0 | carp "Attempting to disconnect() unknown wheel '$w_id'\n", | |||||||||||||||||||||||||||||||||||
| 676 | " This warning may be spurious. Your wheel may have died of natural causes.\n", | ||||||||||||||||||||||||||||||||||||
| 677 | " Try checking '\$conn->has_wheel' before calling disconnect()." ; | ||||||||||||||||||||||||||||||||||||
| 678 | return | ||||||||||||||||||||||||||||||||||||
| 679 | 0 | } | |||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | $self->_disconnected($w_id, $str // "Client disconnect"); | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$str // "Client disconnect"
MC/DC0%0/1
$str // "Client disconnect"
$str
Truth table0%0/2
A
A= $str
| |||||||||||||||||||||||||||||||||||||
| 682 | 0 | $self | |||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||
| 685 | sub _disconnected { | ||||||||||||||||||||||||||||||||||||
| 686 | ## Wheel needs cleanup. | ||||||||||||||||||||||||||||||||||||
| 687 | 2 | ▶ | my ($self, $w_id, $str) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_disconnected: called CC=6 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||
| 688 | 2 | ▶ | return unless $w_id and $self->wheels->{$w_id}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$w_id and $self->wheels->{$w_id}
MC/DC0%0/2
$w_id and $self->wheels->{$w_id}
$w_id
$self->wheels->{$w_id}
Truth table33%1/3
A and B
A= $w_idB= $self->wheels->{$w_id}
| |||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||
| 690 | 2 | my $this_conn = delete $self->wheels->{$w_id}; | |||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||
| 692 | ## Idle timer cleanup | ||||||||||||||||||||||||||||||||||||
| 693 | 2 | ▶ | $poe_kernel->alarm_remove( $this_conn->alarm_id ) | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 694 | if $this_conn->has_alarm_id; | ||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||
| 696 | ## Already a dead Connect (wheel was cleared), nothing to do | ||||||||||||||||||||||||||||||||||||
| 697 | 2 | ▶ | return unless $this_conn->has_wheel; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||
| 699 | 2 | ▶ | if (RUNNING_IN_HELL) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 700 | 0 | $this_conn->wheel->shutdown_input; | |||||||||||||||||||||||||||||||||||
| 701 | 0 | $this_conn->wheel->shutdown_output; | |||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||
| 704 | 2 | $this_conn->clear_wheel; | |||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||
| 706 | 2 | $poe_kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 707 | ircsock_disconnect => $this_conn, $str | ||||||||||||||||||||||||||||||||||||
| 708 | ); | ||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||
| 710 | 2 | 1 | |||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||
| 713 | sub set_compressed_link { | ||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | my ($self, $w_id) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
set_compressed_link: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | confess "set_compressed_link() needs a wheel ID" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 716 | unless defined $w_id; | ||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | confess "Failed to load POE::Filter::Zlib::Stream" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 719 | unless $self->has_zlib_support; | ||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | unless ($self->wheels->{$w_id}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 722 | 0 | carp "set_compressed_link for nonexistant wheel '$w_id'"; | |||||||||||||||||||||||||||||||||||
| 723 | return | ||||||||||||||||||||||||||||||||||||
| 724 | 0 | } | |||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||
| 726 | 0 | $self->wheels->{$w_id}->is_pending_compress(1); | |||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||
| 728 | 0 | $self | |||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||
| 731 | sub set_compressed_link_now { | ||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | my ($self, $w_id) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
set_compressed_link_now: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | confess "set_compressed_link() needs a wheel ID" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 734 | unless defined $w_id; | ||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $this_conn = $self->wheels->{$w_id}; | |||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | unless (defined $this_conn) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 738 | 0 | carp "set_compressed_link_now for nonexistant wheel '$w_id'"; | |||||||||||||||||||||||||||||||||||
| 739 | return | ||||||||||||||||||||||||||||||||||||
| 740 | 0 | } | |||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | confess "Failed to load POE::Filter::Zlib::Stream" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 743 | unless $self->has_zlib_support; | ||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||
| 745 | 0 | $this_conn->wheel->get_input_filter->unshift( | |||||||||||||||||||||||||||||||||||
| 746 | POE::Filter::Zlib::Stream->new | ||||||||||||||||||||||||||||||||||||
| 747 | ); | ||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||
| 749 | 0 | $this_conn->is_pending_compress(0); | |||||||||||||||||||||||||||||||||||
| 750 | 0 | $this_conn->set_compressed(1); | |||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||
| 752 | 0 | $poe_kernel->post( $self->controller => | |||||||||||||||||||||||||||||||||||
| 753 | ircsock_compressed => $this_conn | ||||||||||||||||||||||||||||||||||||
| 754 | ); | ||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||
| 756 | 0 | $self | |||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||
| 759 | sub unset_compressed_link { | ||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | my ($self, $w_id) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
unset_compressed_link: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | confess "unset_compressed_link() needs a wheel ID" | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 762 | unless defined $w_id; | ||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||
| 764 | 0 | my $this_conn = $self->wheels->{$w_id}; | |||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | unless (defined $this_conn && $this_conn->compressed) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $this_conn and $this_conn->compressed
MC/DC0%0/2
defined $this_conn and $this_conn->compressed
defined $this_conn
$this_conn->compressed
Truth table0%0/3
A and B
A= defined $this_connB= $this_conn->compressed
| |||||||||||||||||||||||||||||||||||||
| 766 | 0 | carp | |||||||||||||||||||||||||||||||||||
| 767 | "unset_compressed_link on uncompressed or nonexistant wheel '$w_id'"; | ||||||||||||||||||||||||||||||||||||
| 768 | return | ||||||||||||||||||||||||||||||||||||
| 769 | 0 | } | |||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||
| 771 | 0 | $this_conn->wheel->get_input_filter->shift; | |||||||||||||||||||||||||||||||||||
| 772 | 0 | $this_conn->set_compressed(0); | |||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||
| 774 | 0 | $self | |||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||
| 777 | 1 | ▶ | no warnings 'void'; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 778 | 1 | ▶ | |||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 779 | qq[<CaptObviousman> pretend for a moment that I'm stuck with mysql\n], | ||||||||||||||||||||||||||||||||||||
| 780 | qq[<rnowak> ok, fetching my laughing hat and monocle\n], | ||||||||||||||||||||||||||||||||||||
| 781 | 1 | unless caller; 1; | |||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||
| 784 | =pod | ||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||
| 786 | =for Pod::Coverage has_\w+ RUNNING_IN_HELL get_unpacked_addr | ||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||
| 788 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||
| 790 | POEx::IRC::Backend - IRC client or server backend | ||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||
| 792 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||
| 794 | use POE; | ||||||||||||||||||||||||||||||||||||
| 795 | use POEx::IRC::Backend; | ||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||
| 797 | POE::Session->create( | ||||||||||||||||||||||||||||||||||||
| 798 | package_states => [ | ||||||||||||||||||||||||||||||||||||
| 799 | main => [ qw/ | ||||||||||||||||||||||||||||||||||||
| 800 | _start | ||||||||||||||||||||||||||||||||||||
| 801 | ircsock_registered | ||||||||||||||||||||||||||||||||||||
| 802 | ircsock_input | ||||||||||||||||||||||||||||||||||||
| 803 | / ], | ||||||||||||||||||||||||||||||||||||
| 804 | ], | ||||||||||||||||||||||||||||||||||||
| 805 | ); | ||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||
| 807 | sub _start { | ||||||||||||||||||||||||||||||||||||
| 808 | # Spawn a Backend and register as the controlling session: | ||||||||||||||||||||||||||||||||||||
| 809 | my $backend = POEx::IRC::Backend->spawn; | ||||||||||||||||||||||||||||||||||||
| 810 | $_[HEAP]->{backend} = $backend; | ||||||||||||||||||||||||||||||||||||
| 811 | $_[KERNEL]->post( $backend->session_id, 'register' ); | ||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||
| 814 | sub ircsock_registered { | ||||||||||||||||||||||||||||||||||||
| 815 | my $backend = $_[HEAP]->{backend}; | ||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||
| 817 | # Listen for incoming IRC traffic: | ||||||||||||||||||||||||||||||||||||
| 818 | $backend->create_listener( | ||||||||||||||||||||||||||||||||||||
| 819 | bindaddr => $addr, | ||||||||||||||||||||||||||||||||||||
| 820 | port => $port, | ||||||||||||||||||||||||||||||||||||
| 821 | ); | ||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||
| 823 | # Connect to a remote endpoint: | ||||||||||||||||||||||||||||||||||||
| 824 | $backend->create_connector( | ||||||||||||||||||||||||||||||||||||
| 825 | remoteaddr => $remote, | ||||||||||||||||||||||||||||||||||||
| 826 | remoteport => $remoteport, | ||||||||||||||||||||||||||||||||||||
| 827 | # Optional: | ||||||||||||||||||||||||||||||||||||
| 828 | bindaddr => $bindaddr, | ||||||||||||||||||||||||||||||||||||
| 829 | ipv6 => 1, | ||||||||||||||||||||||||||||||||||||
| 830 | ssl => 1, | ||||||||||||||||||||||||||||||||||||
| 831 | ); | ||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||
| 834 | # Handle and dispatch incoming IRC events: | ||||||||||||||||||||||||||||||||||||
| 835 | sub ircsock_input { | ||||||||||||||||||||||||||||||||||||
| 836 | # POEx::IRC::Backend::Connect obj: | ||||||||||||||||||||||||||||||||||||
| 837 | my $this_conn = $_[ARG0]; | ||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||
| 839 | # IRC::Message::Object obj: | ||||||||||||||||||||||||||||||||||||
| 840 | my $input_obj = $_[ARG1]; | ||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||
| 842 | my $cmd = $input_obj->command; | ||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||
| 844 | # ... dispatch, etc ... | ||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||
| 847 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||
| 849 | A L<POE> IRC socket handler that can be used (by client or server | ||||||||||||||||||||||||||||||||||||
| 850 | implementations) to speak the IRC protocol to endpoints via | ||||||||||||||||||||||||||||||||||||
| 851 | L<IRC::Message::Object> objects. | ||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||
| 853 | Inspired by L<POE::Component::Server::IRC::Backend> & L<POE::Component::IRC>. | ||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||
| 855 | This is a very low-level interface to IRC sockets; the goal is to provide all | ||||||||||||||||||||||||||||||||||||
| 856 | the necessary scaffolding to develop stateless or stateful IRC clients and | ||||||||||||||||||||||||||||||||||||
| 857 | daemons. See L<POEx::IRC::Client::Lite> for an experimental IRC client library | ||||||||||||||||||||||||||||||||||||
| 858 | using this backend (and the L</"SEE ALSO"> section of this documentation for | ||||||||||||||||||||||||||||||||||||
| 859 | related tools). | ||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||
| 861 | =head2 Attributes | ||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||
| 863 | =head3 controller | ||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||
| 865 | Retrieve the L<POE::Session> ID for the backend's registered controller. | ||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||
| 867 | Predicate: B<has_controller> | ||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||
| 869 | =head3 connectors | ||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||
| 871 | A HASH of active Connector objects, keyed on their wheel ID. | ||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||
| 873 | =head3 filter | ||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||
| 875 | A L<POE::Filter::Stackable> instance consisting of the current L</filter_irc> | ||||||||||||||||||||||||||||||||||||
| 876 | stacked with L</filter_line> (at the time the attribute is built). | ||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||
| 878 | =head3 filter_irc | ||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||
| 880 | A L<POE::Filter::IRCv3> instance with B<colonify> disabled, by default (this | ||||||||||||||||||||||||||||||||||||
| 881 | behavior changed in v0.27.2). | ||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||
| 883 | A server-side Backend may want a colonifying filter: | ||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||
| 885 | my $backend = POEx::IRC::Backend->new( | ||||||||||||||||||||||||||||||||||||
| 886 | filter_irc => POE::Filter::IRCv3->new(colonify => 1), | ||||||||||||||||||||||||||||||||||||
| 887 | ... | ||||||||||||||||||||||||||||||||||||
| 888 | ); | ||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||
| 890 | =head3 filter_line | ||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||
| 892 | A L<POE::Filter::Line> instance. | ||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||
| 894 | =head3 listeners | ||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||
| 896 | HASH of active Listener objects, keyed on their wheel ID. | ||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||
| 898 | =head3 session_id | ||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||
| 900 | Returns the backend's session ID. | ||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||
| 902 | =head3 ssl_context | ||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||
| 904 | Returns the L<Net::SSLeay> Context object, if we have one (or C<undef> if | ||||||||||||||||||||||||||||||||||||
| 905 | not); the context is set up by L</spawn> if C<ssl_opts> are specified. | ||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||
| 907 | =head3 wheels | ||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||
| 909 | HASH of actively connected wheels, keyed on their wheel ID. | ||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||
| 912 | =head2 Methods | ||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||
| 914 | =head3 spawn | ||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||
| 916 | my $backend = POEx::IRC::Backend->spawn( | ||||||||||||||||||||||||||||||||||||
| 917 | ## Optional, needed for SSL-ified server-side sockets | ||||||||||||||||||||||||||||||||||||
| 918 | ssl_opts => [ | ||||||||||||||||||||||||||||||||||||
| 919 | 'server.key', | ||||||||||||||||||||||||||||||||||||
| 920 | 'server.cert', | ||||||||||||||||||||||||||||||||||||
| 921 | ], | ||||||||||||||||||||||||||||||||||||
| 922 | ); | ||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||
| 924 | Creates the backend's L<POE::Session>. | ||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||
| 926 | The C<ssl_opts> ARRAY is passed directly to | ||||||||||||||||||||||||||||||||||||
| 927 | L<POE::Component::SSLify/SSLify_ContextCreate>, if present. As of C<v0.28.x>, | ||||||||||||||||||||||||||||||||||||
| 928 | each Backend gets its own L<Net::SSLeay> context object (rather than sharing | ||||||||||||||||||||||||||||||||||||
| 929 | the global context). See L<POE::Component::SSLify> & L<Net::SSLeay>. | ||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||
| 931 | =head3 create_connector | ||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||
| 933 | $backend->create_connector( | ||||||||||||||||||||||||||||||||||||
| 934 | remoteaddr => $addr, | ||||||||||||||||||||||||||||||||||||
| 935 | remoteport => $addr, | ||||||||||||||||||||||||||||||||||||
| 936 | ## Optional: | ||||||||||||||||||||||||||||||||||||
| 937 | bindaddr => $local_addr, | ||||||||||||||||||||||||||||||||||||
| 938 | ipv6 => 1, | ||||||||||||||||||||||||||||||||||||
| 939 | ssl => 1, | ||||||||||||||||||||||||||||||||||||
| 940 | ## Unrecognized opts are stored in the Connector's 'args' hash: | ||||||||||||||||||||||||||||||||||||
| 941 | tag => 'foo', | ||||||||||||||||||||||||||||||||||||
| 942 | ); | ||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||
| 944 | Attempts to create a L<POEx::IRC::Backend::Connector> that | ||||||||||||||||||||||||||||||||||||
| 945 | holds a L<POE::Wheel::SocketFactory> connector wheel; connectors will | ||||||||||||||||||||||||||||||||||||
| 946 | attempt to establish an outgoing connection immediately. | ||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||
| 948 | Unrecognized options are stored in the L<POEx::IRC::Backend::Connector>'s | ||||||||||||||||||||||||||||||||||||
| 949 | C<args> HASH-type attribute; this is passed to successfully created | ||||||||||||||||||||||||||||||||||||
| 950 | L<POEx::IRC::Backend::Connect> instances (as of C<v0.26.x>). Note that the | ||||||||||||||||||||||||||||||||||||
| 951 | reference is shared, not copied. | ||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||
| 953 | =head3 create_listener | ||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||
| 955 | $backend->create_listener( | ||||||||||||||||||||||||||||||||||||
| 956 | bindaddr => $addr, | ||||||||||||||||||||||||||||||||||||
| 957 | port => $port, | ||||||||||||||||||||||||||||||||||||
| 958 | ## Optional: | ||||||||||||||||||||||||||||||||||||
| 959 | ipv6 => 1, | ||||||||||||||||||||||||||||||||||||
| 960 | ssl => 1, | ||||||||||||||||||||||||||||||||||||
| 961 | idle => $seconds, | ||||||||||||||||||||||||||||||||||||
| 962 | ); | ||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||
| 964 | Attempts to create a L<POEx::IRC::Backend::Listener> | ||||||||||||||||||||||||||||||||||||
| 965 | that holds a L<POE::Wheel::SocketFactory> listener wheel. | ||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||
| 967 | Unrecognized arguments will be added to the Listener object's C<args> | ||||||||||||||||||||||||||||||||||||
| 968 | attribute, which is then passed on to L<POEx::IRC::Backend::Connect> objects | ||||||||||||||||||||||||||||||||||||
| 969 | created by incoming connections to that listener, similar to the behavior | ||||||||||||||||||||||||||||||||||||
| 970 | described in L</create_connector> (as of C<v0.28.x>). | ||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||
| 972 | =head3 remove_listener | ||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||
| 974 | $backend->remove_listener( | ||||||||||||||||||||||||||||||||||||
| 975 | listener => $listener_id, | ||||||||||||||||||||||||||||||||||||
| 976 | ); | ||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||
| 978 | ## or via addr, port, or combination thereof: | ||||||||||||||||||||||||||||||||||||
| 979 | $backend->remove_listener( | ||||||||||||||||||||||||||||||||||||
| 980 | addr => '127.0.0.1', | ||||||||||||||||||||||||||||||||||||
| 981 | port => 6667, | ||||||||||||||||||||||||||||||||||||
| 982 | ); | ||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||
| 984 | Removes a listener and clears its B<wheel> attribute; the socket shuts down | ||||||||||||||||||||||||||||||||||||
| 985 | when the L<POE::Wheel::SocketFactory> wheel goes out of scope. | ||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||
| 987 | =head3 disconnect | ||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||
| 989 | $backend->disconnect($wheel_id, $disconnect_string); | ||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||
| 991 | Given a L<POEx::IRC::Backend::Connect> or its C<wheel_id>, mark the specified | ||||||||||||||||||||||||||||||||||||
| 992 | wheel for disconnection. | ||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||
| 994 | This method will warn if the given C<wheel_id> cannot be found, which may be | ||||||||||||||||||||||||||||||||||||
| 995 | due to the connection disappearing prior to calling C<disconnect>. | ||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||
| 997 | You can avoid spurious warnings by checking if the | ||||||||||||||||||||||||||||||||||||
| 998 | L<POEx::IRC::Backend::Connect> still has an active wheel attached: | ||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||
| 1000 | if ($this_conn->has_wheel) { | ||||||||||||||||||||||||||||||||||||
| 1001 | $backend->disconnect( $this_conn ) | ||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||
| 1004 | Note that disconnection typically happens after a buffer flush; if your | ||||||||||||||||||||||||||||||||||||
| 1005 | software does not perform entirely like a traditional platform (server | ||||||||||||||||||||||||||||||||||||
| 1006 | implementations will typically send C<< ERROR: Closing Link >> or similar to | ||||||||||||||||||||||||||||||||||||
| 1007 | clients marked for disconnection, which will trigger a buffer flush) you may | ||||||||||||||||||||||||||||||||||||
| 1008 | currently experience "late" disconnects. See L</disconnect_now>. | ||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||
| 1010 | =head3 disconnect_now | ||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||
| 1012 | Like L</disconnect>, but attempt to destroy the wheel immediately (without | ||||||||||||||||||||||||||||||||||||
| 1013 | waiting for a buffer flush). | ||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||
| 1015 | =head3 send | ||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||
| 1017 | $backend->send( | ||||||||||||||||||||||||||||||||||||
| 1018 | { | ||||||||||||||||||||||||||||||||||||
| 1019 | prefix => $prefix, | ||||||||||||||||||||||||||||||||||||
| 1020 | params => [ @params ], | ||||||||||||||||||||||||||||||||||||
| 1021 | command => $cmd, | ||||||||||||||||||||||||||||||||||||
| 1022 | }, | ||||||||||||||||||||||||||||||||||||
| 1023 | @connect_ids | ||||||||||||||||||||||||||||||||||||
| 1024 | ); | ||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||
| 1026 | use IRC::Message::Object 'ircmsg'; | ||||||||||||||||||||||||||||||||||||
| 1027 | my $msg = ircmsg( | ||||||||||||||||||||||||||||||||||||
| 1028 | command => 'PRIVMSG', | ||||||||||||||||||||||||||||||||||||
| 1029 | params => [ $chan, $string ], | ||||||||||||||||||||||||||||||||||||
| 1030 | ); | ||||||||||||||||||||||||||||||||||||
| 1031 | $backend->send( $msg, $connect_obj ); | ||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||
| 1033 | Feeds L<POE::Filter::IRCv3> and sends the resultant raw IRC | ||||||||||||||||||||||||||||||||||||
| 1034 | line to the specified connection wheel ID(s) or L<POEx::IRC::Backend::Connect> | ||||||||||||||||||||||||||||||||||||
| 1035 | object(s). | ||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||
| 1037 | Accepts either an L<IRC::Message::Object> or a HASH compatible with | ||||||||||||||||||||||||||||||||||||
| 1038 | L<POE::Filter::IRCv3> -- look there for details. | ||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||
| 1040 | Note that unroutable (target connection IDs with no matching live | ||||||||||||||||||||||||||||||||||||
| 1041 | wheel) messages are silently dropped. You can check L</wheels> yourself before | ||||||||||||||||||||||||||||||||||||
| 1042 | sending if this behavior is unwanted: | ||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||
| 1044 | for my $target (@connect_ids) { | ||||||||||||||||||||||||||||||||||||
| 1045 | unless (exists $backend->wheels->{$target}) { | ||||||||||||||||||||||||||||||||||||
| 1046 | warn "Cannot send to nonexistant target '$target'"; | ||||||||||||||||||||||||||||||||||||
| 1047 | next | ||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||
| 1049 | $backend->send( | ||||||||||||||||||||||||||||||||||||
| 1050 | { prefix => $prefix, params => [ @params ], command => $cmd }, | ||||||||||||||||||||||||||||||||||||
| 1051 | $target | ||||||||||||||||||||||||||||||||||||
| 1052 | ); | ||||||||||||||||||||||||||||||||||||
| 1053 | } | ||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||
| 1055 | =head3 has_ssl_support | ||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||
| 1057 | Returns true if L<POE::Component::SSLify> was successfully loaded. | ||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||
| 1059 | =head3 has_zlib_support | ||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||
| 1061 | Returns true if L<POE::Filter::Zlib::Stream> was successfully loaded. | ||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||
| 1063 | =head3 set_compressed_link | ||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||
| 1065 | $backend->set_compressed_link( $conn_id ); | ||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||
| 1067 | Mark a specified connection wheel ID as pending compression; | ||||||||||||||||||||||||||||||||||||
| 1068 | L<POE::Filter::Zlib::Stream> will be added to the filter stack when the | ||||||||||||||||||||||||||||||||||||
| 1069 | next flush event arrives. | ||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||
| 1071 | This method will die unless L</has_zlib_support> is true. | ||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||
| 1073 | =head3 set_compressed_link_now | ||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||
| 1075 | $backend->set_compressed_link_now( $conn_id ); | ||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||
| 1077 | Add a L<POE::Filter::Zlib::Stream> to the connection's filter stack | ||||||||||||||||||||||||||||||||||||
| 1078 | immediately, rather than upon next flush event. | ||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||
| 1080 | This method will die unless L</has_zlib_support> is true. | ||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||
| 1082 | =head3 unset_compressed_link | ||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||
| 1084 | $backend->unset_compressed_link( $conn_id ); | ||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||
| 1086 | Remove L<POE::Filter::Zlib::Stream> from the connection's filter stack. | ||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||
| 1089 | =head2 Received events | ||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||
| 1091 | =head3 register | ||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||
| 1093 | $poe_kernel->post( $backend->session_id, | ||||||||||||||||||||||||||||||||||||
| 1094 | 'register' | ||||||||||||||||||||||||||||||||||||
| 1095 | ); | ||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||
| 1097 | Register the sender session as the backend's controller session. The last | ||||||||||||||||||||||||||||||||||||
| 1098 | session to send 'register' is the session that receives notification | ||||||||||||||||||||||||||||||||||||
| 1099 | events from the backend component. | ||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||
| 1101 | =head3 create_connector | ||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||
| 1103 | Event interface to I<create_connector> -- see L</Methods> | ||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||
| 1105 | =head3 create_listener | ||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||
| 1107 | Event interface to I<create_listener> -- see L</Methods> | ||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||
| 1109 | =head3 remove_listener | ||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||
| 1111 | Event interface to I<remove_listener> -- see L</Methods> | ||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||
| 1113 | =head3 send | ||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||
| 1115 | Event interface to I</send> -- see L</Methods> | ||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||
| 1117 | =head3 shutdown | ||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||
| 1119 | Disconnect all wheels and clean up. | ||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||
| 1122 | =head2 Dispatched events | ||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||
| 1124 | These events are dispatched to the controller session; see L</register>. | ||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||
| 1126 | =head3 ircsock_compressed | ||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||
| 1128 | Dispatched when a connection wheel has had a compression filter added. | ||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||
| 1130 | C<$_[ARG0]> is the connection's L<POEx::IRC::Backend::Connect>. | ||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||
| 1132 | =head3 ircsock_connection_idle | ||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||
| 1134 | Dispatched when a connection wheel has had no input for longer than | ||||||||||||||||||||||||||||||||||||
| 1135 | specified idle time (see L</create_listener> regarding idle times). | ||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||
| 1137 | Currently these events are only issued for incoming Connects accepted on a | ||||||||||||||||||||||||||||||||||||
| 1138 | Listener, not outgoing Connects created by a Connector; if you need to do | ||||||||||||||||||||||||||||||||||||
| 1139 | ping/pong-style heartbeating on an outgoing Connector-spawned socket, you will | ||||||||||||||||||||||||||||||||||||
| 1140 | need to run your own timer. | ||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||
| 1142 | C<$_[ARG0]> is the connection's L<POEx::IRC::Backend::Connect>. | ||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||
| 1144 | See also: L<POEx::IRC::Backend::Connect/ping_pending> | ||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||
| 1146 | =head3 ircsock_connector_failure | ||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||
| 1148 | Dispatched when a Connector has failed due to some sort of socket error. | ||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||
| 1150 | C<$_[ARG0]> is the connection's | ||||||||||||||||||||||||||||||||||||
| 1151 | L<POEx::IRC::Backend::Connector> with wheel() cleared. | ||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||
| 1153 | C<@_[ARG1 .. ARG3]> contain the socket error details reported by | ||||||||||||||||||||||||||||||||||||
| 1154 | L<POE::Wheel::SocketFactory>; operation, errno, and errstr, respectively. | ||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||
| 1156 | =head3 ircsock_connector_open | ||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||
| 1158 | Dispatched when a Connector has established a connection to a peer. | ||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||
| 1160 | C<$_[ARG0]> is the L<POEx::IRC::Backend::Connect> for the | ||||||||||||||||||||||||||||||||||||
| 1161 | connection. | ||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||
| 1163 | =head3 ircsock_disconnect | ||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||
| 1165 | Dispatched when a connection wheel has been cleared. | ||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||
| 1167 | C<$_[ARG0]> is the connection's L<POEx::IRC::Backend::Connect> | ||||||||||||||||||||||||||||||||||||
| 1168 | with wheel() cleared. | ||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||
| 1170 | =head3 ircsock_input | ||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||
| 1172 | Dispatched when there is some IRC input from a connection wheel. | ||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||
| 1174 | C<$_[ARG0]> is the connection's | ||||||||||||||||||||||||||||||||||||
| 1175 | L<POEx::IRC::Backend::Connect>. | ||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||
| 1177 | C<$_[ARG1]> is an L<IRC::Message::Object>. | ||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||
| 1179 | =head3 ircsock_listener_created | ||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||
| 1181 | Dispatched when a L<POEx::IRC::Backend::Listener> has been | ||||||||||||||||||||||||||||||||||||
| 1182 | created. | ||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||
| 1184 | C<$_[ARG0]> is the L<POEx::IRC::Backend::Listener> instance; | ||||||||||||||||||||||||||||||||||||
| 1185 | the instance's port() is altered based on getsockname() details after | ||||||||||||||||||||||||||||||||||||
| 1186 | socket creation and before dispatching this event. | ||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||
| 1188 | =head3 ircsock_listener_failure | ||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||
| 1190 | Dispatched when a Listener has failed due to some sort of socket error. | ||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||
| 1192 | C<$_[ARG0]> is the L<POEx::IRC::Backend::Listener> object. | ||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||
| 1194 | C<@_[ARG1 .. ARG3]> contain the socket error details reported by | ||||||||||||||||||||||||||||||||||||
| 1195 | L<POE::Wheel::SocketFactory>; operation, errno, and errstr, respectively. | ||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||
| 1197 | =head3 ircsock_listener_open | ||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||
| 1199 | Dispatched when a listener accepts a connection. | ||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||
| 1201 | C<$_[ARG0]> is the connection's L<POEx::IRC::Backend::Connect> | ||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||
| 1203 | C<$_[ARG1]> is the connection's L<POEx::IRC::Backend::Listener> | ||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||
| 1205 | =head3 ircsock_listener_removed | ||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||
| 1207 | Dispatched when a Listener has been removed. | ||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||
| 1209 | C<$_[ARG0]> is the L<POEx::IRC::Backend::Listener> object. | ||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||
| 1211 | =head3 ircsock_registered | ||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||
| 1213 | Dispatched when a L</register> event has been successfully received, as a | ||||||||||||||||||||||||||||||||||||
| 1214 | means of acknowledging the controlling session. | ||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||
| 1216 | C<$_[ARG0]> is the Backend's C<$self> object. | ||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||
| 1218 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||
| 1220 | Probably lots. Please report them via RT, e-mail, IRC | ||||||||||||||||||||||||||||||||||||
| 1221 | (C<irc.cobaltirc.org#perl>), or GitHub | ||||||||||||||||||||||||||||||||||||
| 1222 | (L<http://github.com/avenj/poex-irc-backend>). | ||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||
| 1224 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||
| 1226 | L<POEx::IRC::Backend::Connect> | ||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||
| 1228 | L<POEx::IRC::Backend::Connector> | ||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||
| 1230 | L<POEx::IRC::Backend::Listener> | ||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||
| 1232 | L<POEx::IRC::Backend::Role::Socket> | ||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||
| 1234 | L<POEx::IRC::Backend::Role::HasEndpoint> | ||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||
| 1236 | L<POEx::IRC::Backend::Role::HasWheel> | ||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||
| 1238 | L<POEx::IRC::Client::Lite> for an experimental IRC client library using this | ||||||||||||||||||||||||||||||||||||
| 1239 | backend. | ||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||
| 1241 | L<https://github.com/miniCruzer/irssi-bouncer> for an irssi-based | ||||||||||||||||||||||||||||||||||||
| 1242 | bouncer/proxy system using this backend. | ||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||
| 1244 | L<POE::Filter::IRCv3> and L<IRC::Message::Object> for documentation regarding | ||||||||||||||||||||||||||||||||||||
| 1245 | IRC message parsing. | ||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||
| 1247 | L<IRC::Toolkit> for an extensive set of IRC-related utilities. | ||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||
| 1249 | L<POE::Component::IRC> if you're looking for a mature, fully-featured IRC | ||||||||||||||||||||||||||||||||||||
| 1250 | client library. | ||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||
| 1252 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||
| 1254 | Jon Portnoy <avenj@cobaltirc.org> | ||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||
| 1256 | Inspiration derived from L<POE::Component::Server::IRC::Backend> and | ||||||||||||||||||||||||||||||||||||
| 1257 | L<POE::Component::IRC> by BINGOS, HINRIK et al. | ||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||
| 1259 | =cut | ||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||