]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/Anope/0004-ngircd-Do-PING-PONG-on-server-burst-to-sync.patch
Shorten filenames of Anope protocol module patchfiles
[ngircd-alex.git] / contrib / Anope / 0004-ngircd-Do-PING-PONG-on-server-burst-to-sync.patch
1 From 88b2b14a76b8ee053b1f6ea64139350260590043 Mon Sep 17 00:00:00 2001
2 From: DukePyrolator <DukePyrolator@anope.org>
3 Date: Mon, 22 Aug 2011 14:55:07 +0200
4 Subject: [PATCH 04/16] ngircd: Do PING-PONG on server burst to "sync servers"
5
6 Imagine we had three servers, A, B & C linked like so: A<->B<->C:
7
8 If Anope is linked to A and B splits from A and then reconnects B
9 introduces itself, introduces C, sends EOS for C, introduces B's clients
10 introduces C's clients, sends EOS for B. This causes all of C's clients
11 to be introduced with their server "not syncing".
12
13 We now send a PING immediately when receiving a new server and then
14 finish sync once we get a pong back from that server.
15 ---
16  modules/protocol/ngircd.cpp |   28 ++++++++++++++++++++++++++--
17  1 files changed, 26 insertions(+), 2 deletions(-)
18
19 diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
20 index 790b8f4..89aecfd 100644
21 --- a/modules/protocol/ngircd.cpp
22 +++ b/modules/protocol/ngircd.cpp
23 @@ -108,11 +108,13 @@ class ngIRCdProto : public IRCDProto
24  
25         void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf)
26         {
27 +Log(LOG_DEBUG) << "SendModeInternal 1";
28                 send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", dest->name.c_str(), buf.c_str());
29         }
30  
31         void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf)
32         {
33 +Log(LOG_DEBUG) << "SendModeInternal 2";
34                 send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
35         }
36  
37 @@ -212,6 +214,8 @@ class ngIRCdIRCdMessage : public IRCdMessage
38                         do_server("", params[0], 0, params[2], params[1]);
39                 else
40                         do_server(source, params[0], params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[3], params[2]);
41 +
42 +               ircdproto->SendPing(Config->ServerName, params[0]);
43                 return true;
44         }
45  
46 @@ -253,6 +257,25 @@ class ngIRCdIRCdMessage : public IRCdMessage
47         }
48  };
49  
50 +/** This is here because:
51 + *
52 + * If we had three servers, A, B & C linked like so: A<->B<->C
53 + * If Anope is linked to A and B splits from A and then reconnects
54 + * B introduces itself, introduces C, sends EOS for C, introduces Bs clients
55 + * introduces Cs clients, sends EOS for B. This causes all of Cs clients to be introduced
56 + * with their server "not syncing". We now send a PING immediately when receiving a new server
57 + * and then finish sync once we get a pong back from that server.
58 + */
59 +bool event_pong(const Anope::string &source, const std::vector<Anope::string> &params)
60 +{
61 +       Server *s = Server::Find(source);
62 +       if (s && !s->IsSynced())
63 +               s->Sync(false);
64 +       return true;
65 +}
66 +
67 +
68 +
69  /*
70   * CHANINFO <chan> +<modes>
71   * CHANINFO <chan> +<modes> :<topic>
72 @@ -416,7 +439,7 @@ bool event_376(const Anope::string &source, const std::vector<Anope::string> &pa
73  class ProtongIRCd : public Module
74  {
75         Message message_kick, message_pass, message_njoin, message_chaninfo, message_005,
76 -               message_442, message_376;
77 +               message_442, message_376, message_pong;
78  
79         ngIRCdProto ircd_proto;
80         ngIRCdIRCdMessage ircd_message;
81 @@ -457,7 +480,8 @@ class ProtongIRCd : public Module
82         ProtongIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL),
83                 message_kick("KICK", event_kick), message_pass("PASS", event_pass),
84                 message_njoin("NJOIN", event_njoin), message_chaninfo("CHANINFO", event_chaninfo),
85 -               message_005("005", event_005), message_442("442", event_442), message_376("376", event_376)
86 +               message_005("005", event_005), message_442("442", event_442), message_376("376", event_376),
87 +               message_pong("PONG", event_pong)
88         {
89                 this->SetAuthor("Anope");
90  
91 -- 
92 1.7.8.3
93