はじめに
どうも。こんにちは。
42tokyoといったところで、簡単なIRCサーバの実装を行なっています。
今回は、RFC2812 Internet Relay Chat: Client Protocol 3.1 Connection Registrationを読み、クライアントとサーバの接続処理に必要なコマンドについて学んでいきます。
以前、RFC1459 Internet Relay Chat Protocolを読んでみた。(4.1 Connection Registration)を書いたので、本記事では重複している部分の省略(参考リンクを貼り対応)を行なっています。
今回の記事で扱う範囲は、以下のとおりです。
- 3.Message details
- 3.1 Connection Registration
- 3.1.1 Password message
- 3.1.2 Nick message
- 3.1.3 User message
- 3.1.4 Oper message
- 3.1.5 User mode message
-
3.1.6 Service message(範囲外) - 3.1.7 Quit
-
3.1.8 Squit(範囲外)
- 3.1 Connection Registration
間違い等があれば、ご指摘ください。
3. Message Details
RFC1459と内容がほぼ同じなので省略
参考:RFC1459 Internet Relay Chat Protocolを読んでみた。(4.1 Connection Registration)
- ERR_NOSUCHSERVERの意味が変わったかもしれない
<server> parameterが見つからなかった。から、
ターゲットが見つからなかった。に変更か
RFC1459
Where the reply ERR_NOSUCHSERVER is listed, it means that the parameter could not be found.
RFC2812
Where the reply ERR_NOSUCHSERVER is returned, it means that the target of the message could not be found.
3.1 Connection Registration
RFC1459と内容がほぼ同じなので省略
参考:RFC1459 Internet Relay Chat Protocolを読んでみた。(4.1 Connection Registration)
- 接続と登録が成功した場合、サーバはNumeric Repliesを返す
クライアント(ユーザの場合)には、RPL_WELCOME
サービスの場合は、RPL_YOURESERVICEを返す
受信側は、この返信を受け取ることで、接続が登録されIRCネットワーク全体に知られたことを把握する。 - 応答メッセージには、登録された完全なクライアント識別子を含まなければならない [MUST]
3.1.1 Password message
Command : PASS
Parameters: <password>
Numeric Replies:
461 ERR_NEEDMOREPARAMS "<command> :Not enough parameters"
462 ERR_ALREADYREGISTRED ":Unauthorized command (already registered)"
example : PASS secretpasswordhere
RFC1459と内容がほぼ同じなので省略
参考:RFC1459 Internet Relay Chat Protocolを読んでみた。(4.1 Connection Registration)
記述がなくなった箇所
- SERVERコマンドの前に、PASSコマンドを送信すること
- パスワードは、設定ファイルに書かれたものと一致すること
3.1.2 Nick message
Command : NICK
Parameters: <nickname>
Numeric Replies:
431 ERR_NONICKNAMEGIVEN ":No nickname given"
432 ERR_ERRONEUSNICKNAME "<nick> :Erroneous nickname"
433 ERR_NICKNAMEINUSE "<nick> :Nickname is already in use"
436 ERR_NICKCOLLISION "<nick> :Nickname collision KILL from <user>@<host>"
437 ERR_UNAVAILRESOURCE "<nick/channel> :Nick/channel is temporarily unavailable"
484 ERR_RESTRICTED ":Your connection is restricted!"
Examples:
NICK Wiz
; Introducing new nick "Wiz" if session is
still unregistered, or user changing his nickname to "Wiz"
:WiZ!jto@tolsun.oulu.fi NICK Kilroy
; Server telling that WiZ changed his nickname to Kilroy.
- NICKコマンドは、ユーザのニックネーム登録と変更に使用される
3.1.3 User message
Command : USER
Parameters: <user> <mode> <unused> <realname>
Numeric Replies:
461 ERR_NEEDMOREPARAMS "<command> :Not enough parameters"
462 ERR_ALREADYREGISTRED ":Unauthorized command (already registered)"
Example:
USER guest 0 * :Ronnie Reagan
; User registering themselves with a username of "guest" and real name
"Ronnie Reagan".
USER guest 8 * :Ronnie Reagan
; User registering themselves with a username of "guest" and real name
"Ronnie Reagan", and asking to be set invisible.
- USERコマンドは、接続の最初に使用する
- パラメータは、接続する新規ユーザの情報を与える
- 各パラメータの意味は、以下のとおり
- <user> :ユーザ名
- <unused> :ホスト名
- <realname>:実名
- <mode>パラメータには、数値を与えなければならない [SHOULD]
- <mode>パラメータは、サーバへの登録時に、ユーザモードを設定するために使用する
- <mode>パラメータは、ビットマスクで、2ビットだけ意味を持つ
- ビット2は、ユーザーモード「w」を設定することを意味する
- ビット3は、ユーザーモード「i」を設定することを意味する
詳細は、3.1.5 User Modesを参照
- <realname>には、スペースを含めることができる
3.1.4 Oper message
Command: OPER
Parameters: <name> <password>
Numeric Replies:
461 ERR_NEEDMOREPARAMS "<command> :Not enough parameters"
381 RPL_YOUREOPER ":You are now an IRC operator"
491 ERR_NOOPERHOST ":No O-lines for your host"
464 ERR_PASSWDMISMATCH ":Password incorrect"
Example:
OPER foo bar
; Attempt to register as an operator using a username of "foo" and "bar" as the password.
- 通常のユーザは、OPERコマンドを使用してoperator権限を取得する
- operator権限を得るには、<name>と<password>の組み合わせが必須 [REQUIRED]
- 成功すると、ユーザは新しいユーザ・モードを示すMODEメッセージ(3.1.5参照)を受け取る
3.1.5 User mode message
Command : MODE
Parameters: <nickname>
*( ( "+" / "-" ) *( "i" / "w" / "o" / "O" / "r" ) )
Numeric Replies:
461 ERR_NEEDMOREPARAMS "<command> :Not enough parameters"
502 ERR_USERSDONTMATCH ":Cannot change mode for other users"
501 ERR_UMODEUNKNOWNFLAG ":Unknown MODE flag"
221 RPL_UMODEIS "<user mode string>"
Examples:
MODE WiZ -w
; Command by WiZ to turn off reception of WALLOPS messages.
MODE Angel +i
; Command from Angel to make herself invisible.
MODE WiZ -o
; WiZ 'deopping' (removing operator status).
- MODEコマンドは、メッセージ送信者と、<nickname>パラメータの値が一致した場合のみ受け付けること [MUST]
- フラグのないMODEメッセージが送られてきたときは、サーバは、<nickname>の現在の設定を返す
a - [away] ユーザは、退席状態になる;
i - [invisible] ユーザは、不可視状態になる;
w - [wallops] ユーザは、Wallopsを受け取るようになる;
r - [restrict] ユーザは、接続を制限される;
o - [operator] ユーザは、operator権限が与えられる;
O - [operator] ユーザは、local operator権限が与えられる;
s - [server notice] ユーザは、サーバーからの通知を受け取るようになる;
※ 後に追加のモードが利用可能になるかもしれません。
- 「a」 flagは、ユーザがMODEコマンドを使って切り替えてはいけない [SHALL NOT]
代わりにAWAYコマンドを使うことが必須 [REQUIRED] - ユーザーが「+o or +O」 flagを指定した場合、
オペレータ権限を付与する行為なので、無視されるべき [SHOULD]
オペレータ権限の付与は、OPERコマンドだけで行うこと - ただし「-o or -O」 flagを指定して、オペレータ権限を外すことはできる
- ユーザーが「-r」 flagを指定した場合、制限を外す行為なので無視されるべき [SHOULD]
- ただし「+r」 flagを指定して、「ドッピング」(deopping)することはできる
「deopping(ドッピング)」とは、オペレータ権限を外すこと - 「r」 flagは、通常、管理上の理由から接続時にサーバーが設定する
- 「+r」 flagで、制限される内容や範囲は、実装次第
- 制限されたユーザは、一般的に以下のことができない
- ニックネームの変更
- チャンネルでチャンネルオペレータのステータスを利用
- 「s」 flagは、廃止されたが、まだ使用してもかまわない [MAY]
3.1.7 Quit
Command: QUIT
Parameters: [ <Quit Message> ]
Numeric Replies:
None.
Example:
QUIT :Gone to have lunch ; Preferred message format.
:syrk!kalt@millennium.stealth.net QUIT :Gone to have lunch
; User syrk has quit IRC to have lunch.
- クライアント・セッションはquitメッセージで終了する
- サーバはクライアントにERRORメッセージを送ることで確認する
12.Full Copyright Statement
Copyright (C) The Internet Society (2000). All Rights Reserved.
This document and translations of it may be copied and furnished to others,
and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any kind,
provided that the above copyright notice and this paragraph are included on
all such copies and derivative works.
However, this document itself may not be modified in any way,
such as by removing the copyright notice or references to the Internet Society
or other Internet organizations, except as needed for the purpose of developing
Internet standards in which case the procedures for copyrights defined in
the Internet Standards process must be followed, or as required to
translate it into languages other than English.The limited permissions granted above are perpetual and will not be revoked by
the Internet Society or its successors or assigns.This document and the information contained herein is provided on an "AS IS" basis and
THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.Acknowledgement
Funding for the RFC Editor function is currently provided by the Internet Society.
さいごに
RFC1459と比較すると、コマンドに渡すパラメータやNumeric Repliesが多少変更されているようでした。
ありがとうございました。
参考