]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Allow connect classes to be specified without an allow or deny mask
[user/henk/code/inspircd.git] / src / users.cpp
index f429597daf797f015f785dc9c20395bbb857dbe4..c390e3471cf1124bda6428d769f43ca1fb69ac48 100644 (file)
@@ -621,10 +621,7 @@ void User::Oper(OperInfo* info)
                        l->ChangeDisplayedHost(vhost.c_str());
                std::string opClass = oper->getConfig("class");
                if (!opClass.empty())
-               {
                        l->SetClass(opClass);
-                       l->CheckClass();
-               }
        }
 
        ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",
@@ -817,8 +814,10 @@ void LocalUser::FullConnect()
                        return;
                }
        }
+       CheckClass();
+       CheckLines();
 
-       if (this->CheckLines())
+       if (quitting)
                return;
 
        this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network.c_str());
@@ -864,27 +863,6 @@ void LocalUser::FullConnect()
        ServerInstance->BanCache->AddHit(this->GetIPString(), "", "");
 }
 
-/** User::UpdateNick()
- * re-allocates a nick in the user_hash after they change nicknames,
- * returns a pointer to the new user as it may have moved
- */
-User* User::UpdateNickHash(const char* New)
-{
-       //user_hash::iterator newnick;
-       user_hash::iterator oldnick = ServerInstance->Users->clientlist->find(this->nick);
-
-       if (!irc::string(this->nick.c_str()).compare(New))
-               return oldnick->second;
-
-       if (oldnick == ServerInstance->Users->clientlist->end())
-               return NULL; /* doesnt exist */
-
-       User* olduser = oldnick->second;
-       ServerInstance->Users->clientlist->erase(oldnick);
-       (*(ServerInstance->Users->clientlist))[New] = olduser;
-       return olduser;
-}
-
 void User::InvalidateCache()
 {
        /* Invalidate cache */
@@ -971,8 +949,11 @@ bool User::ChangeNick(const std::string& newnick, bool force)
                                /* force the camper to their UUID, and ask them to re-send a NICK. */
                                InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str());
                                InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick.c_str(), InUse->nick.c_str());
-                               InUse->UpdateNickHash(InUse->uuid.c_str());
-                               InUse->nick.assign(InUse->uuid, 0, IS_LOCAL(InUse) ? ServerInstance->Config->Limits.NickMax : MAXBUF);
+
+                               ServerInstance->Users->clientlist->erase(InUse->nick);
+                               (*(ServerInstance->Users->clientlist))[InUse->uuid] = InUse;
+
+                               InUse->nick = InUse->uuid;
                                InUse->InvalidateCache();
                                InUse->registered &= ~REG_NICK;
                        }
@@ -980,7 +961,7 @@ bool User::ChangeNick(const std::string& newnick, bool force)
                        {
                                /* No camping, tell the incoming user  to stop trying to change nick ;p */
                                this->WriteNumeric(433, "%s %s :Nickname is already in use.", this->registered >= REG_NICK ? this->nick.c_str() : "*", newnick.c_str());
-                               return CMD_FAILURE;
+                               return false;
                        }
                }
        }
@@ -989,8 +970,11 @@ bool User::ChangeNick(const std::string& newnick, bool force)
                this->WriteCommon("NICK %s",newnick.c_str());
        std::string oldnick = nick;
        nick = newnick;
+
        InvalidateCache();
-       UpdateNickHash(newnick.c_str());
+       ServerInstance->Users->clientlist->erase(oldnick);
+       (*(ServerInstance->Users->clientlist))[newnick] = this;
+
        FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(this,oldnick));
        return true;
 }
@@ -1621,10 +1605,14 @@ void LocalUser::SetClass(const std::string &explicit_name)
                        {
                                ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "ALLOW %s %d %s", c->host.c_str(), c->GetPort(), c->GetName().c_str());
                        }
-                       else
+                       else if (c->type == CC_DENY)
                        {
                                ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "DENY %s %d %s", c->GetHost().c_str(), c->GetPort(), c->GetName().c_str());
                        }
+                       else
+                       {
+                               continue;
+                       }
 
                        /* check if host matches.. */
                        if (c->GetHost().length() && !InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&