home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / ircd_os2.zip / README.TSora < prev   
Text File  |  1996-01-06  |  15KB  |  321 lines

  1.                        Protocol changes for +TSora
  2.                        ---------------------------
  3.  
  4.  
  5. Note: 
  6.  
  7. The protocols described here implement TimeStamps on IRC channels and 
  8. nicks. The idea of IRC TimeStamps was started on Undernet, and first 
  9. implemented by Run <carlo@runaway.xs4all.nl>. The protocols used here 
  10. are not exactly the same as the ones used on Undernet; the nick-kill 
  11. handling is very similar and must be credited to Run, while the 
  12. "TimeStamped channel description" protocol is quite different.
  13.  
  14.  
  15.  
  16. TSora servers keep track of which version of the TS protocol (if any) 
  17. their neighboring servers are using, and take it into account when 
  18. sending messages to them. This allows for seamless integration of TS 
  19. servers into a non-TS net, and for upgrades of the protocol.
  20.  
  21. Each server knows which is the lowest and the highest version of the
  22. TS protocol it can interact with; currently both of these are set to 1:
  23.  
  24. #define TS_CURRENT 1        /* the highest TS ver we can do */
  25. #define TS_MIN 1        /* the lowest TS ver we can do  */
  26.  
  27.  
  28. Timings and TS versions:
  29. ========================
  30.  
  31. . Keep a 'delta' value to be added to the result of all calls to time(),
  32.   initially 0.
  33.  
  34. . Send a
  35.  
  36.   SVINFO <TS_CURRENT> <TS_MIN> <STANDALONE> :<UTC-TIME>
  37.   
  38.   before "SERVER" and after "PASS", where <STANDALONE> is 1 if we're 
  39.   connected to more TSora servers, and 0 if not, and <UTC-TIME> is our 
  40.   idea of the current UTC time, fixed with the delta.
  41.  
  42. . When we receive a "SVINFO <x> <y> <z> :<t>" line from a connecting 
  43.   server, we ignore it if TS_CURRENT<y or x<TS_MIN, otherwise we
  44.   set a flag remembering that that server is TS-aware, remember the TS 
  45.   version to use with it (min(TS_CURRENT, x)). Additionally, if this is 
  46.   our first connected TS server, we set our delta to t-<OUR_UTC> if
  47.   z==0, and to (t-<OUR_UTC>)/2 if z!=0. The SVINFO data is kept around
  48.   until the server has effectively registered with SERVER, and used
  49.   *after* sending our own SVINFO to that server.
  50.  
  51.  
  52. Explanations:
  53.  
  54.   Servers will always know which of their directly-linked servers
  55.   can do TS, and will use the TS protocol only with servers that
  56.   do understand it. This makes it possible to switch to full TS
  57.   in just one code-replacement step, without incompatibilities.
  58.  
  59.   As long as not all servers are TS-aware, the net will be divided
  60.   into "zones" of linked TS-aware servers. Channel modes will be
  61.   kept synchronized at least within the zone in which the channel
  62.   was created, and nick collisions between servers in the same
  63.   zone will result in only one client being killed.
  64.  
  65.   Time synchronization ensures that servers have the same idea of the 
  66.   current time, and achieves this purpose as long as TS servers are 
  67.   introduced one by one within the same 'zone'. The merging of two zones 
  68.   cannot synchronize them completely, but it is to be expected that 
  69.   within each zone the effective time will be very close to the real 
  70.   time. 
  71.  
  72.   The current time is only used when setting a TS on a new channel or 
  73.   nick, and once such a TS is set, it is never modified because of 
  74.   synchronization, as it is much more important that the TS for a 
  75.   channel or nick stays the same across all servers than that it is 
  76.   accurate to the second.
  77.  
  78.   Note that Undernet's 2.8.x servers have no time synchronization at 
  79.   all, and have had no problems because of it - all of this is more to 
  80.   catch the occasional server with a way-off clock than anything.
  81.  
  82.  
  83. NICK handling patches (anti-nick-collide + shorter connect burst):
  84. ==================================================================
  85.  
  86. . For each nick, store a TS value = the TS value received if any, or our 
  87.   UTC+delta at the time we first heard of the nick. TS's are propagated 
  88.   to TS-aware servers whenever sending a NICK command.
  89.  
  90. . Nick changes reset the TS to the current time.
  91.  
  92. . When sending a connect burst to another TS server, replace the 
  93.   NICK/USER pair with only one NICK command containing the nick, the 
  94.   hopcount, the TS, the umode, and all the USER information.
  95.  
  96.   The format for a full NICK line is:
  97.   NICK <nick> <hops> <TS> <umode> <user> <host> <server> :<ircname>
  98.  
  99.   The umode is a + followed by any applying usermodes.
  100.  
  101.   The format for a nick-change NICK line is:
  102.   :<oldnick> NICK <newnick> :<TS>
  103.  
  104. . When a NICK is received from a TS server, that conflicts with an 
  105.   existing nick:
  106.   + if the userhosts differ or one is not known:
  107.     * if the timestamps are equal, kill ours and the old one if it
  108.       was a nick change
  109.     * if the incoming timestamp is older than ours, kill ours and 
  110.       propagate the new one
  111.     * if the incoming timestamp is younger, ignore the line, but kill 
  112.       the old nick if it was a nick change
  113.   + if the userhosts are the same:
  114.     * if the timestamps are equal, kill ours and the old one if it
  115.       was a nick change
  116.     * if the incoming timestamp is younger, kill ours and propagate
  117.       the new one
  118.     * if the incoming timestamp is older, ignore the line but kill
  119.       the old nick if it was a nick change
  120.  
  121. . When a NICK is received from a non-TS server that conflicts with
  122.   an existing nick, kill both.
  123.  
  124. . Do not send "Fake Prefix" kills in response to lines coming from TS 
  125.   servers; the sanitization works anyway, and this allows the "newer
  126.   nick overruled" case to work.
  127.  
  128. Explanations:
  129.  
  130.   The modified nick-introduction syntax allows for a slightly shorter 
  131.   connect-burst, and most importantly lets the server compare 
  132.   user@host's when determining which nick to kill:  if the user@host
  133.   is the same, then the older nick must be killed rather than the
  134.   newer.
  135.  
  136.   When talking to a non-TS server, we need to behave exactly like one
  137.   because it expects us to. When talkign to a TS server, we don't kill
  138.   the nicks it's introducing, as we know it'll be smart enough to do it
  139.   itself when seeing our own introduced nick.
  140.  
  141.   When we see a nick arriving from a non-TS server, it won't have a TS, 
  142.   but it's safe enough to give it the current time rather than keeping 
  143.   it 0; such TS's won't be the same all across the network (as long as 
  144.   there is more than one TS zone), and when there's a collision, the TS 
  145.   used will be the one in the zone the collision occurs in.
  146.  
  147.   Also, it is important to note that by the time a server sees (and 
  148.   chooses to ignore) a nick introduction, the introducing server has 
  149.   also had the time to put umode changes for that nick on its queue, so 
  150.   we must ignore them too... so we need to ignore fake-prefix lines 
  151.   rather than sending kills for them. This is safe enough, as the rest 
  152.   of the protocol ensures that they'll get killed anyway (and the 
  153.   Undernet does it too, so it's been more than enough tested). Just for 
  154.   an extra bit of compatibility, we still kill fake prefixes coming from 
  155.   non-TS servers.
  156.  
  157.   This part of the TS protocol is almost exactly the same as the 
  158.   Undernet's .anc (anti-nick-collide) patches, except that Undernet 
  159.   servers don't add usermodes to the NICK line.
  160.  
  161.  
  162. TimeStamped channel descriptions (avoiding hacked ops and desynchs):
  163. ====================================================================
  164.  
  165. . For each channel, keep a timestamp, set to the current time when the
  166.   channel is created by a client on the local server, or to the received 
  167.   value if the channel has been propagated from a TS server, or to 0 
  168.   otherwise. This value will have the semantics of "the time of creation 
  169.   of the current ops on the channel", and 0 will mean that the channel 
  170.   is in non-TS mode.
  171.  
  172.   A new server protocol command is introduced, SJOIN, which introduces 
  173.   a full channel description: a timestamp, all the modes (except bans),
  174.   and the list of channel members with their ops and voices. This 
  175.   command will be used instead of JOIN and of (most) MODEs both in 
  176.   connect bursts and when propagating channel creations among TS 
  177.   servers. SJOIN will never be accepted from or sent to users.
  178.  
  179.   The syntax for the command is:
  180.  
  181.   SJOIN <TS> #<channel> <modes> :[@][+]<nick_1> ...  [@][+]<nick_n>
  182.  
  183.   The fields have the following meanings:
  184.  
  185.   * <TS> is the timestamp for the channel
  186.  
  187.   * <modes> is the list of global channel modes, starting with a +
  188.     and a letter for each of the active modes (spmntkil), followed
  189.     by an argument for +l if there is a limit, and an argument for
  190.     +k if there's a key (in the same order they were mentioned in
  191.     the string of letters).
  192.  
  193.     A channel with no modes will have a "+" in that field.
  194.  
  195.     A special value of "0" means that the server does not specify the 
  196.     modes, and will be used when more than one SJOIN line is needed
  197.     to completely describe a channel, or when propagating a SJOIN
  198.     the modes of which were rejected.
  199.  
  200.   * Each nick is preceded by a "@" if the user has ops, and a "+" if
  201.     the user has a voice. For mode +ov, both flags are used.
  202.  
  203.   SJOINs will be propagated (when appropriate) to neighboring TS 
  204.   servers, and converted to JOINs and MODEs for neighboring non-TS 
  205.   servers.
  206.   
  207.   To propagate channels for which not all users fit in one 
  208.   SJOIN line, several SJOINs will be sent consecutively, only the first
  209.   one including actual information in the <mode> field.
  210.   
  211.   An extra ad-hoc restriction is imposed on SJOIN messages, to simplify 
  212.   processing: if a channel has ops, then the first <nick> of the first 
  213.   SJOIN sent to propagate that channel must be one of the ops.
  214.  
  215.   Servers will never attempt to reconstruct a SJOIN from JOIN/MODE 
  216.   information being received at the moment from other servers.
  217.  
  218. . For each user on a channel, keep an extra flag (like ops and voice)
  219.   that is set when the user has received channel ops from another 
  220.   server (in a SJOIN channel description), which we rejected (ignored). 
  221.   Mode changes (but NOT kicks) coming from a TS server and from someone 
  222.   with this flag set will be ignored. The flag will be reset when the 
  223.   user gets ops from another user or server.
  224.  
  225. . On deops done by non-local users, coming from TS servers, on channels 
  226.   with a non-zero TS, do not check that the user has ops but check that 
  227.   their 'deopped' flag is not set. For kicks coming from a TS server, do 
  228.   not check either. This will avoid desynchs, and 'bad' modechanges are 
  229.   avoided anyway. Other mode changes will still only be taken into 
  230.   account and propagated when done by users that are seen as having ops.
  231.  
  232. . When a MODE change that ops someone is received from a server for a 
  233.   channel, that channel's TS is set to 0, and the mode change is 
  234.   propagated. 
  235.  
  236. . When a SJOIN is received for a channel, deal with it in this way:
  237.   * received-TS = 0: 
  238.     + if we have ops or the SJOIN doesn't op anyone, SJOIN propagated
  239.       with our own TS.
  240.     + otherwise, TS set to 0 and SJOIN propagated with 0.
  241.   * received-TS > 0, own-TS = 0: 
  242.     + if the SJOIN ops someone or we don't have ops, set our TS to the
  243.       received TS and propagate.
  244.     + otherwise, propagate with TS = 0.
  245.   * received-TS = own-TS: propagate.
  246.   * received-TS < own-TS: 
  247.     + if the SJOIN ops someone, remove *all* modes (except bans) from 
  248.       the channel and propagate these mode changes to all neighboring
  249.       non-TS servers, and copy the received TS and propagate the SJOIN.
  250.     + if the SJOIN does not op anyone and we have ops, propagate
  251.       with our own TS.
  252.     + otherwise, copy the received TS and propagate the SJOIN.
  253.   * received-TS > own-TS: 
  254.     + if the SJOIN does not introduce any ops, process and propagate
  255.       with our own TS.
  256.     + if we have ops: for each person the mode change would op, set the 
  257.       'deopped' flag; process all the JOINs ignoring the '@' and '+' 
  258.       flags; propagate without the flags and with our TS.
  259.     + if we don't have ops: set our TS to the received one, propagate
  260.       with the flags.
  261.  
  262.  
  263. Explanations:
  264.  
  265.   This part of the protocol is the one that is most different (and 
  266.   incompatible) with the Undernet's: we never timestamp MODE changes, 
  267.   but instead we introduce the concept of time-stamped channel 
  268.   descriptions. This way each server can determine, based on its state 
  269.   and the received description, what the correct modes for a channel 
  270.   are, and deop its own users if necessary. With this protocol, there is 
  271.   *never* the need to reverse and bounce back a mode change. This is
  272.   both faster and more bandwith-effective.
  273.  
  274.   The end goal is to have a protocol will eventually protect channels 
  275.   against hacked ops, while minimizing the impact on a mixed-server net. 
  276.   In order to do this, whenever there is a conflict between a TS server 
  277.   and a non-TS one, the non-TS one's idea of the whole situation 
  278.   prevails. This means that channels will only have a TS when they have 
  279.   been created on a TS-aware server, and will lose it whenever a server 
  280.   op comes from a non-TS server. Also, at most one 'zone' will have a TS 
  281.   for any given channel at any given time, ensuring that there won't be 
  282.   any deops when zones are merged. However, when TS zones are merged, if 
  283.   the side that has a TS also has ops, then the TS is kept across the 
  284.   whole new zone. Effective protection will only be ensured once all 
  285.   servers run TS patches and channels have been re-created, as there is 
  286.   no way servers can assign a TS to a channel they are not creating 
  287.   (like they do with nicks) without having unwanted deops later.
  288.  
  289.   The visible effects of this timestamped channel-description protocol 
  290.   are that when a split rejoins, and one side has hacked ops, the other 
  291.   side doesn't see any server mode changes (just like with Undernet's
  292.   TS), but the side that has hacked ops sees:
  293.  
  294.   * first the first server on the other side deopping and devoicing 
  295.     everyone, and fixing the +spmntkli modes
  296.   * then other users joining, and getting server ops and voices
  297.  
  298.   The less obvious part of this protocol is its behavior in the case 
  299.   that the younger side of a rejoin has servers that are lagged with 
  300.   each other. In such a situation, a SJOIN that clears all modes and 
  301.   sets the legitimate ones is being propagated from one server, and 
  302.   lagged illegitimate mode changes and kicks are being propagated in the 
  303.   opposite direction. In this case, a kick done by someone who is being 
  304.   deopped by the SJOIN must be taken into account to keep the name list 
  305.   in sync (and since it can only be kicking someone who also was on the 
  306.   younger side), while a deop does not matter (and will be ignored by 
  307.   the first server on the other side), and an opping *needs* to be 
  308.   discareded to avoid hacked ops.
  309.  
  310.   The main property of timestamped channel descriptions that makes them 
  311.   a very stable protocol even with lag and splits, is that they leave a 
  312.   server in the same final state, independently of the order in which 
  313.   channel descriptions coming from different servers are received. Even 
  314.   when SJOINs and MODEs for the same channel are being propagated in 
  315.   different direction because of several splits rejoining, the final 
  316.   state will be the same, independently of the exact order in which each 
  317.   server received the SJOINs, and will be the same across all the 
  318.   servers in the same zone.
  319.  
  320.  
  321.