summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h14
-rw-r--r--src/cmd_nick.cpp13
-rw-r--r--src/helperfuncs.cpp22
-rw-r--r--src/users.cpp4
4 files changed, 45 insertions, 8 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index f5a558e6e..aaa597acf 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -625,18 +625,28 @@ class CoreExport InspIRCd : public classbase
*/
void WriteOpers(const std::string &text);
- /** Find a user in the nick hash
+ /** Find a user in the nick hash.
+ * If the user cant be found in the nick hash check the uuid hash
* @param nick The nickname to find
* @return A pointer to the user, or NULL if the user does not exist
*/
userrec* FindNick(const std::string &nick);
- /** Find a user in the nick hash
+ /** Find a user in the nick hash.
+ * If the user cant be found in the nick hash check the uuid hash
* @param nick The nickname to find
* @return A pointer to the user, or NULL if the user does not exist
*/
userrec* FindNick(const char* nick);
+ /** Find a user in the nick hash ONLY
+ */
+ userrec* FindNickOnly(const char* nick);
+
+ /** Find a user in the nick hash ONLY
+ */
+ userrec* FindNickOnly(const std::string &nick);
+
/** Find a channel in the channels hash
* @param chan The channel to find
* @return A pointer to the channel, or NULL if the channel does not exist
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
index 06c1c8766..c1638469e 100644
--- a/src/cmd_nick.cpp
+++ b/src/cmd_nick.cpp
@@ -76,7 +76,8 @@ CmdResult cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
* the nickname too, we force a nickchange on the older user (Simply the one who was
* here first, no TS checks need to take place here)
*/
- userrec* InUse = ServerInstance->FindNick(parameters[0]);
+ userrec* InUse = ServerInstance->FindNickOnly(parameters[0]);
+ ServerInstance->Log(DEBUG,"Nick in use");
if (InUse && (InUse != user) && ((ServerInstance->IsNick(parameters[0]) || allowinvalid)))
{
if (InUse->registered != REG_ALL)
@@ -93,15 +94,19 @@ CmdResult cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
}
else
{
+ ServerInstance->Log(DEBUG,"Nick in use and user REG_ALL");
user->WriteServ("433 %s %s :Nickname is already in use.", user->registered >= REG_NICK ? user->nick : "*", parameters[0]);
return CMD_FAILURE;
}
}
}
- if (((!allowinvalid || !ServerInstance->IsNick(parameters[0]))) && (IS_LOCAL(user)))
+ if (((!ServerInstance->IsNick(parameters[0]))) && (IS_LOCAL(user)))
{
- user->WriteServ("432 %s %s :Erroneous Nickname",user->nick,parameters[0]);
- return CMD_FAILURE;
+ if (!allowinvalid)
+ {
+ user->WriteServ("432 %s %s :Erroneous Nickname",user->nick,parameters[0]);
+ return CMD_FAILURE;
+ }
}
if (user->registered == REG_ALL)
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 4338fb9da..66c9f21ba 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -261,9 +261,29 @@ userrec* InspIRCd::FindNick(const char* nick)
return iter->second;
}
+userrec* InspIRCd::FindNickOnly(const std::string &nick)
+{
+ user_hash::iterator iter = clientlist->find(nick);
+
+ if (iter == clientlist->end())
+ return NULL;
+
+ return iter->second;
+}
+
+userrec* InspIRCd::FindNickOnly(const char* nick)
+{
+ user_hash::iterator iter = clientlist->find(nick);
+
+ if (iter == clientlist->end())
+ return NULL;
+
+ return iter->second;
+}
+
userrec *InspIRCd::FindUUID(const std::string &uid)
{
- return InspIRCd::FindUUID(uid.c_str());
+ return FindUUID(uid.c_str());
}
userrec *InspIRCd::FindUUID(const char *uid)
diff --git a/src/users.cpp b/src/users.cpp
index de745d325..cdcc245d4 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -351,8 +351,10 @@ userrec::userrec(InspIRCd* Instance, const std::string &uid) : ServerInstance(In
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())
+ if (finduuid == Instance->uuidlist->end())
(*Instance->uuidlist)[uuid] = this;
else
throw CoreException("Duplicate UUID "+std::string(uuid)+" in userrec constructor");