X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=5617715fdeb6b9a6b3f2524095d416fba8981f74;hb=4c83624ed825ca123401a45c8d2844ba6453a85b;hp=476a4f1cd28179e5c69793a0c21222ef0986fe51;hpb=78474291ab99852dc92a43286c67f244c7292a31;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 476a4f1cd..5617715fd 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() @@ -863,7 +873,18 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, /* 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); + userrec* New = NULL; + try + { + New = new userrec(Instance); + } + catch (CoreException &e) + { + Instance->Log(DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkies have been unleashed."); + Instance->WriteOpers("*** WARNING *** Duplicate UUID allocated!"); + return; + } + int j = 0; Instance->unregistered_count++; @@ -1364,7 +1385,7 @@ void userrec::Write(std::string text) try { - /* ServerInstance->Log(DEBUG,"C[%d] <- %s", this->GetFd(), text.c_str()); + /* ServerInstance->Log(DEBUG,"C[%d] O %s", this->GetFd(), text.c_str()); * WARNING: The above debug line is VERY loud, do NOT * enable it till we have a good way of filtering it * out of the logs (e.g. 1.2 would be good).