diff options
-rw-r--r-- | src/InspIRCd.dev | 12 | ||||
-rw-r--r-- | src/InspIRCd.layout | 39 | ||||
-rw-r--r-- | src/inspircd.cpp | 107 | ||||
-rw-r--r-- | src/mode.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_chanprotect.cpp | 16 | ||||
-rw-r--r-- | src/modules/m_override.cpp | 137 |
6 files changed, 247 insertions, 80 deletions
diff --git a/src/InspIRCd.dev b/src/InspIRCd.dev index 2012957fc..10bec5936 100644 --- a/src/InspIRCd.dev +++ b/src/InspIRCd.dev @@ -1,7 +1,7 @@ [Project] FileName=InspIRCd.dev Name=InspIRCd - The Inspire Internet Relay Chat Daemon -UnitCount=51 +UnitCount=52 Type=1 Ver=1 ObjFiles= @@ -555,3 +555,13 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit52] +FileName=modules\m_override.cpp +CompileCpp=1 +Folder=Modules +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index cfe4ed1d3..478e0c375 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=1 +Focused=-1 Order=2,4,6,3,7,25,5,24,39,42,43,-1,1,46,0,49 [Editor_0] @@ -12,10 +12,10 @@ LeftChar=1 [Editor_1] Open=1 -Top=1 -CursorCol=42 -CursorRow=2883 -TopLine=2854 +Top=0 +CursorCol=3 +CursorRow=1364 +TopLine=1345 LeftChar=1 [Editor_2] @@ -103,7 +103,7 @@ Open=1 Top=0 CursorCol=9 CursorRow=193 -TopLine=45 +TopLine=102 LeftChar=1 [Editor_13] @@ -165,9 +165,9 @@ LeftChar=1 [Editor_20] Open=1 Top=0 -CursorCol=34 -CursorRow=662 -TopLine=609 +CursorCol=66 +CursorRow=39 +TopLine=1 LeftChar=1 [Editor_21] @@ -323,15 +323,15 @@ LeftChar=1 [Editor_42] Open=1 Top=0 -CursorCol=41 -CursorRow=510 -TopLine=481 +CursorCol=1 +CursorRow=1032 +TopLine=1026 LeftChar=1 [Editor_43] Open=1 Top=0 CursorCol=1 -CursorRow=638 +CursorRow=643 TopLine=614 LeftChar=1 [Editor_44] @@ -379,7 +379,14 @@ LeftChar=1 [Editor_50] Open=1 Top=0 -CursorCol=65 -CursorRow=35 -TopLine=19 +CursorCol=35 +CursorRow=140 +TopLine=95 +LeftChar=1 +[Editor_51] +Open=1 +Top=1 +CursorCol=1 +CursorRow=67 +TopLine=17 LeftChar=1 diff --git a/src/inspircd.cpp b/src/inspircd.cpp index dc7b7942a..4250bdc75 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1312,7 +1312,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri { int MOD_RESULT = 0; FOREACH_RESULT(OnUserPreJoin(user,NULL,cname)); - if (MOD_RESULT) { + if (MOD_RESULT == 1) { return NULL; } @@ -1350,76 +1350,81 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri { int MOD_RESULT = 0; FOREACH_RESULT(OnUserPreJoin(user,Ptr,cname)); - if (MOD_RESULT) { + if (MOD_RESULT == 1) { return NULL; } - if (strcmp(Ptr->key,"")) + if (MOD_RESULT == 0) { - log(DEBUG,"add_channel: %s has key %s",Ptr->name,Ptr->key); - if (!key) - { - log(DEBUG,"add_channel: no key given in JOIN"); - WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name); - return NULL; - } - else + + if (strcmp(Ptr->key,"")) { - log(DEBUG,"key at %p is %s",key,key); - if (strcasecmp(key,Ptr->key)) + log(DEBUG,"add_channel: %s has key %s",Ptr->name,Ptr->key); + if (!key) { - log(DEBUG,"add_channel: bad key given in JOIN"); - WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name); + log(DEBUG,"add_channel: no key given in JOIN"); + WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name); return NULL; } + else + { + log(DEBUG,"key at %p is %s",key,key); + if (strcasecmp(key,Ptr->key)) + { + log(DEBUG,"add_channel: bad key given in JOIN"); + WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name); + return NULL; + } + } } - } - log(DEBUG,"add_channel: no key"); - - if (Ptr->inviteonly) - { - log(DEBUG,"add_channel: channel is +i"); - if (user->IsInvited(Ptr->name)) - { - /* user was invited to channel */ - /* there may be an optional channel NOTICE here */ - } - else + log(DEBUG,"add_channel: no key"); + + if (Ptr->inviteonly) { - WriteServ(user->fd,"473 %s %s :Cannot join channel (Invite only)",user->nick, Ptr->name); - return NULL; + log(DEBUG,"add_channel: channel is +i"); + if (user->IsInvited(Ptr->name)) + { + /* user was invited to channel */ + /* there may be an optional channel NOTICE here */ + } + else + { + WriteServ(user->fd,"473 %s %s :Cannot join channel (Invite only)",user->nick, Ptr->name); + return NULL; + } } - } - log(DEBUG,"add_channel: channel is not +i"); - - if (Ptr->limit) - { - if (usercount(Ptr) == Ptr->limit) + log(DEBUG,"add_channel: channel is not +i"); + + if (Ptr->limit) { - WriteServ(user->fd,"471 %s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name); - return NULL; + if (usercount(Ptr) == Ptr->limit) + { + WriteServ(user->fd,"471 %s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name); + return NULL; + } } - } - - log(DEBUG,"add_channel: about to walk banlist"); - - /* check user against the channel banlist */ - if (Ptr) - { - if (Ptr->bans.size()) + + log(DEBUG,"add_channel: about to walk banlist"); + + /* check user against the channel banlist */ + if (Ptr) { - for (BanList::iterator i = Ptr->bans.begin(); i != Ptr->bans.end(); i++) + if (Ptr->bans.size()) { - if (match(user->GetFullHost(),i->data)) + for (BanList::iterator i = Ptr->bans.begin(); i != Ptr->bans.end(); i++) { - WriteServ(user->fd,"474 %s %s :Cannot join channel (You're banned)",user->nick, Ptr->name); - return NULL; + if (match(user->GetFullHost(),i->data)) + { + WriteServ(user->fd,"474 %s %s :Cannot join channel (You're banned)",user->nick, Ptr->name); + return NULL; + } } } } - } + + log(DEBUG,"add_channel: bans checked"); - log(DEBUG,"add_channel: bans checked"); + } if ((Ptr) && (user)) diff --git a/src/mode.cpp b/src/mode.cpp index 4a7c56bd3..e7ed4badf 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -1046,7 +1046,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user) if ((dest) && (pcnt == 1)) { - WriteServ(user->fd,"221 %s :+%s",user->nick,user->modes); + WriteServ(user->fd,"221 %s :+%s",dest->nick,dest->modes); return; } @@ -1254,10 +1254,18 @@ void handle_mode(char **parameters, int pcnt, userrec *user) } } - if ((cstatus(user,Ptr) < STATUS_HOP) && (Ptr)) - { - WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, Ptr->name); + int MOD_RESULT = 0; + FOREACH_RESULT(OnAccessCheck(user,NULL,Ptr,AC_GENERAL_MODE)); + + if (MOD_RESULT == ACR_DENY) return; + if (MOD_RESULT == ACR_DEFAULT) + { + if ((cstatus(user,Ptr) < STATUS_HOP) && (Ptr)) + { + WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, Ptr->name); + return; + } } process_modes(parameters,user,Ptr,cstatus(user,Ptr),pcnt,false,false,false); diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 99d219d24..ce7680ad4 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -90,12 +90,12 @@ class ModuleChanProtect : public Module case AC_DEOP: if (dest->GetExt("cm_founder_"+std::string(channel->name))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as the're a channel founder"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as the're a channel founder"); return ACR_DENY; } if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as the're protected (+a)"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't deop "+std::string(dest->nick)+" as the're protected (+a)"); return ACR_DENY; } break; @@ -104,12 +104,12 @@ class ModuleChanProtect : public Module case AC_KICK: if (dest->GetExt("cm_founder_"+std::string(channel->name))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as the're a channel founder"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as the're a channel founder"); return ACR_DENY; } if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as the're protected (+a)"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't kick "+std::string(dest->nick)+" as the're protected (+a)"); return ACR_DENY; } break; @@ -118,12 +118,12 @@ class ModuleChanProtect : public Module case AC_DEHALFOP: if (dest->GetExt("cm_founder_"+std::string(channel->name))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as the're a channel founder"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as the're a channel founder"); return ACR_DENY; } if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as the're protected (+a)"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't de-halfop "+std::string(dest->nick)+" as the're protected (+a)"); return ACR_DENY; } break; @@ -132,12 +132,12 @@ class ModuleChanProtect : public Module case AC_DEVOICE: if (dest->GetExt("cm_founder_"+std::string(channel->name))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as the're a channel founder"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as the're a channel founder"); return ACR_DENY; } if ((dest->GetExt("cm_protect_"+std::string(channel->name))) && (!source->GetExt("cm_protect_"+std::string(channel->name)))) { - Srv->SendServ(source->fd,"482 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as the're protected (+a)"); + Srv->SendServ(source->fd,"484 "+std::string(source->nick)+" "+std::string(channel->name)+" :Can't devoice "+std::string(dest->nick)+" as the're protected (+a)"); return ACR_DENY; } break; diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp new file mode 100644 index 000000000..ae90a76a7 --- /dev/null +++ b/src/modules/m_override.cpp @@ -0,0 +1,137 @@ +#include <stdio.h> + +#include "users.h" +#include "channels.h" +#include "modules.h" + +/* $ModDesc: Provides channel modes +a and +q */ + +char dummyvalue[] = "on"; + +class ModuleOverride : public Module +{ + Server *Srv; + bool NoisyOverride; + ConfigReader *Conf; + + public: + + ModuleOverride() + { + + // here we initialise our module. Use new to create new instances of the required + // classes. + + Srv = new Server; + Conf = new ConfigReader; + + // read our config options (main config file) + NoisyOverride = Conf->ReadFlag("override","noisy",0); + } + + virtual void OnRehash() + { + // on a rehash we delete our classes for good measure and create them again. + delete Conf; + Conf = new ConfigReader; + // re-read our config options on a rehash + NoisyOverride = Conf->ReadFlag("override","noisy",0); + } + + virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type) + { + if (strchr(source->modes,'o')) + { + if ((Srv->ChanMode(source,channel) != "%") && (Srv->ChanMode(source,channel) != "@")) + { + switch (access_type) + { + case AC_KICK: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Kicked "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + case AC_DEOP: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + case AC_OP: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + case AC_VOICE: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Voiced "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + case AC_DEVOICE: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Devoiced "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + case AC_HALFOP: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Halfopped "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + case AC_DEHALFOP: + Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Dehalfopped "+std::string(dest->nick)+" on "+std::string(channel->name)); + break; + } + } + return ACR_ALLOW; + } + + return ACR_DEFAULT; + } + + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + { + if (strchr(user->modes,'o')) + { + if (chan) + { + if ((chan->inviteonly) || (chan->key[0]) || (chan->limit >= Srv->CountUsers(chan))) + { + if (NoisyOverride) + { + if (!user->IsInvited(chan->name)) + { + WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,user,"NOTICE %s :%s invited himself into the channel",cname,user->nick); + } + } + Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i, +k or +l on "+std::string(cname)); + } + return -1; + } + } + return 0; + } + + virtual ~ModuleOverride() + { + delete Conf; + delete Srv; + } + + virtual Version GetVersion() + { + return Version(1,0,0,0); + } +}; + + +class ModuleOverrideFactory : public ModuleFactory +{ + public: + ModuleOverrideFactory() + { + } + + ~ModuleOverrideFactory() + { + } + + virtual Module * CreateModule() + { + return new ModuleOverride; + } + +}; + + +extern "C" void * init_module( void ) +{ + return new ModuleOverrideFactory; +} + |