summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-23 22:47:39 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-23 22:47:39 +0000
commitb16e16ac1bae4ac5494778b4b8a7009febb58137 (patch)
tree62839ed4c9a899302146fd9f8bdae2ed919029bf /src
parent18abdab35dcfa6b3677d3bd8b898261af5acb7ee (diff)
Make User::uuid and User::server const
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11962 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp10
-rw-r--r--src/inspircd.cpp3
-rw-r--r--src/modules/m_channames.cpp2
-rw-r--r--src/modules/m_messageflood.cpp2
-rw-r--r--src/modules/m_sakick.cpp3
-rw-r--r--src/modules/m_spanningtree/encap.cpp11
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp27
-rw-r--r--src/modules/m_spanningtree/fmode.cpp28
-rw-r--r--src/modules/m_spanningtree/main.cpp2
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp13
-rw-r--r--src/modules/m_spanningtree/treeserver.h3
-rw-r--r--src/modules/m_spanningtree/treesocket.h8
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp1
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp10
-rw-r--r--src/modules/m_spanningtree/uid.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.cpp6
-rw-r--r--src/modules/m_spanningtree/utils.h3
-rw-r--r--src/usermanager.cpp1
-rw-r--r--src/users.cpp43
20 files changed, 71 insertions, 111 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index a4c24b455..fd9861279 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -483,16 +483,6 @@ void Channel::PartUser(User *user, std::string &reason)
this->DelUser(user);
}
-void Channel::ServerKickUser(User* user, const char* reason, const std::string& servername)
-{
- if (servername.empty() || !ServerInstance->Config->HideWhoisServer.empty())
- ServerInstance->FakeClient->server = ServerInstance->Config->ServerName;
- else
- ServerInstance->FakeClient->server = servername;
-
- KickUser(ServerInstance->FakeClient, user, reason);
-}
-
void Channel::KickUser(User *src, User *user, const char* reason)
{
if (!src || !user || !reason)
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 19f90dd97..58480668b 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -546,8 +546,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
}
/* set up fake client again this time with the correct uid */
- this->FakeClient = new FakeUser("!");
- this->FakeClient->SetFakeServer(Config->ServerName);
+ this->FakeClient = new FakeUser(Config->sid, Config->ServerName);
// Get XLine to do it's thing.
this->XLines->CheckELines();
diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp
index c137d0e71..40746af2c 100644
--- a/src/modules/m_channames.cpp
+++ b/src/modules/m_channames.cpp
@@ -82,7 +82,7 @@ class ModuleChannelNames : public Module
const UserMembList* users = c->GetUsers();
for(UserMembCIter j = users->begin(); j != users->end(); ++j)
if (IS_LOCAL(j->first))
- c->ServerKickUser(j->first, "Channel name no longer valid", NULL);
+ c->KickUser(ServerInstance->FakeClient, j->first, "Channel name no longer valid");
}
badchan = false;
}
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index b2f82777f..c39bc9807 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -232,7 +232,7 @@ class ModuleMsgFlood : public Module
char kickmessage[MAXBUF];
snprintf(kickmessage, MAXBUF, "Channel flood triggered (limit is %d lines in %d secs)", f->lines, f->secs);
- dest->ServerKickUser(user, kickmessage);
+ dest->KickUser(ServerInstance->FakeClient, user, kickmessage);
return MOD_RES_DENY;
}
diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp
index b81df75c6..d6b6e965b 100644
--- a/src/modules/m_sakick.cpp
+++ b/src/modules/m_sakick.cpp
@@ -31,7 +31,6 @@ class CommandSakick : public Command
User* dest = ServerInstance->FindNick(parameters[1]);
Channel* channel = ServerInstance->FindChan(parameters[0]);
const char* reason = "";
- const char* servername = NULL;
if (dest && channel)
{
@@ -56,7 +55,7 @@ class CommandSakick : public Command
*/
if (IS_LOCAL(dest))
{
- channel->ServerKickUser(dest, reason, servername);
+ channel->KickUser(ServerInstance->FakeClient, dest, reason);
Channel *n = ServerInstance->FindChan(parameters[1]);
if (n && n->HasUser(dest))
diff --git a/src/modules/m_spanningtree/encap.cpp b/src/modules/m_spanningtree/encap.cpp
index 175257b0a..e854df2f4 100644
--- a/src/modules/m_spanningtree/encap.cpp
+++ b/src/modules/m_spanningtree/encap.cpp
@@ -23,16 +23,12 @@
/** ENCAP */
-bool TreeSocket::Encap(const std::string &prefix, parameterlist &params)
+void TreeSocket::Encap(User* who, parameterlist &params)
{
if (params.size() > 1)
{
if (InspIRCd::Match(ServerInstance->Config->GetSID(), params[0]))
{
- User* who = ServerInstance->FindUUID(prefix);
- if (!who)
- who = Utils->ServerUser;
-
parameterlist plist(params.begin() + 2, params.end());
ServerInstance->CallCommandHandler(params[1].c_str(), plist, who);
// discard return value, ENCAP shall succeed even if the command does not exist
@@ -42,11 +38,10 @@ bool TreeSocket::Encap(const std::string &prefix, parameterlist &params)
if (params[0].find('*') != std::string::npos)
{
- Utils->DoOneToAllButSender(prefix, "ENCAP", params, prefix);
+ Utils->DoOneToAllButSender(who->server, "ENCAP", params, who->server);
}
else
- Utils->DoOneToOne(prefix, "ENCAP", params, params[0]);
+ Utils->DoOneToOne(who->server, "ENCAP", params, params[0]);
}
- return true;
}
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index 810cf23a5..6895fa051 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -22,7 +22,7 @@
/** FJOIN, almost identical to TS6 SJOIN, except for nicklist handling. */
-bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
+void TreeSocket::ForceJoin(User* srcuser, parameterlist &params)
{
/* 1.1 FJOIN works as follows:
*
@@ -51,7 +51,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
* who succeed at internets. :-)
*/
if (params.size() < 3)
- return true;
+ return;
irc::modestacker modestack(true); /* Modes to apply from the users in the user list */
User* who = NULL; /* User we are currently checking */
@@ -66,13 +66,13 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
if (params.size() > 3)
params[params.size() - 1] = ":" + params[params.size() - 1];
- Utils->DoOneToAllButSender(source,"FJOIN",params,source);
+ Utils->DoOneToAllButSender(srcuser->server,"FJOIN",params,srcuser->server);
if (!TS)
{
ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG? *** TS of 0 sent to FJOIN. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
- ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", source.c_str());
- return true;
+ ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FJOIN with a TS of zero. Total craq. Command was dropped.", srcuser->server.c_str());
+ return;
}
if (created)
@@ -103,7 +103,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
ourTS = TS;
chan->age = TS;
param_list.push_back(channel);
- this->RemoveStatus(ServerInstance->Config->GetSID(), param_list);
+ this->RemoveStatus(ServerInstance->FakeClient, param_list);
}
// The silent case here is ourTS == TS, we don't need to remove modes here, just to merge them later on.
}
@@ -123,7 +123,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
modelist.push_back(params[idx]);
}
- ServerInstance->SendMode(modelist, Utils->ServerUser);
+ ServerInstance->SendMode(modelist, srcuser);
}
/* Now, process every 'modes,nick' pair */
@@ -145,7 +145,7 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
else
{
this->SendError(std::string("Unknown status mode '")+(*unparsedmodes)+"' in FJOIN");
- return false;
+ return;
}
usr++;
@@ -186,18 +186,16 @@ bool TreeSocket::ForceJoin(const std::string &source, parameterlist &params)
while (modestack.GetStackedLine(stackresult))
{
- ServerInstance->SendMode(stackresult, Utils->ServerUser);
+ ServerInstance->SendMode(stackresult, srcuser);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}
-
- return true;
}
-bool TreeSocket::RemoveStatus(const std::string &prefix, parameterlist &params)
+void TreeSocket::RemoveStatus(User* srcuser, parameterlist &params)
{
if (params.size() < 1)
- return true;
+ return;
Channel* c = ServerInstance->FindChan(params[0]);
@@ -221,10 +219,9 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, parameterlist &params)
while (stack.GetStackedLine(stackresult))
{
- ServerInstance->SendMode(stackresult, Utils->ServerUser);
+ ServerInstance->SendMode(stackresult, srcuser);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}
- return true;
}
diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp
index 3bca098d6..4dd05b101 100644
--- a/src/modules/m_spanningtree/fmode.cpp
+++ b/src/modules/m_spanningtree/fmode.cpp
@@ -22,30 +22,17 @@
/** FMODE command - server mode with timestamp checks */
-bool TreeSocket::ForceMode(const std::string &source, parameterlist &params)
+void TreeSocket::ForceMode(User* who, parameterlist &params)
{
/* Chances are this is a 1.0 FMODE without TS */
if (params.size() < 3)
{
/* No modes were in the command, probably a channel with no modes set on it */
- return true;
+ return;
}
- std::string sourceserv;
+ std::string sourceserv = who->server;
- /* Are we dealing with an FMODE from a user, or from a server? */
- User* who = ServerInstance->FindNick(source);
- if (who)
- {
- /* FMODE from a user, set sourceserv to the users server name */
- sourceserv = who->server;
- }
- else
- {
- /* FMODE from a server, use a fake user to receive mode feedback */
- who = Utils->ServerUser;
- sourceserv = source; /* Set sourceserv to the actual source string */
- }
std::vector<std::string> modelist;
time_t TS = 0;
for (unsigned int q = 0; (q < params.size()) && (q < 64); q++)
@@ -83,28 +70,27 @@ bool TreeSocket::ForceMode(const std::string &source, parameterlist &params)
}
else
/* Oops, channel doesnt exist! */
- return true;
+ return;
}
if (!TS)
{
ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG? *** TS of 0 sent to FMODE. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq. Mode was dropped.", sourceserv.c_str());
- return true;
+ return;
}
/* TS is equal or less: Merge the mode changes into ours and pass on.
*/
if (TS <= ourTS)
{
- ServerInstance->Modes->Process(modelist, who, (who == Utils->ServerUser));
+ ServerInstance->Modes->Process(modelist, who, IS_SERVER(who));
/* HOT POTATO! PASS IT ON! */
- Utils->DoOneToAllButSender(source,"FMODE",params,sourceserv);
+ Utils->DoOneToAllButSender(sourceserv,"FMODE",params,sourceserv);
}
/* If the TS is greater than ours, we drop the mode and dont pass it anywhere.
*/
- return true;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 624049357..d14f0ebe4 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -731,7 +731,7 @@ void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::s
{
Utils->DoOneToMany(source->uuid,"KICK",params);
}
- else if (IS_SERVER(source) && source != Utils->ServerUser)
+ else if (source == ServerInstance->FakeClient)
{
Utils->DoOneToMany(ServerInstance->Config->GetSID(),"KICK",params);
}
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 84ca342ec..c382bc874 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -52,7 +52,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, const std::string &
routing = ROUTE_BROADCAST;
else
return;
- if (user == ServerUser)
+ if (IS_SERVER(user) && user != ServerInstance->FakeClient)
return;
}
else if (routing.type == ROUTE_TYPE_OPT_BCAST)
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 5c7162094..38d91f54c 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -27,7 +27,7 @@
* no socket associated with it. Its version string is our own local version.
*/
TreeServer::TreeServer(SpanningTreeUtilities* Util, std::string Name, std::string Desc, const std::string &id)
- : ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util)
+ : ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util), ServerUser(ServerInstance->FakeClient)
{
age = ServerInstance->Time();
bursting = false;
@@ -48,7 +48,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, std::string Name, std::strin
* its ping counters so that it will be pinged one minute from now.
*/
TreeServer::TreeServer(SpanningTreeUtilities* Util, std::string Name, std::string Desc, const std::string &id, TreeServer* Above, TreeSocket* Sock, bool Hide)
- : Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), Hidden(Hide)
+ : Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), ServerUser(new FakeUser(id, Name)), Hidden(Hide)
{
age = ServerInstance->Time();
bursting = true;
@@ -350,10 +350,19 @@ bool TreeServer::Tidy()
return true;
}
+CullResult TreeServer::cull()
+{
+ if (ServerUser != ServerInstance->FakeClient)
+ ServerUser->cull();
+ return classbase::cull();
+}
+
TreeServer::~TreeServer()
{
/* We'd better tidy up after ourselves, eh? */
this->DelHashEntry();
+ if (ServerUser != ServerInstance->FakeClient)
+ delete ServerUser;
server_hash::iterator iter = Utils->sidlist.find(GetID());
if (iter != Utils->sidlist.end())
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index 24f9c0499..353cc00ad 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -51,6 +51,7 @@ class TreeServer : public classbase
void SetID(const std::string &id);
public:
+ FakeUser* const ServerUser; /* User representing this server */
time_t age;
bool Warned; /* True if we've warned opers about high latency on this server */
@@ -194,10 +195,10 @@ class TreeServer : public classbase
/** Recursive call for child servers */
void FinishBurstInternal();
+ CullResult cull();
/** Destructor
*/
~TreeServer();
-
};
#endif
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 8359ebf37..34390f9d0 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -210,13 +210,13 @@ class TreeSocket : public BufferedSocket
void Squit(TreeServer* Current, const std::string &reason);
/** FMODE command - server mode with timestamp checks */
- bool ForceMode(const std::string &source, parameterlist &params);
+ void ForceMode(User* who, parameterlist &params);
/** FTOPIC command */
bool ForceTopic(const std::string &source, parameterlist &params);
/** FJOIN, similar to TS6 SJOIN, but not quite. */
- bool ForceJoin(const std::string &source, parameterlist &params);
+ void ForceJoin(User* who, parameterlist &params);
/* Used on nick collision ... XXX ugly function HACK */
int DoCollision(User *u, time_t remotets, const std::string &remoteident, const std::string &remoteip, const std::string &remoteuid);
@@ -284,7 +284,7 @@ class TreeSocket : public BufferedSocket
/** ENCAP command
*/
- bool Encap(const std::string &prefix, parameterlist &params);
+ void Encap(User* who, parameterlist &params);
/** OPERQUIT command
*/
@@ -352,7 +352,7 @@ class TreeSocket : public BufferedSocket
/** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
* This does not update the timestamp of the target channel, this must be done seperately.
*/
- bool RemoveStatus(const std::string &prefix, parameterlist &params);
+ void RemoveStatus(User* source, parameterlist &params);
/** <- (remote) <- SERVER
*/
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 8ef81173d..9d3de187d 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -214,6 +214,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
SquitServer(from, Current);
Current->Tidy();
Current->GetParent()->DelChild(Current);
+ Current->cull();
delete Current;
if (LocalSquit)
ServerInstance->SNO->WriteToSnoMask('l', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.", num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 4d2c3cd14..0023579fa 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -242,9 +242,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
if (ServerSource)
{
- who = Utils->ServerUser;
- Utils->ServerUser->SetFakeServer(ServerSource->GetName());
- Utils->ServerUser->uuid = ServerSource->GetID();
+ who = ServerSource->ServerUser;
direction = prefix;
}
else
@@ -301,7 +299,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
}
else if (command == "FJOIN")
{
- this->ForceJoin(prefix,params);
+ this->ForceJoin(who,params);
}
else if (command == "STATS")
{
@@ -337,7 +335,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
}
else if (command == "FMODE")
{
- this->ForceMode(prefix,params);
+ this->ForceMode(who,params);
}
else if (command == "FTOPIC")
{
@@ -467,7 +465,7 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
}
else if (command == "ENCAP")
{
- this->Encap(prefix, params);
+ this->Encap(who, params);
}
else if (command == "NICK")
{
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 340b7f496..24691c3ca 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -86,7 +86,7 @@ bool TreeSocket::ParseUID(const std::string &source, parameterlist &params)
User* _new = NULL;
try
{
- _new = new RemoteUser(params[0]);
+ _new = new RemoteUser(params[0], remoteserver->GetName());
}
catch (...)
{
@@ -94,11 +94,9 @@ bool TreeSocket::ParseUID(const std::string &source, parameterlist &params)
return false;
}
(*(ServerInstance->Users->clientlist))[params[2]] = _new;
- _new->SetFd(FD_MAGIC_NUMBER);
_new->nick.assign(params[2], 0, MAXBUF);
_new->host.assign(params[3], 0, 64);
_new->dhost.assign(params[4], 0, 64);
- _new->server = remoteserver->GetName();
_new->ident.assign(params[5], 0, MAXBUF);
_new->fullname.assign(params[params.size() - 1], 0, MAXBUF);
_new->registered = REG_ALL;
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index e5012dcba..723ff9352 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -147,8 +147,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) : Creator(C)
ServerInstance->Logs->Log("m_spanningtree",DEBUG,"***** Using SID for hash: %s *****", ServerInstance->Config->GetSID().c_str());
this->TreeRoot = new TreeServer(this, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
- ServerUser = new FakeUser(TreeRoot->GetID());
-
this->ReadConfiguration();
}
@@ -170,10 +168,8 @@ CullResult SpanningTreeUtilities::cull()
TreeSocket* s = i->first;
ServerInstance->GlobalCulls.AddItem(s);
}
+ TreeRoot->cull();
- ServerUser->uuid = TreeRoot->GetID();
- ServerUser->cull();
- delete ServerUser;
return classbase::cull();
}
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 507cb3c7d..63400563f 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -74,9 +74,6 @@ class SpanningTreeUtilities : public classbase
/** This variable represents the root of the server tree
*/
TreeServer *TreeRoot;
- /** Represents the server whose command we are processing
- */
- FakeUser *ServerUser;
/** IPs allowed to link to us
*/
std::vector<std::string> ValidIPs;
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 511037596..577d52f67 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -63,7 +63,6 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
/* The users default nick is their UUID */
New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax);
- New->server = ServerInstance->Config->ServerName;
New->ident.assign("unknown");
New->registered = REG_NONE;
diff --git a/src/users.cpp b/src/users.cpp
index 170b0c7ec..36b41fb18 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -221,14 +221,14 @@ void User::DecrementModes()
}
}
-User::User(const std::string &uid)
+User::User(const std::string &uid, const std::string& sid)
+ : uuid(uid), server(sid)
{
- server = ServerInstance->Config->ServerName;
age = ServerInstance->Time();
- signon = idle_lastmsg = registered = 0;
+ signon = idle_lastmsg = 0;
+ registered = 0;
quietquit = quitting = exempt = dns_done = false;
fd = -1;
- uuid = uid;
client_sa.sa.sa_family = AF_UNSPEC;
ServerInstance->Logs->Log("USERS", DEBUG, "New UUID for user: %s", uuid.c_str());
@@ -240,7 +240,7 @@ User::User(const std::string &uid)
throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor");
}
-LocalUser::LocalUser() : User(ServerInstance->GetUID())
+LocalUser::LocalUser() : User(ServerInstance->GetUID(), ServerInstance->Config->ServerName)
{
bytes_in = bytes_out = cmds_in = cmds_out = 0;
server_sa.sa.sa_family = AF_UNSPEC;
@@ -250,7 +250,7 @@ LocalUser::LocalUser() : User(ServerInstance->GetUID())
User::~User()
{
- if (uuid.length())
+ if (ServerInstance->Users->uuidlist->find(uuid) != ServerInstance->Users->uuidlist->end())
ServerInstance->Logs->Log("USERS", ERROR, "User destructor for %s called without cull", uuid.c_str());
}
@@ -294,7 +294,7 @@ const std::string& User::MakeHostIP()
return this->cached_hostip;
}
-const std::string User::GetFullHost()
+const std::string& User::GetFullHost()
{
if (!this->cached_fullhost.empty())
return this->cached_fullhost;
@@ -328,7 +328,7 @@ char* User::MakeWildHost()
return nresult;
}
-const std::string User::GetFullRealHost()
+const std::string& User::GetFullRealHost()
{
if (!this->cached_fullrealhost.empty())
return this->cached_fullrealhost;
@@ -584,11 +584,6 @@ CullResult User::cull()
{
if (!quitting)
ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
- if (uuid.empty())
- {
- ServerInstance->Logs->Log("USERS", DEBUG, "User culled twice? UUID empty");
- return Extensible::cull();
- }
PurgeEmptyChannels();
if (IS_LOCAL(this) && fd != INT_MAX)
Close();
@@ -597,7 +592,6 @@ CullResult User::cull()
this->DecrementModes();
ServerInstance->Users->uuidlist->erase(uuid);
- uuid.clear();
return Extensible::cull();
}
@@ -614,6 +608,13 @@ CullResult LocalUser::cull()
return User::cull();
}
+CullResult FakeUser::cull()
+{
+ // Fake users don't quit, they just get culled.
+ quitting = true;
+ return User::cull();
+}
+
void User::Oper(OperInfo* info)
{
if (this->IsModeSet('o'))
@@ -1670,24 +1671,18 @@ void User::ShowRULES()
this->WriteNumeric(RPL_RULESEND, "%s :End of RULES command.",this->nick.c_str());
}
-void FakeUser::SetFakeServer(std::string name)
-{
- this->nick = name;
- this->server = name;
-}
-
-const std::string FakeUser::GetFullHost()
+const std::string& FakeUser::GetFullHost()
{
if (!ServerInstance->Config->HideWhoisServer.empty())
return ServerInstance->Config->HideWhoisServer;
- return nick;
+ return server;
}
-const std::string FakeUser::GetFullRealHost()
+const std::string& FakeUser::GetFullRealHost()
{
if (!ServerInstance->Config->HideWhoisServer.empty())
return ServerInstance->Config->HideWhoisServer;
- return nick;
+ return server;
}
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)