Network Working Group M. Mikulėnas Internet-Draft Independent Updates: 1459, 2812 (if approved) D. Oakley, Ed. Intended status: Informational ircdocs Expires: 24 November 2021 23 May 2021 Internet Relay Chat: Client-to-Client Protocol (CTCP) draft-oakley-irc-ctcp-latest Abstract This document describes the Client-to-Client Protocol (CTCP), which lets Internet Relay Chat (IRC) clients send each other messages that get displayed or responded to in special ways. CTCP has been widely implemented, with most clients supporting it natively. This document outlines how to implement CTCP and the most common messages. This document updates RFCs 1459 and 2812. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on 24 November 2021. Copyright Notice Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/ license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Mikulėnas & Oakley Expires 24 November 2021 [Page 1] Internet-Draft IRC CTCP May 2021 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Protocol Structure . . . . . . . . . . . . . . . . . . . . . 3 3. Message Syntax . . . . . . . . . . . . . . . . . . . . . . . 3 4. Messages . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 4 6. Security Considerations . . . . . . . . . . . . . . . . . . . 4 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 4 8. Normative References . . . . . . . . . . . . . . . . . . . . 4 Appendix A. Message List . . . . . . . . . . . . . . . . . . . . 5 A.1. ACTION . . . . . . . . . . . . . . . . . . . . . . . . . 5 A.2. CLIENTINFO . . . . . . . . . . . . . . . . . . . . . . . 6 A.3. DCC . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 A.4. FINGER . . . . . . . . . . . . . . . . . . . . . . . . . 7 A.5. PING . . . . . . . . . . . . . . . . . . . . . . . . . . 7 A.6. SOURCE . . . . . . . . . . . . . . . . . . . . . . . . . 7 A.7. TIME . . . . . . . . . . . . . . . . . . . . . . . . . . 8 A.8. VERSION . . . . . . . . . . . . . . . . . . . . . . . . . 8 A.9. USERINFO . . . . . . . . . . . . . . . . . . . . . . . . 9 Appendix B. Change History [RFC Editor: Please remove this section] . . . . . . . . . . . . . . . . . . . . . . . . 9 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 9 1. Introduction The core Internet Relay Chat (IRC) protocol as described in [RFC1459] and [RFC2812] does not provide a way to exchange computer-readable information directly between clients. The Client-to-Client Protocol (CTCP) lets them exchange messages that get processed, displayed or responded to in special ways. CTCP can be used to request special formatting on messages, query other clients for metadata, and help initiate file transfers with other clients among other uses. This document covers the subset of CTCP which is commonly implemented, and clients implementing this specification are compatible with those implementing the protocol as described by older documents. 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]. Mikulėnas & Oakley Expires 24 November 2021 [Page 2] Internet-Draft IRC CTCP May 2021 2. Protocol Structure CTCP queries are sent with the PRIVMSG IRC command, and CTCP replies are sent with NOTICE command. To indicate a CTCP query or reply, the body of the message (the second parameter) begins with the CTCP delimiter. Queries MAY be sent to channels. Replies MUST always be sent to the querying client only, not the channel. Many servers implement filters so that only specific CTCP commands can be sent to channels. When this is done, channel operators can typically enable and disable this filtering with a channel mode. 3. Message Syntax The ABNF [RFC5234] for CTCP message bodies is as follows: delim = %x01 command = 1*( %x02-09 / %x0B-0C / %x0E-1F / %x21-FF ) ; any octet except NUL, delim, CR, LF, and SP params = 1*( %x02-09 / %x0B-0C / %x0E-FF ) ; any octet except NUL, delim, CR, and LF body = delim command [ SP params ] [ delim ] Commands are case-insensitive. When creating new CTCP commands, authors SHOULD use only alphanumeric characters for ease of implementation. The final CTCP delimiter SHOULD be sent on outgoing messages for compatibility reasons, but software MUST accept incoming messages which lack it. In message examples throughout this document, the CTCP delimiter is shown as "\x01". Here are two examples of valid CTCP queries and replies: :alice!a@localhost PRIVMSG bob :\x01VERSION\x01 :bob!b@localhost NOTICE alice :\x01VERSION Snak for Mac 4.13\x01 :alice!a@localhost PRIVMSG #ircv3 :\x01PING 1473523796 918320 :bob!b@localhost NOTICE alice :\x01PING 1473523796 918320\x01 Mikulėnas & Oakley Expires 24 November 2021 [Page 3] Internet-Draft IRC CTCP May 2021 4. Messages There is not a formal registry of CTCP message names, and CTCP responses are uniquely flexible. Clients that receive either unexpected messages or known messages with unexpected values SHOULD ignore them and send no response to the querying user. 5. Acknowledgements Thanks to the IRCv3 group for giving feedback on this specification, and to Khaled Mardam-Bey for advice on client flood protection. Thanks to Michael Sandrof for creating CTCP, Troy Rollo for creating the related DCC protocol, as well as Klaus Zeuge and Ben Mesander who wrote and revised related specifications. Special thanks to dequis, Sadie Powell and James Wheare for help with this and related work. 6. Security Considerations CTCP messages are completely untrusted data and clients MUST NOT assume that they are well-formed or complete. Older CTCP specifications describe quoting methods which are complex and not widely implemented. Implementations SHOULD NOT implement "low-level quoting" or "CTCP-level quoting" when parsing messages. CTCP requests can be abused to flood clients off the server they are connected to. Clients SHOULD ignore or delay excessive incoming requests to protect against this. Older CTCP specifications describe including more than one CTCP message inside a single PRIVMSG or NOTICE command. Implementations SHOULD NOT implement this form of CTCP parsing as it is not widely- implemented and may result in an implementation that can be more easily flooded off the server they are connected to. 7. IANA Considerations This document has no actions for IANA. 8. Normative References [RFC1459] Oikarinen, J. and D. Reed, "Internet Relay Chat Protocol", RFC 1459, DOI 10.17487/RFC1459, May 1993, . Mikulėnas & Oakley Expires 24 November 2021 [Page 4] Internet-Draft IRC CTCP May 2021 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . [RFC2812] Kalt, C., "Internet Relay Chat: Client Protocol", RFC 2812, DOI 10.17487/RFC2812, April 2000, . [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, January 2008, . [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, DOI 10.17487/RFC5322, October 2008, . Appendix A. Message List This section is not exhaustive, and only lists those CTCP messages which are widely implemented across the IRC ecosystem. Clients MUST ONLY send params on a query if a params section is listed here. The Query and Reply lines below represent variables by surrounding them with angle brackets. A.1. ACTION Query: ACTION Reply: None Clients which implement this message MUST display as a third- person action or emote. Users typically use the "/me" command in their IRC clients to send this message. If is empty, clients SHOULD still include a single space after "ACTION" (i.e. an empty params section) to help ensure compatibility. Clients SHOULD correctly parse incoming ACTION messages with or without the params section. Leading spaces in SHOULD NOT be stripped before being displayed to users. ACTION is universally implemented and very commonly used. Clients MUST implement this CTCP message to effectively use IRC. Examples: Mikulėnas & Oakley Expires 24 November 2021 [Page 5] Internet-Draft IRC CTCP May 2021 Raw: :dan!user@host PRIVMSG #ircv3 :\x01ACTION does it!\x01 Formatted: * dan does it! Raw: :dan!user@host PRIVMSG #ircv3 :\x01ACTION \x01 Raw: :dan!user@host PRIVMSG #ircv3 :\x01ACTION\x01 Raw: :dan!user@host PRIVMSG #ircv3 :\x01ACTION Formatted: * dan A.2. CLIENTINFO Query: CLIENTINFO Reply: CLIENTINFO Clients which implement this message MUST reply with a list of the CTCP messages they support, delimited by an ASCII space. Some legacy implementations add an extra text message at the end prefixed by a colon, as demonstrated in the examples. CLIENTINFO is widely implemented. Clients SHOULD implement this CTCP message. Example: Query: CLIENTINFO Reply: CLIENTINFO ACTION DCC CLIENTINFO PING TIME VERSION Query: CLIENTINFO Reply: CLIENTINFO CLIENTINFO PING VERSION :Use CLIENTINFO to get more specific information A.3. DCC Query: DCC Reply: Described elsewhere. This message sets up connections that go directly between clients, bypassing the IRC server. This is typically used for features that require a large amount of traffic (e.g. file transfers), or simply direct chat that bypasses the server. The Direct Client-to-Client (DCC) protocol requires its own specification, and is not described in-depth here. DCC is widely implemented. Clients MAY implement this CTCP message. Mikulėnas & Oakley Expires 24 November 2021 [Page 6] Internet-Draft IRC CTCP May 2021 A.4. FINGER Query: FINGER Reply: FINGER Clients which implement this message MUST reply with miscellaneous information about the user (typically the contents of their realname/ gecos field). However, some implementations return the client name and version instead. FINGER is largely obsolete. Clients MAY implement this CTCP message. Example: Query: FINGER Reply: FINGER WeeChat 1.8-dev A.5. PING Query: PING Reply: PING Clients which implement this message MUST send a reply containing exactly the same params as the original query. However, leading spaces MAY be stripped. This message confirms reachability and latency between two clients. PING is universally implemented. Clients SHOULD implement this CTCP message. Example: Query: PING 1473523721 662865 Reply: PING 1473523721 662865 Query: PING foo bar baz Reply: PING foo bar baz A.6. SOURCE Query: SOURCE Reply: SOURCE Clients which implement this message MUST reply with a URL where the source code for the client can be found. SOURCE is rarely implemented. Clients MAY implement this CTCP message. Mikulėnas & Oakley Expires 24 November 2021 [Page 7] Internet-Draft IRC CTCP May 2021 Example: Query: SOURCE Reply: SOURCE https://weechat.org/download A.7. TIME Query: TIME Reply: TIME Clients which implement this message MUST reply with the client's local time in a human-readable format. In practice, both the format returned by ctime() and the format described in Section 3.3 of [RFC5322] are common. Earlier specifications recommended prefixing the time string with a colon, but this is no longer recommended. Clients MAY default to UTC time for privacy reasons and only respond with the local time if the user enables it. TIME is almost universally implemented. Clients MAY implement this CTCP message. Example: Query: TIME Reply: TIME Mon, 08 May 2017 09:15:29 GMT A.8. VERSION Query: VERSION Reply: VERSION Clients which implement this message MUST reply with the name and version of the client software in use. There is no specified format for the version string. Clients MAY receive more than one reply after sending a VERSION query. Clients may allow users to customise the response value for this query. VERSION is universally implemented. Clients SHOULD implement this CTCP message. Example: Query: VERSION Reply: VERSION WeeChat 1.8-dev (git: v1.7-329-g22f2fd03a) Mikulėnas & Oakley Expires 24 November 2021 [Page 8] Internet-Draft IRC CTCP May 2021 A.9. USERINFO Query: USERINFO Reply: USERINFO Clients which implement this message MUST reply with miscellaneous information about the user (typically the contents of their realname/ gecos field). USERINFO is largely obsolete. Clients MAY implement this CTCP message. Example: Query: USERINFO Reply: USERINFO fred (Fred Foobar) Appendix B. Change History [RFC Editor: Please remove this section] Changes from draft 2 (... 2021) * Removed the CTCP Types section (thanks James). * Added advice on leading spaces in messages (thanks Sadie). * Minor ABNF fix. Changes from draft 1 (July 18, 2017) * General editing, fixed mistypes. * Simplified some of the examples. Changes from draft 0 (May 29, 2017) * Added note about servers truncating CTCP messages (thanks Sadie). * Fixed misspellings and added note to TIME about previously- recommended prefix (thanks Patrick). * Mentioned how to parse/send empty ACTION messages (thanks dequis and the crew). Authors' Addresses Mantas Mikulėnas Independent Mikulėnas & Oakley Expires 24 November 2021 [Page 9] Internet-Draft IRC CTCP May 2021 Email: grawity@gmail.com Daniel Oakley (editor) ircdocs Email: daniel@danieloaks.net Mikulėnas & Oakley Expires 24 November 2021 [Page 10]