mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Send WHO reply numerics with User::WriteNumeric(), pass Numeric::Numeric objects to the OnSendWhoLine hook
This commit is contained in:
parent
2a16373ca1
commit
725c954efb
@ -990,10 +990,10 @@ class CoreExport Module : public classbase, public usecountbase
|
|||||||
* @param params The parameters to the /WHO query
|
* @param params The parameters to the /WHO query
|
||||||
* @param user The user that this line of the query is about
|
* @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 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
|
* @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
|
/** 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.
|
* a module like m_cgiirc changing it.
|
||||||
|
@ -63,7 +63,7 @@ class CommandWho : public Command
|
|||||||
syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]";
|
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.
|
/** Handle command.
|
||||||
* @param parameters The parameters to the command
|
* @param parameters The parameters to the command
|
||||||
* @param user The user issuing the command
|
* @param user The user issuing the command
|
||||||
@ -186,44 +186,48 @@ bool CommandWho::CanView(Channel* chan, User* user)
|
|||||||
return false;
|
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)
|
if (!memb)
|
||||||
memb = get_first_visible_channel(u);
|
memb = get_first_visible_channel(u);
|
||||||
|
|
||||||
std::string wholine = initial + (memb ? memb->chan->name : "*") + " " + u->ident + " " +
|
Numeric::Numeric wholine(352);
|
||||||
(opt_showrealhost ? u->host : u->dhost) + " ";
|
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"))
|
if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex"))
|
||||||
wholine.append(ServerInstance->Config->HideWhoisServer);
|
wholine.push(ServerInstance->Config->HideWhoisServer);
|
||||||
else
|
else
|
||||||
wholine.append(u->server->GetName());
|
wholine.push(u->server->GetName());
|
||||||
|
|
||||||
wholine.append(" " + u->nick + " ");
|
wholine.push(u->nick);
|
||||||
|
|
||||||
|
std::string param;
|
||||||
/* away? */
|
/* away? */
|
||||||
if (u->IsAway())
|
if (u->IsAway())
|
||||||
{
|
{
|
||||||
wholine.append("G");
|
param.push_back('G');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wholine.append("H");
|
param.push_back('H');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* oper? */
|
/* oper? */
|
||||||
if (u->IsOper())
|
if (u->IsOper())
|
||||||
{
|
{
|
||||||
wholine.push_back('*');
|
param.push_back('*');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memb)
|
if (memb)
|
||||||
{
|
{
|
||||||
char prefix = memb->GetPrefixChar();
|
char prefix = memb->GetPrefixChar();
|
||||||
if (prefix)
|
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;
|
ModResult res;
|
||||||
FIRST_MOD_RESULT(OnSendWhoLine, res, (user, parms, u, memb, wholine));
|
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_far = false;
|
||||||
opt_time = false;
|
opt_time = false;
|
||||||
|
|
||||||
std::vector<std::string> whoresults;
|
std::vector<Numeric::Numeric> whoresults;
|
||||||
std::string initial = "352 " + user->nick + " ";
|
|
||||||
|
|
||||||
/* Change '0' into '*' so the wildcard matcher can grok it */
|
/* Change '0' into '*' so the wildcard matcher can grok it */
|
||||||
std::string matchtext = ((parameters[0] == "0") ? "*" : parameters[0]);
|
std::string matchtext = ((parameters[0] == "0") ? "*" : parameters[0]);
|
||||||
@ -337,7 +340,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User *
|
|||||||
continue;
|
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;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendWhoLine(user, parameters, initial, NULL, i->second, whoresults);
|
SendWhoLine(user, parameters, NULL, i->second, whoresults);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Send the results out */
|
/* Send the results out */
|
||||||
for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++)
|
for (std::vector<Numeric::Numeric>::const_iterator n = whoresults.begin(); n != whoresults.end(); ++n)
|
||||||
user->WriteServ(*n);
|
user->WriteNumeric(*n);
|
||||||
user->WriteNumeric(RPL_ENDOFWHO, (*parameters[0].c_str() ? parameters[0] : "*"), "End of /WHO list.");
|
user->WriteNumeric(RPL_ENDOFWHO, (*parameters[0].c_str() ? parameters[0] : "*"), "End of /WHO list.");
|
||||||
|
|
||||||
// Penalize the user a bit for large queries
|
// Penalize the user a bit for large queries
|
||||||
|
@ -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::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::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::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); }
|
void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); }
|
||||||
|
|
||||||
#ifdef INSPIRCD_ENABLE_TESTSUITE
|
#ifdef INSPIRCD_ENABLE_TESTSUITE
|
||||||
|
@ -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)
|
if (!memb)
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
|
@ -104,7 +104,7 @@ class ModuleHideOper : public Module, public Whois::LineEventListener
|
|||||||
return MOD_RES_PASSTHRU;
|
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"))
|
if (user->IsModeSet(hm) && !source->HasPrivPermission("users/auspex"))
|
||||||
{
|
{
|
||||||
@ -113,13 +113,14 @@ class ModuleHideOper : public Module, public Whois::LineEventListener
|
|||||||
return MOD_RES_DENY;
|
return MOD_RES_DENY;
|
||||||
|
|
||||||
// hide the "*" that marks the user as an oper from the /WHO line
|
// hide the "*" that marks the user as an oper from the /WHO line
|
||||||
std::string::size_type spcolon = line.find(" :");
|
// #chan ident localhost insp22.test nick H@ :0 Attila
|
||||||
if (spcolon == std::string::npos)
|
if (numeric.GetParams().size() < 6)
|
||||||
return MOD_RES_PASSTHRU;
|
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)
|
if (pos != std::string::npos)
|
||||||
line.erase(pos, 1);
|
param.erase(pos, 1);
|
||||||
}
|
}
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
}
|
}
|
||||||
|
@ -67,32 +67,21 @@ class ModuleNamesX : public Module
|
|||||||
return MOD_RES_PASSTHRU;
|
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)))
|
if ((!memb) || (!cap.get(source)))
|
||||||
return MOD_RES_PASSTHRU;
|
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
|
// Don't do anything if the user has only one prefix
|
||||||
std::string prefixes = memb->GetAllPrefixChars();
|
std::string prefixes = memb->GetAllPrefixChars();
|
||||||
if (prefixes.length() <= 1)
|
if (prefixes.length() <= 1)
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
|
|
||||||
line.erase(pos, 1);
|
// #chan ident localhost insp22.test nick H@ :0 Attila
|
||||||
line.insert(pos, prefixes);
|
if (numeric.GetParams().size() < 6)
|
||||||
|
return MOD_RES_PASSTHRU;
|
||||||
|
|
||||||
|
numeric.GetParams()[5].append(prefixes, 1, std::string::npos);
|
||||||
return MOD_RES_PASSTHRU;
|
return MOD_RES_PASSTHRU;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user