CmdResult Handle (const char* const* parameters, int pcnt, User *user)
{
- ServerInstance->Logs->Log("m_sasl", DEBUG,"AUTHENTICATE");
if (user->registered != REG_ALL)
{
- ServerInstance->Logs->Log("m_sasl", DEBUG,"Sending ENCAP for AUTHENTICATE");
- /* Only allow AUTHENTICATE on unregistered clients */
- std::deque<std::string> params;
- params.push_back("*");
- params.push_back("AUTHENTICATE");
- params.push_back(user->uuid);
-
- for (int i = 0; i < pcnt; ++i)
- params.push_back(parameters[i]);
-
- Event e((char*)¶ms, Creator, "send_encap");
- e.Send(ServerInstance);
+ /* Only act if theyve enabled CAP REQ sasl */
+ if (user->GetExt("sasl"))
+ {
+ /* Only allow AUTHENTICATE on unregistered clients */
+ std::deque<std::string> params;
+ params.push_back("*");
+ params.push_back("AUTHENTICATE");
+ params.push_back(user->uuid);
+
+ for (int i = 0; i < pcnt; ++i)
+ params.push_back(parameters[i]);
+
+ Event e((char*)¶ms, Creator, "send_encap");
+ e.Send(ServerInstance);
+ }
}
return CMD_FAILURE;
}
class ModuleSASL : public Module
{
CommandAuthenticate* sasl;
-
public:
ModuleSASL(InspIRCd* Me)
: Module(Me)
{
- Implementation eventlist[] = { I_OnEvent };
- ServerInstance->Modules->Attach(eventlist, this, 1);
+ Implementation eventlist[] = { I_OnEvent, I_OnUserRegister };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
sasl = new CommandAuthenticate(ServerInstance, this);
ServerInstance->AddCommand(sasl);
+
+ if (!ServerInstance->Modules->Find("m_services_account.so") || !ServerInstance->Modules->Find("m_cap.so"))
+ ServerInstance->Logs->Log("m_sasl", DEFAULT, "WARNING: m_services_account.so and m_cap.so are not loaded! m_sasl.so will NOT function correctly until these two modules are loaded!");
}
+ virtual int OnUserRegister(User *user)
+ {
+ if (user->GetExt("sasl"))
+ {
+ user->WriteServ("906 %s :SASL authentication aborted", user->nick);
+ user->Shrink("sasl");
+ }
+ }
virtual ~ModuleSASL()
{
else if (ev->GetEventID() == "account_login")
{
AccountData* ac = (AccountData*)ev->GetData();
- ac->user->WriteServ("903 %s :SASL authentication successful", ac->user->nick);
+
+ if (ac->user->GetExt("sasl"))
+ {
+ ac->user->WriteServ("903 %s :SASL authentication successful", ac->user->nick);
+ ac->user->Shrink("sasl");
+ }
}
}
};