/**
* Tracks SASL authentication state like charybdis does. --nenolod
*/
-class SaslAuthenticator
+class SaslAuthenticator : public classbase
{
private:
InspIRCd *ServerInstance;
params.push_back("S");
params.push_back(method);
- Event e((char*)¶ms, Creator, "send_encap");
- e.Send(ServerInstance);
+ ServerInstance->PI->SendEncapsulatedData(params);
}
SaslResult GetSaslResult(std::string &result_)
for (int i = 0; i < pcnt; ++i)
params.push_back(parameters[i]);
- Event e((char*)¶ms, Creator, "send_encap");
- e.Send(ServerInstance);
+ ServerInstance->PI->SendEncapsulatedData(params);
if (*parameters[0] == '*')
{
switch (this->result)
{
case SASL_OK:
- this->user->WriteServ("903 %s :SASL authentication successful", this->user->nick);
+ this->user->WriteNumeric(903, "%s :SASL authentication successful", this->user->nick);
break;
case SASL_ABORT:
- this->user->WriteServ("906 %s :SASL authentication aborted", this->user->nick);
+ this->user->WriteNumeric(906, "%s :SASL authentication aborted", this->user->nick);
break;
case SASL_FAIL:
- this->user->WriteServ("904 %s :SASL authentication failed", this->user->nick);
+ this->user->WriteNumeric(904, "%s :SASL authentication failed", this->user->nick);
break;
default:
break;
ModuleSASL(InspIRCd* Me)
: Module(Me)
{
- Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect };
- ServerInstance->Modules->Attach(eventlist, this, 3);
+ Implementation eventlist[] = { I_OnEvent, I_OnUserRegister, I_OnPostConnect, I_OnUserDisconnect, I_OnCleanup };
+ ServerInstance->Modules->Attach(eventlist, this, 5);
sasl = new CommandAuthenticate(ServerInstance, this);
ServerInstance->AddCommand(sasl);
return 0;
}
+ virtual void OnCleanup(int target_type, void *item)
+ {
+ if (target_type == TYPE_USER)
+ OnUserDisconnect((User*)item);
+ }
+
+ virtual void OnUserDisconnect(User *user)
+ {
+ SaslAuthenticator *sasl_;
+ if (user->GetExt("sasl_authenticator", sasl_))
+ {
+ delete sasl_;
+ user->Shrink("sasl_authenticator");
+ }
+ }
+
virtual void OnPostConnect(User* user)
{
if (!IS_LOCAL(user))
std::string* str = NULL;
if (user->GetExt("accountname", str))
- {
- std::deque<std::string> params;
- params.push_back(user->uuid);
- params.push_back("accountname");
- params.push_back(*str);
- Event e((char*)¶ms, this, "send_metadata");
- e.Send(ServerInstance);
- }
+ ServerInstance->PI->SendMetaData(user, TYPE_USER, "accountname", *str);
+
return;
}