}
}
-User::User(const std::string &uid, const std::string& sid)
- : uuid(uid), server(sid)
+User::User(const std::string &uid, const std::string& sid, int type)
+ : uuid(uid), server(sid), usertype(type)
{
age = ServerInstance->Time();
signon = idle_lastmsg = 0;
registered = 0;
quietquit = quitting = exempt = dns_done = false;
- fd = -1;
client_sa.sa.sa_family = AF_UNSPEC;
ServerInstance->Logs->Log("USERS", DEBUG, "New UUID for user: %s", uuid.c_str());
throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor");
}
-LocalUser::LocalUser() : User(ServerInstance->GetUID(), ServerInstance->Config->ServerName)
+LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr)
+ : User(ServerInstance->GetUID(), ServerInstance->Config->ServerName, USERTYPE_LOCAL)
{
bytes_in = bytes_out = cmds_in = cmds_out = 0;
server_sa.sa.sa_family = AF_UNSPEC;
Penalty = 0;
lastping = nping = 0;
+ SetFd(myfd);
+ memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
+ memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs));
}
User::~User()
if (!quitting)
ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
PurgeEmptyChannels();
- if (IS_LOCAL(this) && fd != INT_MAX)
- Close();
this->InvalidateCache();
this->DecrementModes();
+ if (client_sa.sa.sa_family != AF_UNSPEC)
+ ServerInstance->Users->RemoveCloneCounts(this);
+
ServerInstance->Users->uuidlist->erase(uuid);
return Extensible::cull();
}
else
ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
- if (client_sa.sa.sa_family != AF_UNSPEC)
- ServerInstance->Users->RemoveCloneCounts(this);
+ Close();
return User::cull();
}
return cachedip.c_str();
}
-irc::string User::GetCIDRMask()
+irc::sockets::cidr_mask User::GetCIDRMask()
{
int range = 0;
switch (client_sa.sa.sa_family)
range = ServerInstance->Config->c_ipv4_range;
break;
}
- return assign(irc::sockets::mask(client_sa, range));
+ return irc::sockets::cidr_mask(client_sa, range);
}
bool User::SetClientIP(const char* sip)
return;
}
- ServerInstance->Logs->Log("USEROUTPUT", DEBUG,"C[%d] O %s", this->GetFd(), text.c_str());
+ ServerInstance->Logs->Log("USEROUTPUT", DEBUG,"C[%s] O %s", uuid.c_str(), text.c_str());
this->AddWriteBuf(text);
this->AddWriteBuf(wide_newline);
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
- User* u = i->first;
- if (IS_LOCAL(u) && !u->quitting)
+ LocalUser* u = IS_LOCAL(i->first);
+ if (u && !u->quitting)
{
- already_sent[u->fd] = uniq_id;
+ already_sent[u->GetFd()] = uniq_id;
if (i->second)
u->Write(line);
}
const UserMembList* ulist = c->GetUsers();
for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
{
- User* u = i->first;
- if (IS_LOCAL(u) && !u->quitting && already_sent[u->fd] != uniq_id)
+ LocalUser* u = IS_LOCAL(i->first);
+ if (u && !u->quitting && already_sent[u->GetFd()] != uniq_id)
{
- already_sent[u->fd] = uniq_id;
+ already_sent[u->GetFd()] = uniq_id;
u->Write(line);
}
}
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
- User* u = i->first;
- if (IS_LOCAL(u) && !u->quitting)
+ LocalUser* u = IS_LOCAL(i->first);
+ if (u && !u->quitting)
{
- already_sent[u->fd] = uniq_id;
+ already_sent[u->GetFd()] = uniq_id;
if (i->second)
u->Write(IS_OPER(u) ? out2 : out1);
}
const UserMembList* ulist = (*v)->GetUsers();
for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
{
- User* u = i->first;
- if (IS_LOCAL(u) && !u->quitting && (already_sent[u->fd] != uniq_id))
+ LocalUser* u = IS_LOCAL(i->first);
+ if (u && !u->quitting && (already_sent[u->GetFd()] != uniq_id))
{
- already_sent[u->fd] = uniq_id;
+ already_sent[u->GetFd()] = uniq_id;
u->Write(IS_OPER(u) ? out2 : out1);
}
}
for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
{
- User* u = i->first;
- if (IS_LOCAL(u) && !u->quitting)
+ LocalUser* u = IS_LOCAL(i->first);
+ if (u && !u->quitting)
{
if (i->second)
{
- already_sent[u->fd] = seen_id;
+ already_sent[u->GetFd()] = seen_id;
u->Write(quitline);
}
else
{
- already_sent[u->fd] = silent_id;
+ already_sent[u->GetFd()] = silent_id;
}
}
}
const UserMembList *ulist = c->GetUsers();
for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
{
- User* u = i->first;
- if (u == this || !IS_LOCAL(u))
+ LocalUser* u = IS_LOCAL(i->first);
+ if (u == NULL || u == this)
continue;
- if (already_sent[u->fd] == silent_id)
+ if (already_sent[u->GetFd()] == silent_id)
continue;
- if (already_sent[u->fd] != seen_id)
+ if (already_sent[u->GetFd()] != seen_id)
{
u->Write(quitline);
- already_sent[i->first->fd] = seen_id;
+ already_sent[u->GetFd()] = seen_id;
}
u->Write(joinline);
if (modeline.length() > 0)