X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=35a0e716fe50ecb88639e4078a25a61a65dc9227;hb=2b3394855d5adddb16285b905503d9ffe5a1d963;hp=99377a22475d5c8ae69f0407360b486d6a6fea59;hpb=0ba4b96bbaf1ef385fda088be6e02f93d1b03904;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 99377a224..35a0e716f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -12,9 +12,6 @@ */ #include "inspircd.h" -#include "configreader.h" -#include "channels.h" -#include "users.h" #include #include "socketengine.h" #include "wildcard.h" @@ -345,8 +342,19 @@ userrec::userrec(InspIRCd* Instance, const std::string &uid) : ServerInstance(In memset(snomasks,0,sizeof(snomasks)); /* Invalidate cache */ operquit = cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL; - if (!uid.empty()) + + if (uid.empty()) + strlcpy(uuid, Instance->GetUID().c_str(), UUID_LENGTH); + else strlcpy(uuid, uid.c_str(), UUID_LENGTH); + + ServerInstance->Log(DEBUG,"New UUID for user: %s (%s)", uuid, uid.empty() ? "allocated new" : "used remote"); + + user_hash::iterator finduuid = Instance->uuidlist->find(uuid); + if (finduuid == Instance->uuidlist->end()) + (*Instance->uuidlist)[uuid] = this; + else + throw CoreException("Duplicate UUID "+std::string(uuid)+" in userrec constructor"); } void userrec::RemoveCloneCounts() @@ -393,6 +401,8 @@ userrec::~userrec() } #endif } + + ServerInstance->uuidlist->erase(uuid); } char* userrec::MakeHost() @@ -860,9 +870,14 @@ 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) { + /* NOTE: Calling this one parameter constructor for userrec automatically + * allocates a new UUID and places it in the hash_map. + */ userrec* New = new userrec(Instance); + int j = 0; + + Instance->unregistered_count++; - user_hash::iterator iter = Instance->clientlist->find(New->uuid); char ipaddr[MAXBUF]; #ifdef IPV6 if (socketfamily == AF_INET6) @@ -870,13 +885,11 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, else #endif inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr)); - userrec* New; - int j = 0; - Instance->unregistered_count++; + (*(Instance->clientlist))[New->uuid] = New; + New->SetFd(socket); - (*(Instance->clientlist))[user->uuid] = New; - New->fd = socket; + /* The users default nick is their UUID */ strlcpy(New->nick, New->uuid, NICKMAX - 1); New->server = Instance->FindServerNamePtr(Instance->Config->ServerName);