clients using UTF-8, which should be the default today.
References:
- - <http://ngircd.barton.de/doc/Protocol.txt>
- - doc/Protocol.txt
+ - IRC+, <http://ngircd.barton.de/doc/Protocol.txt>
+ - IRC+, doc/Protocol.txt
- NICK
NICK <nickname>
- RFC 1459, 4.1.1 "Password message" (old client and server protocol)
- RFC 2812, 3.1.1 "Password message" (client protocol)
- RFC 2813, 4.1.1 "Password message" (server protocol)
- - doc/Protocol.txt
+ - IRC+, <http://ngircd.barton.de/doc/Protocol.txt>
+ - IRC+, doc/Protocol.txt
- PING
PING <token> [<target>]
unauthorized clients to fake their identity; it is an arbitrary string.
References:
- - doc/Protocol.txt, II.4: "Update webchat/proxy client information"
+ - IRC+, <http://ngircd.barton.de/doc/Protocol.txt>
+ - IRC+, doc/Protocol.txt
General Commands
.
If <message> is omitted, the away status is removed.
+ References:
+ - RFC 2812, 4.1 "Away"
+
- HELP
HELP [<command>]
.
ngIRCd replies using "NOTICE" commands like ircd 2.10/2.11; other
implementations are using numerics 704, 705, and 706.
-
- MODE
- MODE <nickname> <flags> (user)
- MODE <channel> <flags> [<args>]
+ MODE <nickname> [{+|-}<mode>[<mode>] [{+|-}<mode>[<mode>] [...]]]
+ MODE <channel> [{+|-}<mode>[<mode>] [<arg> [<arg> [...]]] [{+|-}<mode>[<mode>] [<arg> [<arg> [...]]] [...]]]
+ .
+ Set and get user and channel modes.
+ .
+ When no mode parameters are given, the currently set user or channel
+ modes are returned. Otherwise the modes are adjusted accordingly
+ and the changes will be reported back to the client.
+ .
+ All user and chnnel "modes" are indicated by single case-sensitive
+ characters.
.
- The MODE command is dual-purpose. It can be used to set both (user) and
- <channel> modes.
+ Please note that a user can only get and set his own modes, and not
+ all user "levels" are allowed to change all channel modes ...
.
- See doc/Modes.txt for more information.
+ The mode parameters can become quite complex, especially when dealing
+ with channel modes that require additional arguments:
+ .
+ {+|-}<mode(s}> -- set or unset one or more modes.
+ +<mode(s)> -<mode(s)> -- set some modes and unset others.
+ +<modes> <arg1> <arg2> -- set (at least) two modes with arguments.
+ .
+ Some examples:
+ .
+ MODE nick +i -- set user to "invisible".
+ MODE #chan +tn -- set "topic lock" and "no external messages".
+ MODE #chan -t +l 50 -- remove "topic lock", set "user limit" to 50.
+ MODE #chan +ov nick1 nick2 -- set "channel op" and "voice" mode
+ to nick1 and nick2 in channel #chan.
+ .
+ A complete list of all modes supported by ngIRCd can be found online
+ here: <http://ngircd.barton.de/doc/Modes.txt>.
+
+ References:
+ - RFC 2811, 4. "Channel Modes"
+ - RFC 2812, 3.1.5 "User mode message"
+ - RFC 2812, 3.2.3 "Channel mode message"
+ - <http://ngircd.barton.de/doc/Modes.txt>
+ - doc/Modes.txt
- NOTICE
NOTICE <target>[,<target>[,...]] <message>
- RFC 2812, 3.4.6 "Time message"
- TRACE
- TRACE [<server>]
+ TRACE [<target>]
+ .
+ Find the route to a specific server and send information about its
+ peers. Each server that processes this command reports back to the
+ sender about it: the replies from pass-through servers form a chain
+ which shows the route to the destination.
.
- Trace a path across the IRC network of the current server, or if given
- of a specific <server>, in a similar method to traceroute.
+ <target> can be a server name, the nickname of a client connected to
+ a specific server, or a mask matching a server name in the network.
+ The server of the current connection is used when <target> is omitted.
+
+ References:
+ - RFC 2812, 3.4.8 "Trace message"
- USERHOST
USERHOST <nickname> [<nickname> [...]]
- RFC 2812, 3.2.7 "Invite message"
- JOIN
- JOIN <channels> [<channel-keys>]
+ JOIN {<channel>[,<channel>[,...]] [<key>[,<key>[,...]]] | 0}
.
- Makes the client join the <channels> (comma-separated list), specifying
- the passwords, if needed, in the comma-separated <channel-keys> list.
- A <channel-key> is only needed, if the <channel> mode "+k" is set.
+ Makes the client join the <channel> (comma-separated list), specifying
+ the channel keys ("passwords"). A <channel-key> is only needed if the
+ <channel> has the mode "+k" set.
.
If the channel(s) do not exist, then they will be created.
+ .
+ Using "JOIN 0" parts all channels at once.
+
+ References:
+ - RFC 2812, 3.2.1 "Join message" (client protocol)
+ - RFC 2813, 4.2.1 "Join message" (server protocol)
- KICK
KICK <channel>[,<channel>[,...]] <nickname>[,<nickname>[,...]] [<reason>]
- RFC 2812, 3.2.8 "Kick command"
- LIST
- LIST [<channels> [<server>]]
+ LIST [<channel>[,<channel>[,...]] [<server>]]
+ .
+ List all visible <channels> (comma-seperated list).
.
- List all visible <channels> (comma-seperated list) on the current
- server.
If <server> is given, the command will be forwarded to <server> for
evaluation.
+ References:
+ - RFC 2812, 3.2.6 "List message"
+
- PART
- PART <channels> [<part-message>]
+ PART <channel>[,<channel>[,...]] [<part-message>]
.
- Leave <channels> (comma-separated list), optional with a
- <part-message>.
+ Leave <channel> (comma-separated list), optionally with sending a
+ <part-message> to all the other channel members.
+
+ References:
+ - RFC 2812, 3.2.2 "Part message"
- TOPIC
- TOPIC <channel> <topic>
+ TOPIC <channel> [<topic>]
.
- Set a <topic> for <channel>.
+ Cchange or view the topic of a channel.
.
- Only <channel> operators are able to set a <topic>.
+ The topic for channel <channel> is returned if there is no <topic>
+ given. If the <topic> parameter is present, the topic for that
+ channel will be changed, if this action is allowed for the user
+ requesting it. If the <topic> parameter is an empty string, the
+ topic for that channel will be removed.
+
+ References:
+ - RFC 2812, 3.2.4 "Topic message"
Administrative Commands
~~~~~~~~~~~~~~~~~~~~~~~
- CONNECT
- CONNECT <target server> [<port> [<remote server> [<mypwd> <peerpwd>]]]
+ CONNECT <server> [<port> [<remote-server> [<my-pwd> <peer-pwd>]]]
+ .
+ Instructs the current server, or <remote-server> if specified,
+ to connect to the server named <server>, which must be configured
+ in the server configuration file.
.
- Instructs the current server, or <remote server> if specified,
- to connect to <target server>.
+ To use this command, the user must be an IRC Operator. To establish
+ a connection on a <remote-server>, you must have remote IRC operator
+ privileges.
.
- To connect <remote server> you need to have remote oper status.
- If <port> is omitted, it uses the server port of the configuration.
- If <mypwd> and <peerpwd> is given, it uses those passwords instead
- of the ones in the configuration.
+ If <port>, <my-pwd> and <peer-pwd> are given, these values override
+ the ones specified in the server configuration file.
+
+ References:
+ - RFC 2812, 3.4.7 "Connect message"
- DIE
DIE
.
Instructs the server to shut down.
+ .
+ To use this command, the user must be an IRC Operator.
+
+ References:
+ - RFC 2812, 4.3 "Die message"
- DISCONNECT
- DISCONNECT [<remote server>]
+ DISCONNECT <server>
.
- Disconnects the current server, or <remote server> if specified.
- To disconnect a <remote server> you need to have remote oper status.
+ Disconnect and disable a locally linked server.
+ .
+ To use this command, the user must be an IRC Operator.
+
+ References:
+ - This command is not specified in the IRC RFCs, it is an extension
+ of ngIRCd.
- GLINE
- GLINE <nick!user@hostmask> <seconds> :<reason>
+ GLINE <nick!user@hostmask> [<timeout> :<reason>]
+ .
+ This command provides timed G-Lines (network-wide bans).
.
- This command provides timed G-Lines (Network-wide bans).
If a client matches a G-Line, it cannot connect to any server on
- the IRC network. If you put 0 as <seconds>, it makes the G-Line
- permanent.
+ the IRC network for <timeout> seconds. When <timoeut> is 0, it make
+ the G-Line permanent.
+ .
+ If no <timeout> and no <reason> is given, the G-Line is removed.
.
- To remove a G-Line, type "GLINE <nick!user@hostmask>".
- To list the G-Lines, type "STATS g".
+ To use this command, the user must be an IRC Operator.
+ .
+ "STATS g" can be used to list all currently active G-Lines.
+
+ References:
+ - This command is not specified in the IRC RFCs, it is an extension
+ of ngIRCd.
- KILL
KILL <nickname> <reason>
.
This command is used internally between servers, too, for example
to disconnect duplicate <nickname>'s after a "net split".
+ .
+ To use this command, the user must be an IRC Operator.
References:
- RFC 2812, 3.7.1 "Kill message"
- KLINE
- KLINE <nick!user@hostmask> <seconds> :<reason>
+ KLINE <nick!user@hostmask> [<timeout> :<reason>]
+ .
+ This command provides timed K-Lines (server-local bans).
.
- This command provides timed K-Lines (Server-local bans).
- If a client matches a K-Line, it cannot connect to the issued server.
- If you put 0 as <seconds>, it makes the K-Line permanent.
+ If a client matches a K-Line, it cannot connect to this server for
+ <timeout> seconds. When <timoeut> is 0, it makes the K-Line permanent.
.
- To remove a K-Line, type "KLINE <nick!user@hostmask>".
- To list the K-Lines, type "STATS k".
+ If no <timeout> and no <reason> is given, the K-Line is removed.
+ .
+ To use this command, the user must be an IRC Operator.
+ .
+ "STATS k" can be used to list all currently active K-Lines.
+
+ References:
+ - This command is not specified in the IRC RFCs, it is an extension
+ of ngIRCd.
- OPER
- OPER <user> <password>
+ OPER <name> <password>
+ .
+ Authenticates a user named <name> as an IRC operator on the current
+ server/network.
+ .
+ This operator <name> must be configured in the server configuration.
.
- Authenticates <user> as an IRC operator on the current server/network.
+ Please note that <name> is NOT related to a nickname at all!
+
+ References:
+ - RFC 2812, 3.1.4 "Oper message"
- REHASH
REHASH
.
Causes the server to re-read and re-process its configuration file(s).
+ .
+ While rehashing, no new connections are accepted, but all already
+ established connections stay connected.
+ .
+ To use this command, the user must be an IRC Operator.
+
+ References:
+ - RFC 2812, 4.2 "Rehash message"
- RESTART
RESTART
.
Restart the server.
+ .
+ While restarting, all connections are reset and no new connections
+ are accepted.
+ .
+ To use this command, the user must be an IRC Operator.
+
+ References:
+ - RFC 2812, 4.4 "Restart message"
- WALLOPS
WALLOPS <message>
.
Sends <message> to all users with user mode "+w".
+ .
+ To use this command, the user must be an IRC Operator.
+ References:
+ - RFC 2812, 4.7 "Operwall message"
IRC Service Commands
~~~~~~~~~~~~~~~~~~~~
CHANINFO is used by servers to inform each other about a channel:
its modes, channel key, user limits and its topic.
.
- See doc/Protocol.txt for more information.
+ The CHANINFO command is allowed on server-links only.
+
+ References:
+ - IRC+, <http://ngircd.barton.de/doc/Protocol.txt>
+ - IRC+, doc/Protocol.txt
- ERROR
ERROR [<message> [<> [...]]]
information of clients, like the hostname, the info text ("real name"),
or the user name.
.
- See doc/Protocol.txt for more information.
+ The METADATA command is allowed on server-links only.
+
+ References:
+ - IRC+, <http://ngircd.barton.de/doc/Protocol.txt>
+ - IRC+, doc/Protocol.txt
- NJOIN
+ NJOIN <channel> [<mode>]<nick>[,[<mode>]<nick>[,...]]
+ .
+ The NJOIN command is used on setver-links to add users with <nick>
+ and <mode> to a <channel> while peering.
+ .
+ The NJOIN command is allowed on server-links only.
+
+ References:
+ - RFC 2813, 4.2.2 "Njoin message"
- SERVER
+ SERVER <servername> <info>
+ SERVER <servername> <hopcount> <info>
+ SERVER <servername> <hopcount> <token> <info>
+ .
+ The first form registers the local connection as a new server in the
+ network, the second (RFC 1459) and third (RFC 2812) form announce a
+ new remote server in the network.
+ .
+ The SERVER command is allowed on unregistered or server-links only.
+
+ References:
+ - RFC 1459, 4.1.4 "Server message"
+ - RFC 2813, 4.1.2 "Server message"
- SQUIT
- SQUIT <server>
+ SQUIT <server> <comment>
.
Disconnects an IRC Server from the network.
+ .
+ This command is used on server-links, but can be used by IRC Operators
+ to forcefully disconnect servers from the network, too.
+ References:
+ - RFC 2812, 3.1.8 "Squit"
+ - RFC 2813, 4.1.6 "Server quit message"
Dummy Commands
~~~~~~~~~~~~~~
- RFC 2812, 4.6 "Users"
- GET
+ GET [...]
+ .
+ Fake HTTP GET command. When received, the connection is shut down
+ immediately again to protect against crazy web browsers ...
+
+ References:
+ - ngIRCd GIT commit 33e8c2480649
- POST
+ POST [...]
+ .
+ Fake HTTP POST command. When received, the connection is shut down
+ immediately again to protect against crazy web browsers ...
+
+ References:
+ - ngIRCd GIT commit 33e8c2480649
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2013 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "parse.h"
#include "irc.h"
#include "irc-info.h"
+#include "irc-macros.h"
#include "irc-write.h"
#include "conf.h"
#include "exp.h"
#include "irc-channel.h"
-
/**
* Part from all channels.
*
return CONNECTED;
} /* part_from_all_channels */
-
/**
* Check weather a local client is allowed to join an already existing
* channel or not.
return true;
} /* join_allowed */
-
/**
* Set user channel modes.
*
Channel_UserModeAdd(chan, target, 'o');
} /* join_set_channelmodes */
-
/**
* Forward JOIN command to a specific server
*
Client_ID(Prefix));
} /* cb_join_forward */
-
/**
* Forward JOIN command to all servers
*
}
} /* join_forward */
-
/**
* Aknowledge user JOIN request and send "channel info" numerics.
*
Channel_Name(chan));
} /* join_send_topic */
-
/**
* Handler for the IRC "JOIN" command.
*
- * See RFC 2812, 3.2.1 "Join message"; RFC 2813, 4.2.1 "Join message".
- *
- * @param Client The client from which this command has been received
- * @param Req Request structure with prefix and all parameters
- * @returns CONNECTED or DISCONNECTED
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_JOIN( CLIENT *Client, REQUEST *Req )
assert (Client != NULL);
assert (Req != NULL);
- /* Bad number of arguments? */
- if (Req->argc < 1 || Req->argc > 2)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
-
- /* Who is the sender? */
- if (Client_Type(Client) == CLIENT_SERVER)
- target = Client_Search(Req->prefix);
- else
- target = Client;
-
- if (!target)
- return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
- Client_ID(Client), Req->prefix);
+ _IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
+ _IRC_GET_SENDER_OR_RETURN_(target, Req, Client)
/* Is argument "0"? */
if (Req->argc == 1 && !strncmp("0", Req->argv[0], 2))
return CONNECTED;
} /* IRC_JOIN */
-
/**
* Handler for the IRC "PART" command.
*
- * See RFC 2812, 3.2.2: "Part message".
- *
- * @param Client The client from which this command has been received
- * @param Req Request structure with prefix and all parameters
- * @returns CONNECTED or DISCONNECTED
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_PART(CLIENT * Client, REQUEST * Req)
assert(Client != NULL);
assert(Req != NULL);
- if (Req->argc < 1 || Req->argc > 2)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
-
- /* Get the sender */
- if (Client_Type(Client) == CLIENT_SERVER)
- target = Client_Search(Req->prefix);
- else
- target = Client;
- if (!target)
- return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
- Client_ID(Client), Req->prefix);
+ _IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
+ _IRC_GET_SENDER_OR_RETURN_(target, Req, Client)
/* Loop over all the given channel names */
chan = strtok(Req->argv[0], ",");
return CONNECTED;
} /* IRC_PART */
-
/**
* Handler for the IRC "TOPIC" command.
*
- * See RFC 2812, 3.2.4 "Topic message".
- *
- * @param Client The client from which this command has been received
- * @param Req Request structure with prefix and all parameters
- * @returns CONNECTED or DISCONNECTED
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_TOPIC( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
- if (Req->argc < 1 || Req->argc > 2)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
-
- if (Client_Type(Client) == CLIENT_SERVER)
- from = Client_Search(Req->prefix);
- else
- from = Client;
+ IRC_SetPenalty(Client, 1);
- if (!from)
- return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
- Client_ID(Client), Req->prefix);
+ _IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
+ _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
chan = Channel_Search(Req->argv[0]);
if (!chan)
return CONNECTED;
} /* IRC_TOPIC */
-
/**
* Handler for the IRC "LIST" command.
*
- * See RFC 2812, 3.2.6 "List message".
- *
- * This implementation handles the local case as well as the forwarding of the
- * LIST command to other servers in the IRC network.
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
assert(Client != NULL);
assert(Req != NULL);
- /* Bad number of prameters? */
- if (Req->argc > 2)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
+ IRC_SetPenalty(Client, 2);
+
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 2)
+ _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
if (Req->argc > 0)
pattern = strtok(Req->argv[0], ",");
else
pattern = "*";
- /* Get sender from prefix, if any */
- if (Client_Type(Client) == CLIENT_SERVER)
- from = Client_Search(Req->prefix);
- else
- from = Client;
-
- if (!from)
- return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
- Client_ID(Client), Req->prefix);
-
if (Req->argc == 2) {
/* Forward to other server? */
target = Client_Search(Req->argv[1]);
pattern = NULL;
}
- IRC_SetPenalty(from, 2);
return IRC_WriteStrClient(from, RPL_LISTEND_MSG, Client_ID(from));
} /* IRC_LIST */
-
/**
- * Handler for the IRC+ command "CHANINFO".
- *
- * See doc/Protocol.txt, section II.3:
- * "Exchange channel-modes, topics, and persistent channels".
+ * Handler for the IRC+ "CHANINFO" command.
*
- * @param Client The client from which this command has been received
- * @param Req Request structure with prefix and all parameters
- * @returns CONNECTED or DISCONNECTED
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_CHANINFO( CLIENT *Client, REQUEST *Req )
Client_ID(Client), Req->command);
/* Compatibility kludge */
- if( Req->argc == 5 ) arg_topic = 4;
- else if( Req->argc == 3 ) arg_topic = 2;
- else arg_topic = -1;
+ if (Req->argc == 5)
+ arg_topic = 4;
+ else if(Req->argc == 3)
+ arg_topic = 2;
+ else
+ arg_topic = -1;
- /* Search origin */
- from = Client_Search( Req->prefix );
- if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
+ _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
/* Search or create channel */
chan = Channel_Search( Req->argv[0] );
- if( ! chan ) chan = Channel_Create( Req->argv[0] );
- if( ! chan ) return CONNECTED;
-
- if( Req->argv[1][0] == '+' )
- {
- ptr = Channel_Modes( chan );
- if( ! *ptr )
- {
- /* OK, this channel doesn't have modes jet, set the received ones: */
- Channel_SetModes( chan, &Req->argv[1][1] );
-
- if( Req->argc == 5 )
- {
- if( strchr( Channel_Modes( chan ), 'k' )) Channel_SetKey( chan, Req->argv[2] );
- if( strchr( Channel_Modes( chan ), 'l' )) Channel_SetMaxUsers( chan, atol( Req->argv[3] ));
- }
- else
- {
+ if (!chan)
+ chan = Channel_Create( Req->argv[0] );
+ if (!chan)
+ return CONNECTED;
+
+ if (Req->argv[1][0] == '+') {
+ ptr = Channel_Modes(chan);
+ if (!*ptr) {
+ /* OK, this channel doesn't have modes jet,
+ * set the received ones: */
+ Channel_SetModes(chan, &Req->argv[1][1]);
+
+ if(Req->argc == 5) {
+ if(strchr(Channel_Modes(chan), 'k'))
+ Channel_SetKey(chan, Req->argv[2]);
+ if(strchr(Channel_Modes(chan), 'l'))
+ Channel_SetMaxUsers(chan, atol(Req->argv[3]));
+ } else {
/* Delete modes which we never want to inherit */
- Channel_ModeDel( chan, 'l' );
- Channel_ModeDel( chan, 'k' );
+ Channel_ModeDel(chan, 'l');
+ Channel_ModeDel(chan, 'k');
}
- strcpy( modes_add, "" );
- ptr = Channel_Modes( chan );
- while( *ptr )
- {
- if( *ptr == 'l' )
- {
- snprintf( l, sizeof( l ), " %lu", Channel_MaxUsers( chan ));
- strlcat( modes_add, l, sizeof( modes_add ));
+ strcpy(modes_add, "");
+ ptr = Channel_Modes(chan);
+ while (*ptr) {
+ if (*ptr == 'l') {
+ snprintf(l, sizeof(l), " %lu",
+ Channel_MaxUsers(chan));
+ strlcat(modes_add, l,
+ sizeof(modes_add));
}
- if( *ptr == 'k' )
- {
- strlcat( modes_add, " ", sizeof( modes_add ));
- strlcat( modes_add, Channel_Key( chan ), sizeof( modes_add ));
+ if (*ptr == 'k') {
+ strlcat(modes_add, " ",
+ sizeof(modes_add));
+ strlcat(modes_add, Channel_Key(chan),
+ sizeof(modes_add));
}
ptr++;
}
/* Inform members of this channel */
- IRC_WriteStrChannelPrefix( Client, chan, from, false, "MODE %s +%s%s", Req->argv[0], Channel_Modes( chan ), modes_add );
+ IRC_WriteStrChannelPrefix(Client, chan, from, false,
+ "MODE %s +%s%s", Req->argv[0],
+ Channel_Modes(chan), modes_add);
}
}
- else Log( LOG_WARNING, "CHANINFO: invalid MODE format ignored!" );
+ else
+ Log(LOG_WARNING, "CHANINFO: invalid MODE format ignored!");
- if( arg_topic > 0 )
- {
+ if (arg_topic > 0) {
/* We got a topic */
ptr = Channel_Topic( chan );
- if(( ! *ptr ) && ( Req->argv[arg_topic][0] ))
- {
+ if (!*ptr && Req->argv[arg_topic][0]) {
/* OK, there is no topic jet */
Channel_SetTopic(chan, Client, Req->argv[arg_topic]);
IRC_WriteStrChannelPrefix(Client, chan, from, false,
}
/* Forward CHANINFO to other serevrs */
- if( Req->argc == 5 ) IRC_WriteStrServersPrefixFlag( Client, from, 'C', "CHANINFO %s %s %s %s :%s", Req->argv[0], Req->argv[1], Req->argv[2], Req->argv[3], Req->argv[4] );
- else if( Req->argc == 3 ) IRC_WriteStrServersPrefixFlag( Client, from, 'C', "CHANINFO %s %s :%s", Req->argv[0], Req->argv[1], Req->argv[2] );
- else IRC_WriteStrServersPrefixFlag( Client, from, 'C', "CHANINFO %s %s", Req->argv[0], Req->argv[1] );
+ if (Req->argc == 5)
+ IRC_WriteStrServersPrefixFlag(Client, from, 'C',
+ "CHANINFO %s %s %s %s :%s",
+ Req->argv[0], Req->argv[1],
+ Req->argv[2], Req->argv[3],
+ Req->argv[4]);
+ else if (Req->argc == 3)
+ IRC_WriteStrServersPrefixFlag(Client, from, 'C',
+ "CHANINFO %s %s :%s",
+ Req->argv[0], Req->argv[1],
+ Req->argv[2]);
+ else
+ IRC_WriteStrServersPrefixFlag(Client, from, 'C',
+ "CHANINFO %s %s",
+ Req->argv[0], Req->argv[1]);
return CONNECTED;
} /* IRC_CHANINFO */
-
/* -eof- */
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "defines.h"
#include "conn.h"
#include "channel.h"
+#include "irc-macros.h"
#include "irc-write.h"
#include "lists.h"
#include "log.h"
#include "exp.h"
#include "irc-mode.h"
-
static bool Client_Mode PARAMS((CLIENT *Client, REQUEST *Req, CLIENT *Origin,
CLIENT *Target));
static bool Channel_Mode PARAMS((CLIENT *Client, REQUEST *Req, CLIENT *Origin,
CLIENT *Prefix, CLIENT *Client,
CHANNEL *Channel, const char *Mask));
-
/**
* Handler for the IRC "MODE" command.
*
- * See RFC 2812 section 3.1.5 ("user mode message") and section 3.2.3
- * ("channel mode message"), and RFC 2811 section 4 ("channel modes").
+ * This function detects whether user or channel modes should be modified
+ * and calls the apropriate sub-functions.
*
- * @param Client The client from which this command has been received.
- * @param Req Request structure with prefix and all parameters.
- * @returns CONNECTED or DISCONNECTED.
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_MODE( CLIENT *Client, REQUEST *Req )
assert(Client != NULL);
assert(Req != NULL);
- /* No parameters? */
- if (Req->argc < 1)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
-
- /* Origin for answers */
- if (Client_Type(Client) == CLIENT_SERVER) {
- origin = Client_Search(Req->prefix);
- if (!origin)
- return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
- Client_ID(Client),
- Req->prefix);
- } else
- origin = Client;
+ _IRC_ARGC_GE_OR_RETURN_(Client, Req, 1)
+ _IRC_GET_SENDER_OR_RETURN_(origin, Req, Client)
/* Channel or user mode? */
cl = NULL; chan = NULL;
Client_ID(Client), Req->argv[0]);
} /* IRC_MODE */
-
/**
* Check if the "mode limit" for a client has been reached.
*
return true;
}
-
/**
* Handle client mode requests
*
- * @param Client The client from which this command has been received.
- * @param Req Request structure with prefix and all parameters.
- * @param Origin The originator of the MODE command (prefix).
- * @param Target The target (client) of this MODE command.
- * @returns CONNECTED or DISCONNECTED.
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @param Origin The originator of the MODE command (prefix).
+ * @param Target The target (client) of this MODE command.
+ * @return CONNECTED or DISCONNECTED.
*/
static bool
Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
return ok;
} /* Client_Mode */
-
+/*
+ * Reply to a channel mode request.
+ *
+ * @param Origin The originator of the MODE command (prefix).
+ * @param Channel The channel of which the modes should be sent.
+ * @return CONNECTED or DISCONNECTED.
+ */
static bool
Channel_Mode_Answer_Request(CLIENT *Origin, CHANNEL *Channel)
{
return CONNECTED;
}
-
/**
* Handle channel mode and channel-user mode changes
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @param Origin The originator of the MODE command (prefix).
+ * @param Channel The target channel of this MODE command.
+ * @return CONNECTED or DISCONNECTED.
*/
static bool
Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
return connected;
} /* Channel_Mode */
-
+/**
+ * Handler for the IRC "AWAY" command.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
+ */
GLOBAL bool
IRC_AWAY( CLIENT *Client, REQUEST *Req )
{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- if(( Req->argc == 1 ) && (Req->argv[0][0] ))
- {
- Client_SetAway( Client, Req->argv[0] );
- Client_ModeAdd( Client, 'a' );
- IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
- return IRC_WriteStrClient( Client, RPL_NOWAWAY_MSG, Client_ID( Client ));
- }
- else
- {
- Client_ModeDel( Client, 'a' );
- IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
- return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
+ assert (Client != NULL);
+ assert (Req != NULL);
+
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
+
+ if (Req->argc == 1 && Req->argv[0][0]) {
+ Client_SetAway(Client, Req->argv[0]);
+ Client_ModeAdd(Client, 'a');
+ IRC_WriteStrServersPrefix(Client, Client, "MODE %s :+a",
+ Client_ID( Client));
+ return IRC_WriteStrClient(Client, RPL_NOWAWAY_MSG,
+ Client_ID( Client));
+ } else {
+ Client_ModeDel(Client, 'a');
+ IRC_WriteStrServersPrefix(Client, Client, "MODE %s :-a",
+ Client_ID( Client));
+ return IRC_WriteStrClient(Client, RPL_UNAWAY_MSG,
+ Client_ID( Client));
}
} /* IRC_AWAY */
-
/**
* Add entries to channel invite, ban and exception lists.
*
return Send_ListChange(true, what, Prefix, Client, Channel, mask);
}
-
/**
* Delete entries from channel invite, ban and exeption lists.
*
return Send_ListChange(false, what, Prefix, Client, Channel, mask);
}
-
/**
* Send information about changed channel invite/ban/exception lists to clients.
*
return ok;
} /* Send_ListChange */
-
/* -eof- */
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors.
+ * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "conf.h"
#include "channel.h"
#include "class.h"
+#include "irc-macros.h"
#include "irc-write.h"
#include "log.h"
#include "match.h"
/**
* Handler for the IRC "OPER" command.
*
- * See RFC 2812, 3.1.4 "Oper message".
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
assert( Client != NULL );
assert( Req != NULL );
- if (Req->argc != 2)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
+ _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
len = array_length(&Conf_Opers, sizeof(*op));
op = array_start(&Conf_Opers);
if (!Client_OperByMe(Client))
Log(LOG_NOTICE|LOG_snotice,
- "Got valid OPER from \"%s\", user is an IRC operator now.",
- Client_Mask(Client));
+ "Got valid OPER for \"%s\" from \"%s\", user is an IRC operator now.",
+ Req->argv[0], Client_Mask(Client));
Client_SetOperByMe(Client, true);
return IRC_WriteStrClient(Client, RPL_YOUREOPER_MSG, Client_ID(Client));
/**
* Handler for the IRC "DIE" command.
*
- * See RFC 2812, 4.3 "Die message".
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
if (!Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
- /* Bad number of parameters? */
#ifdef STRICT_RFC
- if (Req->argc != 0)
+ _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 0)
#else
- if (Req->argc > 1)
+ _IRC_ARGC_LE_OR_RETURN_(Client, Req, 1)
#endif
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
/* Is a message given? */
if (Req->argc > 0) {
/**
* Handler for the IRC "REHASH" command.
*
- * See RFC 2812, 4.2 "Rehash message".
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
if (!Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
- /* Bad number of parameters? */
- if (Req->argc != 0)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command );
+ _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 0)
Log(LOG_NOTICE|LOG_snotice, "Got REHASH command from \"%s\" ...",
Client_Mask(Client));
/**
* Handler for the IRC "RESTART" command.
*
- * See RFC 2812, 4.4 "Restart message".
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
/**
* Handler for the IRC "CONNECT" command.
*
- * See RFC 2812, 3.4.7 "Connect message".
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
/**
* Handler for the IRC "WALLOPS" command.
*
- * See RFC 2812, 4.7 "Operwall message".
- *
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
assert( Client != NULL );
assert( Req != NULL );
- if (Req->argc != 1)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
+ _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 1)
switch (Client_Type(Client)) {
case CLIENT_USER:
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2007 Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "conn-zip.h"
#include "conf.h"
#include "channel.h"
-#include "irc-write.h"
#include "lists.h"
#include "log.h"
#include "messages.h"
#include "numeric.h"
#include "ngircd.h"
#include "irc-info.h"
+#include "irc-macros.h"
+#include "irc-write.h"
#include "op.h"
#include "exp.h"
#include "irc-server.h"
-
/**
- * Handler for the IRC command "SERVER".
- * See RFC 2813 section 4.1.2.
+ * Handler for the IRC "SERVER" command.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_SERVER( CLIENT *Client, REQUEST *Req )
Client_ID(Client), Req->command);
} /* IRC_SERVER */
-
+/*
+ * Handler for the IRC "NJOIN" command.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
+ */
GLOBAL bool
IRC_NJOIN( CLIENT *Client, REQUEST *Req )
{
assert( Client != NULL );
assert( Req != NULL );
- if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+ _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
strcpy( nick_out, "" );
}
/* forward to other servers */
- if( nick_out[0] != '\0' ) IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], nick_out );
+ if (nick_out[0] != '\0')
+ IRC_WriteStrServersPrefix(Client, Client_ThisServer(),
+ "NJOIN %s :%s", Req->argv[0], nick_out);
return CONNECTED;
} /* IRC_NJOIN */
-
/**
- * Handler for the IRC command "SQUIT".
- * See RFC 2813 section 4.1.2 and RFC 2812 section 3.1.8.
+ * Handler for the IRC "SQUIT" command.
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_SQUIT(CLIENT * Client, REQUEST * Req)
&& !Client_HasMode(Client, 'o'))
return Op_NoPrivileges(Client, Req);
- /* Bad number of arguments? */
- if (Req->argc != 2)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
- Client_ID(Client), Req->command);
+ _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix) {
from = Client_Search(Req->prefix);