* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
*/
#include "inspircd.h"
-#include "m_override.h"
/* $ModDesc: Provides support for unreal-style oper-override */
-typedef std::map<std::string,std::string> override_t;
-
class ModuleOverride : public Module
{
- override_t overrides;
bool RequireKey;
bool NoisyOverride;
// read our config options (main config file)
OnRehash(NULL);
ServerInstance->SNO->EnableSnomask('G', "GODMODE");
- if (!ServerInstance->Modules->PublishFeature("Override", this))
- {
- throw ModuleException("m_override: Unable to publish feature 'Override'");
- }
- Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange, I_OnRequest };
- ServerInstance->Modules->Attach(eventlist, this, 7);
+ Implementation eventlist[] = { I_OnRehash, I_OnPreMode, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPreTopicChange };
+ ServerInstance->Modules->Attach(eventlist, this, 6);
}
void OnRehash(User* user)
// re-read our config options on a rehash
NoisyOverride = Conf.ReadFlag("override", "noisy", 0);
RequireKey = Conf.ReadFlag("override", "requirekey", 0);
-
- overrides.clear();
-
- for (int j =0; j < Conf.Enumerate("type"); j++)
- {
- std::string typen = Conf.ReadValue("type","name",j);
- std::string tokenlist = Conf.ReadValue("type","override",j);
- overrides[typen] = tokenlist;
- }
}
void On005Numeric(std::string &output)
bool CanOverride(User* source, const char* token)
{
- // checks to see if the oper's type has <type:override>
- override_t::iterator j = overrides.find(source->oper);
+ std::string tokenlist = source->oper->getConfig("override");
- if (j != overrides.end())
- {
- // its defined or * is set, return its value as a boolean for if the token is set
- return ((j->second.find(token, 0) != std::string::npos) || (j->second.find("*", 0) != std::string::npos));
- }
-
- // its not defined at all, count as false
- return false;
+ // its defined or * is set, return its value as a boolean for if the token is set
+ return ((tokenlist.find(token, 0) != std::string::npos) || (tokenlist.find("*", 0) != std::string::npos));
}
ModResult OnPreMode(User* source,User* dest,Channel* channel, const std::vector<std::string>& parameters)
{
- if (!IS_OPER(source))
- return MOD_RES_PASSTHRU;
if (!source || !channel)
return MOD_RES_PASSTHRU;
+ if (!IS_OPER(source) || !IS_LOCAL(source))
+ return MOD_RES_PASSTHRU;
- unsigned int mode = 0;
- if (channel->HasUser(source))
- mode = channel->GetPrefixValue(source);
+ unsigned int mode = channel->GetPrefixValue(source);
if (mode < HALFOP_VALUE && CanOverride(source, "MODE"))
{
{
if (chan)
{
- if ((chan->modes[CM_INVITEONLY]) && (CanOverride(user,"INVITE")))
+ if (chan->IsModeSet('i') && (CanOverride(user,"INVITE")))
{
irc::string x(chan->name.c_str());
- if (!user->IsInvited(x))
+ if (!IS_LOCAL(user)->IsInvited(x))
{
if (RequireKey && keygiven != "override")
{
return MOD_RES_ALLOW;
}
- if ((chan->modes[CM_KEY]) && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k'))
+ if (chan->IsModeSet('k') && (CanOverride(user,"KEY")) && keygiven != chan->GetModeParameter('k'))
{
if (RequireKey && keygiven != "override")
{
return MOD_RES_ALLOW;
}
- if ((chan->modes[CM_LIMIT]) && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT")))
+ if (chan->IsModeSet('l') && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT")))
{
if (RequireKey && keygiven != "override")
{
return MOD_RES_PASSTHRU;
}
- const char* OnRequest(Request* request)
- {
- if(strcmp(OVRREQID, request->GetId()) == 0)
- {
- OVRrequest* req = static_cast<OVRrequest*>(request);
- return this->CanOverride(req->requser,req->reqtoken.c_str()) ? "yes":"";
- }
- return NULL;
- }
-
~ModuleOverride()
{
- ServerInstance->Modules->UnpublishFeature("Override");
ServerInstance->SNO->DisableSnomask('G');
}
Version GetVersion()
{
- return Version("Provides support for unreal-style oper-override",VF_VENDOR,API_VERSION);
+ return Version("Provides support for unreal-style oper-override",VF_VENDOR);
}
};