mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Merge branch 'master+writenumeric-who'
This commit is contained in:
commit
4f1005acd1
@ -990,9 +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, if empty no line will be returned.
|
||||
* @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 void 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.
|
||||
|
@ -104,6 +104,7 @@ enum
|
||||
RPL_INVITELIST = 346, // insp-specific (stolen from ircu)
|
||||
RPL_ENDOFINVITELIST = 347, // insp-specific (stolen from ircu)
|
||||
RPL_VERSION = 351,
|
||||
RPL_WHOREPLY = 352,
|
||||
RPL_NAMREPLY = 353,
|
||||
RPL_LINKS = 364,
|
||||
RPL_ENDOFLINKS = 365,
|
||||
|
@ -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,48 +186,52 @@ 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(RPL_WHOREPLY);
|
||||
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);
|
||||
|
||||
FOREACH_MOD(OnSendWhoLine, (user, parms, u, memb, wholine));
|
||||
|
||||
if (!wholine.empty())
|
||||
ModResult res;
|
||||
FIRST_MOD_RESULT(OnSendWhoLine, res, (user, parms, u, memb, wholine));
|
||||
if (res != MOD_RES_DENY)
|
||||
whoresults.push_back(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
|
||||
|
@ -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; }
|
||||
void Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, Membership*, std::string&) { DetachEvent(I_OnSendWhoLine); }
|
||||
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
|
||||
|
@ -149,15 +149,15 @@ class ModuleAuditorium : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void 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;
|
||||
return MOD_RES_PASSTHRU;
|
||||
if (IsVisible(memb))
|
||||
return;
|
||||
return MOD_RES_PASSTHRU;
|
||||
if (CanSee(source, memb))
|
||||
return;
|
||||
line.clear();
|
||||
return MOD_RES_PASSTHRU;
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -104,22 +104,25 @@ class ModuleHideOper : public Module, public Whois::LineEventListener
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void 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"))
|
||||
{
|
||||
// Hide the line completely if doing a "/who * o" query
|
||||
if ((params.size() > 1) && (params[1].find('o') != std::string::npos))
|
||||
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)
|
||||
return; // Another module hid the user completely
|
||||
std::string::size_type sp = line.rfind(' ', spcolon-1);
|
||||
std::string::size_type pos = line.find('*', sp);
|
||||
// #chan ident localhost insp22.test nick H@ :0 Attila
|
||||
if (numeric.GetParams().size() < 6)
|
||||
return MOD_RES_PASSTHRU;
|
||||
|
||||
std::string& param = numeric.GetParams()[5];
|
||||
const std::string::size_type pos = param.find('*');
|
||||
if (pos != std::string::npos)
|
||||
line.erase(pos, 1);
|
||||
// hide the line completely if doing a "/who * o" query
|
||||
if (params.size() > 1 && params[1].find('o') != std::string::npos)
|
||||
line.clear();
|
||||
param.erase(pos, 1);
|
||||
}
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE
|
||||
|
@ -67,32 +67,22 @@ class ModuleNamesX : public Module
|
||||
return MOD_RES_PASSTHRU;
|
||||
}
|
||||
|
||||
void 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;
|
||||
|
||||
// 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;
|
||||
pos--;
|
||||
// Don't do anything if the user has no prefixes
|
||||
if ((line[pos] == 'H') || (line[pos] == 'G') || (line[pos] == '*'))
|
||||
return;
|
||||
|
||||
// 352 21DAAAAAB #chan ident localhost insp21.test 21DAAAAAB H@ :0 a
|
||||
// pos
|
||||
return MOD_RES_PASSTHRU;
|
||||
|
||||
// Don't do anything if the user has only one prefix
|
||||
std::string prefixes = memb->GetAllPrefixChars();
|
||||
if (prefixes.length() <= 1)
|
||||
return;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user