本文整理汇总了C++中LocalUser::SetClass方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalUser::SetClass方法的具体用法?C++ LocalUser::SetClass怎么用?C++ LocalUser::SetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalUser
的用法示例。
在下文中一共展示了LocalUser::SetClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Oper
void User::Oper(OperInfo* info)
{
ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
if (this->IsModeSet(opermh))
this->UnOper();
this->SetMode(opermh, true);
this->oper = info;
this->WriteCommand("MODE", "+o");
FOREACH_MOD(OnOper, (this, info->name));
std::string opername;
if (info->oper_block)
opername = info->oper_block->getString("name");
if (IS_LOCAL(this))
{
LocalUser* l = IS_LOCAL(this);
std::string vhost = oper->getConfig("vhost");
if (!vhost.empty())
l->ChangeDisplayedHost(vhost.c_str());
std::string opClass = oper->getConfig("class");
if (!opClass.empty())
l->SetClass(opClass);
}
ServerInstance->SNO->WriteToSnoMask('o',"%s (%[email protected]%s) is now an IRC operator of type %s (using oper '%s')",
nick.c_str(), ident.c_str(), host.c_str(), oper->name.c_str(), opername.c_str());
this->WriteNumeric(RPL_YOUAREOPER, ":You are now %s %s", strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str());
ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->name.c_str());
ServerInstance->Users->all_opers.push_back(this);
// Expand permissions from config for faster lookup
if (IS_LOCAL(this))
oper->init();
FOREACH_MOD(OnPostOper, (this, oper->name, opername));
}
示例2: Oper
void User::Oper(OperInfo* info)
{
if (this->IsModeSet('o'))
this->UnOper();
this->modes[UM_OPERATOR] = 1;
this->oper = info;
this->WriteServ("MODE %s :+o", this->nick.c_str());
FOREACH_MOD(I_OnOper, OnOper(this, info->name));
std::string opername;
if (info->oper_block)
opername = info->oper_block->getString("name");
if (IS_LOCAL(this))
{
LocalUser* l = IS_LOCAL(this);
std::string vhost = oper->getConfig("vhost");
if (!vhost.empty())
l->ChangeDisplayedHost(vhost.c_str());
std::string opClass = oper->getConfig("class");
if (!opClass.empty())
l->SetClass(opClass);
}
ServerInstance->SNO->WriteToSnoMask('o',"%s (%[email protected]%s) is now an IRC operator of type %s (using oper '%s')",
nick.c_str(), ident.c_str(), host.c_str(), oper->NameStr(), opername.c_str());
this->WriteNumeric(381, "%s :You are now %s %s", nick.c_str(), strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->NameStr());
ServerInstance->Logs->Log("OPER", DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->NameStr());
ServerInstance->Users->all_opers.push_back(this);
// Expand permissions from config for faster lookup
if (IS_LOCAL(this))
oper->init();
FOREACH_MOD(I_OnPostOper,OnPostOper(this, oper->name, opername));
}
示例3: AddUser
/* add a client connection to the sockets list */
void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
{
/* NOTE: Calling this one parameter constructor for User automatically
* allocates a new UUID and places it in the hash_map.
*/
LocalUser* New = NULL;
try
{
New = new LocalUser(socket, client, server);
}
catch (...)
{
ServerInstance->Logs->Log("USERS", DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkeys have been unleashed.");
ServerInstance->SNO->WriteToSnoMask('a', "WARNING *** Duplicate UUID allocated!");
return;
}
UserIOHandler* eh = &New->eh;
/* Give each of the modules an attempt to hook the user for I/O */
FOREACH_MOD(I_OnHookIO, OnHookIO(eh, via));
if (eh->GetIOHook())
{
try
{
eh->GetIOHook()->OnStreamSocketAccept(eh, client, server);
}
catch (CoreException& modexcept)
{
ServerInstance->Logs->Log("SOCKET", DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
}
}
ServerInstance->Logs->Log("USERS", DEBUG,"New user fd: %d", socket);
this->unregistered_count++;
/* The users default nick is their UUID */
New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax);
(*(this->clientlist))[New->nick] = New;
New->registered = REG_NONE;
New->signon = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
New->lastping = 1;
ServerInstance->Users->AddLocalClone(New);
ServerInstance->Users->AddGlobalClone(New);
New->localuseriter = this->local_users.insert(local_users.end(), New);
if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds()))
{
ServerInstance->SNO->WriteToSnoMask('a', "Warning: softlimit value has been reached: %d clients", ServerInstance->Config->SoftLimit);
this->QuitUser(New,"No more connections allowed");
return;
}
/*
* First class check. We do this again in FullConnect after DNS is done, and NICK/USER is recieved.
* See my note down there for why this is required. DO NOT REMOVE. :) -- w00t
*/
New->SetClass();
/*
* Check connect class settings and initialise settings into User.
* This will be done again after DNS resolution. -- w00t
*/
New->CheckClass();
if (New->quitting)
return;
/*
* even with bancache, we still have to keep User::exempt current.
* besides that, if we get a positive bancache hit, we still won't fuck
* them over if they are exempt. -- w00t
*/
New->exempt = (ServerInstance->XLines->MatchesLine("E",New) != NULL);
if (BanCacheHit *b = ServerInstance->BanCache->GetHit(New->GetIPString()))
{
if (!b->Type.empty() && !New->exempt)
{
/* user banned */
ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Positive hit for " + New->GetIPString());
if (!ServerInstance->Config->MoronBanner.empty())
New->WriteServ("NOTICE %s :*** %s", New->nick.c_str(), ServerInstance->Config->MoronBanner.c_str());
this->QuitUser(New, b->Reason);
return;
}
else
{
ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Negative hit for " + New->GetIPString());
}
}
else
{
if (!New->exempt)
{
XLine* r = ServerInstance->XLines->MatchesLine("Z",New);
//.........这里部分代码省略.........
示例4: AddUser
/* add a client connection to the sockets list */
void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
{
/* NOTE: Calling this one parameter constructor for User automatically
* allocates a new UUID and places it in the hash_map.
*/
LocalUser* New = NULL;
try
{
New = new LocalUser(socket, client, server);
}
catch (...)
{
ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "*** WTF *** Duplicated UUID! -- Crack smoking monkeys have been unleashed.");
ServerInstance->SNO->WriteToSnoMask('a', "WARNING *** Duplicate UUID allocated!");
return;
}
UserIOHandler* eh = &New->eh;
// If this listener has an IO hook provider set then tell it about the connection
if (via->iohookprov)
via->iohookprov->OnAccept(eh, client, server);
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "New user fd: %d", socket);
this->unregistered_count++;
/* The users default nick is their UUID */
New->nick = New->uuid;
this->clientlist[New->nick] = New;
New->registered = REG_NONE;
New->signon = ServerInstance->Time();
New->lastping = 1;
this->AddClone(New);
this->local_users.push_front(New);
if (this->local_users.size() > ServerInstance->Config->SoftLimit)
{
ServerInstance->SNO->WriteToSnoMask('a', "Warning: softlimit value has been reached: %d clients", ServerInstance->Config->SoftLimit);
this->QuitUser(New,"No more connections allowed");
return;
}
/*
* First class check. We do this again in FullConnect after DNS is done, and NICK/USER is recieved.
* See my note down there for why this is required. DO NOT REMOVE. :) -- w00t
*/
New->SetClass();
/*
* Check connect class settings and initialise settings into User.
* This will be done again after DNS resolution. -- w00t
*/
New->CheckClass(ServerInstance->Config->CCOnConnect);
if (New->quitting)
return;
/*
* even with bancache, we still have to keep User::exempt current.
* besides that, if we get a positive bancache hit, we still won't fuck
* them over if they are exempt. -- w00t
*/
New->exempt = (ServerInstance->XLines->MatchesLine("E",New) != NULL);
BanCacheHit* const b = ServerInstance->BanCache.GetHit(New->GetIPString());
if (b)
{
if (!b->Type.empty() && !New->exempt)
{
/* user banned */
ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString());
if (!ServerInstance->Config->XLineMessage.empty())
New->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage);
this->QuitUser(New, b->Reason);
return;
}
else
{
ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Negative hit for " + New->GetIPString());
}
}
else
{
if (!New->exempt)
{
XLine* r = ServerInstance->XLines->MatchesLine("Z",New);
if (r)
{
r->Apply(New);
return;
}
}
}
if (!SocketEngine::AddFd(eh, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE))
{
//.........这里部分代码省略.........