mirror of
https://github.com/anope/anope.git
synced 2026-07-02 17:53:13 +02:00
Move nickserv validate stuff to an event in nickserv.cpp
This commit is contained in:
@@ -385,19 +385,13 @@ struct IRCDMessageNick : IRCDMessage
|
||||
}
|
||||
|
||||
User *user = new User(params[0], params[4], params[5], "", params[8], s, params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3]);
|
||||
if (user && NickServService)
|
||||
try
|
||||
{
|
||||
const NickAlias *na;
|
||||
if (user->signon == convertTo<time_t>(params[7]) && (na = NickAlias::Find(user->nick)))
|
||||
{
|
||||
NickCore *nc = na->nc;
|
||||
user->Login(nc);
|
||||
if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
NickServService->Validate(user);
|
||||
NickAlias *na;
|
||||
if (NickServService && user->signon == convertTo<time_t>(params[7]) && (na = NickAlias::Find(user->nick)))
|
||||
NickServService->Login(user, na);
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
}
|
||||
else
|
||||
source.GetUser()->ChangeNick(params[0]);
|
||||
|
||||
@@ -502,22 +502,11 @@ struct IRCDMessageUID : IRCDMessage
|
||||
params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
|
||||
params[3], params[7]);
|
||||
|
||||
if (user && NickServService)
|
||||
if (NickServService && params[8] != "0")
|
||||
{
|
||||
const NickAlias *na = NULL;
|
||||
|
||||
if (params[8] != "0")
|
||||
na = NickAlias::Find(params[8]);
|
||||
|
||||
if (na)
|
||||
{
|
||||
user->Login(na->nc);
|
||||
|
||||
if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
NickServService->Validate(user);
|
||||
NickAlias *na = NickAlias::Find(params[8]);
|
||||
if (na != NULL)
|
||||
NickServService->Login(user, na);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -766,14 +766,7 @@ struct IRCDMessageNick : IRCDMessage
|
||||
NickAlias *na = NickAlias::Find(user->nick);
|
||||
Anope::string *svidbuf = na ? na->nc->GetExt<ExtensibleItemClass<Anope::string> *>("authenticationtoken") : NULL;
|
||||
if (na && svidbuf && *svidbuf == params[0])
|
||||
{
|
||||
NickCore *nc = na->nc;
|
||||
user->Login(nc);
|
||||
if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
NickServService->Validate(user);
|
||||
NickServService->Login(user, na);
|
||||
}
|
||||
}
|
||||
else if (params.size() == 1 && source.GetUser())
|
||||
|
||||
@@ -1161,9 +1161,7 @@ struct IRCDMessageUID : IRCDMessage
|
||||
for (unsigned i = 9; i < params.size() - 1; ++i)
|
||||
modes += " " + params[i];
|
||||
|
||||
User *u = new User(params[2], params[5], params[3], params[4], params[6], source.GetServer(), params[params.size() - 1], ts, modes, params[0]);
|
||||
if (u->server->IsSynced() && NickServService)
|
||||
NickServService->Validate(u);
|
||||
new User(params[2], params[5], params[3], params[4], params[6], source.GetServer(), params[params.size() - 1], ts, modes, params[0]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1221,7 +1219,7 @@ class ProtoInspIRCd : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
|
||||
Implementation i[] = { I_OnUserNickChange, I_OnServerSync };
|
||||
Implementation i[] = { I_OnUserNickChange };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
|
||||
Servers::Capab.insert("NOQUIT");
|
||||
@@ -1244,17 +1242,6 @@ class ProtoInspIRCd : public Module
|
||||
*/
|
||||
u->RemoveMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
|
||||
void OnServerSync(Server *s) anope_override
|
||||
{
|
||||
if (NickServService)
|
||||
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
|
||||
{
|
||||
User *u = it->second;
|
||||
if (u->server == s && !u->IsIdentified())
|
||||
NickServService->Validate(u);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(ProtoInspIRCd)
|
||||
|
||||
@@ -432,9 +432,7 @@ struct IRCDMessageNick : IRCDMessage
|
||||
else if (params.size() == 7)
|
||||
{
|
||||
// a new user is connecting to the network
|
||||
User *user = new User(params[0], params[2], params[3], "", "", source.GetServer(), params[6], Anope::CurTime, params[5], "");
|
||||
if (user && NickServService)
|
||||
NickServService->Validate(user);
|
||||
new User(params[0], params[2], params[3], "", "", source.GetServer(), params[6], Anope::CurTime, params[5], "");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+19
-21
@@ -261,15 +261,27 @@ struct IRCDMessageUID : IRCDMessage
|
||||
if (ip == "0")
|
||||
ip.clear();
|
||||
|
||||
User *user = new User(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7]);
|
||||
if (params[8] != "0" && params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == user->timestamp)
|
||||
time_t ts;
|
||||
try
|
||||
{
|
||||
NickAlias *na = NickAlias::Find(user->nick);
|
||||
if (na)
|
||||
user->Login(na->nc);
|
||||
ts = convertTo<time_t>(params[2]);
|
||||
}
|
||||
else if (user && user->server->IsSynced() && NickServService)
|
||||
NickServService->Validate(user);
|
||||
catch (const ConvertException &)
|
||||
{
|
||||
ts = Anope::CurTime;
|
||||
}
|
||||
|
||||
User *user = new User(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7]);
|
||||
try
|
||||
{
|
||||
if (NickServService && params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == user->timestamp)
|
||||
{
|
||||
NickAlias *na = NickAlias::Find(user->nick);
|
||||
if (na)
|
||||
NickServService->Login(user, na);
|
||||
}
|
||||
}
|
||||
catch (const ConvertException &) { }
|
||||
}
|
||||
};
|
||||
|
||||
@@ -363,26 +375,12 @@ class ProtoPlexus : public Module
|
||||
throw ModuleException("No protocol interface for hybrid");
|
||||
|
||||
this->AddModes();
|
||||
|
||||
Implementation i[] = { I_OnServerSync };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
}
|
||||
|
||||
~ProtoPlexus()
|
||||
{
|
||||
ModuleManager::UnloadModule(m_hybrid, NULL);
|
||||
}
|
||||
|
||||
void OnServerSync(Server *s) anope_override
|
||||
{
|
||||
if (NickServService)
|
||||
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
|
||||
{
|
||||
User *u = it->second;
|
||||
if (u->server == s && !u->IsIdentified())
|
||||
NickServService->Validate(u);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(ProtoPlexus)
|
||||
|
||||
@@ -171,9 +171,7 @@ struct IRCDMessageUID : IRCDMessage
|
||||
void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
/* Source is always the server */
|
||||
User *user = new User(params[0], params[4], params[5], "", params[6], source.GetServer(), params[8], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7]);
|
||||
if (user && user->server->IsSynced() && NickServService)
|
||||
NickServService->Validate(user);
|
||||
new User(params[0], params[4], params[5], "", params[6], source.GetServer(), params[8], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -255,26 +253,12 @@ class ProtoRatbox : public Module
|
||||
throw ModuleException("No protocol interface for hybrid");
|
||||
|
||||
this->AddModes();
|
||||
|
||||
Implementation i[] = { I_OnServerSync };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
}
|
||||
|
||||
~ProtoRatbox()
|
||||
{
|
||||
ModuleManager::UnloadModule(m_hybrid, NULL);
|
||||
}
|
||||
|
||||
void OnServerSync(Server *s) anope_override
|
||||
{
|
||||
if (NickServService)
|
||||
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
|
||||
{
|
||||
User *u = it->second;
|
||||
if (u->server == s && !u->IsIdentified())
|
||||
NickServService->Validate(u);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(ProtoRatbox)
|
||||
|
||||
@@ -803,7 +803,7 @@ struct IRCDMessageNick : IRCDMessage
|
||||
|
||||
User *user = new User(params[0], params[3], params[4], vhost, ip, s, params[10], user_ts, params[7]);
|
||||
|
||||
const NickAlias *na = NULL;
|
||||
NickAlias *na = NULL;
|
||||
|
||||
if (params[6] == "0")
|
||||
;
|
||||
@@ -817,14 +817,8 @@ struct IRCDMessageNick : IRCDMessage
|
||||
na = NickAlias::Find(params[6]);
|
||||
}
|
||||
|
||||
if (na)
|
||||
{
|
||||
user->Login(na->nc);
|
||||
if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else if (NickServService)
|
||||
NickServService->Validate(user);
|
||||
if (na && NickServService)
|
||||
NickServService->Login(user, na);
|
||||
}
|
||||
else
|
||||
source.GetUser()->ChangeNick(params[0]);
|
||||
|
||||
@@ -129,6 +129,14 @@ class MyNickServService : public NickServService
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Login(User *user, NickAlias *na) anope_override
|
||||
{
|
||||
const NickAlias *u_na = NickAlias::Find(user->nick);
|
||||
user->Login(na->nc);
|
||||
if (u_na && *u_na->nc == *na->nc && !Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
};
|
||||
|
||||
class ExpireCallback : public CallBack
|
||||
@@ -190,7 +198,7 @@ class NickServCore : public Module
|
||||
throw ModuleException("No bot named " + Config->NickServ);
|
||||
|
||||
Implementation i[] = { I_OnBotDelete, I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup,
|
||||
I_OnNickUpdate, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, I_OnUserConnect };
|
||||
I_OnNickUpdate, I_OnUserConnect, I_OnServerSync, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
}
|
||||
|
||||
@@ -295,6 +303,28 @@ class NickServCore : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnUserConnect(Reference<User> &u, bool &exempt) anope_override
|
||||
{
|
||||
if (!u || !u->server->IsSynced())
|
||||
return;
|
||||
|
||||
const NickAlias *na = NickAlias::Find(u->nick);
|
||||
if (!Config->NoNicknameOwnership && !Config->NSUnregisteredNotice.empty() && !na)
|
||||
u->SendMessage(NickServ, Config->NSUnregisteredNotice);
|
||||
else if (na)
|
||||
this->mynickserv.Validate(u);
|
||||
}
|
||||
|
||||
void OnServerSync(Server *s) anope_override
|
||||
{
|
||||
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
|
||||
{
|
||||
User *u = it->second;
|
||||
if (u->server == s && !u->IsIdentified())
|
||||
NickServService->Validate(u);
|
||||
}
|
||||
}
|
||||
|
||||
void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override
|
||||
{
|
||||
const NickAlias *na = NickAlias::Find(u->nick);
|
||||
@@ -357,12 +387,6 @@ class NickServCore : public Module
|
||||
"will result in, at minimum, loss of the abused\n"
|
||||
"nickname(s)."), Config->NickServ.c_str());
|
||||
}
|
||||
|
||||
void OnUserConnect(Reference<User> &u, bool &exempt) anope_override
|
||||
{
|
||||
if (!Config->NoNicknameOwnership && !Config->NSUnregisteredNotice.empty() && u && !NickAlias::Find(u->nick))
|
||||
u->SendMessage(NickServ, Config->NSUnregisteredNotice);
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(NickServCore)
|
||||
|
||||
@@ -7,6 +7,7 @@ class NickServService : public Service
|
||||
NickServService(Module *m) : Service(m, "NickServService", "NickServ") { }
|
||||
|
||||
virtual void Validate(User *u) = 0;
|
||||
virtual void Login(User *u, NickAlias *na) = 0;
|
||||
};
|
||||
|
||||
static ServiceReference<NickServService> NickServService("NickServService", "NickServ");
|
||||
|
||||
Reference in New Issue
Block a user