summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:48:02 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:48:02 +0000
commit8eeb07be8cd397ea9b54f965ae72d8939ffdccc2 (patch)
treeb15981f058d7bdee764e4a3dd12c4c2ee66af818 /src/modules
parent77ead8fe331060d19525cac5b880c41c47c12f11 (diff)
Route whois notices using ENCAP WHOISNOTICE to properly fix remote user PrivPermission bug
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11625 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_showwhois.cpp72
1 files changed, 44 insertions, 28 deletions
diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp
index 473fd6adc..7464a0d21 100644
--- a/src/modules/m_showwhois.cpp
+++ b/src/modules/m_showwhois.cpp
@@ -45,14 +45,41 @@ class SeeWhois : public ModeHandler
}
};
+class WhoisNoticeCmd : public Command
+{
+ public:
+ WhoisNoticeCmd(InspIRCd* Instance) : Command(Instance,"WHOISNOTICE", 0, 1)
+ {
+ this->source = "m_showwhois.cpp";
+ }
+
+ void HandleFast(User* dest, User* src)
+ {
+ dest->WriteServ("NOTICE %s :*** %s (%s@%s) did a /whois on you",
+ dest->nick.c_str(), src->nick.c_str(), src->ident.c_str(),
+ dest->HasPrivPermission("users/auspex") ? src->host.c_str() : src->dhost.c_str());
+ }
+
+ CmdResult Handle(const std::vector<std::string> &parameters, User *user)
+ {
+ User* dest = ServerInstance->FindNick(parameters[0]);
+
+ if (IS_LOCAL(dest))
+ HandleFast(dest, user);
+
+ return CMD_SUCCESS;
+ }
+};
+
class ModuleShowwhois : public Module
{
bool ShowWhoisFromOpers;
SeeWhois* sw;
+ WhoisNoticeCmd cmd;
public:
- ModuleShowwhois(InspIRCd* Me) : Module(Me)
+ ModuleShowwhois(InspIRCd* Me) : Module(Me), cmd(Me)
{
ConfigReader conf(ServerInstance);
bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0);
@@ -61,6 +88,7 @@ class ModuleShowwhois : public Module
sw = new SeeWhois(ServerInstance, OpersOnly);
if (!ServerInstance->Modes->AddMode(sw))
throw ModuleException("Could not add new modes!");
+ ServerInstance->AddCommand(&cmd);
Implementation eventlist[] = { I_OnWhois };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
@@ -78,35 +106,23 @@ class ModuleShowwhois : public Module
virtual void OnWhois(User* source, User* dest)
{
- if ((dest->IsModeSet('W')) && (source != dest))
- {
- if (!ShowWhoisFromOpers && IS_OPER(source))
- return;
+ if (!dest->IsModeSet('W') || source == dest)
+ return;
- std::string wmsg = "*** ";
- wmsg += source->nick + " (" + source->ident + "@";
+ if (!ShowWhoisFromOpers && (IS_OPER(source) != IS_OPER(dest)))
+ return;
- /* XXX HasPrivPermission doesn't work correctly for remote users */
- if (IS_LOCAL(dest) && dest->HasPrivPermission("users/auspex"))
- {
- wmsg += source->host;
- }
- else
- {
- wmsg += source->dhost;
- }
-
- wmsg += ") did a /whois on you";
-
- if (IS_LOCAL(dest))
- {
- dest->WriteServ("NOTICE %s :%s", dest->nick.c_str(), wmsg.c_str());
- }
- else
- {
- std::string msg = std::string("::") + dest->server + " NOTICE " + dest->nick + " :" + wmsg;
- ServerInstance->PI->PushToClient(dest, msg);
- }
+ if (IS_LOCAL(dest))
+ {
+ cmd.HandleFast(dest, source);
+ }
+ else
+ {
+ std::vector<std::string> params;
+ params.push_back(dest->server);
+ params.push_back("WHOISNOTICE");
+ params.push_back(dest->uuid);
+ ServerInstance->PI->SendEncapsulatedData(params);
}
}