From 6d64862fb556c43568efdf6b4f65de3fbd33c576 Mon Sep 17 00:00:00 2001 From: w00t Date: Thu, 7 Aug 2008 16:35:58 +0000 Subject: [PATCH] Implement , 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 --- conf/inspircd.conf.example | 15 ++++++++++----- include/configreader.h | 6 +++++- src/channels.cpp | 23 ++++++++++++++++++----- src/configreader.cpp | 3 ++- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/conf/inspircd.conf.example b/conf/inspircd.conf.example index 4e82a152a..f9762b5a5 100644 --- a/conf/inspircd.conf.example +++ b/conf/inspircd.conf.example @@ -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. # +# # +# # + exemptchanops="" + invitebypassmodes="yes"> #-#-#-#-#-#-#-#-#-#-#-# PERFORMANCE CONFIGURATION #-#-#-#-#-#-#-#-#-#-# diff --git a/include/configreader.h b/include/configreader.h index 51eb2f5fd..9ec68b9e8 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -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 diff --git a/src/channels.cpp b/src/channels.cpp index 4d32f6719..0b24aa4b7 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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()); + } } } } diff --git a/src/configreader.cpp b/src/configreader.cpp index 4a4e97a89..424f3ad68 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -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} }; -- 2.39.2