]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Clean up excessive bits in User struct
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 17 Oct 2009 02:43:07 +0000 (02:43 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 17 Oct 2009 02:43:07 +0000 (02:43 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11882 e03df62e-2008-0410-955e-edbf42e46eb7

include/users.h
src/commands/cmd_pass.cpp
src/users.cpp

index fbeba1bb9fa4fe938f6d4030749218041414bf3b..ed672450ee00839611cf6f7e0d005fc2a54b53bd 100644 (file)
@@ -291,16 +291,6 @@ class CoreExport User : public StreamSocket
         */
        int cmds_out;
 
-       /** True if user has authenticated, false if otherwise
-        */
-       bool haspassed;
-
-       /** Used by User to indicate the registration status of the connection
-        * It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate
-        * the connection state.
-        */
-       char registered;
-
        /** Time the connection was last pinged
         */
        time_t lastping;
@@ -400,28 +390,43 @@ class CoreExport User : public StreamSocket
         */
        std::string oper;
 
-       /** True when DNS lookups are completed.
-        * The UserResolver classes res_forward and res_reverse will
-        * set this value once they complete.
-        */
-       bool dns_done;
-
        /** Password specified by the user when they registered.
         * This is stored even if the <connect> block doesnt need a password, so that
         * modules may check it.
         */
        std::string password;
 
+       /** This value contains how far into the penalty threshold the user is. Once its over
+        * the penalty threshold then commands are held and processed on-timer.
+        */
+       int Penalty;
+
+       /** Used by User to indicate the registration status of the connection
+        * It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate
+        * the connection state.
+        */
+       unsigned int registered:3;
+
+       /** True when DNS lookups are completed.
+        * The UserResolver classes res_forward and res_reverse will
+        * set this value once they complete.
+        */
+       unsigned int dns_done:1;
+
        /** Whether or not to send an snotice about this user's quitting
         */
-       bool quietquit;
+       unsigned int quietquit:1;
 
        /** If this is set to true, then all socket operations for the user
         * are dropped into the bit-bucket.
         * This value is set by QuitUser, and is not needed seperately from that call.
         * Please note that setting this value alone will NOT cause the user to quit.
         */
-       bool quitting;
+       unsigned int quitting:1;
+
+       /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
+        */
+       unsigned int exempt:1;
 
        /** Server address and port that this user is connected to.
         * If unknown, address family is AF_UNKNOWN
@@ -458,15 +463,6 @@ class CoreExport User : public StreamSocket
         */
        const char *GetCIDRMask(int range);
 
-       /** This is true if the user matched an exception (E:Line). It is used to save time on ban checks.
-        */
-       bool exempt;
-
-       /** This value contains how far into the penalty threshold the user is. Once its over
-        * the penalty threshold then commands are held and processed on-timer.
-        */
-       int Penalty;
-
        /** Default constructor
         * @throw CoreException if the UID allocated to the user already exists
         * @param Instance Creator instance
index 6219118ee7335d138a0ba4d025463a15479e8499..21b5b275990dd7cde97c2df55cb509ca4d62b9f6 100644 (file)
@@ -36,19 +36,13 @@ class CommandPass : public Command
 
 CmdResult CommandPass::Handle (const std::vector<std::string>& parameters, User *user)
 {
-       // Check to make sure they havnt registered -- Fix by FCS
+       // Check to make sure they haven't registered -- Fix by FCS
        if (user->registered == REG_ALL)
        {
                user->WriteNumeric(ERR_ALREADYREGISTERED, "%s :You may not reregister",user->nick.c_str());
                return CMD_FAILURE;
        }
-       ConnectClass* a = user->GetClass();
-       if (!a)
-               return CMD_FAILURE;
-
-       user->password.assign(parameters[0], 0, 63);
-       if (!ServerInstance->PassCompare(user, a->pass.c_str(), parameters[0].c_str(), a->hash.c_str()))
-               user->haspassed = true;
+       user->password = parameters[0];
 
        return CMD_SUCCESS;
 }
index 324edbfdbd0f0590649598ce789c05cff54ab3ff..657225069823aadb95832ff26b1fd4c857722dd6 100644 (file)
@@ -228,17 +228,16 @@ User::User(const std::string &uid)
        Penalty = 0;
        lastping = signon = idle_lastmsg = nping = registered = 0;
        bytes_in = bytes_out = cmds_in = cmds_out = 0;
-       quietquit = quitting = exempt = haspassed = dns_done = false;
+       quietquit = quitting = exempt = dns_done = false;
        fd = -1;
        server_sa.sa.sa_family = AF_UNSPEC;
        client_sa.sa.sa_family = AF_UNSPEC;
-       MyClass = NULL;
        AllowedPrivs = AllowedOperCommands = NULL;
 
        if (uid.empty())
-               uuid.assign(ServerInstance->GetUID(), 0, UUID_LENGTH - 1);
+               uuid = ServerInstance->GetUID();
        else
-               uuid.assign(uid, 0, UUID_LENGTH - 1);
+               uuid = uid;
 
        ServerInstance->Logs->Log("USERS", DEBUG,"New UUID for user: %s (%s)", uuid.c_str(), uid.empty() ? "allocated new" : "used remote");
 
@@ -846,10 +845,13 @@ void User::FullConnect()
        /* Check the password, if one is required by the user's connect class.
         * This CANNOT be in CheckClass(), because that is called prior to PASS as well!
         */
-       if (this->MyClass && !this->MyClass->GetPass().empty() && !this->haspassed)
+       if (MyClass && !MyClass->pass.empty())
        {
-               ServerInstance->Users->QuitUser(this, "Invalid password");
-               return;
+               if (ServerInstance->PassCompare(this, MyClass->pass.c_str(), password.c_str(), MyClass->hash.c_str()))
+               {
+                       ServerInstance->Users->QuitUser(this, "Invalid password");
+                       return;
+               }
        }
 
        if (this->CheckLines())