diff options
author | Peter Powell <petpow@saberuk.com> | 2016-10-02 13:07:51 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-10-02 13:07:51 -0400 |
commit | 3bcb041dc67f9335c9543d89ba144e43d0274a81 (patch) | |
tree | a30904f9d95cc922c8f1ab08ce12747f9d8ec217 /modules/sasl.cpp | |
parent | 3af83256c654711fa03d5c3a78d7d126112cc538 (diff) |
Implement support for SASL 3.2 mechanism lists.
Diffstat (limited to 'modules/sasl.cpp')
-rw-r--r-- | modules/sasl.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/modules/sasl.cpp b/modules/sasl.cpp index d5a3acf6f..42d3bd9f3 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -321,14 +321,38 @@ void IdentifyRequestListener::OnFail(NickServ::IdentifyRequest *req) } class ModuleSASL : public Module + , public EventHook<Event::ModuleLoad> + , public EventHook<Event::ModuleUnload> + , public EventHook<Event::PreUplinkSync> { SASLService sasl; Plain plain; External *external = nullptr; + std::vector<Anope::string> mechs; + + void CheckMechs() + { + std::vector<Anope::string> names; + for (Mechanism *mech : ServiceManager::Get()->FindServices<Mechanism *>()) + names.push_back(mech->GetName()); + + if (mechs == names) + return; + + mechs = names; + + // 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) + , EventHook<Event::ModuleLoad>(this) + , EventHook<Event::ModuleUnload>(this) + , EventHook<Event::PreUplinkSync>(this) , sasl(this) , plain(&sasl, this) { @@ -337,12 +361,30 @@ class ModuleSASL : public Module external = new External(&sasl, this); } catch (ModuleException &) { } + + CheckMechs(); } ~ModuleSASL() { delete external; } + + void OnModuleLoad(User *, Module *) override + { + CheckMechs(); + } + + void OnModuleUnload(User *, Module *) override + { + CheckMechs(); + } + + void OnPreUplinkSync(Server *) override + { + // We have not yet sent a mechanism list so always do it here. + IRCD->SendSASLMechanisms(mechs); + } }; MODULE_INIT(ModuleSASL) |