diff options
author | Peter Powell <petpow@saberuk.com> | 2016-02-20 16:59:21 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2016-02-28 16:36:43 +0000 |
commit | 52fdc455976e22e860736b07c431c6a6464f5d70 (patch) | |
tree | 38fe08488c10b1b33f52f16f0f33dcd3903ad47b | |
parent | 413b38b1c1b6786d8abce2c77c3c3a7a7e0d3fe9 (diff) |
Implement support for SASL 3.2 mechanism lists.
-rw-r--r-- | include/protocol.h | 1 | ||||
-rw-r--r-- | modules/m_sasl.cpp | 32 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 9 |
3 files changed, 42 insertions, 0 deletions
diff --git a/include/protocol.h b/include/protocol.h index 01ce6fbe3..2811a8c3f 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -227,6 +227,7 @@ class CoreExport IRCDProto : public Service */ virtual void SendOper(User *u); + virtual void SendSASLMechanisms(std::vector<Anope::string> &) { } virtual void SendSASLMessage(const SASL::Message &) { } virtual void SendSVSLogin(const Anope::string &uid, const Anope::string &acc) { } diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp index 98a554259..1d60561fe 100644 --- a/modules/m_sasl.cpp +++ b/modules/m_sasl.cpp @@ -266,6 +266,21 @@ class ModuleSASL : public Module Plain plain; External *external; + std::vector<Anope::string> mechs; + + void CheckMechs() + { + std::vector<Anope::string> newmechs = ::Service::GetServiceKeys("SASL::Mechanism"); + if (newmechs == mechs) + return; + + mechs = newmechs; + + // If we are connected to the network then broadcast the mechlist. + if (Me && Me->IsSynced()) + IRCD->SendSASLMechanisms(mechs); + } + public: ModuleSASL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), sasl(this), plain(this), external(NULL) @@ -273,6 +288,7 @@ class ModuleSASL : public Module try { external = new External(this); + CheckMechs(); } catch (ModuleException &) { } } @@ -281,6 +297,22 @@ class ModuleSASL : public Module { delete external; } + + void OnModuleLoad(User *, Module *) anope_override + { + CheckMechs(); + } + + void OnModuleUnload(User *, Module *) anope_override + { + CheckMechs(); + } + + void OnPreUplinkSync(Server *) anope_override + { + // We have not yet sent a mechanism list so always do it here. + IRCD->SendSASLMechanisms(mechs); + } }; MODULE_INIT(ModuleSASL) diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index c54cfe184..a295ee999 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -42,6 +42,15 @@ class InspIRCd20Proto : public IRCDProto insp12->SendConnect(); } + void SendSASLMechanisms(std::vector<Anope::string> &mechanisms) anope_override + { + Anope::string mechlist; + for (unsigned i = 0; i < mechanisms.size(); ++i) + mechlist += "," + mechanisms[i]; + + UplinkSocket::Message(Me) << "METADATA * saslmechlist :" << (mechanisms.empty() ? "" : mechlist.substr(1)); + } + void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) anope_override { insp12->SendSVSKillInternal(source, user, buf); } void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalNotice(bi, dest, msg); } void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalPrivmsg(bi, dest, msg); } |