IRC by Telnet

Introduction

Internet Relay Chat (IRC) is an application layer protocol that facilitates communication in the form of text.

And this chapter is a demo of irc client chat using telnet utility.

The rfc RFC2812 which does not specify an Internet standard of any kind.

So Please ref the standard rfc RFC1459.

For, secure connection to IRC servers, ref RFC7194.

Message Format in BNF

<message>  ::= [':' <prefix> <SPACE> ] <command> <params> <crlf>
<prefix>   ::= <servername> | <nick> [ '!' <user> ] [ '@' <host> ]
<command> ::= <letter> { <letter> } | <number> <number> <number>
<SPACE>    ::= ' ' { ' ' }
<params>   ::= <SPACE> [ ':' <trailing> | <middle> <params> ]
<middle>   ::= <Any *non-empty* sequence of octets not including SPACE
               or NUL or CR or LF, the first of which may not be ':'>
<trailing> ::= <Any, possibly *empty*, sequence of octets not including
               NUL or CR or LF>
<crlf>     ::= CR LF

Notes

NOTES:

  1)    <SPACE> is consists only of SPACE character(s) (0x20).
        Specially notice that TABULATION, and all other control
        characters are considered NON-WHITE-SPACE.

  2)    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.

  3)    The fact that CR and LF cannot appear in parameter strings is
        just artifact of the message framing. This might change later.

  4)    The NUL character is not special in message framing, and
        basically could end up inside a parameter, but as it would
        cause extra complexities in normal C string handling. Therefore
        NUL is not allowed within messages.

  5)    The last parameter may be an empty string.

  6)    Use of the extended prefix (['!' <user> ] ['@' <host> ]) must
        not be used in server to server communications and is only
        intended for server to client messages in order to provide
        clients with more useful information about who a message is
        from without the need for additional queries.

Message Length Limit

IRC messages are always lines of characters terminated with a CR-LF
   (Carriage Return - Line Feed) pair, and these messages shall not
   exceed 512 characters in length, counting all characters including
   the trailing CR-LF. Thus, there are 510 characters maximum allowed
   for the command and its parameters. There is no provision for
   continuation message lines.  See section 7 for more details about
   current implementations.

Commands to initialize a connection

  • Pass
>telent chat.freenode.net 6667
Trying 38.229.70.22...
Connected to chat.freenode.net.
Escape character is '^]'.
:card.freenode.net NOTICE * :*** Looking up your hostname...
:card.freenode.net NOTICE * :*** Checking Ident
:card.freenode.net NOTICE * :*** Couldn't look up your hostname
:card.freenode.net NOTICE * :*** No Ident response
>pass none
  • Nick
>nick testnick
  • User
>user guest 8 * :guest's full description

:hitchcock.freenode.net 001 testnick :Welcome to the freenode Internet Relay Chat Network testnick
:hitchcock.freenode.net 002 testnick :Your host is hitchcock.freenode.net[31.13.222.109/6667], running version ircd-seven-1.1.3
:hitchcock.freenode.net 003 testnick :This server was created Tue Jul 21 2015 at 18:44:23 UTC
:hitchcock.freenode.net 004 testnick hitchcock.freenode.net ircd-seven-1.1.3 DOQRSZaghilopswz CFILMPQSbcefgijklmnopqrstvz bkloveqjfI
:hitchcock.freenode.net 005 testnick CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQScgimnprstz CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode KNOCK STATUSMSG=@+ CALLERID=g :are supported by this server
:hitchcock.freenode.net 005 testnick CASEMAPPING=rfc1459 CHARSET=ascii NICKLEN=16 CHANNELLEN=50 TOPICLEN=390 ETRACE CPRIVMSG CNOTICE DEAF=D MONITOR=100 FNC TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: :are supported by this server
:hitchcock.freenode.net 005 testnick EXTBAN=$,ajrxz WHOX CLIENTVER=3.0 SAFELIST ELIST=CTU :are supported by this server
:hitchcock.freenode.net 251 testnick :There are 158 users and 82770 invisible on 27 servers
:hitchcock.freenode.net 252 testnick 24 :IRC Operators online
:hitchcock.freenode.net 253 testnick 11 :unknown connection(s)
:hitchcock.freenode.net 254 testnick 52231 :channels formed
:hitchcock.freenode.net 255 testnick :I have 5333 clients and 1 servers
:hitchcock.freenode.net 265 testnick 5333 5991 :Current local users 5333, max 5991
:hitchcock.freenode.net 266 testnick 82928 95450 :Current global users 82928, max 95450
:hitchcock.freenode.net 250 testnick :Highest connection count: 5992 (5991 clients) (956663 connections received)
:hitchcock.freenode.net 375 testnick :- hitchcock.freenode.net Message of the Day -
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- Welcome to hitchcock.freenode.net in Sofia, Bulgaria, EU, kindly sponsored by
:hitchcock.freenode.net 372 testnick :- Neterra Communications (www.neterra.net)
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- HITCHCOCK, SIR ALFRED [1899 - 1980] Born in Essex,
:hitchcock.freenode.net 372 testnick :- England, Sir Alfred Hitchcock was a noted film director
:hitchcock.freenode.net 372 testnick :- and producer. Over a long career he pioneered many modern
:hitchcock.freenode.net 372 testnick :- techniques in film-making, made more than 50 feature films,
:hitchcock.freenode.net 372 testnick :- and influenced many present-day directors and producers.
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- Welcome to freenode - supporting the free and open source
:hitchcock.freenode.net 372 testnick :- software communities since 1998.
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- By connecting to freenode you indicate that you have read and
:hitchcock.freenode.net 372 testnick :- accept our policies as set out on http://www.freenode.net
:hitchcock.freenode.net 372 testnick :- freenode runs an open proxy scanner. Please join #freenode for
:hitchcock.freenode.net 372 testnick :- any network-related questions or queries, where a number of
:hitchcock.freenode.net 372 testnick :- volunteer staff and helpful users will be happy to assist you.
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- You can meet us at FOSSCON (http://www.fosscon.org) where we get
:hitchcock.freenode.net 372 testnick :- together with like-minded FOSS enthusiasts for talks and
:hitchcock.freenode.net 372 testnick :- real-life collaboration.
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- We would like to thank Private Internet Access
:hitchcock.freenode.net 372 testnick :- (https://www.privateinternetaccess.com/) and the other
:hitchcock.freenode.net 372 testnick :- organisations that help keep freenode and our other projects
:hitchcock.freenode.net 372 testnick :- running for their sustained support.
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 372 testnick :- In particular we would like to thank the sponsor
:hitchcock.freenode.net 372 testnick :- of this server, details of which can be found above.
:hitchcock.freenode.net 372 testnick :-
:hitchcock.freenode.net 376 testnick :End of /MOTD command.
:testnick MODE testnick :+i


:NickServ!NickServ@services. NOTICE testnick :testnick is not a registered nickname.

As you see above, following User command, is a long MOTD message.

8.5 Establishing a server to client connection

   Upon connecting to an IRC server, a client is sent the MOTD (if
   present) as well as the current user/server count (as per the LUSER
   command).  The server is also required to give an unambiguous message
   to the client which states its name and version as well as any other
   introductory messages which may be deemed appropriate.

   After dealing with this, the server must then send out the new user's
   nickname and other information as supplied by itself (USER command)
   and as the server could discover (from DNS/authentication servers).
   The server must send this information out with NICK first followed by
   USER.

Mode operations

  • Mode
    see footnode

Send message

  • PrivMsg
>privmsg testnick :hello, i am here too.

If trying to send message to multiple buddies, use , to separate:

>privmsg testnick,testnick1,testnick2 :hi, all
  • Notice
>notice testnick  :hello, i am here too.

Chat on a channel

  • Join
>join #testch
:[email protected] JOIN #testch
:wolfe.freenode.net MODE #testch +ns
:wolfe.freenode.net 353 testnick @ #testch :@testnick
:wolfe.freenode.net 366 testnick #testch :End of /NAMES list.
:services. MODE #testch -o testnick
:wolfe.freenode.net NOTICE #testch :*** Notice -- TS for #testch changed from 1445409153 to 1241476800
:services. MODE #testch +t-s
:ChanServ!ChanServ@services. JOIN #testch
:services. MODE #testch +o ChanServ

Now, you can send (broadcast) message on this channel:

>privmsg #testch :hello, this is a long sentence with many SPACES, prefixed by colon
  • Part

To leave a channel, use Part command.

>part #testch
:testnick!~guest@58.000.000.000 PART #testch

Close a connection

  • Quit
>quit
:[email protected] QUIT :Client Quit
ERROR :Closing Link: 58.000.000.000 (Client Quit)
Connection closed by foreign host.

Excellent C-language library

libircclient official

Open Source Daemon

Wiki
UnrealIrcD official
download

Channel management

Channel Manage
Channel Modes

DCC(Direct Client-to-Client)

Wiki

你可能感兴趣的:(internet,relay,chat)