From 0ba4b96bbaf1ef385fda088be6e02f93d1b03904 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 27 Aug 2007 11:24:43 +0000 Subject: Allocate uid in userrec constructor. Optional param added, if its empty, the server allocates one, if its not empty the user gets the one given (this is used for remote users) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7873 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/treesocket1.cpp | 3 +-- src/users.cpp | 31 +++++++----------------------- 2 files changed, 8 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 4d94ed957..a0eb6ad7f 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -976,11 +976,10 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque &pa tempnick = params[0].c_str(); } - userrec* _new = new userrec(this->Instance); + userrec* _new = new userrec(this->Instance, params[0]); (*(this->Instance->clientlist))[tempnick] = _new; _new->SetFd(FD_MAGIC_NUMBER); strlcpy(_new->nick, tempnick, NICKMAX - 1); - strlcpy(_new->uuid, params[0].c_str(), UUID_LENGTH); strlcpy(_new->host, params[3].c_str(),64); strlcpy(_new->dhost, params[4].c_str(),64); _new->server = this->Instance->FindServerNamePtr(source.c_str()); diff --git a/src/users.cpp b/src/users.cpp index 1c1181689..99377a224 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -323,7 +323,7 @@ void userrec::DecrementModes() } } -userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance) +userrec::userrec(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance) { *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = *uuid = 0; server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName); @@ -345,6 +345,8 @@ userrec::userrec(InspIRCd* Instance) : ServerInstance(Instance) memset(snomasks,0,sizeof(snomasks)); /* Invalidate cache */ operquit = cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL; + if (!uid.empty()) + strlcpy(uuid, uid.c_str(), UUID_LENGTH); } void userrec::RemoveCloneCounts() @@ -858,10 +860,9 @@ void userrec::AddToWhoWas() /* add a client connection to the sockets list */ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, int socketfamily, sockaddr* ip) { - std::string tempnick = Instance->GetUID(); + userrec* New = new userrec(Instance); - Instance->Log(DEBUG,"New client has UID %s ..", tempnick.c_str()); - user_hash::iterator iter = Instance->clientlist->find(tempnick); + user_hash::iterator iter = Instance->clientlist->find(New->uuid); char ipaddr[MAXBUF]; #ifdef IPV6 if (socketfamily == AF_INET6) @@ -874,27 +875,9 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, Instance->unregistered_count++; - /* - * fix by brain. - * as these nicknames are 'RFC impossible', we can be sure nobody is going to be - * using one as a registered connection. As they are per fd, we can also safely assume - * that we wont have collisions. Therefore, if the nick exists in the list, its only - * used by a dead socket, erase the iterator so that the new client may reclaim it. - * this was probably the cause of 'server ignores me when i hammer it with reconnects' - * issue in earlier alphas/betas - */ - if (iter != Instance->clientlist->end()) - { - userrec* goner = iter->second; - DELETE(goner); - Instance->clientlist->erase(iter); - } - - New = new userrec(Instance); - (*(Instance->clientlist))[tempnick] = New; + (*(Instance->clientlist))[user->uuid] = New; New->fd = socket; - strlcpy(New->nick, tempnick.c_str(), NICKMAX - 1); - strlcpy(New->uuid, tempnick.c_str(), UUID_LENGTH); + strlcpy(New->nick, New->uuid, NICKMAX - 1); New->server = Instance->FindServerNamePtr(Instance->Config->ServerName); /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */ -- cgit v1.2.3