Log in | Back to darenet.org

P10 Protocol

(Channels)
 
(40 intermediate revisions not shown)
Line 1: Line 1:
{{NeedUpdate}}
{{NeedUpdate}}
-
This document is based on Undernet's P10 protocol specification as of ircu2.10.11. It aims to be a practical guide for implementing and maintaining the protocol, with DareNET's extensions, not just a reference manual; therefore, it can be considered a "work in progress," continually being updated.
+
This document is based on Undernet's P10 protocol specification, as of ircu2.10.12. It aims to be a practical guide for implementing and maintaining the protocol, with DareNET's extensions, not just as a reference manual; therefore, it can be considered a "work in progress," continually being updated.
-
== Terminology ==
+
== Concepts ==
-
Definitions of some commonly used terms in this document.
+
The P10 protocol uses a scheme of "Numerics" to uniquely identify a server or client within the network. Each server has its own unique numeric (0 -> 4095), and each client has its own numeric within that server (0 -> 262,143).
-
* '''Byte''' - A unit of 8 bits of data.
+
The numerics are encoded into a Base64 stream to maintain human readable data flow and reduce the size of the messages. The Base64 character set used by the P10 protocol is included below, this defines all valid characters allowed in a Base64 numeric with "A" representing 0 and "]" representing 63.
-
 
+
-
* '''Character''' - One byte, notated as a decimal number in the range 0-255, or a printable ASCII character (example: 65, 'A').
+
-
 
+
-
* '''Char''' - Character.
+
-
 
+
-
* '''String''' - A sequence of bytes.
+
-
 
+
-
* '''Space''' - ASCII 32 ($20).
+
-
 
+
-
* '''CR''' - Carriage return. '\r' (ASCII 13)
+
-
 
+
-
* '''LF''' - Line feed (also known as 'new line'). '\n' (ASCII 10)
+
-
 
+
-
* '''CRLF''' - Carriage return + Line feed (<CRLF>).
+
-
 
+
-
* '''NULL''' - Character 0.
+
-
 
+
-
* '''EOL''' - End of Line (line termination).
+
-
 
+
-
* '''Parser''' - The implementation which receives and processes the stream.
+
-
 
+
-
* '''Generate''' - Sending data which has not been received, as opposed to passing data on which has been received.
+
-
 
+
-
* '''TS''' - Timestamp. An ASCII decimal notation of a date+time since [[Wikipedia:Unix time|Unix epoch]].
+
-
 
+
-
* '''Nick''' - Refers to a nickname.
+
-
 
+
-
* '''Numnick''' = Refers to a client's numeric nickname.
+
-
 
+
-
"Must", "must not", "should", "may" are as described in [http://www.ietf.org/rfc/rfc2119.txt RFC2119]. Interpret "disallowed" as "must not."
+
-
 
+
-
Hexadecimal numbers in this document use pascal notation: a $ prefix. The number of hex digits (nibbles) represents the size of the data; for example, a byte can be anything between $00 and $ff.
+
-
 
+
-
== Stream of Data, Lines, Line Termination ==
+
-
 
+
-
P10 is a 'text' protocol, that is, it is human readable and writable. Communication between two servers is done by means of a stream of bytes. The stream must be connected, reliable and ordered. So, the definition of the stream would be as follows:
+
-
 
+
-
<code><line><EOL><line><EOL> ... <junk></code>
+
-
 
+
-
=== Line termination (EOL) ===
+
-
 
+
-
When sending, line termination may be either <CRLF> or <LF>. It ''must not'' be anything else.
+
-
 
+
-
The parser ''must'' accept <LF> and <CRLF> as line termination. It ''may'' accept any other sequence of <CR> and <LF> as EOL. It ''must not'' parse anything else as line termination.
+
-
 
+
-
=== Line ===
+
-
 
+
-
A line (also commonly referred to as a "message") is defined as a sequence of characters, minimum length being 1 byte, maximum length 510 bytes, ''not'' including the EOL (which makes a total of 512 bytes). If a parser encounters a line with a length of 0 bytes, it ''must'' be silently ignored, and it ''must not'' do anything else. A line which is longer than the maximum length is disallowed.
+
-
 
+
-
NULL, CR and LF are disallowed in a line, any other character is allowed.
+
-
 
+
-
{{Newuser_note | text= A parser can encounter a line which contains a NULL character. It ''may'' terminate the line at the first NULL character (removing anything after and including the first NULL character from the line).}}<br>
+
-
 
+
-
=== Junk ===
+
-
 
+
-
Any data between the last EOL and the end of the stream. It ''must not'' be parsed as a line.
+
-
 
+
-
== P10 Base64 ==
+
-
 
+
-
The P10 protocol uses a modified base64 notation for numeric nicks, and for the IP parameter in the <code>NICK</code> message. It uses the following set of 64 characters, in the sequence from 0 to 63 (henceforth referred to as the P10 base64 characters):
+
<code>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]</code>
<code>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]</code>
-
A P10 base64 string is a sequence of P10 base64 characters, with a minimum length of 1 character. It ''must not'' contain any other character. If the string has a length of more than one character, the string begins with the most significant character and ends with the least significant character.
+
Server numerics consist of two (2) characters, with the minimum, 0, being represented by "AA", and the maximum, 4095, being represented by "]]". Client numerics are three (3) characters long, with the minimum, 0, being represented by "AAA", and the maximum, 262,143, being represented by "]]]".
-
{{Newuser_note | text= P10 base64 strings are case sensitive.}}<br>
+
The unique identifier of a client on the network, referred to as a numnick, is five (5) characters long and consists of a combination of both the server and client numeric in the format SSCCC.
-
== Numerics ==
+
As an example, consider a server "irc.darenet.org" which has a numeric of 2, translating to "AC" in Base64. On this server exists a client, which has been allocated the numeric 63, translating to "AA]" in Base64. Therefore, the numnick of this client on the network is "ACAA]". From this, we can determine which server the message came from, as well as the client who sent it.
-
The P10 protocol uses a scheme of "numerics" to uniquely identify a client or server within the network. Each server has its own unique numeric (0 -> 4095) and each client has its own numeric within that server (0 -> 262,143).
+
These numerics are used to prefix every message issued on the stream except for the initial <code>PASS</code> or <code>SERVER</code> message, which are not prefixed. Therefore, every message that can be received from a server will consist of the format:
-
These numerics are encoded into a base64 string to maintain human readable data flow, and to reduce the size of messages.
+
<code>[NUMERIC PREFIX] [TOKEN] [DATA]</code>
-
Server numerics consist of 2 characters, with the minimum, 0, being represented by "AA", and the maximum, 4095, being represented by "]]". Client numerics are 3 characters in length, with the minimum, 0, being represented by "AAA", and the maximum, 262,143, being represented by "]]]". The unique identifier (known as a numnick) of a client on the network consists of a combination of both the server and client numeric in the format SSCCC - a total of 5 base64 characters.
+
For example:
-
 
+
-
A server has a maximum client numeric, which is sent in the <code>SERVER</code> message. A client numeric on a server, ANDed with the maximum server numeric, must be unique. For example, if the server YY's max client numeric is YYA[[ (4095), clients YYBXX and YYCXX cannot exist at the same time. Doing this would result in a "numeric collision", which is a protocol violation. However, such numerics which occupy the same "slot" are not identical - a message sent to use YYBXX in this example ''must not'' reach user YYCXX.
+
-
 
+
-
Taken what we know from above, let's go through an example. Consider a server "peanuts.darenet.org" which as a numeric of 2, translating to "AC" in base64. On this server exists a client, whom has been allocated the numeric 63 (which translates to "AA]" in base64); therefore, the unique identifier of this client on the network is "ACAA]". From this, we can determine which server the message came from, as well as the client who sent it.
+
-
 
+
-
{{Newuser_note | text= The P10 protocol defines two types of numerics: short numerics and extended numerics. For the purpose of this document, we have chosen to use extended numerics, as implemented by Undernet, DareNET and most other networks utilizing the P10 protocol.}}<br>
+
-
 
+
-
== Syntax of a line/message ==
+
-
 
+
-
The source, command, and parameters are separated by spaces.
+
-
 
+
-
<code><source> <command> [<parameters>]</code>
+
-
 
+
-
One ''must'' send only the short command token. One ''must'' parse both the short command token and its long unabbreviated name, and if one does, they ''must'' be considered equivalent; for example <code>N</code> = <code>NICK</code>. So if I say "receives a <code>NICK</code> message" it may actually be a <code>N</code> token.
+
-
 
+
-
Command tokens are uppercase. One ''must'' not send lowercase command tokens. One ''may'' parse them.
+
-
 
+
-
If source begins with a colon, it (except for the colon) is the name; otherwise, it is a numeric. One ''must'' only send messages with a numeric source prefix, except for the initial <code>PASS</code> and <code>SERVER</code> command, which are not prefixed.
+
-
 
+
-
If the source does not exist, if the command is <code>SQUIT</code> or <code>KILL</code> (or their respective short token), the message ''must'' be parsed anyway, with the directly linked server from which the message came as the source; otherwise, the message ''must'' be ignored.
+
-
 
+
-
If the source exists but the message comes from the wrong direction, it ''must'' be ignored. The direction of a source is defined as the link over which the corresponding message was received, that originally introduced the source. A link is the connection with another server.
+
-
 
+
-
A message ''may'' have up to 15 parameters. Parameters are separated by spaces.
+
-
The last parameter ''may'' be prefixed by a colon; this allows the last parameter to have spaces, or to have a length of 0 characters. For example: <code><source> <command> <param1> <paramN> :<last parameter></code>. A parser ''must'' be able to parse messages with colon prefixed last parameter, and without. For example, parameters "a b c" and "a b :c" are equivalent.
+
<code>A[A5j P ABAAA :Foo.</code>
== Command Token Table ==
== Command Token Table ==
Line 113: Line 29:
The below table lists all acceptable messages, along with their relevant "token", which is used in server<>server communication. The aim of tokenization is to reduce the bandwidth used during network communication by reducing the total length of common message identifiers.
The below table lists all acceptable messages, along with their relevant "token", which is used in server<>server communication. The aim of tokenization is to reduce the bandwidth used during network communication by reducing the total length of common message identifiers.
-
{| class="widefat" width="40%" style="font-size: 85%; text-align: left;"
+
{| class="simpletable" width="100%" style="text-align: left;"
|-
|-
-
! style="background-color: #333; color: #fff;" width="200px"|Token
+
! style="text-align: left;" width="200px"|Token
-
! style="background-color: #333; color: #fff;"|Command/Message
+
! style="text-align: left;"|Command/Message
|-
|-
Line 431: Line 347:
|-
|-
-
| SLIS
+
| style="background-color: #f6f5f5;"|SLIS
-
| SERVLIST
+
| style="background-color: #f6f5f5;"|SERVLIST
|-
|-
-
| SSET
+
| style="background-color: #f6f5f5;"|SSET
-
| SERVSET
+
| style="background-color: #f6f5f5;"|SERVSET
|-
|-
Line 600: Line 516:
=== Server Registration and Authentication ===
=== Server Registration and Authentication ===
-
After a TCP connection has been established, the server initially introduces itself via a "<code>PASS</code>" message as follows:
+
After a TCP has been established, the server initially introduces itself via a <code>PASS</code> message, as follows:
-
<code>PASS :<password></code>
+
<code>PASS :[PASSWORD]</code>
-
<password> is simply a plain text password that is compared with the password present in the destination servers configuration file, and is used to confirm credentials after "<code>SERVER</code>" message has been received, as follows:
+
''password'' is simply a plain text password that is compared with the password present in the destination servers configuration file, and is used to confirm credentials after the <code>SERVER</code> message has been received, as follows:
-
<code>SERVER <server_name> <hop_count> <boot_time> <link_time> <protocol> <numeric/maxconn> :<description></code>
+
<code> SERVER [SERVER_NAME] [HOP_COUNT] [BOOT_TS] [LINK_TS] [PROTOCOL] [NUMERIC/MAXCONN] [+FLAGS] :[DESCRIPTION]</code>
-
For example:
+
For example
<pre>
<pre>
-
1      2                   3 4        5        6  7    8
+
1      2               3 4        5        6  7    8 9
-
SERVER peanuts.darenet.org 1 933022556 947908144 J10 AA]]] :[127.0.0.1] A DareNET Client Server.</pre>
+
SERVER irc.darenet.org 1 933022556 947908144 J10 AA]]] + :[127.0.0.1] A DareNET Client Server.</pre>
-
 
+
-
Notes:
+
# The <code>SERVER</code> message indicates this connection wishes to introduce a new server to the network.
# The <code>SERVER</code> message indicates this connection wishes to introduce a new server to the network.
-
# '''<serv_name>''' - The name of the server you are introducing, ''must'' be a valid server name.
+
# The name of the server being introduced.
-
# '''<hop_count>''' - The hop count of the server you are introducing; this is always 1 when you are introducing yourself.
+
# The hop count of the server being introduced; this is always 1 if you are introducing yourself.
-
# '''<boot_time>''' - The epoch timestamp specifying when the ircd was started.
+
# The epoch timestamp specifying when the ircd was started.
-
# '''<link_time>''' - The epoch timestamp specifying the time the server initiated the link to the network.
+
# The epoch timestamp specifying when the server initiated the link to the network.
-
# '''<protocol>''' - The protocol identifier for this server.
+
# The protocol identifier of the server being introduced.
-
## If the server being introduced has not yet successfully synced its database with the network (i.e., completed its net.burst), then the protocol token should be prefixed with a J, sintead of a P (e.g., J10) to indicate it is currently still joining the network.
+
## This identifier informs the network which protocol it is compliant with. If it is P10 compliant, the value for this parameter will be "P10".
-
## The protocol token should always be JXX when the server is introducing itself.
+
## If the server being introduced has not yet successfully synced its database with the network (i.e., completed its net.burst), then the value should be prefixed with a "J" instead of a "P" (e.g., J10) to indicate it is currently still joining the network.
-
# The numeric and maximum connections identifier for this server.
+
## The protocol should always be prefixed with a J (e.g., JXX) when the server is introducing itself.
-
## This token is formatted exactly the same as a client numeric is formatted. The first 2 characters identify the server's numeric, whilst in this situation, the final 3 characters define the maximum number of clients that this server can hold (and more importantly, the maximum number of numerics it will generate). This is always one less than a power of two, because the server uses this as a bitmask. A server can give out a higher numeric than this; however, it will be ANDed with this number to find its entry slot. The reason for this is so a server which is near the maximum number of clients can give out more numerics than it's using to prevent a new client getting a numeric that was used only seconds ago, and maybe get messages destined to the old user.
+
# The numeric, and maximum connections identifier for this server.
 +
## This numeric is formatted exactly the same as a numnick. The first two (2) characters identify the server's numeric, whilst in this situation, the final three (3) characters define the maximum number of clients that this server can hold (and more importantly, the maximum number of numerics it will generate). This is always one less than power of two, because the server uses this as a bitmask. A server can give out a higher numeric than this; however, it will be ANDed with this number to find its entry slot. The reason for this is so a server, which is near the maximum number of clients, can give out more numerics than it's using to prevent a new client getting a numeric that was used only seconds ago, and possibly get messages destined to the old user.
## The example "AA]]]" shows that this is a server with numeric 0, which will generate client numerics up to 262,143.
## The example "AA]]]" shows that this is a server with numeric 0, which will generate client numerics up to 262,143.
-
# '''<description>''' - This final parameter simply consists of a textual description of the server prefixed by a colon. This is displayed in a clients <code>WHOIS</code> line, as well as in the <code>LINKS</code> reply. By convention, if this is a leaf server, it contains the servers IP in square brackets at the beginning of the string.
+
# Possibly one or more flags indicating the type of server this is.
 +
## Allowed values: + (normal server), +h (hub, hidden in /map), +s (services). It may also be "0" for implementations which do not support the flags parameter.
 +
# The final parameter simply consists of a textual description of the server prefixed by a colon. This is displayed in a client's <code>WHOIS</code> line, as well as in the <code>LINKS</code> reply. By convention, if this is a leaf server, it contains the server's IP in square brackets at the beginning of the string.
-
==== Boot timestamp ====
+
=== Network Database Resynchronization ===
-
As mentioned above, this is an epoch timestamp indicating when the ircd was started. It can be seen as the age of the net/net fragment. If a boot TS in a received <code>SERVER</code> message is younger than OLDEST_TS (780000000), and older than the existing boot TS, the existing boot TS is overwritten with the received boot TS. The boot TS can be used for making decisions.
+
As discussed above, the connection is established by sending a <code>PASS</code> message, and a <code>SERVER</code> message. One ''may'' send <code>PING</code> messages, and one ''must'' reply with the proper <code>PONG</code> messages (in long/"non P10" format). One ''must not'' send anything else in this stage. One ''may'' ignore other messages on the receiving end, such as any status notices.
-
==== Link timestamp ====
+
Once the connection (server link) has been established and verified, the next step is to synchronize various databases between the two servers. A net burst is sent to tell the other end of the link about the complete network state. The server which initiated the connection ''should'' wait until it has received the <code>SERVER</code> message from the accepting server, before it sends the net burst.
-
As mentioned above, this is a n epoch timestamp specifying the time the server initiated the link to the network. Both ends of a link have the same link TS for that link: it is the link TS parameter in the <code>SERVER</code> message sent from the accepting server to the connecting server. When a server link is established, one of the two servers ''may'' adjust its clock so that the link TS of the received <code>SERVER</code> message becomes "now". It does so if it does not have RELIABLE_CLOCK set, if the received boot TS is older than the existing boot TS, or if the received boot TS is equal to the existing boot TS and the server initiated the connection.
+
The messages that form the net burst ''must'' be generated in an order which allows the receiving server to create the objects and relationships represented by each message, at the moment the message is received. So, first server objects must be created and then the client objects connected to that server, and so on. Likewise, a server that is connected closer must be created first before a server behind it can be introduced, etc.
-
==== Server Collision ====
+
Because servers may be rejected as function of which servers are introduced, it makes most sense to first introduce all servers before introducing clients. This in order to avoid processing parts of a net burst, creating client objects, which need to be destructed a second later again.
-
=== Network Database Resynchronization ===
+
Therefore, the net burst is constructed as follows:
-
After the connection (link) has been established and verified, the next step is to synchronize the database of client / server / channel information between the two servers.
+
==== Servers ====
-
====SERVER Messages====
+
Server details are transmitted via <code>SERVER</code> messages, similar to the initial introduction message, with the following format:
-
Server details are transmitted via "SERVER" messages, similar to the initial introduction message, with the following format:
+
<code><source> S <server_name> <hop_count> <boot_time> <link_time> <protocol> <numeric/maxconn> <+flags> :<description></code>
-
'''<code>[OWNING SERVER PREFIX] S [SERVERNAME] [HOPCOUNT] [START TIME] [LINK TIME] [PROTOCOL] [NUMERIC/MAXCONN] 0 :[DESCRIPTION]</code>'''
+
The syntax of this message is nearly identical to the originally received server message, with the exception being that the message is prefixed (i.e., <source>) with a numeric to indicate which server sent this message (and also, therefore, which hub this new server is linked too). For implementations that do not support the flags parameter, a fixed 0 should be used in its place.
-
The syntax of this message is almost identical to the originally received server message, with the exception being that the message is prefixed with a numeric to indicate which server sent this message (and also, therefore, which hub this new server is linked too). There is also a fixed "0" present before the ''Description'' field, which is just a placeholder for future use and currently unused.
+
A <code>SERVER</code> message is sent for all servers on the network. Before a <code>SERVER</code> message for a given server is sent, a <code>SERVER</code> message for any server in front of that server ''must'' have already been sent. This can be implemented by first sending <code>SERVER</code> messages for all servers with hop count 1, then for all servers with hop count 2, and so on.
-
====NICK Messages====
+
==== Glines ====
-
Client information is transmitted via "NICK" messages, of the following format:
+
Any currently unexpired global Glines are transmitted via <code>GLINE</code> messages along with lastmod TS.
-
'''<code>[NUMERIC PREFIX] N [NICK] [HOPCOUNT] [TIMESTAMP] [USERNAME] [HOST] <+modes> [BASE64 IP] [NUMERIC] :[USERINFO]</code>'''
+
==== Zlines ====
-
For example:
+
Any currently unexpired global Zlines are transmitted via <code>ZLINE</code> messages along with lastmod TS.
-
'''<pre>
+
-
1  2 3      4 5        6    7            8    9      10    11
+
-
AF N Client1 1 947957573 User userhost.net +oiwg DAqAoB AFAAA :Generic Client.</pre>'''
+
-
''Notes:''
+
==== Shuns ====
-
# The numeric of the server sending this message. (hence, owning this client).
+
Any currently unexpired global Shuns are transmitted via <code>SHUN</code> messages along with lastmod TS.
-
# The "NICK" token.
+
-
# The nickname of this client, currently max 30 chars.
+
-
# The "Hopcount" of this client, i.e: how many servers away it is on.
+
-
# The epoch timestamp indicating when the user was created.
+
-
# The "User" part of the user@host mask.
+
-
# the "Host" part of the user@host mask.
+
-
# [Optional]: User modes. If present, this is always +<user modes for this client>. Note that the special +r usermode is followed by the client's account name; see the documentation for ACCOUNT.
+
-
# The real IP address of this client, a Base64 encoded 32bit int.
+
-
# This client's numeric, in SSCCC format.
+
-
# Free format user info line.
+
-
====BURST Messages====
+
==== Jupes ====
-
Channel details and membership information is synchronized on one (or more) "BURST" messages for each channel that exists, formatted as follows:
+
Any currently unexpired JUPEs are transmitted via <code>JUPE</code> messages with the following format:
-
'''<code>[NUMERIC PREFIX] B [CHANNEL] [CREATION TIMESTAMP] <+MODES> <ARG1> <ARG2> [MEMBER LIST] <:%BANS></code>'''
+
<code><source> JU * <+|-><server_name> <lifetime> <lastmod> :<reason></code>
For example:
For example:
-
'''<pre>
 
-
1  2 3        4        5      6  7  8                                        9
 
-
AZ B #darenet 949217470 +tinkl key 56 AAAAA,AAAAB,AAAAC,ABAAA,ABAAB,ABAAC,ACAAA :%*!*@*.net</pre>'''
 
-
''Notes:''
+
<pre>
-
# The numeric of the server sending this message.
+
2 3 4                  5        6        7
-
# The "BURST" token.
+
AZ JU * +juped.darenet.org 000003593 955419707 :Juped Server</pre>
-
# The name of the channel to which this data belongs. Currently #Channel and +Channel names can be sent in a BURST message, &Channels are not because by definition they are local to the server.
+
-
# The epoch timestamp indicating when the channel was created.
+
-
# [Optional]: Channel Modes.
+
-
##The channel may have a number of modes set, a swell as relevant mode arguments in the following 2 parameters.
+
-
# [Optional]: Channel Key, this parameter is present if the channel modes contain a "k" mode.
+
-
# [Optional]: Channel Limit, this parameter is present if the channel modes contain a "l" mode.
+
-
# A comma seperated list of client numerics, with the following specific formatting rules to indicate +o, +v and +ov channel members.
+
-
##Numerics can have the following symbols appended on them; ":ohv", ":oh", ":ov", ":hv", ":v", ":h" or ":o". These indicate that this numeric is either Opped (:o), Halfoped (:h) Voiced (:v) and so on. This state applies to the numeric it is attached too, and all subsequent numerics until another state is encountered. For Example: AAABA:ov, AAABB:o,AAABC,AAABD,AAABE:v,AAABZ. Here, AAABA is both opped, and voiced, AAABB, AAABC and AAABD are opped leaving AAABE and AAABZ voiced.
+
-
##  The first numeric of the member list will always contain a state symbol.
+
-
# A space seperated list of bans present in the channel. The start of the ban stream is indicated by a ":%", everything following the ":%" is the ban list.
+
-
For Example:<br>
+
Notes:
-
<nowiki>:%*!*@*.foobar.net another!ban@*.com *!*fred@a.host.co.uk</nowiki>
+
-
Would add the following bans to the channel:<br>
+
# '''<source>''' - The numeric of the server sending this message.
-
<nowiki>*!*@*.foobar.net</nowiki><br>
+
# The <code>JUPE</code> message token.
-
another!ban@*.com<br>
+
# The target that ''should'' apply this JUPE (always "*" during bursts).
-
<nowiki>*!*fred@a.host.co.uk</nowiki>
+
# '''<server_name''' - The name of the server to JUPE, prefixed with a "+" if the JUPE is active, or with a "-" if its not.
 +
# '''<lifetime>''' - The remaining absolute lifetime of the JUPE, expressed in seconds.
 +
# '''<lastmod>''' - An epoc timestamp of the last time the JUPE was modified.
 +
# '''<reason>''' - The reason the JUPE was applied.
-
''NOTE: We BURST excepts in the same manner.''
+
==== Welcomes ====
-
If the length of a BURST message exceeds the maximum lengh of a line (512 characters) then the remaining channel members/bans are sent in subsequent BURST lines. The subsequent burst lines are only used to add additional members to the channel, and if necessary, channel bans. There will be no "Mode" parameters present. A sample additional burst line would be:
+
Any global Welcomes are transmitted via <code>WELCOME</code> messages along with lastmod TS.
-
<font color="blue">'''<code>AZ BURST #darenet 949217470 ACAAB:o,ACAAD :%*!*another@*.ban.com</code>'''</font>
+
====Clients====
-
====JUPE Messages====
+
Information on all clients/users is transmitted via <code>NICK</code> messages, of the following format:
-
Any currently unexpired JUPEs are transmitted via "JUPE" messages with the following format:
+
<code><source> N <nick> <hop_count> <timestamp> <username> <host> [+modes] <base64 IP> <numeric> :<gecos></code>
-
'''<code>[NUMERIC PREFIX] JU * (+|-)[SERVER NAME] [LIFETIME] [LAST MOD] :[REASON]</code>'''
+
For example:
 +
 
 +
<pre>
 +
1  2 3      4 5        6    7            8    9      10    11
 +
AF N Client1 1 947957573 User userhost.net +oiwg DAqAoB AFAAA :Generic Client.</pre>
 +
 
 +
Notes:
 +
 
 +
# '''<source>''' - The numeric of the server sending this message (hence, owning this client).
 +
# The <code>NICK</code> message token.
 +
# '''<nick>''' - The nickname of this client, currently max 30 characters.
 +
# '''<hop_count>''' - The hop count of this client (i.e., how many servers away it is on).
 +
# '''<timestamp>''' - An epoch timestamp indicating when the user was created.
 +
# '''<username>''' - The "user" part of the user@host mask.
 +
# '''<host>''' - The "host" part of the user@host mask.
 +
# [OPTIONAL] '''<+modes>''' - User modes. If present, this is always "+<user modes for this client>. The special +r usermode is followed by the client's account name; see documentation for <code>ACCOUNT</code>.
 +
# '''<base64 IP>''' - The real IP address of this client, a base64 encoded 32bit int.
 +
# '''<numeric>''' - The client's numeric (numnick), in SSCCC format.
 +
# '''<gecos>''' - Free form user info line.
 +
 
 +
====Channels====
 +
 
 +
Channel details and membership information is synchronized through one (or more) <code>BURST</code> messages for each channel that exists, which are formatted as follows:
 +
 
 +
<code><source> B <channel> <creation_ts> [+modes] [arg1] [arg2] <member_list> [:%bans [~ excepts]]</code>
For example:
For example:
-
'''<pre>
+
<pre>
-
1  2 3 4                 5         6         7
+
1  2 3       4        5      6   7 8                                        9       
-
AZ JU * +juped.darenet.org 000003593 955419707 :Juped Server</pre>'''
+
AZ B #darenet 949217470 +tinkl key 56 AAAAA,AAAAB,AAAAC,ABAAA,ABAAB,ABAAC,ACAAA :%*!*@*.net ~ *!*@*.com</pre>  
-
''Notes:''
+
Notes:
-
# The numeric of the server sending this message.
+
-
# The "JUPE" token.
+
-
# The target that should apply this JUPE (always "*" during bursts).
+
-
# The name of the server to JUPE, prefixed with a "+" if the JUPE is active, or with a "-" if it is not.
+
-
# The remaining absolute lifetime of the JUPE, expressed in seconds.
+
-
# The last time the JUPE was modified.
+
-
# The reason the JUPE was applied.
+
-
=== Summary ===
+
# '''<source>''' - The numeric of the server sending this message.
 +
# The <code>BURST</code> command token.
 +
# '''<channel>''' - The name of the channel to which this data belongs to. Currently #Channel and +Channel names can be sent in a <code>BURST</code> message; however, &Channels are not, since by definition they are local to the server.
 +
# '''<creation_ts>''' An epoch timestamp indicating when the channel was created.
 +
# [OPTIONAL] '''[+modes]''' - Channel modes.
 +
## The channel may have a number of modes set. as well as relevant mode arguments in the following 2 parameters.
 +
# [OPTIONAL] '''[arg1]''' - Channel key, this parameter is present if the channel modes contain a "k" mode.
 +
# [OPTIONAL] '''[arg2]''' - Channel limit, this parameter is present if the channel modes contain a "l" mode.
 +
# '''<member_list>''' - A comma separated list of client numerics, with the following specific formatting rules to indicate +o, +h, +v and +ohv channel members.
 +
## Numerics can have the following symbols appended on then: ":ohv", ":oh", ":ov", ":hv", ":v", ":h" or ":o". These indicate that this numeric is either opped (:o), halfoped, (:h), voiced (:v) or a combination of the three. This state applies to the numeric it is attached to, and all subsequent numerics until another state is encountered. For example: AAABA:ov,AAABB:o,AAABC,AAABD,AAABE:v,AAABZ. In this example, AAABA is both opped and voiced; AAABB, AAABC and AAABD are opped leaving AAABE and AAABZ voiced.
 +
## The first numeric of the member list will always contain a state symbol.
 +
# [OPTIONAL] '''[:%bans [~ excepts]]''' - A space separated list of bans and/or excepts present in the channel. The start of the ban stream is indicated by a ":%', with everything following being the ban list, up until a single "~", which indicates the start of an except stream, with everything following being the except list.
 +
## For example: "<code>:%*!*@*.foobar.net another!ban@*.com ~ *!*fred@a.host.co.uk</code>" which would add the following bans to the channel "*!*@*.foobar.net and another!ban@*.com, and the following except *!*fred@a.host.co.uk.
-
The following table summarizes the sequence of events that occur when a server connects (links) to another server. S1 is our server, while S2 is a HUB on the target network.
+
If the length of a <code>BURST</code> message exceeds the maximum length of a line (512 characters), then the remaining channel members/bans/excepts are sent in subsequent <code>BURST</code> messages. The subsequent <code>BURST</code> messages are only used to add additional members to the channel, and if necessary, channel bans and excepts. There will be no "mode" parameters presents. A sample additional <code>BURST</code> message is shown below:
-
S1: Sends Password.<br>
+
<pre>AZ B #darenet 949217470 ACAAB:o,ACAAD :%*!*another@*.ban.com</pre>
-
S1: Sends initial SERVER message.
+
-
''S2 Confirms S1 has the correct credentials, and if so, proceeds. If not, S1 is squit with a relevant reason.''
+
=== Nick collisions ===
-
S2: Sends Password.<br>
+
Each received <code>NICK</code> message with a server as source introduces a new client, while each <code>NICK</code> message with a client as source changes the name of a given client. The name (i.e., nickname) of a client ''must'' be unique on the network. Nick collisions are a result of an incoming <code>NICK</code> message, when an existing user already has the nick.
-
S2: Sends initial SERVER message.
+
-
''S1 Confirms S2 has the correct credentials, and if so, proceeds. If not, S2 is squit with a relevant reason.''
+
If the collision is with a local client which has yet to fully register with the server (i.e., has yet to be broadcasted to the other servers), then this local client is removed.
-
'''''The following occurs asynchronously, however it is shown separately below for simplicity.'''''
+
Otherwise:
-
S1: Sends all the servers it is aware of as a stream of SERVER messages.<br>
+
* Both users are killed if their TS (last nick change) is equal, or
-
S1: Sends all the clients it is aware of as a stream of NICK messages.<br>
+
* the user with the higher TS is killed if the user@host differs, or
-
S1: Sends the database of channel states on the network, as a stream of BURST messages.<br>
+
* the user with the lower TS is killed if the user@host are equal.
-
S1: Sends all the jupes it is aware of as a stream of JUPE messages.<br>
+
-
S1: Sends a END_OF_BURST token (EB) to indicate it has finished sending.  
+
-
S2: Sends all the servers it is aware of as a stream of SERVER messages.<br>
+
Since the target of the <code>KILL</code> message is the numeric, it is safe to send them in any needed direction; no risk of killing the wrong user. If the collision is with a local client, also send a <code>KILL</code> upstream (this for security reasons and might not really be necessary).
-
S2: Sends all the clients it is aware of as a stream of NICK messages.<br>
+
-
S2: Sends the database of channel states on the network, as a stream of BURST messages.<br>
+
-
S2: Sends all the jupes it is aware of as a stream of JUPE messages.<br>
+
-
S2: Sends a END_OF_BURST token (EB) to indicate it has finished sending.
+
-
S2: Sends an EOB_ACK token (EA) to indicate it has succesfully recieved the END_OF_BURST from S1<br>
+
=== Local channels ===
-
S1: Sends an EOB_ACK token (EA) to indicate it has succesfully recieved the END_OF_BURST from S2
+
-
'''''Example Session:'''''
+
Local channel names (those starting with an ampersand, "&") are "disallowed" in the P10 protocol, being a server<>server protocol. One ''must'' take care to not send any messages about local channels to other servers, and to not accept them when parsing messages.
 +
 
 +
=== Summary ===
 +
 
 +
The following table summarizes the sequence of events that occur when a server connects (links) to another server. S1 is our server, while S2 is a HUB on the target network.
 +
 
 +
{| class="widefat"
 +
| S1: Sends Password.
 +
|-
 +
| S1: Sends initial <code>SERVER</code> message.
 +
|-
 +
| style="background-color: #f6f5f5;"|''S2 confirms S1 has the correct credentials, and if so, proceeds. If not, S1 is squit with a relevant reason.''
 +
|-
 +
| S2: Sends Password.
 +
|-
 +
| S2: Sends initial <code>SERVER</code> message.
 +
|-
 +
| style="background-color: #f6f5f5;"|''S1 confirms S2 has the correct credentials, and if so, proceeds. If not, S2 is squit with a relevant reason.''
 +
|-
 +
| style="background-color: #f6f5f5;"|''The following occurs asynchronously; however, it is shown separately below for simplicity.''
 +
|-
 +
| S1: Sends all the servers it is aware of as a stream of <code>SERVER</code> messages.
 +
|-
 +
| S1: Sends all the global glines it is aware of as a stream of <code>GLINE</code> messages.
 +
|-
 +
| S1: Sends all the global zlines it is aware of as a stream of <code>ZLINE</code> messages.
 +
|-
 +
| S1: Sends all the global shuns it is aware of as a stream of <code>SHUN</code> messages.
 +
|-
 +
| S1: Sends all the jupes it is aware of as a stream of <code>JUPE</code> messages.
 +
|-
 +
| S1: Sends all the global welcomes it is aware of as a stream of <code>WELCOME</code> messages.
 +
|-
 +
| S1: Sends all the clients it is aware of as a stream of <code>NICK</code> messages.
 +
|-
 +
| S1: Sends the database of channel states on the network, as a stream of <code>BURST</code> messages.
 +
|-
 +
| S1: Sends a <code>END_OF_BURST</code> token (<code>EB</code>) to indicate it has finished sending.
 +
|-
 +
| S2: Sends all the servers it is aware of as a stream of <code>SERVER</code> messages.
 +
|-
 +
| S2: Sends all the global glines it is aware of as a stream of <code>GLINE</code> messages.
 +
|-
 +
| S2: Sends all the global zlines it is aware of as a stream of <code>ZLINE</code> messages.
 +
|-
 +
| S2: Sends all the global shuns it is aware of as a stream of <code>SHUN</code> messages.
 +
|-
 +
| S2: Sends all the jupes it is aware of as a stream of <code>JUPE</code> messages.
 +
|-
 +
| S2: Sends all the global welcomes it is aware of as a stream of <code>WELCOME</code> messages.
 +
|-
 +
| S2: Sends all the clients it is aware of as a stream of <code>NICK</code> messages.
 +
|-
 +
| S2: Sends the database of channel states on the network, as a stream of <code>BURST</code> messages.
 +
|-
 +
| S2: Sends a <code>END_OF_BURST</code> token (<code>EB</code>) to indicate it has finished sending.
 +
|-
 +
| S2: Sends an <code>EOB_ACK</code> token (<code>EA</code>) to indicate it has succesfully recieved the <code>END_OF_BURST</code> from S1
 +
|-
 +
| S1: Sends an <code>EOB_ACK</code> token (<code>EA</code>) to indicate it has succesfully recieved the <code>END_OF_BURST</code> from S2
 +
|}
 +
 
 +
'''Example Session:'''
<pre>
<pre>
[WRITE]: PASS :54321
[WRITE]: PASS :54321
Line 790: Line 765:
== Continuous Operation ==
== Continuous Operation ==
 +
----
 +
This section provides details of the various messages that can be sent after successfully linking to the network, and maintaining a synchronized state.
-
This section provides details of the various messages that can be sent after successfully linking to the network, and synchronizing the channel/user database.
+
=== Server State Operations ===
-
=== Channel State Operations ===
+
As discussed earlier, a server object is created when a new server is introduced by means of the <code>SERVER</code> message. A server object is destructed when an <code>SQUIT</code> message is received.
-
There are a number of messages that can modify the state of a channel, these are:
+
==== SQUIT ====
-
====MODE====
+
Removes a server from the network.
-
The MODE message can modify channel modes and bans, and also give or take operator/halfop//voice status from channel members.
+
Syntax:<pre>
 +
  1        2        -1
 +
SQ <target> <link_ts> [:<reason>]</pre>
-
'''<code>[NUMERIC PREFIX] M [CHANNEL] (+|-)[MODESTRING] <MODESTRING PARAMETERS></code>'''
+
* '''<target>''' - The name of the target server (not its numeric), without wildcards.
 +
* '''<link_ts>''' - If the <link_ts> parameter is equal to the link timestamp of the target server, or equal to 0, it applies; otherwise, the <code>SQUIT</code> message is ignored.
 +
* [OPTIONAL] - '''[:reason]''' - An optional reason indicating why the server is being disconnected.
-
For example:
+
Example:
-
'''<pre>
+
<pre> AZ SQ server2.darenet.org 1278767962 :Performing updates.</pre>
-
1    2 3        4        5
+
-
AZAAA M #darenet +stinlko 500 TestKey BAC
+
-
</pre>
+
-
''Notes:''
+
The message is propagated to all links except the link where the message cam from, and the target server if it is directly linked.
-
# The numeric of the user issuing this MODE command. It can be assumed this user is opped on the target channel.
+
If a <code>SQUIT</code> message is to be sent to a directly linked target, the <target> parameter will be the name of the local server. In this case, ircu sends a link timestamp of 0.
-
# The "MODE" token.
+
-
# The target channel.
+
-
# The "Mode string".
+
-
## This consists of up to 6 '+' or '-' (add or remove) prefixed channel modes. (If no '+' or '-' are specified, a '+' is assumed unless a '-' has been encountered previously in the mode string). For example, '+s+t+n-l-io' is a valid mode string, as is '+stnmov'.
+
-
# The "Mode string Parameters".
+
-
## This is a matching list of parameters to the modes supplied in the "Modestring".
+
-
## ''Example:'' If the Modestring is "+stnlo", a typical parameter string would be "500 AZAAA". The first 3 modes, 's', 't' and 'n' do not require parameters, so non are present. The following two, 'l' and 'o' both require parameters, so they are 500 and AZAAA respectively (This sets the channel limit to 500 users, and ops the numeric AZAAA).
+
-
NOTE: The "MODE" message is also used to modify a client's user modes, not just channel modes.
+
==== SETTIME ====
-
====OPMODE====
+
Sets the "clock" of one or all servers.
-
The OPMODE message is identical in syntax to the MODE message, however it will only ever have an operator as the source. It is likely that the source of this mode will not have ops in the target channel, but it should succeed never the less.
+
Syntax:<pre>
 +
  1          2
 +
SE <timestamp> [<target_numeric>]</pre>
-
====JOIN====
+
* '''<timestamp>''' - An epoch timestamp of the current time.
 +
* [OPTIONAL] '''[<target_numeric>]''' - The numeric of the target server. This parameter is present if an oper issued "/settime <timestamp> <target server numeric>". In which case, the change will only apply to that specific server. If this parameter is not present, the change will be broadcasted to all servers.
-
====PART====
+
Servers with RELIABLE_CLOCK will change the timestamp parameter of any <code>SETTIME</code> message to its own perception of what the current time is.
-
====KICK====
+
Example:
 +
<pre>AF SE 1278767962</pre>
-
====TOPIC====
+
=== Channel State Operations ===
-
====CLEARMODE====
 
-
 
-
'''<code>[NUMERIC PREFIX] CM [CHANNEL] [MODES]</code>'''
 
=== Client State Operations ===
=== Client State Operations ===
-
 
-
====NICK====
 
-
 
-
'''<code>AZAAA N Nick2 955423230</code>'''
 
-
 
-
====MODE====
 
-
 
-
'''<code>AZAAA M Nick2 :+odi</code>'''
 
-
 
-
====ACCOUNT====
 
-
 
-
'''<code>AX AC AZAAA oper</code>'''
 
-
 
-
The ACCOUNT message provides a way for servers, such as the channel service server, to set the account name information that is associated with a client. Once set, it cannot be unset or changed, and will be propagated in NICK during net bursts using the special user mode +r followed by the account name.
 
-
 
-
=== Channel/Client Messaging ===
 
-
 
-
====PRIVMSG====
 
-
 
-
====NOTICE====
 
-
 
-
====CNOTICE====
 
-
 
-
====CPRIVMSG====
 
==Programmers reference: Client/Server Structures==
==Programmers reference: Client/Server Structures==

Current revision as of 18:42, 30 June 2012

Important
This page needs an update. Information posted here has been viewed as incorrect, incomplete, or out of date. Anyone is welcome to correct these flaws if this page has not been locked. Otherwise, contact a Support Team member and give them notice of this issue. Thank you.


This document is based on Undernet's P10 protocol specification, as of ircu2.10.12. It aims to be a practical guide for implementing and maintaining the protocol, with DareNET's extensions, not just as a reference manual; therefore, it can be considered a "work in progress," continually being updated.

In This Guide:

Concepts

The P10 protocol uses a scheme of "Numerics" to uniquely identify a server or client within the network. Each server has its own unique numeric (0 -> 4095), and each client has its own numeric within that server (0 -> 262,143).

The numerics are encoded into a Base64 stream to maintain human readable data flow and reduce the size of the messages. The Base64 character set used by the P10 protocol is included below, this defines all valid characters allowed in a Base64 numeric with "A" representing 0 and "]" representing 63.

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]

Server numerics consist of two (2) characters, with the minimum, 0, being represented by "AA", and the maximum, 4095, being represented by "]]". Client numerics are three (3) characters long, with the minimum, 0, being represented by "AAA", and the maximum, 262,143, being represented by "]]]".

The unique identifier of a client on the network, referred to as a numnick, is five (5) characters long and consists of a combination of both the server and client numeric in the format SSCCC.

As an example, consider a server "irc.darenet.org" which has a numeric of 2, translating to "AC" in Base64. On this server exists a client, which has been allocated the numeric 63, translating to "AA]" in Base64. Therefore, the numnick of this client on the network is "ACAA]". From this, we can determine which server the message came from, as well as the client who sent it.

These numerics are used to prefix every message issued on the stream except for the initial PASS or SERVER message, which are not prefixed. Therefore, every message that can be received from a server will consist of the format:

[NUMERIC PREFIX] [TOKEN] [DATA]

For example:

A[A5j P ABAAA :Foo.

Command Token Table

The below table lists all acceptable messages, along with their relevant "token", which is used in server<>server communication. The aim of tokenization is to reduce the bandwidth used during network communication by reducing the total length of common message identifiers.

Token Command/Message
AT ACCEPT
AC ACCOUNT
AD ADMIN
ALIST ALIST
LL ASLL
A AWAY
BC BCAST
B BURST
CH CHALLENGE
CC CHECK
CM CLEARMODE
CLOSE CLOSE
CN CNOTICE
COMMANDS COMMANDS
CR COPYRIGHT
CO CONNECT
CP CPRIVMSG
C CREATE
F CREDITS
DE DESTRUCT
DS DESYNC
DIE DIE
DLIST DLIST
DNS DNS
EB END_OF_BURST
EA EOB_ACK
Y ERROR
EX EXEMPT
EWEBIRC EWEBIRC
FA FAKE
FINGERPRINT FINGERPRINT
GET GET
GL GLINE
GLOBOPS GLOBOPS
HASH HASH
HELP HELP
F INFO
I INVITE
IR IRCOPS
ISON ISON
J JOIN
JU JUPE
K KICK
D KILL
LI LINKS
LIST LIST
LU LUSERS
MAP MAP
MK MARK
MKPASSWD MKPASSWD
M MODE
MO MOTD
NACHAT NACHAT
E NAMES
N NICK
O NOTICE
OPER OPER
OM OPMODE
L PART
PA PASS
G PING
Z PONG
POST POST
P PRIVMSG
PRIVS PRIVS
PROTO PROTO
PROTOCTL PROTOCTL
PUT PUT
Q QUIT
RB REBURST
REHASH REHASH
RESET RESET
RESTART RESTART
RML RMLINE
RI RPING
RO RPONG
ST SCAST
S SERVER
SLIS SERVLIST
SSET SERVSET
SET SET
SH SETHOST
SE SETTIME
SU SHUN
U SILENCE
SMO SMO
SNO SNO
SQUERY SQUERY
SQ SQUIT
R STATS
SVI SVINFO
SID SVSIDENT
SI SVSINFO
SJ SVSJOIN
SM SVSMODE
SN SVSNICK
SO SVSNOOP
SP SVSPART
SX SVSQUIT
SW SWHOIS
TI TIME
T TOPIC
TR TRACE
UHELP UHELP
UP UPING
USER USER
USERHOST USERHOST
USERIP USERIP
V VERSION
WC WALLCHOPS
WA WALLOPS
WU WALLUSERS
WV WALLVOICES
WATCH WATCH
WEBIRC WEBIRC
H WHO
W WHOIS
X WHOWAS
ZL ZLINE

Registration and Synchronization

Server Registration and Authentication

After a TCP has been established, the server initially introduces itself via a PASS message, as follows:

PASS :[PASSWORD]

password is simply a plain text password that is compared with the password present in the destination servers configuration file, and is used to confirm credentials after the SERVER message has been received, as follows:

SERVER [SERVER_NAME] [HOP_COUNT] [BOOT_TS] [LINK_TS] [PROTOCOL] [NUMERIC/MAXCONN] [+FLAGS] :[DESCRIPTION]

For example

1      2               3 4         5         6   7     8 9
SERVER irc.darenet.org 1 933022556 947908144 J10 AA]]] + :[127.0.0.1] A DareNET Client Server.
  1. The SERVER message indicates this connection wishes to introduce a new server to the network.
  2. The name of the server being introduced.
  3. The hop count of the server being introduced; this is always 1 if you are introducing yourself.
  4. The epoch timestamp specifying when the ircd was started.
  5. The epoch timestamp specifying when the server initiated the link to the network.
  6. The protocol identifier of the server being introduced.
    1. This identifier informs the network which protocol it is compliant with. If it is P10 compliant, the value for this parameter will be "P10".
    2. If the server being introduced has not yet successfully synced its database with the network (i.e., completed its net.burst), then the value should be prefixed with a "J" instead of a "P" (e.g., J10) to indicate it is currently still joining the network.
    3. The protocol should always be prefixed with a J (e.g., JXX) when the server is introducing itself.
  7. The numeric, and maximum connections identifier for this server.
    1. This numeric is formatted exactly the same as a numnick. The first two (2) characters identify the server's numeric, whilst in this situation, the final three (3) characters define the maximum number of clients that this server can hold (and more importantly, the maximum number of numerics it will generate). This is always one less than power of two, because the server uses this as a bitmask. A server can give out a higher numeric than this; however, it will be ANDed with this number to find its entry slot. The reason for this is so a server, which is near the maximum number of clients, can give out more numerics than it's using to prevent a new client getting a numeric that was used only seconds ago, and possibly get messages destined to the old user.
    2. The example "AA]]]" shows that this is a server with numeric 0, which will generate client numerics up to 262,143.
  8. Possibly one or more flags indicating the type of server this is.
    1. Allowed values: + (normal server), +h (hub, hidden in /map), +s (services). It may also be "0" for implementations which do not support the flags parameter.
  9. The final parameter simply consists of a textual description of the server prefixed by a colon. This is displayed in a client's WHOIS line, as well as in the LINKS reply. By convention, if this is a leaf server, it contains the server's IP in square brackets at the beginning of the string.

Network Database Resynchronization

As discussed above, the connection is established by sending a PASS message, and a SERVER message. One may send PING messages, and one must reply with the proper PONG messages (in long/"non P10" format). One must not send anything else in this stage. One may ignore other messages on the receiving end, such as any status notices.

Once the connection (server link) has been established and verified, the next step is to synchronize various databases between the two servers. A net burst is sent to tell the other end of the link about the complete network state. The server which initiated the connection should wait until it has received the SERVER message from the accepting server, before it sends the net burst.

The messages that form the net burst must be generated in an order which allows the receiving server to create the objects and relationships represented by each message, at the moment the message is received. So, first server objects must be created and then the client objects connected to that server, and so on. Likewise, a server that is connected closer must be created first before a server behind it can be introduced, etc.

Because servers may be rejected as function of which servers are introduced, it makes most sense to first introduce all servers before introducing clients. This in order to avoid processing parts of a net burst, creating client objects, which need to be destructed a second later again.

Therefore, the net burst is constructed as follows:

Servers

Server details are transmitted via SERVER messages, similar to the initial introduction message, with the following format:

<source> S <server_name> <hop_count> <boot_time> <link_time> <protocol> <numeric/maxconn> <+flags> :<description>

The syntax of this message is nearly identical to the originally received server message, with the exception being that the message is prefixed (i.e., <source>) with a numeric to indicate which server sent this message (and also, therefore, which hub this new server is linked too). For implementations that do not support the flags parameter, a fixed 0 should be used in its place.

A SERVER message is sent for all servers on the network. Before a SERVER message for a given server is sent, a SERVER message for any server in front of that server must have already been sent. This can be implemented by first sending SERVER messages for all servers with hop count 1, then for all servers with hop count 2, and so on.

Glines

Any currently unexpired global Glines are transmitted via GLINE messages along with lastmod TS.

Zlines

Any currently unexpired global Zlines are transmitted via ZLINE messages along with lastmod TS.

Shuns

Any currently unexpired global Shuns are transmitted via SHUN messages along with lastmod TS.

Jupes

Any currently unexpired JUPEs are transmitted via JUPE messages with the following format:

<source> JU * <+|-><server_name> <lifetime> <lastmod> :<reason>

For example:

1  2  3 4                  5         6         7
AZ JU * +juped.darenet.org 000003593 955419707 :Juped Server

Notes:

  1. <source> - The numeric of the server sending this message.
  2. The JUPE message token.
  3. The target that should apply this JUPE (always "*" during bursts).
  4. <server_name - The name of the server to JUPE, prefixed with a "+" if the JUPE is active, or with a "-" if its not.
  5. <lifetime> - The remaining absolute lifetime of the JUPE, expressed in seconds.
  6. <lastmod> - An epoc timestamp of the last time the JUPE was modified.
  7. <reason> - The reason the JUPE was applied.

Welcomes

Any global Welcomes are transmitted via WELCOME messages along with lastmod TS.

Clients

Information on all clients/users is transmitted via NICK messages, of the following format:

<source> N <nick> <hop_count> <timestamp> <username> <host> [+modes] <base64 IP> <numeric> :<gecos>

For example:

1  2 3       4 5         6    7            8     9      10    11
AF N Client1 1 947957573 User userhost.net +oiwg DAqAoB AFAAA :Generic Client.

Notes:

  1. <source> - The numeric of the server sending this message (hence, owning this client).
  2. The NICK message token.
  3. <nick> - The nickname of this client, currently max 30 characters.
  4. <hop_count> - The hop count of this client (i.e., how many servers away it is on).
  5. <timestamp> - An epoch timestamp indicating when the user was created.
  6. <username> - The "user" part of the user@host mask.
  7. <host> - The "host" part of the user@host mask.
  8. [OPTIONAL] <+modes> - User modes. If present, this is always "+<user modes for this client>. The special +r usermode is followed by the client's account name; see documentation for ACCOUNT.
  9. <base64 IP> - The real IP address of this client, a base64 encoded 32bit int.
  10. <numeric> - The client's numeric (numnick), in SSCCC format.
  11. <gecos> - Free form user info line.

Channels

Channel details and membership information is synchronized through one (or more) BURST messages for each channel that exists, which are formatted as follows:

<source> B <channel> <creation_ts> [+modes] [arg1] [arg2] <member_list> [:%bans [~ excepts]]

For example:

1  2 3        4         5      6   7  8                                         9         
AZ B #darenet 949217470 +tinkl key 56 AAAAA,AAAAB,AAAAC,ABAAA,ABAAB,ABAAC,ACAAA :%*!*@*.net ~ *!*@*.com

Notes:

  1. <source> - The numeric of the server sending this message.
  2. The BURST command token.
  3. <channel> - The name of the channel to which this data belongs to. Currently #Channel and +Channel names can be sent in a BURST message; however, &Channels are not, since by definition they are local to the server.
  4. <creation_ts> An epoch timestamp indicating when the channel was created.
  5. [OPTIONAL] [+modes] - Channel modes.
    1. The channel may have a number of modes set. as well as relevant mode arguments in the following 2 parameters.
  6. [OPTIONAL] [arg1] - Channel key, this parameter is present if the channel modes contain a "k" mode.
  7. [OPTIONAL] [arg2] - Channel limit, this parameter is present if the channel modes contain a "l" mode.
  8. <member_list> - A comma separated list of client numerics, with the following specific formatting rules to indicate +o, +h, +v and +ohv channel members.
    1. Numerics can have the following symbols appended on then: ":ohv", ":oh", ":ov", ":hv", ":v", ":h" or ":o". These indicate that this numeric is either opped (:o), halfoped, (:h), voiced (:v) or a combination of the three. This state applies to the numeric it is attached to, and all subsequent numerics until another state is encountered. For example: AAABA:ov,AAABB:o,AAABC,AAABD,AAABE:v,AAABZ. In this example, AAABA is both opped and voiced; AAABB, AAABC and AAABD are opped leaving AAABE and AAABZ voiced.
    2. The first numeric of the member list will always contain a state symbol.
  9. [OPTIONAL] [:%bans [~ excepts]] - A space separated list of bans and/or excepts present in the channel. The start of the ban stream is indicated by a ":%', with everything following being the ban list, up until a single "~", which indicates the start of an except stream, with everything following being the except list.
    1. For example: ":%*!*@*.foobar.net another!ban@*.com ~ *!*fred@a.host.co.uk" which would add the following bans to the channel "*!*@*.foobar.net and another!ban@*.com, and the following except *!*fred@a.host.co.uk.

If the length of a BURST message exceeds the maximum length of a line (512 characters), then the remaining channel members/bans/excepts are sent in subsequent BURST messages. The subsequent BURST messages are only used to add additional members to the channel, and if necessary, channel bans and excepts. There will be no "mode" parameters presents. A sample additional BURST message is shown below:

AZ B #darenet 949217470 ACAAB:o,ACAAD :%*!*another@*.ban.com

Nick collisions

Each received NICK message with a server as source introduces a new client, while each NICK message with a client as source changes the name of a given client. The name (i.e., nickname) of a client must be unique on the network. Nick collisions are a result of an incoming NICK message, when an existing user already has the nick.

If the collision is with a local client which has yet to fully register with the server (i.e., has yet to be broadcasted to the other servers), then this local client is removed.

Otherwise:

  • Both users are killed if their TS (last nick change) is equal, or
  • the user with the higher TS is killed if the user@host differs, or
  • the user with the lower TS is killed if the user@host are equal.

Since the target of the KILL message is the numeric, it is safe to send them in any needed direction; no risk of killing the wrong user. If the collision is with a local client, also send a KILL upstream (this for security reasons and might not really be necessary).

Local channels

Local channel names (those starting with an ampersand, "&") are "disallowed" in the P10 protocol, being a server<>server protocol. One must take care to not send any messages about local channels to other servers, and to not accept them when parsing messages.

Summary

The following table summarizes the sequence of events that occur when a server connects (links) to another server. S1 is our server, while S2 is a HUB on the target network.

S1: Sends Password.
S1: Sends initial SERVER message.
S2 confirms S1 has the correct credentials, and if so, proceeds. If not, S1 is squit with a relevant reason.
S2: Sends Password.
S2: Sends initial SERVER message.
S1 confirms S2 has the correct credentials, and if so, proceeds. If not, S2 is squit with a relevant reason.
The following occurs asynchronously; however, it is shown separately below for simplicity.
S1: Sends all the servers it is aware of as a stream of SERVER messages.
S1: Sends all the global glines it is aware of as a stream of GLINE messages.
S1: Sends all the global zlines it is aware of as a stream of ZLINE messages.
S1: Sends all the global shuns it is aware of as a stream of SHUN messages.
S1: Sends all the jupes it is aware of as a stream of JUPE messages.
S1: Sends all the global welcomes it is aware of as a stream of WELCOME messages.
S1: Sends all the clients it is aware of as a stream of NICK messages.
S1: Sends the database of channel states on the network, as a stream of BURST messages.
S1: Sends a END_OF_BURST token (EB) to indicate it has finished sending.
S2: Sends all the servers it is aware of as a stream of SERVER messages.
S2: Sends all the global glines it is aware of as a stream of GLINE messages.
S2: Sends all the global zlines it is aware of as a stream of ZLINE messages.
S2: Sends all the global shuns it is aware of as a stream of SHUN messages.
S2: Sends all the jupes it is aware of as a stream of JUPE messages.
S2: Sends all the global welcomes it is aware of as a stream of WELCOME messages.
S2: Sends all the clients it is aware of as a stream of NICK messages.
S2: Sends the database of channel states on the network, as a stream of BURST messages.
S2: Sends a END_OF_BURST token (EB) to indicate it has finished sending.
S2: Sends an EOB_ACK token (EA) to indicate it has succesfully recieved the END_OF_BURST from S1
S1: Sends an EOB_ACK token (EA) to indicate it has succesfully recieved the END_OF_BURST from S2

Example Session:

[WRITE]: PASS :54321
[WRITE]: SERVER irc.darenet.org 1 947957852 947957852 J10 AB]]] :DareNET Client Server.
[WRITE]: AB N MrFoo 1 947957852 ~me myhost.foo.net +diksw DAqAoB ABAAA :Mr Foo (foo@bar.com).
[WRITE]: AB B #mychannel 946101324 ABAAA:o
[WRITE]: AB EB
[ READ]: PASS :54321
[ READ]: SERVER server1.darenet.org 1 947901540 947958150 J10 AFAD] :A Generic Server.
[ READ]: AF S server2.darenet.org 2 0 947957585 P10 AZAD] 0 :[192.168.10.3] A Generic Server.
[ READ]: AZ S server3.darenet.org 3 0 947957607 P10 AIAD] 0 :[192.168.10.5] A Generic Server.
[ READ]: AF N Client1 1 947957573 Ident userhost.net +oiwg DAqAoB AFAAA :Generic Client.
[ READ]: AZ N Client2 2 947957719 Ident userhost.net +iwg DAqAoB AZAAA :Generic Client.
[ READ]: AI N Client3 3 947957742 Ident userhost.net +iwg DAqAoB AIAAA :Generic Client.
[ READ]: AI N Client4 3 947958121 Ident userhost.net +iwg DAqAoB AIAAB :Generic Client.
[ READ]: AF B #foo 947957734 +tink akey AIAAB,AIAAA:v,AZAAA:o :%*!*another@*.ban.com *!*foo@bar.net
[ READ]: AF B #darenet 947957727 AIAAB,AZAAA:o
[ READ]: AF B #another 946101321 AFAAA
[ READ]: AF JU * +juped.darenet.org 3600 947958100 :Broken, please fix
[ READ]: AF EB
[WRITE]: AB EA
[ READ]: AF EA

Continuous Operation


This section provides details of the various messages that can be sent after successfully linking to the network, and maintaining a synchronized state.

Server State Operations

As discussed earlier, a server object is created when a new server is introduced by means of the SERVER message. A server object is destructed when an SQUIT message is received.

SQUIT

Removes a server from the network.

Syntax:
   1        2         -1
SQ <target> <link_ts> [:<reason>]
  • <target> - The name of the target server (not its numeric), without wildcards.
  • <link_ts> - If the <link_ts> parameter is equal to the link timestamp of the target server, or equal to 0, it applies; otherwise, the SQUIT message is ignored.
  • [OPTIONAL] - [:reason] - An optional reason indicating why the server is being disconnected.

Example:

 AZ SQ server2.darenet.org 1278767962 :Performing updates.

The message is propagated to all links except the link where the message cam from, and the target server if it is directly linked.

If a SQUIT message is to be sent to a directly linked target, the <target> parameter will be the name of the local server. In this case, ircu sends a link timestamp of 0.

SETTIME

Sets the "clock" of one or all servers.

Syntax:
   1           2
SE <timestamp> [<target_numeric>]
  • <timestamp> - An epoch timestamp of the current time.
  • [OPTIONAL] [<target_numeric>] - The numeric of the target server. This parameter is present if an oper issued "/settime <timestamp> <target server numeric>". In which case, the change will only apply to that specific server. If this parameter is not present, the change will be broadcasted to all servers.

Servers with RELIABLE_CLOCK will change the timestamp parameter of any SETTIME message to its own perception of what the current time is.

Example:

AF SE 1278767962

Channel State Operations

Client State Operations

Programmers reference: Client/Server Structures

This section provides information on the standard Client/Server structures, for easy reference during development.