Internet Relay Chat(IRC) Guide(2): Internet Relay Chat

Yeshin Lee
8 min readMar 5, 2022

이전 포스트에 이어 작성되었습니다.

IRC is one of the earliest network protocols for text messaging and multi-participant chatting. It was created in 1988 and, despite the emergence of more sophisticated messaging protocols (including open standards like XMPP and SIP/SIMPLE, and proprietary protocols such as Microsoft’s MSNP, AOL’s OSCAR, and Skype), IRC remains a popular standard and still sees heavy use in certain communities, specially the open source software community.

IRC는 텍스트 메시징과 다중-참여자 채팅을 위한 가장 초창기 네트워크 프로토콜 중 하나입니다. 1988년에 만들어졌고, 더욱 정교한 메시징 프로토콜(XMPP와 SIP/SIMPLE 같은 오픈 표준과 업체 고유 프로토콜인 Microsoft의 MSNP, AOL의 OSCAL 그리고 Skype)의 출현에도, 여전히 인기 있는 표준으로 남아있고 특정 커뮤니티, 특히 오픈 소스 소프트웨어 커뮤니티에서 비중 있게 사용되는 것을 볼 수 있습니다.

기본 IRC 구조

The basic architecture of IRC, shown in the figure above, is fairly straightforward. In the simplest case, there is a single IRC server to which multiple IRC clients can connect to. An IRC client connects to the server with a specific identity. Most notably, each client must choose a unique nickname, or “nick”. Once a client is connected, it can communicate one-to-one with other users. Additionally, clients can run commands to query the server’s state (e.g., to obtain a list of connected users, or to obtain additional details about a specific nick). IRC also supports the creation of chat rooms called channels for one-to-many communication. Users can join channels and send messages to the channel; these messages will, in turn, be sent to every user in the channel.

위 그림에서 보이듯이, IRC의 기본 구조는 아주 간단합니다. 간단한 예로, 여러 IRC 클라이언트가 연결할 수 있는 단일 IRC 서버가 있습니다. IRC 클라이언트는 특정 ID로 서버에 연결합니다. 특히, 각 클라이언트는 고유한 닉네임, 또는 “nick”을 무조건 선택해야 합니다. 일단 클라이언트가 연결되면, 다른 사용자와 일대일 통신을 할 수 있습니다. 추가로, 클라이언트는 명령어로 서버의 상태(예를 들어, 연결된 사용자의 리스트를 포함하거나 특정 닉네임에 대한 추가적인 설명을 포함하는)를 조회할 수 있습니다. 또한, IRC는 일대다 통신을 위해 채널이라고 불리는 채팅방을 만드는 것을 지원합니다. 사용자는 채널에 들어가고 채널에 메시지를 보낼 수 있습니다; 그 메시지들은 차례대로 채널의 모든 사용자에게 보내질 것입니다.

다중 서버 IRC 구조

IRC also supports the formation of server networks, where multiple servers form a tree of connections to support more clients and provide greater capacity. Servers in the same network share information about local events (e.g., a new client connects, a user connected to a given server joins a channel, etc.) so that all servers will have a copy of the same global state. In this project, we will only consider the case where there is a single IRC server.

또한 IRC는 서버 네트워크(더 많은 클라이언트를 지원하고 더 큰 용량을 제공하기 위해 여러 서버로 형성한 연결 트리)형식을 지원합니다. 같은 네트워크에 있는 서버들은 local 이벤트(예를 들어, 새 클라이언트 연결, 특정 서버에 연결된 사용자가 채널에 들어가는 등) 정보들을 공유합니다. 따라서 모든 서버는 동일하게 전역 상태의 복사본을 갖게 됩니다. 이 프로젝트에서, 우리는 단일 IRC 서버가 있는 경우만 고려할 것입니다.

The IRC Protocol

The IRC protocol used by IRC servers and clients is a text-based TCP protocol. Originally specified in 1993 [RFC1459], it was subsequently specified in more detail in 2000 through the following RFCs:

IRC 서버와 클라이언트가 사용한 IRC 프로토콜은 텍스트 기반 TCP 프로토콜입니다. 원래 1993년에 지정되었고, RFC를 따르면서 2000년에 더 자세히 명시되었습니다.

- [RFC2810] Internet Relay Chat: Architecture. This document describes the overall architecture of IRC.

  • [RFC2810] Internet Relay Chat: Architecture. 이 문서는 IRC의 전체 구조를 알려줍니다.

- [RFC2811] Internet Relay Chat: Channel Management. This document describes how channels are managed in IRC.

  • [RFC2811] Internet Relay Chat: Channel Management. 이 문서는 채널이 IRC에서 어떻게 관리되는지 알려줍니다.

- [RFC2812] Internet Relay Chat: Client Protocol. This document describes the protocol used between IRC clients and servers (sometimes referred to as the “client-server” protocol)

  • [RFC2812] Internet Relay Chat: Client Protocol. 이 문서는 IRC 클라이언트와 서버 사이에 사용되는 프로토콜(가끔 “클라이언트-서버” 프로토콜로 불리는)을 알려줍니다.

- [RFC2813] Internet Relay Chat: Server Protocol. This document describes the “server-server” protocol used between IRC servers in the same network.

  • [RFC2813] Internet Relay Chat: Server Protocol. 이 문서는 동일한 네트워크의 IRC 서버들 사이에 사용되는 “서버-서버” 프로토콜을 알려줍니다.

You are not expected to read all of these documents. More specifically:

- We recommend you do read all of [RFC2810], as it will give you a good sense of what the IRC architecture looks like. You may want to give it a cursory read at first, and revisit it as you become more familiar with the finer points of the IRC protocol.
- In the second assignment you will implement a subset of [RFC2812]. We suggest you read [RFC2812 §1] and [RFC2812 §2]. For the remainder of the RFC, you should only read the sections relevant to the parts of the IRC protocol you will be implementing.
- In the third assignment you will implement a subset of the functionality described in [RFC2811], which will require implementing additional parts of [RFC2812]. We suggest you hold off on reading [RFC2811] until we reach the third assignment; if you do want to read the introductory sections, take into account that we will only be supporting “standard channels” in the “#” namespace, and that we will not be supporting server networks.
- In the fifth assignment, you will implement a subset of [RFC2813], which will require implementing and updating some parts of [RFC2812]. You will not be dealing with server-to-server connections until the fifth assignment, so you can safely skip reading [RFC2813] until then.

[추후 번역] 모든 문서를 읽는 것은 기대하지 않습니다. 더 구체적으로 말하자면:

Finally, you should take into account that, although IRC has an official specification, most IRC servers and clients do not conform to these RFCs. Most (if not all) servers do not implement the full specification (and even contradict it in some cases), and there are many features that are unique to specific implementations. In this project, we will produce an implementation that is partially compliant with these RFCs, and sufficiently compliant to work with some of the main IRC clients currently available

마지막으로, IRC가 공식 사양을 가지고 있지만, 대부분의 IRC 서버와 클라이언트는 이러한 RFC를 따르지 않는다는 점을 고려해야 합니다. 대부분(전부는 아닌)의 서버는 전체 사양을 구현하지 않으며(때에 따라 모순되기도 하는), 특정 구현에만 고유한 많은 기능이 있습니다. 이 프로젝트에서는 이러한 RFC를 부분적으로 준수하고 현재 사용 가능한 주요 IRC 클라이언트 일부와 충분히 호환되도록 구현해볼 것입니다.

In the remainder of this section, we will see an overview of the message format used in IRC. Then, in the next section, we will see several example communications (involving multiple messages between a client and a server).

이 섹션의 나머지 부분에서는, IRC를 사용한 메시지 형식의 개요를 볼 것입니다. 그런 후, 다음 섹션에서, (클라이언트와 서버 사이의 여러 메시지를 포함한) 몇 개의 통신 예시를 볼 것입니다.

Message format

IRC clients and servers communicate by sending plain ASCII messages to each other over TCP. The format of these messages is described in [RFC2812 §2.3], and can be summarized thusly:

IRC 클라이언트와 서버는 TCP를 통해 서로에게 일반 ASCII 메시지를 보내면서 통신합니다. 이 메시지 형식은 [RFC2812 2.3]에 설명되어 있으며, 다음과 같이 요약할 수 있습니다:

- The IRC protocol is a text-based protocol, meaning that messages are encoded in plain ASCII. Although not as efficient as a pure binary format, this has the advantage of being fairly human-readable, and easy to debug just by reading the verbatim messages exchanged between clients and servers.

  • IRC 프로토콜은 텍스트 기반 프로토콜로, 메시지가 일반 ASCII로 인코딩되는 것을 의미합니다. 순수 바이너리 형식만큼 효율적이지 않지만, 클라이언트와 서버 사이에 교환되는 메시지를 그대로 읽는 것만으로 이해할 수 있고 디버깅하기 쉬운 이점이 있습니다.

- A single message is a string of characters with a maximum length of 512 characters. The end of the string is denoted by a CR-LF (Carriage Return — Line Feed) pair (i.e., “\r\n”). There is no null terminator. The 512 character limit includes this delimiter, meaning that a message only has space for 510 useful characters.

  • 단일 메시지는 최대 길이가 512자인 문자열입니다. 문자열의 끝은 CR-LF(Carriage Return — Line Feed) 쌍(“\r\n”)으로 표기되어 있습니다. Null 종료자는 없습니다. 512자 제한은 이 구분자를 포함하며, 메시지는 510자의 유용한 문자만 사용할 수 있다는 것을 의미합니다.

- The IRC specification includes no provisions for supporting messages longer than 512 characters, although many servers and clients support non-standard solutions (including ignoring the 512 limit altogether). In our implementation, any message with more than 510 characters (not counting the delimiter) will be truncated, with the last two characters replaced with “\r\n”.

  • 비록 많은 서버와 클라이언트가 비표준 솔루션(512자 제한 무시 포함)을 지원하지만, IRC 표준은 512자 문자가 초과하는 것을 지원하는 규정이 없습니다. 우리의 구현물에서는, 510자 문자가 넘어가는(구분자는 포함되지 않습니다) 메시지는 잘리고 마지막 두 문자는 “\r\n”으로 대체됩니다.

- A message contains at least two parts: the command and the command parameters. There may be at most 15 parameters. The command and the parameters are all separated by a single ASCII space character. The following are examples of valid IRC messages:

NICK amy

WHOIS doctor

MODE amy +o

JOIN #tardis

QUIT
  • 메시지는 적어도 두 파트를 포함합니다: 명령어와 명령어 매개 변수. 최대 15개의 매개 변수가 있을 것입니다. 명령어와 매개 변수는 단일 ASCII 공백 문자로 구분됩니다. 유효한 IRC 메시지의 예시입니다.

When the last parameter is prefixed with a colon character, the value of that parameter will be the remainder of the message (including space characters). The following are examples of valid IRC messages with a “long parameter”:

PRIVMSG rory :Hey Rory...

PRIVMSG #cmsc23300 :Hello everybody

QUIT :Done for the day, leaving
  • 마지막 매개변수의 접두사가 콜론(:) 문자라면, 매개변수의 값은 공백을 포함한 메시지 전부입니다. 다음은 “긴 매개변수”로 유효한 IRC 메시지의 예시입니다.

Some messages also include a prefix before the command and the command parameters. The presence of a prefix is indicated with a single leading colon character. The prefix is used to indicate the origin of the message. For example, when a user sends a message to a channel, the server will forward that message to all the users in the channel, and will include a prefix to specify the user that sent that message originally. We will explain the use of prefixes in more detail in the next section.

또한 일부 메시지는 명령어와 명령어 매개변수 전에 접두사가 포함되어 있습니다. 접두사의 존재는 단일로 앞에 있는 콜론(:) 문자로 표시됩니다. 그 접두사는 메시지의 출처를 나타내는데 사용됩니다. 예를 들어, 사용자가 채널에 메시지를 보낼 때, 서버는 채널의 모든 사용자에게 메시지를 보낼 것이고, 원본 메시지를 보낸 사용자를 명시하기 위해 접두사를 포함할 것입니다. 다음 섹션에서 더욱 자세하게 접두사 사용법을 설명할 것입니다.

The following are examples of valid IRC messages with prefixes:

:borja!borja@polaris.cs.uchicago.edu PRIVMSG #cmsc23300 :Hello everybody

:doctor!doctor@baz.example.org QUIT :Done for the day, leaving
  • 다음은 접두사가 있는 유효한 IRC 메시지의 예시입니다.

Replies

The IRC protocol includes a special type of message called a reply. When a client sends a command to a server, the server will send a reply (except in a few special commands where a reply should not be expected). Replies are used to acknowledge that a command was processed correctly, to indicate errors, or to provide information when the command performs a server query (e.g., asking for the list of users or channels).

IRC 프로토콜은 reply라는 특정 타입의 메시지를 포함하고 있습니다. 클라이언트가 서버에 명령어를 보낼 때, 서버는 (응답이 오면 안 되는 몇 개의 특정 명령어를 제외하고) 응답을 보낼 것입니다. 응답은 명령어가 올바르게 처리되었는지 알거나, 에러를 나타내거나, 또는 명령어가 서버 쿼리(사용자나 채널 목록 요청)를 수행할 때 정보를 제공하는데 사용됩니다.

A reply is a message with the following characteristics:

응답은 다음 특징을 가진 메시지입니다.

It always includes a prefix.

  • 접두사를 항상 포함해야 합니다.

The command will be a three-digit code. The full list of possible replies is specified in [RFC2812 §5].

  • 명령어는 세 자리 코드일 것입니다. 가능한 응답의 전체 목록은 [RFC2812 5]에 명시되어 있습니다.

The first parameter is always the target of the reply, typically a nick.

  • 첫 번째 매개변수는 항상 응답의 대상입니다. 일반적으로 닉네임입니다.

The following are examples of valid IRC replies:

:irc.example.com 001 borja :Welcome to the Internet Relay Network borja!borja@polaris.cs.uchicago.edu

:irc.example.com 433 * borja :Nickname is already in use.

:irc.example.org 332 borja #cmsc23300 :A channel for CMSC 23300 students

다음은 유효한 IRC 응답의 예시입니다.

--

--