0004-ngircd-Do-PING-PONG-on-server-burst-to-sync-servers.patch 3.5 KB

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