| IRCv3 Core | May 2015 | |
| Pitcock, et al. | Standards Track | [Page] |
The IRC protocol has been developed by the greater IRC user and administrator community since the first version formalized in [RFC1459]. It has adapted over the years to be the primary collaboration tool for many groups because of it's simplicity and robustness.¶
The IRC Core Protocol version 3 updates [RFC1459] and [RFC2812] with a base protocol and framework for extensions which has been developed over the past decade, as well as standardizes current known best practices in the greater IRC community. The IRC Core Protocol version 3 framework mechanisms also provide some level of compatibility with legacy IRC clients.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].¶
IRC networks have been maintained over several decades for use with text-based conferencing. This document describes the core IRC client protocol and a framework for extending the protocol.¶
IRC itself is a distributed teleconferencing and signalling system which is well-suited for running on many machines in a distributed manner. A typical setup involves many clients connecting to an IRC server which is connected to other servers in the network. The IRC server handles all of the necessary message routing and broadcast tasks.¶
In a typical IRC network, the servers are linked to each other in a topology which resembles an acyclic graph, however, some experimental networks have developed alternative topologies such as mesh-like topologies. Other IRC server software implements support for hot failover connections, however this is usually dependent on a specialized server-to-server protocol.¶
A client is anything connected to a server which is using the IRC client protocol. Each client is distinguished from other clients by having a unique nickname. In addition to the nickname, every server on the network maintains other information on the client, such as the real hostname of the client, the username that the client has selected and other information about the client such as the name of the user.¶
To facilitate maintenance of the network, IRC features a type of privileged user known as an "IRC operator". IRC operators are granted special privilege to perform maintenance-related tasks such as rerouting servers as needed to mitigate bad network routing.¶
Operators also typically have the ability to enforce network policy by removing users from the network who do not comply with the network's policies.¶
A channel is a named group of zero or more clients which will all receive messages that are addressed to that channel. The channel is typically created when the first client joins it, and typically ceases to exist when the last client leaves it, however some IRC server software support keeping the channel open when no clients are presently using it in order to maintain the channel's settings.¶
Channel names are strings which begin with a configured CHANPREFIX of length up to a configured CHANNELLEN length. Apart from the requirement that the channel name begin with a recognized CHANPREFIX, the only other restriction is that may not contain any spaces, control codes or commas (",") which is used as a list-item separator by the protocol.¶
A channel may have zero or more channel operators which provide for the maintenance and moderation of the channel. Depending on the server software in use, the channel operators may have special sigils as designated by the PREFIX configuration value.¶
In a channel which is moderated, users which are allowed to bypass the moderation are given "voice" status. Users who have "voice" status MAY be given the "+" sigil to designate that they have the ability to bypass moderation.¶
A common feature of the present-day IRC networks are the usage of services servers. These servers provide specialized bots which provide an authentication layer on the network, allowing for ownership of nicknames and channels. Services usually provide facilities for account management and authentication, and map ownership of objects such as nicknames and channels to those accounts.¶
This protocol is a superset of [RFC1459], and is intended to be backwards compatible with [RFC1459] where possible. It describes only the client side of the protocol unlike [RFC1459], as the server protocols have diverged over the years and are no longer compatible.¶
While [RFC1459] does not specify any specific character set, servers implementing the IRCv3 core protocol SHOULD use UTF-8 as defined by [RFC3629]. Clients SHOULD send UTF-8 unless explicitly configured not to do so.¶
Because of IRC's Scandinavian origin, some IRC servers specify that the characters {}| be mapped to be the lower-case equivalents of []\. This is specified using the CASEMAPPING configuration attribute, and an IRC network MUST use the same CASEMAPPING attribute in the entire network.¶
Servers and clients send messages between each other which may or may not generate a reply. If the message contains a valid command, as described in later sections, the client SHOULD expect a reply as specified, but it is not advised to wait for the reply. Client to server communications should be treated as asynchronous in nature.¶
IRC messages consist of up to four parts: the tags section (optional), the prefix (optional), the command and it's parameters. All components of the message are separated using the UTF-8 space character (0x20).¶
The presence of a tags section is designated with a single leading "@" symbol (0x40). The tags section consists of a set of key-value pairs delimited by an equals sign (0x3D). Each key-value pair is delimited by a semi-colon (";") (0x3B), which may be escaped using a backslash ("\") (0x5C). There MUST NOT be any whitespace between the "@" symbol and the key-value pairs.¶
The presence of a prefix is designated with a single leading colon (":") (0x3A). There MUST NOT be any whitespace between the ":" symbol and the prefix itself. The prefix is used by servers to designate the origin of the message. If the prefix is missing, then clients SHOULD assume it came from the server the client is connected to. Clients SHOULD NOT use the prefix when they are sending a message to a server, but MAY send relevant tags.¶
The command must be either a valid IRC command or a three-digit number represented in UTF-8 text.¶
IRC messages are always lines of characters delimited with a CR-LF (Carriage Return - Line Feed) pair, and these messages SHOULD NOT exceed 1024 octets in length (512 bytes for tags, 512 for the rest) unless otherwise indicated by the server (see Section 3.8.2.1.17). If the limit is exceeded, the line MAY be silently truncated.¶
The protocol messages must be extracted from the contiguous stream of octets. The current solution is to designate two characters, CR and LF, as separators. Empty messages are silently ignored, which permits the use of the sequence CR-LF between messages without extra problems.¶
The extracted message is parsed into the components <tags>, <prefix>, <command> and list of parameters (<params>).¶
The Augmented BNF representation for this is:¶
message = [ "@" tags SPACE ] [ ":" prefix SPACE ] command [ params ] crlf
prefix = servername / ( nickname [ [ "!" user ] "@" host ] )
command = 1*letter / 3digit
params = *14( SPACE middle ) [ SPACE ":" trailing ]
=/ 14( SPACE middle ) [ SPACE [ ":" ] trailing ]
nospcrlfcl = %x01-09 / %x0B-0C / %x0E-1F / %x21-39 / %x3B-FF
; any octet except NUL, CR, LF, " " and ":"
middle = nospcrlfcl *( ":" / nospcrlfcl )
trailing = *( ":" / " " / nospcrlfcl )
tags = tag [';' tag]*
tag = key ['=' value]
nospcrlfscl = %x01-09 / %x0B-0C / %x0E-1F / %x21-39 / %x3C-FF
key = [ vendor '/' ] *( nospcrflscl )
value = nospcrflscl *( nospcrflscl )
SPACE = %x20 ; space character
crlf = %x0D %x0A ; "carriage return" "linefeed"¶
Notes:¶
SPACE explicitly is only the octet 0x20. Other forms of whitespace, such as tabs, are not considered part of SPACE.¶
After extracting the parameter list, all parameters are equal, whether matched by "middle" or "trailing". "trailing" is just a syntactic trick to allow SPACE within parameter.¶
The NUL character is not special in message framing but as it would cause extra complexities in normal C string handling it is not allowed within messages.¶
The trailing parameter may be an empty string.¶
Most protocol messages specify additional semantics and syntax for the extracted parameter strings dictated by their position in the list. For example, many server commands will assume that the first parameter after the command is the list of targets.¶
Most of the messages sent to the server generate a reply of some sort. The most common type of reply is a numeric reply, used for both errors and normal replies. The numeric reply MUST be sent as one message consisting of the sender prefix, the three-digit numeric and the target of the reply. A numeric reply MUST NOT originate from the client. In all other respects, a numeric reply SHOULD be treated as any other message, with the exception that the command keyword is made up of 3 numeric digits rather than a string of letters. A list of different replies is included in Section 3.8.¶
When wildcards are allowed in a string, it is referred as a "mask".¶
For string matching purposes, the protocol allows the use of two special characters: "?" (0x3F) to match one and only one character, and "*" (0x2A) to match any number of any characters. These two characters can be escaped using the character "\" (0x5C).¶
The Augmented BNF syntax for this is:¶
mask = *( nowild / noesc wildone / noesc wildmany )
wildone = %x3F
wildmany = %x2A
nowild = %x01-29 / %x2B-3E / %x40-FF
; any octet except NUL, "*", "?"
noesc = %x01-5B / %x5D-FF
; any octet except NUL and "\"
matchone = %x01-FF
; matches wildone
matchmany = *matchone
; matches wildmany¶
Immediately upon establishing a connection the client must attempt registration without waiting for any banner message from the server.¶
Until registration is complete, only a small subset of commands may be accepted by the server.¶
The recommended order of commands during registration is:¶
If the transport layer is not secured by TLS it is RECOMMENDED that the client attempt to opportunistically enable encryption by sending the STARTTLS (see Section 3.7.5) command before sending any other messages.¶
The PASS command (see Section 3.7.4) is not required for the connection to be registered, but if included it MUST precede the latter of the NICK and USER commands.¶
If the server supports capability negotiation the CAP command (see Section 3.7.1) suspends the registration process and immediately starts the capability negotiation process. See Section 3.6.1 for more information.¶
The NICK and USER commands (see Section 3.7.2 and Section 3.7.3, respectively) are used to identify the user's nickname, username and "real name". Once both commands have been submitted, the registration process will end, unless it is still suspended by a STARTTLS or CAP negotiation.¶
Upon successful completion of the registration process, the server MUST send the RPL_WELCOME (001) and RPL_ISUPPORT (005) numerics. The server SHOULD also send the MOTD (Message of the Day), if one exists, and MAY send other numerics.¶
The RPL_ISUPPORT (005) numeric contains significant information for clients and is covered in more detail in Section 3.8.2.¶
IRC is an asynchronous protocol, which means that IRC clients may issue additional IRC commands while previous commands are being processed. Some servers also do not complain about unknown commands during registration, which means that a client cannot reliably do passive implementation discovery at registration time.¶
The solution to these problems is to extend the registration process with actual capability negotiation. If the server supports capability negotiation, the registration process will be suspended until negotiation is completed. If the server does not support capability negotiation, then registration will complete immediately, and the client will not use any IRCv3 capabilities.¶
Capability negotiation is started by the client issuing a CAP LS command. Negotiation is then performed with the CAP REQ, CAP ACK, and CAP NAK commands, and ended with the CAP END command. See Section 3.7.1 for more information.¶
Once capability negotiation has ended, the registration process SHALL resume.¶
Syntax: "NICK <new nickname>"¶
The NICK message serves a dual purpose: it can be used to give the user a nickname or it can be used by an existing user to change their nickname.¶
Numeric Replies:¶
Syntax: "USER <username> <ignored> <ignored> <realname>"¶
The USER message is used at registration time to inform the server of the username and realname of the user.¶
The realname parameter may contain a space and if so MUST be preceeded by the colon (:) delimiter.¶
NOTE: parameters 2 and 3 are ignored and are simply included for backward compatibility with [RFC1459]¶
Numeric Replies:¶
Syntax: "PASS <password>"¶
The PASS message is used at registration time to provide a password to fully open a connection with the server. It SHOULD NOT be used to authenticate the user and is instead intended to be a way of limiting access to the server to only those with access to the password.¶
The PASS command can be sent multiple times but only the last attempt is utilized and the command SHOULD NOT be used after registration.¶
Numeric Replies:¶
Syntax: "432 <nickname> :Erroneous nickname"¶
Returned when a NICK command is sent with a nickname argument which does not comply with the format of a nickname set out in Section 3.3.1¶
Syntax: "433 <nickname> :Nickname is already in use"¶
Returned when a NICK command is sent with a nickname argument which currently exists (i.e. is currently the nickname of another user)¶
Syntax: "433 <nickname> :Nickname collision"¶
Returned when the server detects a nickname collision (e.g. when a heal of a netsplit occurs and both sides have a different user with the same nickname). This error may be followed by a possible termination of the connection through a KILL command or a forcible changing of nick through a NICK command or the use of some other server specific system.¶
Syntax: "433 <command> :Not enough parameters"¶
Returned when a command was sent by the client with not enough parameters.¶
Syntax: "462 <command> :You may not reregister"¶
Returned when the client tries to send a command which may be only used at registration time (e.g. PASS, USER) after registration has completed.¶