mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
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
This commit is contained in:
parent
9cb422d3e5
commit
0ba4b96bba
@ -461,6 +461,11 @@ class CoreExport InspIRCd : public classbase
|
||||
*/
|
||||
user_hash* clientlist;
|
||||
|
||||
/** Client list stored by UUID. Contains all clients, and is updated
|
||||
* automatically by the constructor and destructor of userrec.
|
||||
*/
|
||||
user_hash* uuidlist;
|
||||
|
||||
/** Channel list, a hash_map containing all channels
|
||||
*/
|
||||
chan_hash* chanlist;
|
||||
|
@ -661,8 +661,10 @@ class CoreExport userrec : public connection
|
||||
|
||||
/** Default constructor
|
||||
* @throw Nothing at present
|
||||
* @param Instance Creator instance
|
||||
* @param uid User UUID, or empty to allocate one automatically
|
||||
*/
|
||||
userrec(InspIRCd* Instance);
|
||||
userrec(InspIRCd* Instance, const std::string &uid = "");
|
||||
|
||||
/** Returns the full displayed host of the user
|
||||
* This member function returns the hostname of the user as seen by other users
|
||||
|
@ -976,11 +976,10 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &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());
|
||||
|
@ -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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user