return data.c_str();
}
-User::User(const std::string &uid, const std::string& sid, int type)
- : uuid(uid), server(sid), usertype(type)
+User::User(const std::string& uid, Server* srv, int type)
+ : uuid(uid), server(srv), usertype(type)
{
age = ServerInstance->Time();
signon = 0;
registered = 0;
- quietquit = quitting = false;
+ quitting = false;
client_sa.sa.sa_family = AF_UNSPEC;
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "New UUID for user: %s", uuid.c_str());
}
LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr)
- : User(ServerInstance->UIDGen.GetUID(), ServerInstance->Config->ServerName, USERTYPE_LOCAL), eh(this),
- localuseriter(ServerInstance->Users->local_users.end()),
+ : User(ServerInstance->UIDGen.GetUID(), ServerInstance->FakeClient->server, USERTYPE_LOCAL), eh(this),
bytes_in(0), bytes_out(0), cmds_in(0), cmds_out(0), nping(0), CommandFloodPenalty(0),
already_sent(0)
{
CullResult LocalUser::cull()
{
- // The iterator is initialized to local_users.end() in the constructor. It is
- // overwritten in UserManager::AddUser() with the real iterator so this check
- // is only a precaution currently.
- if (localuseriter != ServerInstance->Users->local_users.end())
- {
- ServerInstance->Users->local_count--;
- ServerInstance->Users->local_users.erase(localuseriter);
- }
- else
- ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: LocalUserIter does not point to a valid entry for " + this->nick);
-
+ ServerInstance->Users->local_users.erase(this);
ClearInvites();
eh.cull();
return User::cull();
this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s", ServerInstance->Config->ServerName.c_str(), BRANCH, modelist.c_str());
ServerInstance->ISupport.SendTo(this);
- this->WriteNumeric(RPL_YOURUUID, "%s :your unique ID", this->uuid.c_str());
/* Now registered */
if (ServerInstance->Users->unregistered_count)
{
for (UCListIter i = this->chans.begin(); i != this->chans.end(); i++)
{
- Channel *chan = *i;
+ Channel* chan = (*i)->chan;
if (chan->GetPrefixValue(this) < VOICE_VALUE && chan->IsBanned(this))
{
this->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str());
irc::sockets::satoap(client_sa, cachedip, port);
/* IP addresses starting with a : on irc are a Bad Thing (tm) */
if (cachedip[0] == ':')
- cachedip.insert(0,1,'0');
+ cachedip.insert(cachedip.begin(),1,'0');
}
return cachedip;
if (MOD_RESULT == MOD_RES_DENY)
return;
-
+
const std::string message = InspIRCd::Format(":%s %03u %s %s", ServerInstance->Config->ServerName.c_str(),
numeric, !this->nick.empty() ? this->nick.c_str() : "*", text.c_str());
this->Write(message);
LocalUser::already_sent_id++;
- UserChanList include_c(chans);
+ IncludeChanList include_c(chans.begin(), chans.end());
std::map<User*,bool> exceptions;
exceptions[this] = include_self;
u->Write(line);
}
}
- for (UCListIter v = include_c.begin(); v != include_c.end(); ++v)
+ for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v)
{
- Channel* c = *v;
+ Channel* c = (*v)->chan;
const UserMembList* ulist = c->GetUsers();
for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
{
const std::string normalMessage = ":" + this->GetFullHost() + " QUIT :" + normal_text;
const std::string operMessage = ":" + this->GetFullHost() + " QUIT :" + oper_text;
- UserChanList include_c(chans);
+ IncludeChanList include_c(chans.begin(), chans.end());
std::map<User*,bool> exceptions;
FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions));
u->Write(u->IsOper() ? operMessage : normalMessage);
}
}
- for (UCListIter v = include_c.begin(); v != include_c.end(); ++v)
+ for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v)
{
- const UserMembList* ulist = (*v)->GetUsers();
+ const UserMembList* ulist = (*v)->chan->GetUsers();
for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
{
LocalUser* u = IS_LOCAL(i->first);
*/
bool User::SharesChannelWith(User *other)
{
- if ((!other) || (this->registered != REG_ALL) || (other->registered != REG_ALL))
+ if ((this->registered != REG_ALL) || (other->registered != REG_ALL))
return false;
/* Outer loop */
/* Eliminate the inner loop (which used to be ~equal in size to the outer loop)
* by replacing it with a map::find which *should* be more efficient
*/
- if ((*i)->HasUser(other))
+ if ((*i)->chan->HasUser(other))
return true;
}
return false;
void User::PurgeEmptyChannels()
{
// firstly decrement the count on each channel
- for (UCListIter f = this->chans.begin(); f != this->chans.end(); f++)
+ for (UCListIter i = this->chans.begin(); i != this->chans.end(); )
{
- Channel* c = *f;
+ Channel* c = (*i)->chan;
+ ++i;
c->DelUser(this);
}
{
if (!ServerInstance->Config->HideWhoisServer.empty())
return ServerInstance->Config->HideWhoisServer;
- return server;
+ return server->GetName();
}
const std::string& FakeUser::GetFullRealHost()
{
if (!ServerInstance->Config->HideWhoisServer.empty())
return ServerInstance->Config->HideWhoisServer;
- return server;
+ return server->GetName();
}
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)