diff options
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | src/coremods/core_who.cpp | 41 | ||||
-rw-r--r-- | src/modules.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_auditorium.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_hideoper.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_namesx.cpp | 23 |
6 files changed, 39 insertions, 46 deletions
diff --git a/include/modules.h b/include/modules.h index a349a5d2a..46aa13e40 100644 --- a/include/modules.h +++ b/include/modules.h @@ -990,10 +990,10 @@ class CoreExport Module : public classbase, public usecountbase * @param params The parameters to the /WHO query * @param user The user that this line of the query is about * @param memb The member shown in this line, NULL if no channel is in this line - * @param line The raw line to send; modifiable. + * @param numeric Numeric to send; modifiable. * @param Return MOD_RES_PASSTHRU to allow the line to be displayed, MOD_RES_DENY to hide it */ - virtual ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, std::string& line); + virtual ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric); /** Called whenever a local user's IP is set for the first time, or when a local user's IP changes due to * a module like m_cgiirc changing it. diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 6cccb3634..d79006e84 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -63,7 +63,7 @@ class CommandWho : public Command syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]"; } - void SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string& initial, Membership* memb, User* u, std::vector<std::string>& whoresults); + void SendWhoLine(User* user, const std::vector<std::string>& parms, Membership* memb, User* u, std::vector<Numeric::Numeric>& whoresults); /** Handle command. * @param parameters The parameters to the command * @param user The user issuing the command @@ -186,44 +186,48 @@ bool CommandWho::CanView(Channel* chan, User* user) return false; } -void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms, const std::string& initial, Membership* memb, User* u, std::vector<std::string>& whoresults) +void CommandWho::SendWhoLine(User* user, const std::vector<std::string>& parms, Membership* memb, User* u, std::vector<Numeric::Numeric>& whoresults) { if (!memb) memb = get_first_visible_channel(u); - std::string wholine = initial + (memb ? memb->chan->name : "*") + " " + u->ident + " " + - (opt_showrealhost ? u->host : u->dhost) + " "; + Numeric::Numeric wholine(352); + wholine.push(memb ? memb->chan->name : "*").push(u->ident); + wholine.push(opt_showrealhost ? u->host : u->dhost); if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) - wholine.append(ServerInstance->Config->HideWhoisServer); + wholine.push(ServerInstance->Config->HideWhoisServer); else - wholine.append(u->server->GetName()); + wholine.push(u->server->GetName()); - wholine.append(" " + u->nick + " "); + wholine.push(u->nick); + std::string param; /* away? */ if (u->IsAway()) { - wholine.append("G"); + param.push_back('G'); } else { - wholine.append("H"); + param.push_back('H'); } /* oper? */ if (u->IsOper()) { - wholine.push_back('*'); + param.push_back('*'); } if (memb) { char prefix = memb->GetPrefixChar(); if (prefix) - wholine.push_back(prefix); + param.push_back(prefix); } - wholine.append(" :0 " + u->fullname); + wholine.push(param); + wholine.push("0 "); + wholine.GetParams().back().append(u->fullname); ModResult res; FIRST_MOD_RESULT(OnSendWhoLine, res, (user, parms, u, memb, wholine)); @@ -253,8 +257,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * opt_far = false; opt_time = false; - std::vector<std::string> whoresults; - std::string initial = "352 " + user->nick + " "; + std::vector<Numeric::Numeric> whoresults; /* Change '0' into '*' so the wildcard matcher can grok it */ std::string matchtext = ((parameters[0] == "0") ? "*" : parameters[0]); @@ -337,7 +340,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * continue; } - SendWhoLine(user, parameters, initial, i->second, i->first, whoresults); + SendWhoLine(user, parameters, i->second, i->first, whoresults); } } } @@ -360,7 +363,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * continue; } - SendWhoLine(user, parameters, initial, NULL, oper, whoresults); + SendWhoLine(user, parameters, NULL, oper, whoresults); } } } @@ -377,14 +380,14 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * continue; } - SendWhoLine(user, parameters, initial, NULL, i->second, whoresults); + SendWhoLine(user, parameters, NULL, i->second, whoresults); } } } } /* Send the results out */ - for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++) - user->WriteServ(*n); + for (std::vector<Numeric::Numeric>::const_iterator n = whoresults.begin(); n != whoresults.end(); ++n) + user->WriteNumeric(*n); user->WriteNumeric(RPL_ENDOFWHO, (*parameters[0].c_str() ? parameters[0] : "*"), "End of /WHO list."); // Penalize the user a bit for large queries diff --git a/src/modules.cpp b/src/modules.cpp index b9151b590..18f2dc4d1 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -137,7 +137,7 @@ void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { De ModResult Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { DetachEvent(I_OnNamesListItem); return MOD_RES_PASSTHRU; } ModResult Module::OnNumeric(User*, const Numeric::Numeric&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; } ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; } -ModResult Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, Membership*, std::string&) { DetachEvent(I_OnSendWhoLine); return MOD_RES_PASSTHRU; } +ModResult Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, Membership*, Numeric::Numeric&) { DetachEvent(I_OnSendWhoLine); return MOD_RES_PASSTHRU; } void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); } #ifdef INSPIRCD_ENABLE_TESTSUITE diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index 6185d6d95..6f9eeb252 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -149,7 +149,7 @@ class ModuleAuditorium : public Module } } - ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, std::string& line) CXX11_OVERRIDE + ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE { if (!memb) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 5389ed18d..3d8f8910c 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -104,7 +104,7 @@ class ModuleHideOper : public Module, public Whois::LineEventListener return MOD_RES_PASSTHRU; } - ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, std::string& line) CXX11_OVERRIDE + ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE { if (user->IsModeSet(hm) && !source->HasPrivPermission("users/auspex")) { @@ -113,13 +113,14 @@ class ModuleHideOper : public Module, public Whois::LineEventListener return MOD_RES_DENY; // hide the "*" that marks the user as an oper from the /WHO line - std::string::size_type spcolon = line.find(" :"); - if (spcolon == std::string::npos) + // #chan ident localhost insp22.test nick H@ :0 Attila + if (numeric.GetParams().size() < 6) return MOD_RES_PASSTHRU; - std::string::size_type sp = line.rfind(' ', spcolon-1); - std::string::size_type pos = line.find('*', sp); + + std::string& param = numeric.GetParams()[5]; + const std::string::size_type pos = param.find('*'); if (pos != std::string::npos) - line.erase(pos, 1); + param.erase(pos, 1); } return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 14f89807f..beac968ef 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -67,32 +67,21 @@ class ModuleNamesX : public Module return MOD_RES_PASSTHRU; } - ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, std::string& line) CXX11_OVERRIDE + ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE { if ((!memb) || (!cap.get(source))) return MOD_RES_PASSTHRU; - // Channel names can contain ":", and ":" as a 'start-of-token' delimiter is - // only ever valid after whitespace, so... find the actual delimiter first! - // Thanks to FxChiP for pointing this out. - std::string::size_type pos = line.find(" :"); - if (pos == std::string::npos || pos == 0) - return MOD_RES_PASSTHRU; - pos--; - // Don't do anything if the user has no prefixes - if ((line[pos] == 'H') || (line[pos] == 'G') || (line[pos] == '*')) - return MOD_RES_PASSTHRU; - - // 352 21DAAAAAB #chan ident localhost insp21.test 21DAAAAAB H@ :0 a - // pos - // Don't do anything if the user has only one prefix std::string prefixes = memb->GetAllPrefixChars(); if (prefixes.length() <= 1) return MOD_RES_PASSTHRU; - line.erase(pos, 1); - line.insert(pos, prefixes); + // #chan ident localhost insp22.test nick H@ :0 Attila + if (numeric.GetParams().size() < 6) + return MOD_RES_PASSTHRU; + + numeric.GetParams()[5].append(prefixes, 1, std::string::npos); return MOD_RES_PASSTHRU; } }; |