summaryrefslogtreecommitdiff
path: root/modules/m_sasl.cpp
diff options
context:
space:
mode:
authorAdam <adam@sigterm.info>2016-03-15 17:41:48 -0500
committerAdam <adam@sigterm.info>2016-03-15 17:41:48 -0500
commit448967cefc6c718c139993157d9679650e0d1540 (patch)
treef443ca0f54aa70e527727bc7c16f64651a1758b0 /modules/m_sasl.cpp
parent979027138be9cdc34af5d7247e1ee218715f0d54 (diff)
parent52fdc455976e22e860736b07c431c6a6464f5d70 (diff)
Merge pull request #156 from SaberUK/2.0+sasl-mechlist
Implement support for SASL 3.2 mechanism lists.
Diffstat (limited to 'modules/m_sasl.cpp')
-rw-r--r--modules/m_sasl.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp
index ef29a1b45..630c5e3ab 100644
--- a/modules/m_sasl.cpp
+++ b/modules/m_sasl.cpp
@@ -276,6 +276,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)
@@ -283,6 +298,7 @@ class ModuleSASL : public Module
try
{
external = new External(this);
+ CheckMechs();
}
catch (ModuleException &) { }
}
@@ -291,6 +307,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)