* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
* E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
* ---------------------------------------------------
*/
+using namespace std;
+
#include <stdio.h>
#include "users.h"
#include "channels.h"
#include "modules.h"
+#include "helperfuncs.h"
/* $ModDesc: Provides support for unreal-style oper-override */
-char dummyvalue[] = "on";
-
class ModuleOverride : public Module
{
Server *Srv;
public:
- ModuleOverride()
+ ModuleOverride(Server* Me)
+ : Module::Module(Me)
{
// here we initialise our module. Use new to create new instances of the required
// classes.
- Srv = new Server;
+ Srv = Me;
Conf = new ConfigReader;
// read our config options (main config file)
NoisyOverride = Conf->ReadFlag("override","noisy",0);
}
- virtual void OnRehash()
+ virtual void OnRehash(std::string parameter)
{
// on a rehash we delete our classes for good measure and create them again.
delete Conf;
NoisyOverride = Conf->ReadFlag("override","noisy",0);
}
+ void Implements(char* List)
+ {
+ List[I_OnRehash] = List[I_OnAccessCheck] = List[I_On005Numeric] = List[I_OnUserPreJoin] = List[I_OnUserPreKick] = 1;
+ }
+
virtual void On005Numeric(std::string &output)
{
output = output + std::string(" OVERRIDE");
// its not defined at all, count as false
return false;
}
+
+ virtual int OnUserPreKick(userrec* source, userrec* user, chanrec* chan, std::string reason)
+ {
+ if ((*source->oper) && (CanOverride(source,"KICK")))
+ {
+ if (((Srv->ChanMode(source,chan) == "%") && (Srv->ChanMode(user,chan) == "@")) || (Srv->ChanMode(source,chan) == ""))
+ {
+ Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
+ }
+ /* Returning -1 explicitly allows the kick */
+ return -1;
+ }
+ return 0;
+ }
virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
{
- if (strchr(source->modes,'o'))
+ if (*source->oper)
{
if ((Srv) && (source) && (channel))
{
{
switch (access_type)
{
- case AC_KICK:
- if (CanOverride(source,"KICK"))
- {
- Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
- }
- else return ACR_DEFAULT;
- break;
case AC_DEOP:
- if (CanOverride(source,"MODEOP"))
+ if (CanOverride(source,"MODEDEOP"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
else return ACR_DEFAULT;
break;
case AC_OP:
- if (CanOverride(source,"MODEDEOP"))
+ if (CanOverride(source,"MODEOP"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name));
return ACR_ALLOW;
virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
{
- if (strchr(user->modes,'o'))
+ if (*user->oper)
{
if (chan)
{
- if ((chan->inviteonly) && (CanOverride(user,"INVITE")))
+ if ((chan->binarymodes & CM_INVITEONLY) && (CanOverride(user,"INVITE")))
{
if (NoisyOverride)
{
- if (!user->IsInvited(chan->name))
+ irc::string x = chan->name;
+ if (!user->IsInvited(x))
{
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,user,"NOTICE %s :%s invited himself into the channel",cname,user->nick);
+ WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s invited himself into the channel",cname,user->nick);
}
}
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
if ((chan->key[0]) && (CanOverride(user,"KEY")))
{
if (NoisyOverride)
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,user,"NOTICE %s :%s bypassed the channel key",cname,user->nick);
+ WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s bypassed the channel key",cname,user->nick);
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +k on "+std::string(cname));
return -1;
}
if ((chan->limit >= Srv->CountUsers(chan)) && (CanOverride(user,"LIMIT")))
{
if (NoisyOverride)
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,user,"NOTICE %s :%s passed through your channel limit",cname,user->nick);
+ WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s passed through your channel limit",cname,user->nick);
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +l on "+std::string(cname));
return -1;
}
virtual ~ModuleOverride()
{
delete Conf;
- delete Srv;
}
virtual Version GetVersion()
{
}
- virtual Module * CreateModule()
+ virtual Module * CreateModule(Server* Me)
{
- return new ModuleOverride;
+ return new ModuleOverride(Me);
}
};