]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Make User::uuid and User::server const
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 23 Oct 2009 22:47:39 +0000 (22:47 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 23 Oct 2009 22:47:39 +0000 (22:47 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11962 e03df62e-2008-0410-955e-edbf42e46eb7

22 files changed:
include/channels.h
include/users.h
src/channels.cpp
src/inspircd.cpp
src/modules/m_channames.cpp
src/modules/m_messageflood.cpp
src/modules/m_sakick.cpp
src/modules/m_spanningtree/encap.cpp
src/modules/m_spanningtree/fjoin.cpp
src/modules/m_spanningtree/fmode.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/postcommand.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treeserver.h
src/modules/m_spanningtree/treesocket.h
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/uid.cpp
src/modules/m_spanningtree/utils.cpp
src/modules/m_spanningtree/utils.h
src/usermanager.cpp
src/users.cpp

index 2915ed390573a35b395ad846d73b36f54b4981fc..5207acfdd45e3cac3d16777ebf9db9a7c4350348 100644 (file)
@@ -229,26 +229,13 @@ class CoreExport Channel : public Extensible
         * @param src The source of the kick
         * @param user The user being kicked (must be on this channel)
         * @param reason The reason for the kick
-        * @return The number of users left on the channel. If this is zero
-        * when the method returns, you MUST delete the Channel immediately!
         */
        void KickUser(User *src, User *user, const char* reason);
 
-       /** Make the server kick user from this channel with the given reason.
-        * @param user The user being kicked (must be on this channel)
-        * @param reason The reason for the kick
-        * @param triggerevents True if you wish this kick to trigger module events
-        * @return The number of users left on the channel. If this is zero
-        * when the method returns, you MUST delete the Channel immediately!
-        */
-       void ServerKickUser(User* user, const char* reason, const std::string& servername = "");
-
        /** Part a user from this channel with the given reason.
         * If the reason field is NULL, no reason will be sent.
         * @param user The user who is parting (must be on this channel)
         * @param reason The part reason
-        * @return The number of users left on the channel. If this is zero
-        * when the method returns, you MUST delete the Channel immediately!
         */
        void PartUser(User *user, std::string &reason);
 
index 8fac0d10813641c0a26bec5b9e6dd6c0a9ed1ff9..5e75414a498f19dac707567804ec7000a54c8dd3 100644 (file)
@@ -297,7 +297,7 @@ class CoreExport User : public StreamSocket
        /** The user's unique identifier.
         * This is the unique identifier which the user has across the network.
         */
-       std::string uuid;
+       const std::string uuid;
 
        /** The users ident reply.
         * Two characters are added to the user-defined limit to compensate for the tilde etc.
@@ -336,7 +336,7 @@ class CoreExport User : public StreamSocket
 
        /** The server the user is connected to.
         */
-       std::string server;
+       const std::string server;
 
        /** The user's away message.
         * If this string is empty, the user is not marked as away.
@@ -401,8 +401,9 @@ class CoreExport User : public StreamSocket
         * @throw CoreException if the UID allocated to the user already exists
         * @param Instance Creator instance
         * @param uid User UUID, or empty to allocate one automatically
+        * @param srv Server that this user is from
         */
-       User(const std::string &uid);
+       User(const std::string &uid, const std::string& srv);
 
        /** Check if the user matches a G or K line, and disconnect them if they do.
         * @param doZline True if ZLines should be checked (if IP has changed since initial connect)
@@ -415,7 +416,7 @@ class CoreExport User : public StreamSocket
         * on the server, in nick!ident&at;host form.
         * @return The full masked host of the user
         */
-       virtual const std::string GetFullHost();
+       virtual const std::string& GetFullHost();
 
        /** Returns the full real host of the user
         * This member function returns the hostname of the user as seen by other users
@@ -423,7 +424,7 @@ class CoreExport User : public StreamSocket
         * e.g. through a module, then this method will ignore it and return the true hostname.
         * @return The full real host of the user
         */
-       virtual const std::string GetFullRealHost();
+       virtual const std::string& GetFullRealHost();
 
        /** This clears any cached results that are used for GetFullRealHost() etc.
         * The results of these calls are cached as generating them can be generally expensive.
@@ -891,7 +892,7 @@ class CoreExport LocalUser : public User
 class CoreExport RemoteUser : public User
 {
  public:
-       RemoteUser(const std::string& uid) : User(uid)
+       RemoteUser(const std::string& uid, const std::string& srv) : User(uid, srv)
        {
                SetFd(FD_MAGIC_NUMBER);
        }
@@ -901,15 +902,16 @@ class CoreExport RemoteUser : public User
 class CoreExport FakeUser : public User
 {
  public:
-       FakeUser(const std::string &uid) : User(uid)
+       FakeUser(const std::string &uid, const std::string& srv) : User(uid, srv)
        {
                SetFd(FD_FAKEUSER_NUMBER);
+               nick = srv;
        }
 
+       virtual CullResult cull();
        virtual void SendText(const std::string& line);
-       virtual const std::string GetFullHost();
-       virtual const std::string GetFullRealHost();
-       void SetFakeServer(std::string name);
+       virtual const std::string& GetFullHost();
+       virtual const std::string& GetFullRealHost();
 };
 
 /* Faster than dynamic_cast */
index a4c24b4551bc286924d3e6c9c00f386dd863f372..fd9861279e15258972b5086b10cdce92c3c1c0ed 100644 (file)
@@ -483,16 +483,6 @@ void Channel::PartUser(User *user, std::string &reason)
        this->DelUser(user);
 }
 
-void Channel::ServerKickUser(User* user, const char* reason, const std::string& servername)
-{
-       if (servername.empty() || !ServerInstance->Config->HideWhoisServer.empty())
-               ServerInstance->FakeClient->server = ServerInstance->Config->ServerName;
-       else
-               ServerInstance->FakeClient->server = servername;
-
-       KickUser(ServerInstance->FakeClient, user, reason);
-}
-
 void Channel::KickUser(User *src, User *user, const char* reason)
 {
        if (!src || !user || !reason)
index 19f90dd9785ac445cc36ebfa18bff67cfd1e3ac4..58480668b99e1d01db636dd40c1fcfd077ad8550 100644 (file)
@@ -546,8 +546,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
        }
 
        /* set up fake client again this time with the correct uid */
-       this->FakeClient = new FakeUser("!");
-       this->FakeClient->SetFakeServer(Config->ServerName);
+       this->FakeClient = new FakeUser(Config->sid, Config->ServerName);
 
        // Get XLine to do it's thing.
        this->XLines->CheckELines();
index c137d0e716a9bde936348e46b096f325a3987dae..40746af2cab80969da4d52dc0a72e058f47ba12a 100644 (file)
@@ -82,7 +82,7 @@ class ModuleChannelNames : public Module
                        const UserMembList* users = c->GetUsers();
                        for(UserMembCIter j = users->begin(); j != users->end(); ++j)
                                if (IS_LOCAL(j->first))
-                                       c->ServerKickUser(j->first, "Channel name no longer valid", NULL);
+                                       c->KickUser(ServerInstance->FakeClient, j->first, "Channel name no longer valid");
                }
                badchan = false;
        }
index b2f82777fdbf17c6c12e63a16da2796bfdd5185f..c39bc980744cada0890ced417cbcad7f105d7179 100644 (file)
@@ -232,7 +232,7 @@ class ModuleMsgFlood : public Module
                                char kickmessage[MAXBUF];
                                snprintf(kickmessage, MAXBUF, "Channel flood triggered (limit is %d lines in %d secs)", f->lines, f->secs);
 
-                               dest->ServerKickUser(user, kickmessage);
+                               dest->KickUser(ServerInstance->FakeClient, user, kickmessage);
 
                                return MOD_RES_DENY;
                        }
index b81df75c6c6aac53c01035aea82cf24ae7130759..d6b6e965bde7742470cd0c6d9b9ece44f8d7486e 100644 (file)
@@ -31,7 +31,6 @@ class CommandSakick : public Command
                User* dest = ServerInstance->FindNick(parameters[1]);
                Channel* channel = ServerInstance->FindChan(parameters[0]);
                const char* reason = "";
-               const char* servername = NULL;
 
                if (dest && channel)
                {
@@ -56,7 +55,7 @@ class CommandSakick : public Command
                         */
                        if (IS_LOCAL(dest))
                        {
-                               channel->ServerKickUser(dest, reason, servername);
+                               channel->KickUser(ServerInstance->FakeClient, dest, reason);
 
                                Channel *n = ServerInstance->FindChan(parameters[1]);
                                if (n && n->HasUser(dest))
index 175257b0a804e64b02865ef8432a606a539d06db..e854df2f4740a3f7d0e90756408c40ac236600c7 100644 (file)
 
 
 /** ENCAP */
-bool TreeSocket::Encap(const std::string &prefix, parameterlist &params)
+void TreeSocket::Encap(User* who, parameterlist &params)
 {
        if (params.size() > 1)
        {
                if (InspIRCd::Match(ServerInstance->Config->GetSID(), params[0]))
                {
-                       User* who = ServerInstance->FindUUID(prefix);
-                       if (!who)
-                               who = Utils->ServerUser;
-
                        parameterlist plist(params.begin() + 2, params.end());
                        ServerInstance->CallCommandHandler(params[1].c_str(), plist, who);
                        // discard return value, ENCAP shall succeed even if the command does not exist
@@ -42,11 +38,10 @@ bool TreeSocket::Encap(const std::string &prefix, parameterlist &params)
 
                if (params[0].find('*') != std::string::npos)
                {
-                       Utils->DoOneToAllButSender(prefix, "ENCAP", params, prefix);
+                       Utils->DoOneToAllButSender(who->server, "ENCAP", params, who->server);
                }
                else
-                       Utils->DoOneToOne(prefix, "ENCAP", params, params[0]);
+                       Utils->DoOneToOne(who->server, "ENCAP", params, params[0]);
        }
-       return true;
 }
 
index 810cf23a54fe6f7f63f38e74554441e2bbf928ec..6895fa05160ed1d853b51e81628d00db1876d235 100644 (file)
@@ -22,7 +22,7 @@
 
 
 /** FJOIN, almost identical to TS6 SJOIN, except for nicklist handling. */
-bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
+void TreeSocket::ForceJoin(User* srcuser, parameterlist &params)
 {
        /* 1.1 FJOIN works as follows:
         *
@@ -51,7 +51,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
         * who succeed at internets. :-)
         */
        if (params.size() < 3)
-               return true;
+               return;
 
        irc::modestacker modestack(true);                       /* Modes to apply from the users in the user list */
        User* who = NULL;                                               /* User we are currently checking */
@@ -66,13 +66,13 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
        if (params.size() > 3)
                params[params.size() - 1] = ":" + params[params.size() - 1];
 
-       Utils->DoOneToAllButSender(source,"FJOIN",params,source);
+       Utils->DoOneToAllButSender(srcuser->server,"FJOIN",params,srcuser->server);
 
        if (!TS)
        {
                ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG? *** TS of 0 sent to FJOIN. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
-               ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", source.c_str());
-               return true;
+               ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", srcuser->server.c_str());
+               return;
        }
 
        if (created)
@@ -103,7 +103,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
                        ourTS = TS;
                        chan->age = TS;
                        param_list.push_back(channel);
-                       this->RemoveStatus(ServerInstance->Config->GetSID(), param_list);
+                       this->RemoveStatus(ServerInstance->FakeClient, param_list);
                }
                // The silent case here is ourTS == TS, we don't need to remove modes here, just to merge them later on.
        }
@@ -123,7 +123,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
                        modelist.push_back(params[idx]);
                }
 
-               ServerInstance->SendMode(modelist, Utils->ServerUser);
+               ServerInstance->SendMode(modelist, srcuser);
        }
 
        /* Now, process every 'modes,nick' pair */
@@ -145,7 +145,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
                                else
                                {
                                        this->SendError(std::string("Unknown status mode '")+(*unparsedmodes)+"' in FJOIN");
-                                       return false;
+                                       return;
                                }
 
                                usr++;
@@ -186,18 +186,16 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
 
                while (modestack.GetStackedLine(stackresult))
                {
-                       ServerInstance->SendMode(stackresult, Utils->ServerUser);
+                       ServerInstance->SendMode(stackresult, srcuser);
                        stackresult.erase(stackresult.begin() + 1, stackresult.end());
                }
        }
-
-       return true;
 }
 
-bool TreeSocket::RemoveStatus(const std::string &prefix, parameterlist &params)
+void TreeSocket::RemoveStatus(User* srcuser, parameterlist &params)
 {
        if (params.size() < 1)
-               return true;
+               return;
 
        Channel* c = ServerInstance->FindChan(params[0]);
 
@@ -221,10 +219,9 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, parameterlist &params)
 
                while (stack.GetStackedLine(stackresult))
                {
-                       ServerInstance->SendMode(stackresult, Utils->ServerUser);
+                       ServerInstance->SendMode(stackresult, srcuser);
                        stackresult.erase(stackresult.begin() + 1, stackresult.end());
                }
        }
-       return true;
 }
 
index 3bca098d62898eedef49bb23036161af221194f2..4dd05b101fabe3ecd67f53f035416966a265161c 100644 (file)
 
 
 /** FMODE command - server mode with timestamp checks */
-bool TreeSocket::ForceMode(const std::string &source, parameterlist &params)
+void TreeSocket::ForceMode(User* who, parameterlist &params)
 {
        /* Chances are this is a 1.0 FMODE without TS */
        if (params.size() < 3)
        {
                /* No modes were in the command, probably a channel with no modes set on it */
-               return true;
+               return;
        }
 
-       std::string sourceserv;
+       std::string sourceserv = who->server;
 
-       /* Are we dealing with an FMODE from a user, or from a server? */
-       User* who = ServerInstance->FindNick(source);
-       if (who)
-       {
-               /* FMODE from a user, set sourceserv to the users server name */
-               sourceserv = who->server;
-       }
-       else
-       {
-               /* FMODE from a server, use a fake user to receive mode feedback */
-               who = Utils->ServerUser;
-               sourceserv = source;    /* Set sourceserv to the actual source string */
-       }
        std::vector<std::string> modelist;
        time_t TS = 0;
        for (unsigned int q = 0; (q < params.size()) && (q < 64); q++)
@@ -83,28 +70,27 @@ bool TreeSocket::ForceMode(const std::string &source, parameterlist &params)
                }
                else
                        /* Oops, channel doesnt exist! */
-                       return true;
+                       return;
        }
 
        if (!TS)
        {
                ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG? *** TS of 0 sent to FMODE. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
                ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq. Mode was dropped.", sourceserv.c_str());
-               return true;
+               return;
        }
 
        /* TS is equal or less: Merge the mode changes into ours and pass on.
         */
        if (TS <= ourTS)
        {
-               ServerInstance->Modes->Process(modelist, who, (who == Utils->ServerUser));
+               ServerInstance->Modes->Process(modelist, who, IS_SERVER(who));
 
                /* HOT POTATO! PASS IT ON! */
-               Utils->DoOneToAllButSender(source,"FMODE",params,sourceserv);
+               Utils->DoOneToAllButSender(sourceserv,"FMODE",params,sourceserv);
        }
        /* If the TS is greater than ours, we drop the mode and dont pass it anywhere.
         */
-       return true;
 }
 
 
index 62404935777766db0b9235a3b79be62519146e04..d14f0ebe45b09ba9f453106e0806798cc7db7cbd 100644 (file)
@@ -731,7 +731,7 @@ void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::s
        {
                Utils->DoOneToMany(source->uuid,"KICK",params);
        }
-       else if (IS_SERVER(source) && source != Utils->ServerUser)
+       else if (source == ServerInstance->FakeClient)
        {
                Utils->DoOneToMany(ServerInstance->Config->GetSID(),"KICK",params);
        }
index 84ca342ecb2879fe67ee73c940630e829306f3d2..c382bc874c259272de168e06cb92a2f1afd757bb 100644 (file)
@@ -52,7 +52,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, const std::string &
                        routing = ROUTE_BROADCAST;
                else
                        return;
-               if (user == ServerUser)
+               if (IS_SERVER(user) && user != ServerInstance->FakeClient)
                        return;
        }
        else if (routing.type == ROUTE_TYPE_OPT_BCAST)
index 5c7162094738724e5f8832e1be4260b645f7bf08..38d91f54cbf695f43b4e81716bde634d17c2c1bd 100644 (file)
@@ -27,7 +27,7 @@
  * no socket associated with it. Its version string is our own local version.
  */
 TreeServer::TreeServer(SpanningTreeUtilities* Util, std::string Name, std::string Desc, const std::string &id)
-                                               : ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util)
+       : ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util), ServerUser(ServerInstance->FakeClient)
 {
        age = ServerInstance->Time();
        bursting = false;
@@ -48,7 +48,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, std::string Name, std::strin
  * its ping counters so that it will be pinged one minute from now.
  */
 TreeServer::TreeServer(SpanningTreeUtilities* Util, std::string Name, std::string Desc, const std::string &id, TreeServer* Above, TreeSocket* Sock, bool Hide)
-       : Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), Hidden(Hide)
+       : Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), ServerUser(new FakeUser(id, Name)), Hidden(Hide)
 {
        age = ServerInstance->Time();
        bursting = true;
@@ -350,10 +350,19 @@ bool TreeServer::Tidy()
        return true;
 }
 
+CullResult TreeServer::cull()
+{
+       if (ServerUser != ServerInstance->FakeClient)
+               ServerUser->cull();
+       return classbase::cull();
+}
+
 TreeServer::~TreeServer()
 {
        /* We'd better tidy up after ourselves, eh? */
        this->DelHashEntry();
+       if (ServerUser != ServerInstance->FakeClient)
+               delete ServerUser;
 
        server_hash::iterator iter = Utils->sidlist.find(GetID());
        if (iter != Utils->sidlist.end())
index 24f9c0499131e873d3e1dd5f1bcdf8d2c3389b77..353cc00adf9a43442c6532e590444402288024bc 100644 (file)
@@ -51,6 +51,7 @@ class TreeServer : public classbase
        void SetID(const std::string &id);
 
  public:
+       FakeUser* const ServerUser;             /* User representing this server */
        time_t age;
 
        bool Warned;                            /* True if we've warned opers about high latency on this server */
@@ -194,10 +195,10 @@ class TreeServer : public classbase
        /** Recursive call for child servers */
        void FinishBurstInternal();
 
+       CullResult cull();
        /** Destructor
         */
        ~TreeServer();
-
 };
 
 #endif
index 8359ebf37e76b9a28be16ce626736da9ae1047c8..34390f9d0dd927edc3e17fe18e4b6263f00d7078 100644 (file)
@@ -210,13 +210,13 @@ class TreeSocket : public BufferedSocket
        void Squit(TreeServer* Current, const std::string &reason);
 
        /** FMODE command - server mode with timestamp checks */
-       bool ForceMode(const std::string &source, parameterlist &params);
+       void ForceMode(User* who, parameterlist &params);
 
        /** FTOPIC command */
        bool ForceTopic(const std::string &source, parameterlist &params);
 
        /** FJOIN, similar to TS6 SJOIN, but not quite. */
-       bool ForceJoin(const std::string &source, parameterlist &params);
+       void ForceJoin(User* who, parameterlist &params);
 
        /* Used on nick collision ... XXX ugly function HACK */
        int DoCollision(User *u, time_t remotets, const std::string &remoteident, const std::string &remoteip, const std::string &remoteuid);
@@ -284,7 +284,7 @@ class TreeSocket : public BufferedSocket
 
        /** ENCAP command
         */
-       bool Encap(const std::string &prefix, parameterlist &params);
+       void Encap(User* who, parameterlist &params);
 
        /** OPERQUIT command
         */
@@ -352,7 +352,7 @@ class TreeSocket : public BufferedSocket
        /** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
         * This does not update the timestamp of the target channel, this must be done seperately.
         */
-       bool RemoveStatus(const std::string &prefix, parameterlist &params);
+       void RemoveStatus(User* source, parameterlist &params);
 
        /** <- (remote) <- SERVER
         */
index 8ef81173db9380e4195171a2fb7f1063c289c461..9d3de187dfa48d4e00952001142829665c0ebeaa 100644 (file)
@@ -214,6 +214,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
                SquitServer(from, Current);
                Current->Tidy();
                Current->GetParent()->DelChild(Current);
+               Current->cull();
                delete Current;
                if (LocalSquit)
                        ServerInstance->SNO->WriteToSnoMask('l', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.", num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
index 4d2c3cd14145d80e6a14dfa9458fe5333659b581..0023579faa439bec724ddd3eb8958e20f615b7ea 100644 (file)
@@ -242,9 +242,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
 
                if (ServerSource)
                {
-                       who = Utils->ServerUser;
-                       Utils->ServerUser->SetFakeServer(ServerSource->GetName());
-                       Utils->ServerUser->uuid = ServerSource->GetID();
+                       who = ServerSource->ServerUser;
                        direction = prefix;
                }
                else
@@ -301,7 +299,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
        }
        else if (command == "FJOIN")
        {
-               this->ForceJoin(prefix,params);
+               this->ForceJoin(who,params);
        }
        else if (command == "STATS")
        {
@@ -337,7 +335,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
        }
        else if (command == "FMODE")
        {
-               this->ForceMode(prefix,params);
+               this->ForceMode(who,params);
        }
        else if (command == "FTOPIC")
        {
@@ -467,7 +465,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
        }
        else if (command == "ENCAP")
        {
-               this->Encap(prefix, params);
+               this->Encap(who, params);
        }
        else if (command == "NICK")
        {
index 340b7f496492e55d7b866ca2f9998494d4a3b9ce..24691c3ca5d274c3790270722953ddc32fd9e157 100644 (file)
@@ -86,7 +86,7 @@ bool TreeSocket::ParseUID(const std::string &source, parameterlist &params)
        User* _new = NULL;
        try
        {
-               _new = new RemoteUser(params[0]);
+               _new = new RemoteUser(params[0], remoteserver->GetName());
        }
        catch (...)
        {
@@ -94,11 +94,9 @@ bool TreeSocket::ParseUID(const std::string &source, parameterlist &params)
                return false;
        }
        (*(ServerInstance->Users->clientlist))[params[2]] = _new;
-       _new->SetFd(FD_MAGIC_NUMBER);
        _new->nick.assign(params[2], 0, MAXBUF);
        _new->host.assign(params[3], 0, 64);
        _new->dhost.assign(params[4], 0, 64);
-       _new->server = remoteserver->GetName();
        _new->ident.assign(params[5], 0, MAXBUF);
        _new->fullname.assign(params[params.size() - 1], 0, MAXBUF);
        _new->registered = REG_ALL;
index e5012dcba5378a44744940eaa9d312bd4876f4f0..723ff9352f18ff0d05f8530a0284e6f0d84bd5dc 100644 (file)
@@ -147,8 +147,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) : Creator(C)
        ServerInstance->Logs->Log("m_spanningtree",DEBUG,"***** Using SID for hash: %s *****", ServerInstance->Config->GetSID().c_str());
 
        this->TreeRoot = new TreeServer(this, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
-       ServerUser = new FakeUser(TreeRoot->GetID());
-
        this->ReadConfiguration();
 }
 
@@ -170,10 +168,8 @@ CullResult SpanningTreeUtilities::cull()
                TreeSocket* s = i->first;
                ServerInstance->GlobalCulls.AddItem(s);
        }
+       TreeRoot->cull();
 
-       ServerUser->uuid = TreeRoot->GetID();
-       ServerUser->cull();
-       delete ServerUser;
        return classbase::cull();
 }
 
index 507cb3c7d2cc6b95303e8377b29b1d0817c265ef..63400563f962f72ba3449fc8a9e91a43a9ea4235 100644 (file)
@@ -74,9 +74,6 @@ class SpanningTreeUtilities : public classbase
        /** This variable represents the root of the server tree
         */
        TreeServer *TreeRoot;
-       /** Represents the server whose command we are processing
-        */
-       FakeUser *ServerUser;
        /** IPs allowed to link to us
         */
        std::vector<std::string> ValidIPs;
index 5110375962e8476bdd10d23b76449e893b503fa7..577d52f6772cdd9f7f245a7d21cd47c639433fe1 100644 (file)
@@ -63,7 +63,6 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
        /* The users default nick is their UUID */
        New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax);
 
-       New->server = ServerInstance->Config->ServerName;
        New->ident.assign("unknown");
 
        New->registered = REG_NONE;
index 170b0c7ece22054d656696274680625638007e54..36b41fb189d2b711ab8dec822a6533f502560197 100644 (file)
@@ -221,14 +221,14 @@ void User::DecrementModes()
        }
 }
 
-User::User(const std::string &uid)
+User::User(const std::string &uid, const std::string& sid)
+       : uuid(uid), server(sid)
 {
-       server = ServerInstance->Config->ServerName;
        age = ServerInstance->Time();
-       signon = idle_lastmsg = registered = 0;
+       signon = idle_lastmsg = 0;
+       registered = 0;
        quietquit = quitting = exempt = dns_done = false;
        fd = -1;
-       uuid = uid;
        client_sa.sa.sa_family = AF_UNSPEC;
 
        ServerInstance->Logs->Log("USERS", DEBUG, "New UUID for user: %s", uuid.c_str());
@@ -240,7 +240,7 @@ User::User(const std::string &uid)
                throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor");
 }
 
-LocalUser::LocalUser() : User(ServerInstance->GetUID())
+LocalUser::LocalUser() : User(ServerInstance->GetUID(), ServerInstance->Config->ServerName)
 {
        bytes_in = bytes_out = cmds_in = cmds_out = 0;
        server_sa.sa.sa_family = AF_UNSPEC;
@@ -250,7 +250,7 @@ LocalUser::LocalUser() : User(ServerInstance->GetUID())
 
 User::~User()
 {
-       if (uuid.length())
+       if (ServerInstance->Users->uuidlist->find(uuid) != ServerInstance->Users->uuidlist->end())
                ServerInstance->Logs->Log("USERS", ERROR, "User destructor for %s called without cull", uuid.c_str());
 }
 
@@ -294,7 +294,7 @@ const std::string& User::MakeHostIP()
        return this->cached_hostip;
 }
 
-const std::string User::GetFullHost()
+const std::string& User::GetFullHost()
 {
        if (!this->cached_fullhost.empty())
                return this->cached_fullhost;
@@ -328,7 +328,7 @@ char* User::MakeWildHost()
        return nresult;
 }
 
-const std::string User::GetFullRealHost()
+const std::string& User::GetFullRealHost()
 {
        if (!this->cached_fullrealhost.empty())
                return this->cached_fullrealhost;
@@ -584,11 +584,6 @@ CullResult User::cull()
 {
        if (!quitting)
                ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
-       if (uuid.empty())
-       {
-               ServerInstance->Logs->Log("USERS", DEBUG, "User culled twice? UUID empty");
-               return Extensible::cull();
-       }
        PurgeEmptyChannels();
        if (IS_LOCAL(this) && fd != INT_MAX)
                Close();
@@ -597,7 +592,6 @@ CullResult User::cull()
        this->DecrementModes();
 
        ServerInstance->Users->uuidlist->erase(uuid);
-       uuid.clear();
        return Extensible::cull();
 }
 
@@ -614,6 +608,13 @@ CullResult LocalUser::cull()
        return User::cull();
 }
 
+CullResult FakeUser::cull()
+{
+       // Fake users don't quit, they just get culled.
+       quitting = true;
+       return User::cull();
+}
+
 void User::Oper(OperInfo* info)
 {
        if (this->IsModeSet('o'))
@@ -1670,24 +1671,18 @@ void User::ShowRULES()
        this->WriteNumeric(RPL_RULESEND, "%s :End of RULES command.",this->nick.c_str());
 }
 
-void FakeUser::SetFakeServer(std::string name)
-{
-       this->nick = name;
-       this->server = name;
-}
-
-const std::string FakeUser::GetFullHost()
+const std::string& FakeUser::GetFullHost()
 {
        if (!ServerInstance->Config->HideWhoisServer.empty())
                return ServerInstance->Config->HideWhoisServer;
-       return nick;
+       return server;
 }
 
-const std::string FakeUser::GetFullRealHost()
+const std::string& FakeUser::GetFullRealHost()
 {
        if (!ServerInstance->Config->HideWhoisServer.empty())
                return ServerInstance->Config->HideWhoisServer;
-       return nick;
+       return server;
 }
 
 ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)