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 (%s@%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)); }
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 (%s@%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)); }
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { LocalUser* user = IS_LOCAL(dest); /* For remote clients, we don't take any action, we just allow it. * The local server where they are will set their cloak instead. * This is fine, as we will receive it later. */ if (!user) { dest->SetMode(this, adding); return MODEACTION_ALLOW; } if (user->uuid == debounce_uid && debounce_ts == ServerInstance->Time()) { // prevent spamming using /mode user +x-x+x-x+x-x if (++debounce_count > 2) return MODEACTION_DENY; } else { debounce_uid = user->uuid; debounce_count = 1; debounce_ts = ServerInstance->Time(); } if (adding == user->IsModeSet(this)) return MODEACTION_DENY; /* don't allow this user to spam modechanges */ if (source == dest) user->CommandFloodPenalty += 5000; if (adding) { std::string* cloak = ext.get(user); if (!cloak) { /* Force creation of missing cloak */ creator->OnUserConnect(user); cloak = ext.get(user); } if (cloak) { user->ChangeDisplayedHost(*cloak); user->SetMode(this, true); return MODEACTION_ALLOW; } else return MODEACTION_DENY; } else { /* User is removing the mode, so restore their real host * and make it match the displayed one. */ user->SetMode(this, false); user->ChangeDisplayedHost(user->host.c_str()); return MODEACTION_ALLOW; } }