diff options
30 files changed, 31 insertions, 334 deletions
diff --git a/include/mode.h b/include/mode.h index 2fca1204d..091d11c3d 100644 --- a/include/mode.h +++ b/include/mode.h @@ -80,13 +80,6 @@ enum ParamSpec PARAM_ALWAYS }; -/** - * Used by ModeHandler::ModeSet() to return the state of a mode upon a channel or user. - * The pair contains an activity flag, true if the mode is set with the given parameter, - * and the parameter of the mode (or the parameter provided) in the std::string. - */ -typedef std::pair<bool,std::string> ModePair; - /** Each mode is implemented by ONE ModeHandler class. * You must derive ModeHandler and add the child class to * the list of modes handled by the ircd, using @@ -286,21 +279,6 @@ class CoreExport ModeHandler : public classbase virtual bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel* channel); /** - * When a remote server needs to bounce a set of modes, it will call this method for every mode - * in the mode string to determine if the mode is set or not. - * @param source of the mode change, this will be NULL for a server mode - * @param dest Target user of the mode change, if this is a user mode - * @param channel Target channel of the mode change, if this is a channel mode - * @param parameter The parameter given for the mode change, or an empty string - * @returns The first value of the pair should be true if the mode is set with the given parameter. - * In the case of permissions modes such as channelmode +o, this should return true if the user given - * as the parameter has the given privilage on the given channel. The string value of the pair will hold - * the current setting for this mode set locally, when the bool is true, or, the parameter given. - * This allows the local server to enforce our locally set parameters back to a remote server. - */ - virtual ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); - - /** * When a MODETYPE_USER mode handler is being removed, the server will call this method for every user on the server. * Your mode handler should remove its user mode from the user by sending the appropriate server modes using * InspIRCd::SendMode(). The default implementation of this method can remove simple modes which have no parameters, @@ -578,18 +556,6 @@ class CoreExport ModeParser /** This returns the PREFIX=(ohv)@%+ section of the 005 numeric. */ std::string BuildPrefixes(); - - /** This returns the privilages of a user upon a channel, in the format of a mode change. - * For example, if a user has privilages +avh, this will return the string "avh nick nick nick". - * This is used by the core when cycling a user to refresh their hostname. You may use it for - * similar purposes. - * @param user The username to look up - * @param channel The channel name to look up the privilages of the user for - * @param nick_suffix true (the default) if you want nicknames in the mode string, for easy - * use with the mode stacker, false if you just want the "avh" part of "avh nick nick nick". - * @return The mode string. - */ - std::string ModeString(User* user, Channel* channel, bool nick_suffix = true); }; #endif diff --git a/include/modes/cmode_b.h b/include/modes/cmode_b.h index 0fdbaee3b..7e6139417 100644 --- a/include/modes/cmode_b.h +++ b/include/modes/cmode_b.h @@ -29,7 +29,6 @@ class ModeChannelBan : public ModeHandler std::string& DelBan(User *user,std::string& dest,Channel *chan,int status); void DisplayList(User* user, Channel* channel); void DisplayEmptyList(User* user, Channel* channel); - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); void RemoveMode(User* user, irc::modestacker* stack = NULL); void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); }; diff --git a/include/modes/cmode_h.h b/include/modes/cmode_h.h index aea56ba32..a93e8bf6a 100644 --- a/include/modes/cmode_h.h +++ b/include/modes/cmode_h.h @@ -24,7 +24,6 @@ class ModeChannelHalfOp : public ModeHandler public: ModeChannelHalfOp(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); unsigned int GetPrefixRank(); void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); void RemoveMode(User* user, irc::modestacker* stack = NULL); diff --git a/include/modes/cmode_k.h b/include/modes/cmode_k.h index bb3597923..e26d7e5a6 100644 --- a/include/modes/cmode_k.h +++ b/include/modes/cmode_k.h @@ -22,7 +22,6 @@ class ModeChannelKey : public ModeHandler public: ModeChannelKey(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); void RemoveMode(User* user, irc::modestacker* stack = NULL); }; diff --git a/include/modes/cmode_l.h b/include/modes/cmode_l.h index d83c4f1cf..dc93396d7 100644 --- a/include/modes/cmode_l.h +++ b/include/modes/cmode_l.h @@ -22,6 +22,5 @@ class ModeChannelLimit : public ModeHandler public: ModeChannelLimit(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel* channel); }; diff --git a/include/modes/cmode_o.h b/include/modes/cmode_o.h index 524d254ee..06c7862c4 100644 --- a/include/modes/cmode_o.h +++ b/include/modes/cmode_o.h @@ -24,7 +24,6 @@ class ModeChannelOp : public ModeHandler public: ModeChannelOp(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); unsigned int GetPrefixRank(); void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); void RemoveMode(User* user, irc::modestacker* stack = NULL); diff --git a/include/modes/cmode_v.h b/include/modes/cmode_v.h index 77e8562f2..30a1650ad 100644 --- a/include/modes/cmode_v.h +++ b/include/modes/cmode_v.h @@ -24,7 +24,6 @@ class ModeChannelVoice : public ModeHandler public: ModeChannelVoice(); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding); - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter); unsigned int GetPrefixRank(); void RemoveMode(User* user, irc::modestacker* stack = NULL); void RemoveMode(Channel* channel, irc::modestacker* stack = NULL); diff --git a/src/channels.cpp b/src/channels.cpp index fd9861279..500791ea3 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -377,7 +377,9 @@ Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs, Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str()); /* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */ - std::string ms = ServerInstance->Modes->ModeString(user, Ptr); + std::string ms = memb->modes; + for(unsigned int i=0; i < memb->modes.length(); i++) + ms.append(" ").append(user->nick); if ((Ptr->GetUserCounter() > 1) && (ms.length())) Ptr->WriteAllExceptSender(user, true, 0, "MODE %s +%s", Ptr->name.c_str(), ms.c_str()); diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 038c665be..43584eae1 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -71,16 +71,12 @@ void ListenSocket::AcceptInternal() irc::sockets::sockaddrs client; irc::sockets::sockaddrs server; - ServerInstance->Logs->Log("SOCKET",DEBUG,"HandleEvent for Listensoket"); - int incomingSockfd; - socklen_t length = sizeof(client); - incomingSockfd = ServerInstance->SE->Accept(this, &client.sa, &length); + int incomingSockfd = ServerInstance->SE->Accept(this, &client.sa, &length); + ServerInstance->Logs->Log("SOCKET",DEBUG,"HandleEvent for Listensoket %s nfd=%d", bind_desc.c_str(), incomingSockfd); if (incomingSockfd < 0) { - ServerInstance->SE->Shutdown(incomingSockfd, 2); - ServerInstance->SE->Close(incomingSockfd); ServerInstance->stats->statsRefused++; return; } @@ -141,7 +137,6 @@ void ListenSocket::AcceptInternal() } ServerInstance->SE->NonBlocking(incomingSockfd); - ServerInstance->stats->statsAccept++; ModResult res; FIRST_MOD_RESULT(OnAcceptConnection, res, (incomingSockfd, this, &client, &server)); @@ -154,8 +149,13 @@ void ListenSocket::AcceptInternal() res = MOD_RES_ALLOW; } } - if (res != MOD_RES_ALLOW) + if (res == MOD_RES_ALLOW) { + ServerInstance->stats->statsAccept++; + } + else + { + ServerInstance->stats->statsRefused++; ServerInstance->Logs->Log("SOCKET",DEFAULT,"Refusing connection on %s - %s", bind_desc.c_str(), res == MOD_RES_DENY ? "Connection refused by module" : "Module for this port not found"); ServerInstance->SE->Close(incomingSockfd); diff --git a/src/mode.cpp b/src/mode.cpp index d19647cae..d12469aef 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -121,18 +121,6 @@ ModeAction ModeHandler::OnModeChange(User*, User*, Channel*, std::string&, bool) return MODEACTION_DENY; } -ModePair ModeHandler::ModeSet(User*, User* dest, Channel* channel, const std::string&) -{ - if (dest) - { - return std::make_pair(dest->IsModeSet(this->mode), ""); - } - else - { - return std::make_pair(channel->IsModeSet(this->mode), ""); - } -} - void ModeHandler::DisplayList(User*, Channel*) { } @@ -768,40 +756,6 @@ ModeHandler* ModeParser::FindPrefix(unsigned const char pfxletter) return NULL; } -std::string ModeParser::ModeString(User* user, Channel* channel, bool nick_suffix) -{ - std::string types; - std::string pars; - - if (!channel || !user) - return ""; - - for (unsigned char mode = 'A'; mode <= 'z'; mode++) - { - unsigned char pos = (mode-65) | MASK_CHANNEL; - ModeHandler* mh = modehandlers[pos]; - if ((mh) && (mh->GetNumParams(true)) && (mh->GetNumParams(false))) - { - ModePair ret; - ret = mh->ModeSet(NULL, user, channel, user->nick); - if ((ret.first) && (ret.second == user->nick)) - { - if (nick_suffix) - { - pars.append(" "); - pars.append(user->nick); - } - types.push_back(mh->GetModeChar()); - } - } - } - - if (nick_suffix) - return types+pars; - else - return types; -} - std::string ModeParser::GiveModeList(ModeMasks m) { std::string type1; /* Listmodes EXCEPT those with a prefix */ diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index 477d87544..b2b3f3c6f 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -141,18 +141,6 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan return dest; } -ModePair ModeChannelBan::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - for (BanList::iterator i = channel->bans.begin(); i != channel->bans.end(); i++) - { - if (!strcasecmp(i->data.c_str(), parameter.c_str())) - { - return std::make_pair(true, i->data); - } - } - return std::make_pair(false, parameter); -} - std::string& ModeChannelBan::DelBan(User *user, std::string& dest, Channel *chan, int) { if ((!user) || (!chan)) diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 9ca050de2..0b0f0b700 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -32,24 +32,6 @@ unsigned int ModeChannelHalfOp::GetPrefixRank() return HALFOP_VALUE; } -ModePair ModeChannelHalfOp::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* memb = channel->GetUser(x); - if (memb && memb->hasMode('h')) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, x->nick); - } - } - return std::make_pair(false, parameter); -} - void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* clist = channel->GetUsers(); diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index 5b273cdd1..d8b04b576 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -21,19 +21,6 @@ ModeChannelKey::ModeChannelKey() : ModeHandler(NULL, "key", 'k', PARAM_ALWAYS, M { } -ModePair ModeChannelKey::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - if (channel->modes[CM_KEY]) - { - std::string ckey = channel->GetModeParameter('k'); - return std::make_pair(true, ckey); - } - else - { - return std::make_pair(false, parameter); - } -} - void ModeChannelKey::RemoveMode(Channel* channel, irc::modestacker* stack) { /** +k needs a parameter when being removed, diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp index 0fddf2af0..fce195200 100644 --- a/src/modes/cmode_l.cpp +++ b/src/modes/cmode_l.cpp @@ -21,19 +21,6 @@ ModeChannelLimit::ModeChannelLimit() : ModeHandler(NULL, "limit", 'l', PARAM_SET { } -ModePair ModeChannelLimit::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - std::string climit = channel->GetModeParameter('l'); - if (!climit.empty()) - { - return std::make_pair(true, climit); - } - else - { - return std::make_pair(false, parameter); - } -} - bool ModeChannelLimit::ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel*) { /* When TS is equal, the higher channel limit wins */ diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index 1bab9db26..e706302dc 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -32,25 +32,6 @@ unsigned int ModeChannelOp::GetPrefixRank() return OP_VALUE; } -ModePair ModeChannelOp::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* memb = channel->GetUser(x); - if (memb && memb->hasMode('o')) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } - } - return std::make_pair(false, parameter); -} - - void ModeChannelOp::RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* clist = channel->GetUsers(); diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index b791f5574..6e5ebd0a9 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -33,24 +33,6 @@ unsigned int ModeChannelVoice::GetPrefixRank() return VOICE_VALUE; } -ModePair ModeChannelVoice::ModeSet(User*, User*, Channel* channel, const std::string ¶meter) -{ - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* memb = channel->GetUser(x); - if (memb && memb->hasMode('v')) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } - } - return std::make_pair(false, parameter); -} - void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* clist = channel->GetUsers(); diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 9164d9992..369703d2c 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -44,31 +44,6 @@ class FounderProtectBase { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* memb = channel->GetUser(x); - if (!memb) - { - return std::make_pair(false, parameter); - } - else - { - if (memb->hasMode(mode)) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } - } - } - return std::make_pair(false, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* cl = channel->GetUsers(); @@ -143,11 +118,6 @@ class ChanFounder : public ModeHandler, public FounderProtectBase return FOUNDER_VALUE; } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - return FounderProtectBase::ModeSet(source, dest, channel, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { FounderProtectBase::RemoveMode(channel, stack); @@ -215,11 +185,6 @@ class ChanProtect : public ModeHandler, public FounderProtectBase return PROTECT_VALUE; } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - return FounderProtectBase::ModeSet(source, dest, channel, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { FounderProtectBase::RemoveMode(channel, stack); diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 5c545c2f6..cde9ed047 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -154,9 +154,12 @@ void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std: /* Display the join to everyone else (the user who joined got it earlier) */ channel->WriteAllExceptSender(user, false, 0, "JOIN %s", channel->name.c_str()); - std::string n = ServerInstance->Modes->ModeString(user, channel); - if (n.length() > 0) - channel->WriteAllExceptSender(user, false, 0, "MODE %s +%s", channel->name.c_str(), n.c_str()); + std::string ms = memb->modes; + for(unsigned int i=0; i < memb->modes.length(); i++) + ms.append(" ").append(user->nick); + + if (ms.length() > 0) + channel->WriteAllExceptSender(user, false, 0, "MODE %s +%s", channel->name.c_str(), ms.c_str()); } MODULE_INIT(ModuleDelayJoin) diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index 0432bce5b..192bca15f 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -28,19 +28,6 @@ class DelayMsgMode : public ModeHandler levelrequired = OP_VALUE; } - ModePair ModeSet(User*, User*, Channel* channel, const std::string ¶meter) - { - std::string climit = channel->GetModeParameter('d'); - if (!climit.empty()) - { - return std::make_pair(true, climit); - } - else - { - return std::make_pair(false, parameter); - } - } - bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel*) { return (atoi(their_param.c_str()) < atoi(our_param.c_str())); diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index 0c7cc4dc7..cc2080f7f 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -49,7 +49,11 @@ class InvisibleMode : public ModeHandler snprintf(tb,MAXBUF,":%s %s %s", dest->GetFullHost().c_str(), adding ? "PART" : "JOIN", (*f)->name.c_str()); std::string out = tb; - std::string n = ServerInstance->Modes->ModeString(dest, (*f)); + Membership* memb = (**f).GetUser(dest); + std::string ms = memb->modes; + for(unsigned int i=0; i < memb->modes.length(); i++) + ms.append(" ").append(dest->nick); + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { @@ -57,8 +61,8 @@ class InvisibleMode : public ModeHandler if (IS_LOCAL(i->first) && !IS_OPER(i->first)) { i->first->Write(out); - if (!n.empty() && !adding) - i->first->WriteServ("MODE %s +%s", (*f)->name.c_str(), n.c_str()); + if (!ms.empty() && !adding) + i->first->WriteServ("MODE %s +%s", (**f).name.c_str(), ms.c_str()); } } } diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index e0555b37f..77d02a288 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -88,15 +88,6 @@ class JoinFlood : public ModeHandler JoinFlood(Module* Creator) : ModeHandler(Creator, "joinflood", 'j', PARAM_SETONLY, MODETYPE_CHANNEL), ext("joinflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - joinfloodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, ConvToStr(x->joins)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (adding) diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 9d5fe3b62..aee4bf869 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -34,14 +34,6 @@ class KickRejoin : public ModeHandler KickRejoin(Module* Creator) : ModeHandler(Creator, "kicknorejoin", 'J', PARAM_SETONLY, MODETYPE_CHANNEL), ext("norejoinusers", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - if (channel->IsModeSet('J')) - return std::make_pair(true, channel->GetModeParameter('J')); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (!adding) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index c39bc9807..5fceee19c 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -78,15 +78,6 @@ class MsgFlood : public ModeHandler MsgFlood(Module* Creator) : ModeHandler(Creator, "flood", 'f', PARAM_SETONLY, MODETYPE_CHANNEL), ext("messageflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - floodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, (x->ban ? "*" : "")+ConvToStr(x->lines)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { floodsettings *f = ext.get(channel); diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index a267cd404..f34cc81e4 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -92,15 +92,6 @@ class NickFlood : public ModeHandler NickFlood(Module* Creator) : ModeHandler(Creator, "nickflood", 'F', PARAM_SETONLY, MODETYPE_CHANNEL), ext("nickflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - nickfloodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, ConvToStr(x->nicks)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { nickfloodsettings *f = ext.get(channel); diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index d5f7b9443..775dea204 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -103,31 +103,6 @@ class NetworkPrefix : public ModeHandler m_paramtype = TR_NICK; } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* m = channel->GetUser(x); - if (!m) - { - return std::make_pair(false, parameter); - } - else - { - if (m->hasMode('Y')) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } - } - } - return std::make_pair(false, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* cl = channel->GetUsers(); diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index da1e4d242..e40f6b050 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -49,27 +49,6 @@ class OperPrefixMode : public ModeHandler } } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - User* x = ServerInstance->FindNick(parameter); - Membership* m = channel->GetUser(x); - if (x) - { - if (!m) - { - return std::make_pair(false, parameter); - } - else - { - if (m->hasMode('y')) - return std::make_pair(true, x->nick); - else - return std::make_pair(false, parameter); - } - } - return std::make_pair(false, parameter); - } - bool NeedsOper() { return true; } }; diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 9a138b7fc..50d2e929f 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -22,14 +22,6 @@ class Redirect : public ModeHandler public: Redirect(Module* Creator) : ModeHandler(Creator, "redirect", 'L', PARAM_SETONLY, MODETYPE_CHANNEL) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - if (channel->IsModeSet('L')) - return std::make_pair(true, channel->GetModeParameter('L')); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (adding) diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 7fd867e9b..dcb0cd7d5 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -79,11 +79,12 @@ class ModuleServProtectMode : public Module User *u = ServerInstance->FindNick(param); if (u) { + Membership* memb = chan->GetUser(u); /* The target user has +k set on themselves, and you are trying to remove a privilege mode the user has set on themselves. * This includes any prefix permission mode, even those registered in other modules, e.g. +qaohv. Using ::ModeString() * here means that the number of modes is restricted to only modes the user has, limiting it to as short a loop as possible. */ - if (u->IsModeSet('k') && ServerInstance->Modes->ModeString(u, chan, false).find(mode) != std::string::npos) + if (u->IsModeSet('k') && memb && memb->modes.find(mode) != std::string::npos) { /* BZZZT, Denied! */ user->WriteNumeric(482, "%s %s :You are not permitted to remove privileges from %s services", user->nick.c_str(), chan->name.c_str(), ServerInstance->Config->Network.c_str()); diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 82b6c2b68..981c903a1 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -103,7 +103,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { size_t ptrlen = 0; - std::string modestr = ServerInstance->Modes->ModeString(i->first, c, false); + std::string modestr = i->second->modes; if ((curlen + modestr.length() + i->first->uuid.length() + 4) > 480) { diff --git a/src/users.cpp b/src/users.cpp index 36b41fb18..424484b8c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1376,9 +1376,12 @@ void User::DoHostCycle(const std::string &quitline) Channel* c = *v; snprintf(buffer, MAXBUF, ":%s JOIN %s", GetFullHost().c_str(), c->name.c_str()); std::string joinline(buffer); - std::string modeline = ServerInstance->Modes->ModeString(this, c); + Membership* memb = c->GetUser(this); + std::string modeline = memb->modes; if (modeline.length() > 0) { + for(unsigned int i=0; i < memb->modes.length(); i++) + modeline.append(" ").append(nick); snprintf(buffer, MAXBUF, ":%s MODE %s +%s", GetFullHost().c_str(), c->name.c_str(), modeline.c_str()); modeline = buffer; } |