ServerInstance->Logs->Log("USERS", LOG_DEBUG, "New UUID for user: %s", uuid.c_str());
- if (!ServerInstance->Users->uuidlist->insert(std::make_pair(uuid, this)).second)
+ if (!ServerInstance->Users->uuidlist.insert(std::make_pair(uuid, this)).second)
throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor");
}
User::~User()
{
- if (ServerInstance->Users->uuidlist->find(uuid) != ServerInstance->Users->uuidlist->end())
+ if (ServerInstance->FindUUID(uuid))
ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "User destructor for %s called without cull", uuid.c_str());
}
// Fake users don't quit, they just get culled.
quitting = true;
// Fake users are not inserted into UserManager::clientlist, they're only in the uuidlist
- ServerInstance->Users->uuidlist->erase(uuid);
+ ServerInstance->Users->uuidlist.erase(uuid);
return User::cull();
}
ServerInstance->Modes->Process(parameters, this);
- /* remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 */
- ServerInstance->Users->all_opers.remove(this);
+ // Remove the user from the oper list
+ stdalgo::vector::swaperase(ServerInstance->Users->all_opers, this);
ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
this->SetMode(opermh, false);
}
else if (clone_count)
{
- if ((a->GetMaxLocal()) && (ServerInstance->Users->LocalCloneCount(this) > a->GetMaxLocal()))
+ const UserManager::CloneCounts& clonecounts = ServerInstance->Users->GetCloneCounts(this);
+ if ((a->GetMaxLocal()) && (clonecounts.local > a->GetMaxLocal()))
{
ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)");
if (a->maxconnwarn)
ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString().c_str());
return;
}
- else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal()))
+ else if ((a->GetMaxGlobal()) && (clonecounts.global > a->GetMaxGlobal()))
{
ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)");
if (a->maxconnwarn)
cached_fullrealhost.clear();
}
-bool User::ChangeNick(const std::string& newnick, bool force)
+bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
{
if (quitting)
{
{
// case change, don't need to check Q:lines and such
// and, if it's identical including case, we can leave right now
+ // We also don't update the nick TS if it's a case change, either
if (newnick == nick)
return true;
}
if (InUse->registered != REG_ALL)
{
/* force the camper to their UUID, and ask them to re-send a NICK. */
- InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str());
+ InUse->WriteFrom(InUse, "NICK %s", InUse->uuid.c_str());
InUse->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", InUse->nick.c_str());
- ServerInstance->Users->clientlist->erase(InUse->nick);
- (*(ServerInstance->Users->clientlist))[InUse->uuid] = InUse;
+ ServerInstance->Users->clientlist.erase(InUse->nick);
+ ServerInstance->Users->clientlist[InUse->uuid] = InUse;
InUse->nick = InUse->uuid;
InUse->InvalidateCache();
return false;
}
}
+
+ age = newts ? newts : ServerInstance->Time();
}
if (this->registered == REG_ALL)
nick = newnick;
InvalidateCache();
- ServerInstance->Users->clientlist->erase(oldnick);
- (*(ServerInstance->Users->clientlist))[newnick] = this;
+ ServerInstance->Users->clientlist.erase(oldnick);
+ ServerInstance->Users->clientlist[newnick] = this;
if (registered == REG_ALL)
FOREACH_MOD(OnUserPostNick, (this,oldnick));
this->WriteFrom(user, textbuffer);
}
-
-/* write text to an destination user from a source user (e.g. user privmsg) */
-
-void User::WriteTo(User *dest, const char *data, ...)
-{
- std::string textbuffer;
- VAFORMAT(textbuffer, data, data);
- this->WriteTo(dest, textbuffer);
-}
-
-void User::WriteTo(User *dest, const std::string &data)
-{
- dest->WriteFrom(this, data);
-}
-
void User::WriteCommon(const char* text, ...)
{
if (this->registered != REG_ALL || quitting)
this->WriteCommonRaw(textbuffer, true);
}
-void User::WriteCommonExcept(const char* text, ...)
-{
- if (this->registered != REG_ALL || quitting)
- return;
-
- std::string textbuffer;
- VAFORMAT(textbuffer, text, text);
- textbuffer = ":" + this->GetFullHost() + " " + textbuffer;
- this->WriteCommonRaw(textbuffer, false);
-}
-
void User::WriteCommonRaw(const std::string &line, bool include_self)
{
if (this->registered != REG_ALL || quitting)
*/
bool User::SharesChannelWith(User *other)
{
- if ((this->registered != REG_ALL) || (other->registered != REG_ALL))
- return false;
-
/* Outer loop */
for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
{
FOREACH_MOD(OnChangeHost, (this,shost));
- this->dhost.assign(shost, 0, 64);
+ this->dhost.assign(shost, 0, ServerInstance->Config->Limits.MaxHost);
this->InvalidateCache();
if (IS_LOCAL(this))
return true;
}
-void User::SendAll(const char* command, const char* text, ...)
-{
- std::string textbuffer;
- VAFORMAT(textbuffer, text, text);
- const std::string message = ":" + this->GetFullHost() + " " + command + " $* :" + textbuffer;
-
- for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
- {
- if ((*i)->registered == REG_ALL)
- (*i)->Write(message);
- }
-}
-
/*
* Sets a user's connection class.
* If the class name is provided, it will be used. Otherwise, the class will be guessed using host/ip/ident/etc.
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
: config(tag), type(t), fakelag(true), name("unnamed"), registration_timeout(0), host(mask),
pingtime(0), softsendqmax(0), hardsendqmax(0), recvqmax(0),
- penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxconnwarn(true), maxchans(0),
+ penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxconnwarn(true), maxchans(ServerInstance->Config->MaxChans),
limit(0), resolvehostnames(true)
{
}