本文整理汇总了C++中ModeHandler::NeedsOper方法的典型用法代码示例。如果您正苦于以下问题:C++ ModeHandler::NeedsOper方法的具体用法?C++ ModeHandler::NeedsOper怎么用?C++ ModeHandler::NeedsOper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModeHandler
的用法示例。
在下文中一共展示了ModeHandler::NeedsOper方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnOper
void User::UnOper()
{
if (!this->IsOper())
return;
/*
* unset their oper type (what IS_OPER checks).
* note, order is important - this must come before modes as -o attempts
* to call UnOper. -- w00t
*/
oper = NULL;
/* Remove all oper only modes from the user when the deoper - Bug #466*/
Modes::ChangeList changelist;
const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes->GetModes(MODETYPE_USER);
for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); ++i)
{
ModeHandler* mh = i->second;
if (mh->NeedsOper())
changelist.push_remove(mh);
}
ServerInstance->Modes->Process(this, NULL, this, changelist);
// 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);
}
示例2: UnOper
void User::UnOper()
{
if (!IS_OPER(this))
return;
/*
* unset their oper type (what IS_OPER checks).
* note, order is important - this must come before modes as -o attempts
* to call UnOper. -- w00t
*/
oper = NULL;
/* Remove all oper only modes from the user when the deoper - Bug #466*/
std::string moderemove("-");
for (unsigned char letter = 'A'; letter <= 'z'; letter++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(letter, MODETYPE_USER);
if (mh && mh->NeedsOper())
moderemove += letter;
}
std::vector<std::string> parameters;
parameters.push_back(this->nick);
parameters.push_back(moderemove);
ServerInstance->Parser->CallHandler("MODE", 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);
this->modes[UM_OPERATOR] = 0;
}
示例3: UnOper
void User::UnOper()
{
if (!this->IsOper())
return;
/*
* unset their oper type (what IS_OPER checks).
* note, order is important - this must come before modes as -o attempts
* to call UnOper. -- w00t
*/
oper = NULL;
/* Remove all oper only modes from the user when the deoper - Bug #466*/
std::string moderemove("-");
for (unsigned char letter = 'A'; letter <= 'z'; letter++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(letter, MODETYPE_USER);
if (mh && mh->NeedsOper())
moderemove += letter;
}
std::vector<std::string> parameters;
parameters.push_back(this->nick);
parameters.push_back(moderemove);
ServerInstance->Modes->Process(parameters, 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);
}
示例4: Handle
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName.c_str())
return CMD_SUCCESS;
User *targuser;
Channel *targchan;
std::string checkstr;
std::string chliststr;
checkstr = ":" + ServerInstance->Config->ServerName + " 304 " + user->nick + " :CHECK";
targuser = ServerInstance->FindNick(parameters[0]);
targchan = ServerInstance->FindChan(parameters[0]);
/*
* Syntax of a /check reply:
* :server.name 304 target :CHECK START <target>
* :server.name 304 target :CHECK <field> <value>
* :server.name 304 target :CHECK END
*/
user->SendText(checkstr + " START " + parameters[0]);
if (targuser)
{
LocalUser* loctarg = IS_LOCAL(targuser);
/* /check on a user */
user->SendText(checkstr + " nuh " + targuser->GetFullHost());
user->SendText(checkstr + " realnuh " + targuser->GetFullRealHost());
user->SendText(checkstr + " realname " + targuser->fullname);
user->SendText(checkstr + " modes +" + targuser->FormatModes());
user->SendText(checkstr + " snomasks " + GetSnomasks(targuser));
user->SendText(checkstr + " server " + targuser->server->GetName());
user->SendText(checkstr + " uid " + targuser->uuid);
user->SendText(checkstr + " signon " + timestring(targuser->signon));
user->SendText(checkstr + " nickts " + timestring(targuser->age));
if (loctarg)
user->SendText(checkstr + " lastmsg " + timestring(loctarg->idle_lastmsg));
if (targuser->IsAway())
{
/* user is away */
user->SendText(checkstr + " awaytime " + timestring(targuser->awaytime));
user->SendText(checkstr + " awaymsg " + targuser->awaymsg);
}
if (targuser->IsOper())
{
OperInfo* oper = targuser->oper;
/* user is an oper of type ____ */
user->SendText(checkstr + " opertype " + oper->name);
if (loctarg)
{
std::string umodes;
std::string cmodes;
for(char c='A'; c < 'z'; c++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_USER))
umodes.push_back(c);
mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_CHANNEL))
cmodes.push_back(c);
}
user->SendText(checkstr + " modeperms user=" + umodes + " channel=" + cmodes);
std::string opcmds;
for(std::set<std::string>::iterator i = oper->AllowedOperCommands.begin(); i != oper->AllowedOperCommands.end(); i++)
{
opcmds.push_back(' ');
opcmds.append(*i);
}
std::stringstream opcmddump(opcmds);
user->SendText(checkstr + " commandperms", opcmddump);
std::string privs;
for(std::set<std::string>::iterator i = oper->AllowedPrivs.begin(); i != oper->AllowedPrivs.end(); i++)
{
privs.push_back(' ');
privs.append(*i);
}
std::stringstream privdump(privs);
user->SendText(checkstr + " permissions", privdump);
}
}
if (loctarg)
{
user->SendText(checkstr + " clientaddr " + loctarg->client_sa.str());
user->SendText(checkstr + " serveraddr " + loctarg->server_sa.str());
std::string classname = loctarg->GetClass()->name;
if (!classname.empty())
user->SendText(checkstr + " connectclass " + classname);
}
else
user->SendText(checkstr + " onip " + targuser->GetIPString());
for (UCListIter i = targuser->chans.begin(); i != targuser->chans.end(); i++)
{
Channel* c = (*i)->chan;
//.........这里部分代码省略.........
示例5: DoStats
//.........这里部分代码省略.........
case 'T':
{
results.push_back("249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats->statsAccept)+" refused "+ConvToStr(ServerInstance->stats->statsRefused));
results.push_back("249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats->statsUnknown));
results.push_back("249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats->statsCollisions));
results.push_back("249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats->statsDnsGood+ServerInstance->stats->statsDnsBad)+" succeeded "+ConvToStr(ServerInstance->stats->statsDnsGood)+" failed "+ConvToStr(ServerInstance->stats->statsDnsBad));
results.push_back("249 "+user->nick+" :connection count "+ConvToStr(ServerInstance->stats->statsConnects));
results.push_back(InspIRCd::Format("249 %s :bytes sent %5.2fK recv %5.2fK", user->nick.c_str(),
ServerInstance->stats->statsSent / 1024.0, ServerInstance->stats->statsRecv / 1024.0));
}
break;
/* stats o */
case 'o':
{
ConfigTagList tags = ServerInstance->Config->ConfTags("oper");
for(ConfigIter i = tags.first; i != tags.second; ++i)
{
ConfigTag* tag = i->second;
results.push_back("243 "+user->nick+" O "+tag->getString("host")+" * "+
tag->getString("name") + " " + tag->getString("type")+" 0");
}
}
break;
case 'O':
{
for (OperIndex::const_iterator i = ServerInstance->Config->OperTypes.begin(); i != ServerInstance->Config->OperTypes.end(); ++i)
{
OperInfo* tag = i->second;
tag->init();
std::string umodes;
std::string cmodes;
for(char c='A'; c < 'z'; c++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
if (mh && mh->NeedsOper() && tag->AllowedUserModes[c - 'A'])
umodes.push_back(c);
mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
if (mh && mh->NeedsOper() && tag->AllowedChanModes[c - 'A'])
cmodes.push_back(c);
}
results.push_back("243 "+user->nick+" O "+tag->name.c_str() + " " + umodes + " " + cmodes);
}
}
break;
/* stats l (show user I/O stats) */
case 'l':
results.push_back("211 "+user->nick+" :nick[[email protected]] sendq cmds_out bytes_out cmds_in bytes_in time_open");
for (LocalUserList::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
{
LocalUser* i = *n;
results.push_back("211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->eh.getSendQSize())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
}
break;
/* stats L (show user I/O stats with IP addresses) */
case 'L':
results.push_back("211 "+user->nick+" :nick[[email protected]] sendq cmds_out bytes_out cmds_in bytes_in time_open");
for (LocalUserList::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++)
{
LocalUser* i = *n;
results.push_back("211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->eh.getSendQSize())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age));
}
break;
/* stats u (show server uptime) */
case 'u':
{
time_t current_time = 0;
current_time = ServerInstance->Time();
time_t server_uptime = current_time - ServerInstance->startup_time;
struct tm* stime;
stime = gmtime(&server_uptime);
/* i dont know who the hell would have an ircd running for over a year nonstop, but
* Craig suggested this, and it seemed a good idea so in it went */
if (stime->tm_year > 70)
{
results.push_back(InspIRCd::Format("242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",
user->nick.c_str(), stime->tm_year - 70, stime->tm_yday, stime->tm_hour,
stime->tm_min, stime->tm_sec));
}
else
{
results.push_back(InspIRCd::Format("242 %s :Server up %d days, %.2d:%.2d:%.2d",
user->nick.c_str(), stime->tm_yday, stime->tm_hour, stime->tm_min,
stime->tm_sec));
}
}
break;
default:
break;
}
results.push_back("219 "+user->nick+" "+statschar+" :End of /STATS report");
ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%[email protected]%s)",
(IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host.c_str());
return;
}
示例6: TryMode
ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool adding, const unsigned char modechar,
std::string ¶meter, bool SkipACL)
{
ModeType type = chan ? MODETYPE_CHANNEL : MODETYPE_USER;
ModeHandler *mh = FindMode(modechar, type);
int pcnt = mh->GetNumParams(adding);
// crop mode parameter size to 250 characters
if (parameter.length() > 250 && adding)
parameter = parameter.substr(0, 250);
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, modechar, parameter, adding, pcnt));
if (IS_LOCAL(user) && (MOD_RESULT == MOD_RES_DENY))
return MODEACTION_DENY;
if (chan && !SkipACL && (MOD_RESULT != MOD_RES_ALLOW))
{
MOD_RESULT = mh->AccessCheck(user, chan, parameter, adding);
if (MOD_RESULT == MOD_RES_DENY)
return MODEACTION_DENY;
if (MOD_RESULT == MOD_RES_PASSTHRU)
{
unsigned int neededrank = mh->GetLevelRequired();
/* Compare our rank on the channel against the rank of the required prefix,
* allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown
* in NAMES(X) are not in rank order, we know the most powerful mode is listed
* first, so we don't need to iterate, we just look up the first instead.
*/
unsigned int ourrank = chan->GetPrefixValue(user);
if (ourrank < neededrank)
{
PrefixMode* neededmh = NULL;
for(char c='A'; c <= 'z'; c++)
{
PrefixMode* privmh = FindPrefixMode(c);
if (privmh && privmh->GetPrefixRank() >= neededrank)
{
// this mode is sufficient to allow this action
if (!neededmh || privmh->GetPrefixRank() < neededmh->GetPrefixRank())
neededmh = privmh;
}
}
if (neededmh)
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have channel %s access or above to %sset channel mode %c",
user->nick.c_str(), chan->name.c_str(), neededmh->name.c_str(), adding ? "" : "un", modechar);
else
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You cannot %sset channel mode %c",
user->nick.c_str(), chan->name.c_str(), adding ? "" : "un", modechar);
return MODEACTION_DENY;
}
}
}
// Ask mode watchers whether this mode change is OK
std::pair<ModeWatchIter, ModeWatchIter> itpair = modewatchermap.equal_range(mh->name);
for (ModeWatchIter i = itpair.first; i != itpair.second; ++i)
{
ModeWatcher* mw = i->second;
if (mw->GetModeType() == type)
{
if (!mw->BeforeMode(user, targetuser, chan, parameter, adding))
return MODEACTION_DENY;
// A module whacked the parameter completely, and there was one. Abort.
if (pcnt && parameter.empty())
return MODEACTION_DENY;
}
}
if (IS_LOCAL(user) && !user->IsOper())
{
char* disabled = (type == MODETYPE_CHANNEL) ? ServerInstance->Config->DisabledCModes : ServerInstance->Config->DisabledUModes;
if (disabled[modechar - 'A'])
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - %s mode %c has been locked by the administrator",
user->nick.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar);
return MODEACTION_DENY;
}
}
if (adding && IS_LOCAL(user) && mh->NeedsOper() && !user->HasModePermission(modechar, type))
{
/* It's an oper only mode, and they don't have access to it. */
if (user->IsOper())
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper type %s does not have access to set %s mode %c",
user->nick.c_str(), user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar);
}
else
{
user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Only operators may set %s mode %c",
user->nick.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar);
}
return MODEACTION_DENY;
}
//.........这里部分代码省略.........