Make +z in set::modes-on-join work (and auto +Z setting). Reported by FwdInTime ().

This commit is contained in:
Bram Matthys 2017-02-10 14:24:10 +01:00
parent a687ab022b
commit 5fcff0dd90
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
2 changed files with 21 additions and 2 deletions
src/modules/chanmodes

View file

@ -180,9 +180,14 @@ void issecure_set(aChannel *chptr, aClient *sptr, int notice)
DLLFUNC int issecure_join(aClient *cptr, aClient *sptr, aChannel *chptr, char *parv[])
{
/* Only care if chan already +zZ and the user joining is insecure (no need to count) */
/* Check only if chan already +zZ and the user joining is insecure (no need to count) */
if (IsSecureJoin(chptr) && IsSecureChanIndicated(chptr) && !IsSecureConnect(sptr) && !IsULine(sptr))
issecure_unset(chptr, sptr, 1);
/* Special case for +z in modes-on-join and first user creating the channel */
if ((chptr->users == 1) && IsSecureJoin(chptr) && !IsSecureChanIndicated(chptr) && !channel_has_insecure_users(chptr))
issecure_set(chptr, NULL, 0);
return 0;
}

View file

@ -37,6 +37,7 @@ void secureonly_channel_sync (aChannel* chptr, unsigned short merge, unsigned sh
int secureonly_check_send (aClient *acptr, aChannel* chptr);
int secureonly_check_secure (aChannel* chptr);
int secureonly_check_sajoin (aClient *acptr, aChannel* chptr, aClient *sptr);
int secureonly_specialcheck(aClient *sptr, aChannel *chptr, char *parv[]);
MOD_TEST(sslonly)
{
@ -52,7 +53,8 @@ MOD_INIT(sslonly)
req.flag = 'z';
req.is_ok = extcmode_default_requirechop;
CmodeAdd(modinfo->handle, req, &EXTCMODE_SSLONLY);
HookAdd(modinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, 0, secureonly_specialcheck);
HookAdd(modinfo->handle, HOOKTYPE_CAN_JOIN, 0, secureonly_check_join);
HookAddVoid(modinfo->handle, HOOKTYPE_CHANNEL_SYNCED, 0, secureonly_channel_sync);
HookAdd(modinfo->handle, HOOKTYPE_IS_CHANNEL_SECURE, 0, secureonly_check_secure);
@ -171,3 +173,15 @@ int secureonly_check_sajoin (aClient *acptr, aChannel* chptr, aClient *sptr)
return HOOK_CONTINUE;
}
/* Special check for +z in set::modes-on-join. Needs to be done early.
* Perhaps one day this will be properly handled in the core so this can be removed.
*/
int secureonly_specialcheck(aClient *sptr, aChannel *chptr, char *parv[])
{
if ((chptr->users == 0) && (iConf.modes_on_join.extmodes & EXTCMODE_SSLONLY) && !IsSecure(sptr) && !IsOper(sptr))
{
sendto_one(sptr, err_str(ERR_SECUREONLYCHAN), me.name, sptr->name, chptr->chname);
return HOOK_DENY;
}
return HOOK_ALLOW;
}