| POE-Component-Server-IRC documentation | view source | Contained in the POE-Component-Server-IRC distribution. |
configureadd_authdel_authadd_operatordel_operatoradd_peerdel_peerstate_nicksstate_chansstate_peersstate_nick_existsstate_chan_existsstate_peer_existsstate_user_fullstate_user_nickstate_user_umodestate_user_is_operatorstate_user_chansstate_user_serverstate_chan_liststate_chan_list_prefixedstate_chan_topicstate_chan_mode_setstate_is_chan_memberstate_user_chan_modestate_is_chan_opstate_is_chan_hopstate_has_chan_voiceadd_spoofed_nickdel_spoofed_nickircd_daemon_errorircd_daemon_serverircd_daemon_squitircd_daemon_nickircd_daemon_umodeircd_daemon_quitircd_daemon_joinircd_daemon_partircd_daemon_kickircd_daemon_modeircd_daemon_topicircd_daemon_publicircd_daemon_privmsgircd_daemon_noticeircd_daemon_inviteircd_daemon_rehashircd_daemon_dieircd_daemon_glineircd_daemon_klineircd_daemon_rklineircd_daemon_unklineircd_daemon_locopsircd_daemon_operwallircd_daemon_wallopsPOE::Component::Server::IRC - A fully event-driven networkable IRC server daemon module.
# A fairly simple example:
use strict;
use warnings;
use POE qw(Component::Server::IRC);
my %config = (
servername => 'simple.poco.server.irc',
nicklen => 15,
network => 'SimpleNET'
);
my $pocosi = POE::Component::Server::IRC->spawn( config => \%config );
POE::Session->create(
package_states => [
'main' => [qw(_start _default)],
],
heap => { ircd => $pocosi },
);
$poe_kernel->run();
sub _start {
my ($kernel, $heap) = @_[KERNEL, HEAP];
$heap->{ircd}->yield('register', 'all');
# Anyone connecting from the loopback gets spoofed hostname
$heap->{ircd}->add_auth(
mask => '*@localhost',
spoof => 'm33p.com',
no_tilde => 1,
);
# We have to add an auth as we have specified one above.
$heap->{ircd}->add_auth(mask => '*@*');
# Start a listener on the 'standard' IRC port.
$heap->{ircd}->add_listener(port => 6667);
# Add an operator who can connect from localhost
$heap->{ircd}->add_operator(
{
username => 'moo',
password => 'fishdont',
}
);
}
sub _default {
my ($event, $args) = @_[ARG0 .. $#_];
print "$event: ";
for my $arg (@$args) {
if (ref($arg) eq 'ARRAY') {
print "[", join ( ", ", @$arg ), "] ";
}
elsif (ref($arg) eq 'HASH') {
print "{", join ( ", ", %$arg ), "} ";
}
else {
print "'$arg' ";
}
print "\n";
}
POE::Component::Server::IRC is a POE component which implements an IRC server (also referred to as an IRC daemon or IRCd). It should be compliant with the pertient IRC RFCs and is based on reverse engineering Hybrid IRCd behaviour with regards to interactions with IRC clients and other IRC servers.
Yes, that's right. POE::Component::Server::IRC is capable of linking to foreign IRC networks. It supports the TS5 server to server protocol and has been tested with linking to Hybrid-7 based networks. It should in theory work with any TS5-based IRC network.
POE::Component::Server::IRC also has a services API, which enables one to extend the IRCd to create IRC Services. This is fully event-driven (of course =]). There is also a Plugin system, similar to that sported by POE::Component::IRC.
Note: This is a subclass of POE::Component::Server::IRC::Backend (POE::Component::IRC::Server::Backend). You should read its documentation too.
spawnReturns a new instance of the component. Takes the following parameters:
configure|/configure method for details.Any other parameters will be passed along to
POE::Component::Server::IRC::Backend's
create|POE::Component::Server::IRC::Backend/create method.
If the component is spawned from within another session then that session
will automagically be registered with the component to receive events and
be sent an ircd_registered|POE::Component::IRC::Server::Backend/ircd_registered
event.
server_nameNo arguments, returns the name of the ircd.
server_versionNo arguments, returns the software version of the ircd.
server_createdNo arguments, returns a string signifying when the ircd was created.
server_configTakes one argument, the server configuration value to query.
These methods provide mechanisms for configuring and controlling the IRCd component.
configureConfigures your new shiny IRCd.
Takes a number of parameters:
add_authBy default the IRCd allows any user to connect to the server without a password. Configuring auths enables you to control who can connect and set passwords required to connect.
Takes the following parameters:
Auth masks are processed in order of addition.
If auth masks have been defined, then a connecting user *must* match one of the masks in order to be authorised to connect. This is a feature >;)
del_authTakes a single argument, the mask to remove.
add_operatorThis adds an O line to the IRCd. Takes a number of parameters:
A scalar ipmask can contain '*' to match any number of characters or '?' to match one character. If no 'ipmask' is provided, operators are only allowed to OPER from the loopback interface.
'password' can be either plain-text, crypt|crypt'd or unix/apache
md5. See the mkpasswd function in
POE::Component::Server::IRC::Common
for how to generate passwords.
del_operatorTakes a single argument, the username to remove.
add_peerAdds peer servers that we will allow to connect to us and who we will connect to. Takes the following parameters:
del_peerTakes a single argument, the peer to remove. This does not disconnect the said peer if it is currently connected.
The following methods allow you to query state information regarding nicknames, channels, and peers.
state_nicksTakes no arguments, returns a list of all nicknames in the state.
state_chansTakes no arguments, returns a list of all channels in the state.
state_peersTakes no arguments, returns a list of all irc servers in the state.
state_nick_existsTakes one argument, a nickname, returns true or false dependent on whether the given nickname exists or not.
state_chan_existsTakes one argument, a channel name, returns true or false dependent on whether the given channel exists or not.
state_peer_existsTakes one argument, a peer server name, returns true or false dependent on whether the given peer exists or not.
state_user_fullTakes one argument, a nickname, returns that users full nick!user@host if they exist, undef if they don't.
state_user_nickTakes one argument, a nickname, returns the proper nickname for that user. Returns undef if the nick doesn't exist.
state_user_umodeTakes one argument, a nickname, returns that users mode setting.
state_user_is_operatorTakes one argument, a nickname, returns true or false dependent on whether the given nickname is an IRC operator or not.
state_user_chansTakes one argument, a nickname, returns a list of channels that that nick is a member of.
state_user_serverTakes one argument, a nickname, returns the name of the peer server that that user is connected from.
state_chan_listTakes one argument, a channel name, returns a list of the member nicks on that channel.
state_chan_list_prefixedTakes one argument, a channel name, returns a list of the member nicks on that channel, nicknames will be prefixed with @%+ if they are +o +h or +v, respectively.
state_chan_topicTakes one argument, a channel name, returns undef if no topic is set on that channel, or an arrayref consisting of the topic, who set it and the time they set it.
state_chan_mode_setTakes two arguments, a channel name and a channel mode character. Returns true if that channel mode is set, false otherwise.
state_is_chan_memberTakes two arguments, a nick and a channel name. Returns true if that nick is on channel, false otherwise.
state_user_chan_modeTakes two arguments, a nick and a channel name. Returns that nicks status (+ohv or '') on that channel.
state_is_chan_opTakes two arguments, a nick and a channel name. Returns true if that nick is an channel operator, false otherwise.
state_is_chan_hopTakes two arguments, a nick and a channel name. Returns true if that nick is an channel half-operator, false otherwise.
state_has_chan_voiceTakes two arguments, a nick and a channel name. Returns true if that nick has channel voice, false otherwise.
daemon_server_killTakes two arguments, a nickname and a comment (which is optional); Issues a SERVER KILL of the given nick;
daemon_server_modeFirst argument is a channel name, remaining arguments are channel modes and their parameters to apply.
daemon_server_kickTakes two arguments that are mandatory and an optional one: channel name, nickname of the user to kick and a pithy comment.
daemon_server_removeTakes two arguments that are mandatory and an optional one: channel name, nickname of the user to remove and a pithy comment.
daemon_server_wallopsTakes one argument, the message text to send.
These are POE events that can be sent to the component.
add_spoofed_nickTakes a single argument a hashref which should have the following keys:
Note: spoofed nicks are currently only really functional for use as IRC services.
del_spoofed_nickTakes a single mandatory argument, the spoofed nickname to remove. Optionally, you may specify a quit message for the spoofed nick.
The following input events are for the benefit of spoofed nicks. All require a nickname of a spoofed nick as the first argument.
daemon_cmd_joinTakes two arguments, a spoofed nick and a channel name to join.
daemon_cmd_partTakes two arguments, a spoofed nick and a channel name to part from.
daemon_cmd_modeTakes at least three arguments, a spoofed nick, a channel and a channel mode to apply. Additional arguments are parameters for the channel modes.
daemon_cmd_kickTakes at least three arguments, a spoofed nick, a channel name and the nickname of a user to kick from that channel. You may supply a fourth argument which will be the kick comment.
daemon_cmd_topicTakes three arguments, a spoofed nick, a channel name and the topic to set on that channel. If the third argument is an empty string then the channel topic will be unset.
daemon_cmd_nickTakes two arguments, a spoofed nick and a new nickname to change to.
daemon_cmd_glineTakes three arguments, a spoofed nick, a user@host mask to gline and a reason for the gline.
daemon_cmd_klineTakes a number of arguments depending on where the KLINE is to be applied and for how long:
To set a permanent KLINE:
$ircd->yield(
'daemon_cmd_kline',
$spoofed_nick,
$nick || $user_host_mask,
$reason,
);
To set a temporary 10 minute KLINE:
$ircd->yield(
'daemon_cmd_kline',
$spoofed_nick,
10,
$nick || $user_host_mask,
$reason,
);
To set a temporary 10 minute KLINE on all servers:
$ircd->yield(
'daemon_cmd_kline',
$spoofed_nick,
10,
$nick || $user_host_mask,
'on',
'*',
$reason,
);
daemon_cmd_unklineRemoves a KLINE as indicated by the user@host mask supplied.
To remove a KLINE:
$ircd->yield(
'daemon_cmd_unkline',
$spoofed_nick,
$user_host_mask,
);
To remove a KLINE from all servers:
$ircd->yield(
'daemon_cmd_unkline',
$spoofed_nick,
$user_host_mask,
'on',
'*',
);
daemon_cmd_rklineUsed to set a regex based KLINE. The regex given must be based on a user@host mask.
To set a permanent RKLINE:
$ircd->yield(
'daemon_cmd_rkline',
$spoofed_nick,
'^.*$@^(yahoo|google|microsoft)\.com$',
$reason,
);
To set a temporary 10 minute RKLINE:
$ircd->yield(
'daemon_cmd_rkline',
$spoofed_nick,
10,
'^.*$@^(yahoo|google|microsoft)\.com$',
$reason,
);
To set a temporary 10 minute RKLINE on all servers:
$ircd->yield(
'daemon_cmd_kline',
$spoofed_nick,
10,
'^.*$@^(yahoo|google|microsoft)\.com$',
'on',
'*',
$reason,
);
daemon_cmd_sjoinTakes two arguments a spoofed nickname and an existing channel name. This command will then manipulate the channel timestamp to clear all modes on that channel, including existing channel operators, reset the channel mode to '+nt', the spoofed nick will then join the channel and gain channel ops.
daemon_cmd_privmsgTakes three arguments, a spoofed nickname, a target (which can be a nickname or a channel name) and whatever text you wish to send.
daemon_cmd_noticeTakes three arguments, a spoofed nickname, a target (which can be a nickname or a channel name) and whatever text you wish to send.
daemon_cmd_locopsTakes two arguments, a spoofed nickname and the text message to send to local operators.
daemon_cmd_wallopsTakes two arguments, a spoofed nickname and the text message to send to all operators.
daemon_cmd_operwallTakes two arguments, a spoofed nickname and the text message to send to all operators.
ircd_daemon_error
ARG0, the connection id;ARG1, the server name;ARG2, the reason;ircd_daemon_server
ARG0, the server name;ARG1, the name of the server that is introducing them;ARG2, the hop count;ARG3, the server description;ircd_daemon_squit
ARG0, the server name;ircd_daemon_nick
ARG0, the nickname;ARG1, the hop count;ARG2, the time stamp (TS);ARG3, the user mode;ARG4, the ident;ARG5, the hostname;ARG6, the server name;ARG7, the real name;
ARG0, the full nick!user@host;ARG1, the new nickname;ircd_daemon_umode
ARG0, the full nick!user@host;ARG1, the user mode change;ircd_daemon_quit
ARG0, the full nick!user@host;ARG1, the quit message;ircd_daemon_join
ARG0, the full nick!user@host;ARG1, the channel name;ircd_daemon_part
ARG0, the full nick!user@host;ARG1, the channel name;ARG2, the part message;ircd_daemon_kick
ARG0, the full nick!user@host of the kicker;ARG1, the channel name;ARG2, the nick of the kicked user;ARG3, the kick message;ircd_daemon_mode
ARG0, the full nick!user@host or server name;ARG1, the channel name;ARG2..$#_, the modes and their arguments;ircd_daemon_topic
ARG0, the full nick!user@host of the changer;ARG1, the channel name;ARG2, the new topic;ircd_daemon_public
ARG0, the full nick!user@host of the sender;ARG1, the channel name;ARG2, the message;ircd_daemon_privmsg
ARG0, the full nick!user@host of the sender;ARG1, the spoofed nick targeted;ARG2, the message;ircd_daemon_notice
ARG0, the full nick!user@host of the sender;ARG1, the spoofed nick targeted or channel spoofed nick is in;ARG2, the message;ircd_daemon_invite
ARG0, the full nick!user@host of the inviter;ARG1, the spoofed nick being invited;ARG2, the channel being invited to;ircd_daemon_rehash
ARG0, the full nick!user@host of the oper;ircd_daemon_die
ARG0, the full nick!user@host of the oper;Note: the component will shutdown, this is a feature;
ircd_daemon_gline
ARG0, the full nick!user@host;ARG1, the user mask;ARG2, the host mask;ARG3, the reason;ircd_daemon_kline
ARG0, the full nick!user@host;ARG1, the target for the KLINE;ARG2, the duration in seconds;ARG3, the user mask;ARG4, the host mask;ARG5, the reason;ircd_daemon_rkline
ARG0, the full nick!user@host;ARG1, the target for the RKLINE;ARG2, the duration in seconds;ARG3, the user mask;ARG4, the host mask;ARG5, the reason;ircd_daemon_unkline
ARG0, the full nick!user@host;ARG1, the target for the UNKLINE;ARG2, the user mask;ARG3, the host mask;ircd_daemon_locops
ARG0, the full nick!user@host;ARG1, the locops message;ircd_daemon_operwall
ARG0, the full nick!user@host;ARG1, the wallops or operwall message;ircd_daemon_wallops
ARG0, the server name;ARG1, the wallops message;A few have turned up in the past and they are sure to again. Please use http://rt.cpan.org/ to report any. Alternatively, email the current maintainer.
You can find the latest source on github: http://github.com/bingos/poe-component-server-irc
The project's developers usually hang out in the #poe IRC channel on
irc.perl.org. Do drop us a line.
Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Chris 'BinGOs' Williams
Copyright (c) Chris Williams
This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details.
Rocco Caputo for creating POE.
Buu for pestering me when I started to procrastinate =]
POE::Component::Server::IRC::Backend (POE::Component::IRC::Server::Backend)
Hybrid IRCD http://ircd-hybrid.com/
TSOra http://www.idolnet.org/docs/README.TSora
RFC 2810 http://www.faqs.org/rfcs/rfc2810.html
RFC 2811 http://www.faqs.org/rfcs/rfc2811.html
| POE-Component-Server-IRC documentation | view source | Contained in the POE-Component-Server-IRC distribution. |