Implement <options:invitebypassmodes>, optionally circumvent +blk if invited on join. Based on a patch provided by mixx941, closes bug #589.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10120 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
w00t 2008-08-07 16:35:58 +00:00
parent fd657b6cd1
commit 6d64862fb5
4 changed files with 35 additions and 12 deletions

View File

@ -874,10 +874,6 @@
# This can be useful for finding servers which are #
# at risk of pinging out due to network issues. #
# #
# exemptchanops - This option allows channel operators to be exempted#
# from certain channel modes. #
# Supported modes are +SfFgNc. Defaults to off. #
# #
# defaultmodes - The default modes to be given to each channel on #
# creation. Defaults to 'nt'. There should be no + #
# or - symbols in this sequence, if you add them #
@ -889,6 +885,14 @@
# is totally freeform, you may place any text here #
# you wish. #
# #
# exemptchanops - This option allows channel operators to be exempted#
# from certain channel modes. #
# Supported modes are +SfFgNc. Defaults to off. #
# #
# invitebypassmodes - This option allows /invite to bypass modes #
# other than +i. #
# #
# #
<options prefixquit="Quit: "
suffixquit=""
@ -909,7 +913,8 @@
allowhalfop="yes"
defaultmodes="nt"
moronbanner="You're banned! Email haha@abuse.com with the ERROR line below for help."
exemptchanops="">
exemptchanops=""
invitebypassmodes="yes">
#-#-#-#-#-#-#-#-#-#-#-# PERFORMANCE CONFIGURATION #-#-#-#-#-#-#-#-#-#-#

View File

@ -861,7 +861,11 @@ class CoreExport ServerConfig : public Extensible
* @return True if the file exists and is readable.
*/
static bool FileExists(const char* file);
/** If this value is true, invites will bypass more than just +i
*/
bool InvBypassModes;
};
/** Initialize the disabled commands list

View File

@ -336,32 +336,36 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
else if (MOD_RESULT == 0)
{
std::string ckey = Ptr->GetModeParameter('k');
bool invited = user->IsInvited(Ptr->name.c_str());
bool can_bypass = Instance->Config->InvBypassModes && invited;
if (!ckey.empty())
{
MOD_RESULT = 0;
FOREACH_RESULT_I(Instance, I_OnCheckKey, OnCheckKey(user, Ptr, key ? key : ""));
if (!MOD_RESULT)
{
if ((!key) || ckey != key)
// If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
if ((!key || ckey != key) && !can_bypass)
{
user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
}
if (Ptr->IsModeSet('i'))
{
MOD_RESULT = 0;
FOREACH_RESULT_I(Instance,I_OnCheckInvite,OnCheckInvite(user, Ptr));
if (!MOD_RESULT)
{
if (!user->IsInvited(Ptr->name.c_str()))
if (!invited)
{
user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
user->RemoveInvite(Ptr->name.c_str());
}
std::string limit = Ptr->GetModeParameter('l');
@ -372,7 +376,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
if (!MOD_RESULT)
{
long llimit = atol(limit.c_str());
if (Ptr->GetUserCounter() >= llimit)
if (Ptr->GetUserCounter() >= llimit && !can_bypass)
{
user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
@ -382,12 +386,21 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
if (Ptr->bans.size())
{
if (Ptr->IsBanned(user))
if (Ptr->IsBanned(user) && !can_bypass)
{
user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
return NULL;
}
}
/*
* If the user has invites for this channel, remove them now
* after a successful join so they don't build up.
*/
if (invited)
{
user->RemoveInvite(Ptr->name.c_str());
}
}
}
}

View File

@ -44,7 +44,7 @@ ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance)
WhoWasGroupSize = WhoWasMaxGroups = WhoWasMaxKeep = 0;
log_file = NULL;
NoUserDns = forcedebug = OperSpyWhois = nofork = HideBans = HideSplits = UndernetMsgPrefix = false;
CycleHosts = writelog = AllowHalfop = true;
CycleHosts = writelog = AllowHalfop = InvBypassModes = true;
dns_timeout = DieDelay = 5;
MaxTargets = 20;
NetBufferSize = 10240;
@ -878,6 +878,7 @@ void ServerConfig::Read(bool bail, User* user)
{"limits", "maxkick", "255", new ValueContainerST (&this->Limits.MaxKick), DT_INTEGER, NoValidation},
{"limits", "maxgecos", "128", new ValueContainerST (&this->Limits.MaxGecos), DT_INTEGER, NoValidation},
{"limits", "maxaway", "200", new ValueContainerST (&this->Limits.MaxAway), DT_INTEGER, NoValidation},
{"options", "invitebypassmodes", "1", new ValueContainerBool (&this->InvBypassModes), DT_BOOLEAN, NoValidation},
{NULL, NULL, NULL, NULL, DT_NOTHING, NoValidation}
};