POE::Component::IRC::Plugin::Proxy - A lightweight IRC proxy/bouncer for the POE::Component::IRC manpage.
use strict; use warnings; use POE qw(Component::IRC Component::IRC::Plugin::Proxy Component::IRC::Connector);
my ($irc) = POE::Component::IRC->spawn();
POE::Session->create( package_states => [ 'main' => [ qw(_start) ], ], heap => { irc => $irc }, );
$poe_kernel->run(); exit 0;
sub _start { my ($kernel,$heap) = @_[KERNEL,HEAP]; $heap->{irc}->yield( register => 'all' ); $heap->{proxy} = POE::Component::IRC::Plugin::Proxy->new( bindport => 6969, password => "m00m00" ); $heap->{irc}->plugin_add( 'Connector' => POE::Component::IRC::Connector->new() ); $heap->{irc}->plugin_add( 'Proxy' => $heap->{proxy} ); $heap->{irc}->yield ( connect => { Nick => 'testbot', Server => 'someserver.com' } ); undef; }
POE::Component::IRC::Plugin::Proxy is a the POE::Component::IRC manpage plugin that provides lightweight IRC proxy/bouncer server to your the POE::Component::IRC manpage bots. It enables multiple IRC clients to be hidden behind a single IRC client-server connection.
Spawn a the POE::Component::IRC manpage session and add in a POE::Component::IRC::Plugin::Proxy plugin object, specifying a bindport and a password the connecting IRC clients have to use. When the component is connected to an IRC network a listening port is opened by the plugin for multiple IRC clients to connect.
Neat, huh? >;o)
Takes a number of arguments:
'password', the password to require from connecting clients; 'bindaddr', a local address to bind the listener to, default is 'localhost'; 'bindport', what port to bind to, default is 0, ie. randomly allocated by OS;
Returns an object suitable for passing to the POE::Component::IRC manpage's plugin_add()
method.
Takes no arguments, returns a list of the channels that the component is currently a member of.
Takes no arguments. Accesses the listeners getsockname()
method. See the POE::Wheel::SocketFactory manpage for details of the return value;
Takes no arguments. Returns a list of wheel ids of the current connected clients.
Takes one parameter, a wheel ID to query. Returns undef if an invalid wheel id is passed. In a scalar context returns the time that the client connected in unix time. In a list context returns a list consisting of the peer address, port, tthe connect time and the lag in seconds for that connection.
The plugin emits the following the POE::Component::IRC manpage events:
Emitted when the listener is successfully started. ARG0 is the result of the listener getsockname().
Emitted when a client connects to the listener. ARG0 is the wheel ID of the client.
Emitted when the Wheel::ReadWrite fails on a connection. ARG0 is the wheel ID of the client.
Emitted when a connecting client successfully negotiates an IRC session with the plugin. ARG0 is the wheel ID of the client.
Emitted when a connected client disconnects. ARG0 is the wheel ID of the client.
Emitted when the listener is successfully shutdown. ARG0 is the result of the listener getsockname().
Connecting IRC clients will not be able to change nickname. This is a feature.
Chris 'BinGOs' Williams