summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-05-01 16:20:53 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-05-01 16:20:53 +0000
commitce9efee8c8f22425e21165465e0ba63255eacffe (patch)
treedfeb7b983c6bc0ad074e404687f32fc3d98b5975 /src
parent90cc4b0ee93696e6e6b3208cd2877ae6e786440d (diff)
Added comments
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@768 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_chanprotect.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp
index a37b4d325..ce43a90a4 100644
--- a/src/modules/m_chanprotect.cpp
+++ b/src/modules/m_chanprotect.cpp
@@ -54,6 +54,10 @@ class ModuleChanProtect : public Module
{
if (Srv->CountUsers(channel) == 1)
{
+ // we're using Extensible::Extend to add data into user objects.
+ // this way is best as it adds data thats accessible to other modules
+ // (so long as you document your code properly) without breaking anything
+ // because its encapsulated neatly in a map.
if (user->Extend("cm_founder_"+std::string(channel->name),dummyvalue))
{
Srv->Log(DEBUG,"Marked user "+std::string(user->nick)+" as founder for "+std::string(channel->name));
@@ -64,19 +68,27 @@ class ModuleChanProtect : public Module
virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type)
{
+ // here we perform access checks, this is the important bit that actually stops kicking/deopping
+ // etc of protected users. There are many types of access check, we're going to handle
+ // a relatively small number of them relevent to our module using a switch statement.
+
// don't allow action if:
// (A) Theyre founder (no matter what)
// (B) Theyre protected, and you're not
// always allow the action if:
// (A) The source is ulined
- if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)))
+
+ // firstly, if a ulined nick, or a server, is setting the mode, then allow them to set the mode
+ // without any access checks, we're not worthy :p
+ if ((Srv->IsUlined(source->nick)) || (Srv->IsUlined(source->server)) || (!strcmp(source->server,"")))
{
return ACR_ALLOW;
}
switch (access_type)
{
+ // a user has been deopped. Do we let them? hmmm...
case AC_DEOP:
if (dest->GetExt("cm_founder_"+std::string(channel->name)))
{
@@ -90,6 +102,7 @@ class ModuleChanProtect : public Module
}
break;
+ // a user is being kicked. do we chop off the end of the army boot?
case AC_KICK:
if (dest->GetExt("cm_founder_"+std::string(channel->name)))
{
@@ -103,6 +116,7 @@ class ModuleChanProtect : public Module
}
break;
+ // a user is being dehalfopped. Yes, we do disallow -h of a +ha user
case AC_DEHALFOP:
if (dest->GetExt("cm_founder_"+std::string(channel->name)))
{
@@ -116,6 +130,7 @@ class ModuleChanProtect : public Module
}
break;
+ // same with devoice.
case AC_DEVOICE:
if (dest->GetExt("cm_founder_"+std::string(channel->name)))
{
@@ -129,6 +144,8 @@ class ModuleChanProtect : public Module
}
break;
}
+
+ // we dont know what this access check is, or dont care. just carry on, nothing to see here.
return ACR_DEFAULT;
}
@@ -149,6 +166,7 @@ class ModuleChanProtect : public Module
if (!Srv->IsOnChannel(theuser,chan))
return -1;
+ // source is a server, or ulined, we'll let them +-q the user.
if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!strcmp(user->server,"")))
{
if (mode_on)
@@ -172,6 +190,7 @@ class ModuleChanProtect : public Module
}
else
{
+ // whoops, someones being naughty!
WriteServ(user->fd,"482 %s %s :Only servers may set channel mode +q",user->nick, chan->name);
return -1;
}
@@ -189,7 +208,8 @@ class ModuleChanProtect : public Module
// given user isnt even on the channel, eat the mode change
if (!Srv->IsOnChannel(theuser,chan))
return -1;
-
+
+ // source has +q, is a server, or ulined, we'll let them +-a the user.
if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!strcmp(user->server,"")) || (user->GetExt("cm_founder_"+std::string(chan->name))))
{
if (mode_on)
@@ -213,6 +233,7 @@ class ModuleChanProtect : public Module
}
else
{
+ // bzzzt, wrong answer!
WriteServ(user->fd,"482 %s %s :You are not a channel founder",user->nick, chan->name);
return -1;
}
@@ -233,6 +254,9 @@ class ModuleChanProtect : public Module
virtual string_list OnChannelSync(chanrec* chan)
{
+ // this is called when the server is linking into a net and wants to sync channel data.
+ // we should send our mode changes for the channel here to ensure that other servers
+ // know whos +q/+a on the channel.
chanuserlist cl = Srv->GetUsers(chan);
string_list commands;
for (int i = 0; i < cl.size(); i++)