]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
This should probably be tested, but makes a whole lot more sense like this (users...
[user/henk/code/inspircd.git] / src / channels.cpp
index c03a69ace9222a66d3a95cd8b42859069c69e21e..effc47d73572a38ebb1c62b5a8f2fb956bc95015 100644 (file)
@@ -20,7 +20,7 @@
 
 Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance)
 {
-       chan_hash::iterator findchan = ServerInstance->chanlist->find(name);
+       chan_hash::iterator findchan = ServerInstance->chanlist->find(cname);
        if (findchan != Instance->chanlist->end())
                throw CoreException("Cannot create duplicate channel " + cname);
 
@@ -450,6 +450,37 @@ bool Channel::IsBanned(User* user)
        return false;
 }
 
+bool Channel::IsExtBanned(User *user, char type)
+{
+       // XXX. do we need events?
+       char mask[MAXBUF];
+       char *maskptr;
+
+       snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString());
+
+       for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++)
+       {
+               if (i->data[0] != type || i->data[1] != ':')
+                       continue;
+
+               // Iterate past char and : to get to the mask without doing a data copy(!)
+               maskptr = i->data;
+               maskptr++; // past the char
+               maskptr++; // past the :
+
+               /* This allows CIDR ban matching
+                * 
+                *        Full masked host                             Full unmasked host                     IP with/without CIDR
+                */
+               if ((match(user->GetFullHost(), maskptr)) || (match(user->GetFullRealHost(), maskptr)) || (match(mask, maskptr, true)))
+               {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 /* Channel::PartUser
  * remove a channel from a users record, and return the number of users left.
  * Therefore, if this function returns 0 the caller should delete the Channel.
@@ -492,7 +523,7 @@ long Channel::PartUser(User *user, const char* reason)
        return this->GetUserCounter();
 }
 
-long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents)
+long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents, const char* servername)
 {
        bool silent = false;
 
@@ -508,6 +539,9 @@ long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents)
                }
        }
 
+       if (servername == NULL)
+               servername = ServerInstance->Config->ServerName;
+
        if (triggerevents)
        {
                FOREACH_MOD(I_OnUserKick,OnUserKick(NULL, user, this, reason, silent));
@@ -517,7 +551,7 @@ long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents)
        if (i != user->chans.end())
        {
                if (!silent)
-                       this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason);
+                       this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name, user->nick, reason);
 
                user->chans.erase(i);
                this->RemoveAllPrefixes(user);