]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
publish "JSON-RPC" interface
[user/henk/code/inspircd.git] / src / users.cpp
index 5bfc9a46bc13482f8cdeb9b5aecdb0ca2faa8099..7da7d6b0960291d0b14f2867e8c0eea03808b741 100644 (file)
@@ -198,7 +198,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
        else if ((this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
        {
                /* Both lookups completed */
-               std::string result2 = "0::ffff:";
+               std::string result2("0::ffff:");
                result2.append(result);
                if (this->bound_user->GetIPString() == result || this->bound_user->GetIPString() == result2)
                {
@@ -210,7 +210,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl,
                                {
                                        /* Hostnames starting with : are not a good thing (tm) */
                                        if (*(hostname.c_str()) == ':')
-                                               hostname = "0" + hostname;
+                                               hostname.insert(0, "0");
 
                                        this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname.c_str(), (cached ? " -- cached" : ""));
                                        this->bound_user->dns_done = true;
@@ -344,6 +344,29 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance)
        operquit = cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL;
 }
 
+void userrec::RemoveCloneCounts()
+{
+       clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
+       if (x != ServerInstance->local_clones.end())
+       {
+               x->second--;
+               if (!x->second)
+               {
+                       ServerInstance->local_clones.erase(x);
+               }
+       }
+       
+       clonemap::iterator y = ServerInstance->global_clones.find(this->GetIPString());
+       if (y != ServerInstance->global_clones.end())
+       {
+               y->second--;
+               if (!y->second)
+               {
+                       ServerInstance->global_clones.erase(y);
+               }
+       }
+}
+
 userrec::~userrec()
 {
        this->InvalidateCache();
@@ -352,25 +375,7 @@ userrec::~userrec()
                free(operquit);
        if (ip)
        {
-               clonemap::iterator x = ServerInstance->local_clones.find(this->GetIPString());
-               if (x != ServerInstance->local_clones.end())
-               {
-                       x->second--;
-                       if (!x->second)
-                       {
-                               ServerInstance->local_clones.erase(x);
-                       }
-               }
-
-               clonemap::iterator y = ServerInstance->global_clones.find(this->GetIPString());
-               if (y != ServerInstance->global_clones.end())
-               {
-                       y->second--;
-                       if (!y->second)
-                       {
-                               ServerInstance->global_clones.erase(y);
-                       }
-               }
+               this->RemoveCloneCounts();
 
                if (this->GetProtocolFamily() == AF_INET)
                {
@@ -1181,10 +1186,7 @@ bool userrec::ForceNickChange(const char* newnick)
 
                if (this->registered == REG_ALL)
                {
-                       const char* pars[1];
-                       pars[0] = newnick;
-                       std::string cmd = "NICK";
-                       return (ServerInstance->Parser->CallHandler(cmd, pars, 1, this) == CMD_SUCCESS);
+                       return (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
                }
                return false;
        }
@@ -1378,6 +1380,9 @@ void userrec::Write(std::string text)
        {
                try
                {
+                       /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
+                        * implement their own buffering mechanisms
+                        */
                        ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
                }
                catch (CoreException& modexcept)
@@ -1620,7 +1625,8 @@ void userrec::WriteWallOps(const std::string &text)
        if (!IS_OPER(this) && IS_LOCAL(this))
                return;
 
-       std::string wallop = "WALLOPS :" + text;
+       std::string wallop("WALLOPS :");
+       wallop.append(text);
 
        for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
        {