mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-04 04:43:14 +02:00
Add HOOKTYPE_IS_HANDSHAKE_FINISHED: if a module returns 0 then register_user()
will not be called. This is used, for example, by m_cap when the CAP LS handshake is still in progress. Modules can add their own requirements as they see fit. Note that, as for (CAP) functionality, this adds nothing new, it just implements it in a cleaner way, rather than all over the place, like in UnrealIRCd 4.x.
This commit is contained in:
@@ -38,6 +38,7 @@ ModuleHeader MOD_HEADER(m_cap)
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cap_is_handshake_finished(aClient *acptr);
|
||||
int cap_never_visible(aClient *acptr);
|
||||
|
||||
/* Variables */
|
||||
@@ -93,6 +94,8 @@ MOD_INIT(m_cap)
|
||||
c.name = "extended-join";
|
||||
ClientCapabilityAdd(modinfo->handle, &c, &CAP_EXTENDED_JOIN);
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_IS_HANDSHAKE_FINISHED, 0, cap_is_handshake_finished);
|
||||
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -369,6 +372,15 @@ int cap_never_visible(aClient *acptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Is our handshake done? */
|
||||
int cap_is_handshake_finished(aClient *acptr)
|
||||
{
|
||||
if (HasCapabilityFast(acptr, CAP_IN_PROGRESS))
|
||||
return 0; /* We are in CAP LS stage, waiting for a CAP END */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
CMD_FUNC(m_cap)
|
||||
{
|
||||
struct clicap_cmd *cmd;
|
||||
|
||||
@@ -1095,7 +1095,7 @@ CMD_FUNC(m_nick)
|
||||
}
|
||||
/* This had to be copied here to avoid problems.. */
|
||||
strlcpy(sptr->name, nick, sizeof(sptr->name));
|
||||
if (user_ready_for_register(sptr))
|
||||
if (is_handshake_finished(sptr))
|
||||
{
|
||||
/*
|
||||
** USER already received, now we have NICK.
|
||||
|
||||
@@ -135,7 +135,7 @@ CMD_FUNC(m_nospoof)
|
||||
sendto_one(sptr, NULL, ":IRC!IRC@%s PRIVMSG %s :\1VERSION\1",
|
||||
me.name, sptr->name);
|
||||
|
||||
if (user_ready_for_register(sptr))
|
||||
if (is_handshake_finished(sptr))
|
||||
return register_user(cptr, sptr, sptr->name,
|
||||
sptr->user->username, NULL, NULL, NULL);
|
||||
return 0;
|
||||
|
||||
@@ -169,7 +169,7 @@ CMD_FUNC(m_user)
|
||||
|
||||
strlcpy(sptr->info, realname, sizeof(sptr->info));
|
||||
if (*sptr->name &&
|
||||
(IsServer(cptr) || user_ready_for_register(cptr))
|
||||
(IsServer(cptr) || is_handshake_finished(cptr))
|
||||
)
|
||||
/* NICK and no-spoof already received, now we have USER... */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user