summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-11-14 15:01:21 +0000
committerPeter Powell <petpow@saberuk.com>2018-11-15 19:24:47 +0000
commit6adca3e0997781eae4adb02f19a2f8c312512ae1 (patch)
treedb7b860b6f5a78975b84d079b8671c3252eaa793 /src/modules
parent19c0cfa3e5c3b71521c29d9bcf98f45b7ce13a09 (diff)
Fix the OnSendWhoLine event being completely broken with WHOX.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_auditorium.cpp10
-rw-r--r--src/modules/m_hideoper.cpp35
-rw-r--r--src/modules/m_namesx.cpp34
3 files changed, 66 insertions, 13 deletions
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp
index 8485f1d7a..818242795 100644
--- a/src/modules/m_auditorium.cpp
+++ b/src/modules/m_auditorium.cpp
@@ -22,6 +22,7 @@
#include "inspircd.h"
#include "modules/exemption.h"
+#include "modules/who.h"
class AuditoriumMode : public SimpleChannelModeHandler
{
@@ -55,7 +56,9 @@ class JoinHook : public ClientProtocol::EventHook
}
-class ModuleAuditorium : public Module
+class ModuleAuditorium
+ : public Module
+ , public Who::EventListener
{
CheckExemption::EventProvider exemptionprov;
AuditoriumMode aum;
@@ -66,7 +69,8 @@ class ModuleAuditorium : public Module
public:
ModuleAuditorium()
- : exemptionprov(this)
+ : Who::EventListener(this)
+ , exemptionprov(this)
, aum(this)
, joinhook(this)
{
@@ -173,7 +177,7 @@ class ModuleAuditorium : public Module
}
}
- ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE
+ ModResult OnWhoLine(const Who::Request& request, LocalUser* source, 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 2bca0a156..f04d88809 100644
--- a/src/modules/m_hideoper.cpp
+++ b/src/modules/m_hideoper.cpp
@@ -21,6 +21,7 @@
#include "inspircd.h"
#include "modules/stats.h"
+#include "modules/who.h"
#include "modules/whois.h"
/** Handles user mode +H
@@ -50,13 +51,20 @@ class HideOper : public SimpleUserModeHandler
}
};
-class ModuleHideOper : public Module, public Stats::EventListener, public Whois::LineEventListener
+class ModuleHideOper
+ : public Module
+ , public Stats::EventListener
+ , public Who::EventListener
+ , public Whois::LineEventListener
{
+ private:
HideOper hm;
bool active;
+
public:
ModuleHideOper()
: Stats::EventListener(this)
+ , Who::EventListener(this)
, Whois::LineEventListener(this)
, hm(this)
, active(false)
@@ -107,20 +115,37 @@ class ModuleHideOper : public Module, public Stats::EventListener, public Whois:
return MOD_RES_PASSTHRU;
}
- ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE
+ ModResult OnWhoLine(const Who::Request& request, LocalUser* source, 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))
+ if (request.flags['o'])
return MOD_RES_DENY;
+ size_t flag_index = 5;
+ if (request.whox)
+ {
+ // We only need to fiddle with the flags if they are present.
+ if (!request.whox_fields['f'])
+ return MOD_RES_PASSTHRU;
+
+ // WHOX makes this a bit tricky as we need to work out the parameter which the flags are in.
+ flag_index = 0;
+ static const char* flags = "tcuihsn";
+ for (size_t i = 0; i < strlen(flags); ++i)
+ {
+ if (request.whox_fields[flags[i]])
+ flag_index += 1;
+ }
+ }
+
// hide the "*" that marks the user as an oper from the /WHO line
// #chan ident localhost insp22.test nick H@ :0 Attila
- if (numeric.GetParams().size() < 6)
+ if (numeric.GetParams().size() <= flag_index)
return MOD_RES_PASSTHRU;
- std::string& param = numeric.GetParams()[5];
+ std::string& param = numeric.GetParams()[flag_index];
const std::string::size_type pos = param.find('*');
if (pos != std::string::npos)
param.erase(pos, 1);
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp
index 708b98e56..defb66b78 100644
--- a/src/modules/m_namesx.cpp
+++ b/src/modules/m_namesx.cpp
@@ -22,12 +22,19 @@
#include "inspircd.h"
#include "modules/cap.h"
+#include "modules/who.h"
-class ModuleNamesX : public Module
+class ModuleNamesX
+ : public Module
+ , public Who::EventListener
{
+ private:
Cap::Capability cap;
+
public:
- ModuleNamesX() : cap(this, "multi-prefix")
+ ModuleNamesX()
+ : Who::EventListener(this)
+ , cap(this, "multi-prefix")
{
}
@@ -67,7 +74,7 @@ class ModuleNamesX : public Module
return MOD_RES_PASSTHRU;
}
- ModResult OnSendWhoLine(User* source, const std::vector<std::string>& params, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE
+ ModResult OnWhoLine(const Who::Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE
{
if ((!memb) || (!cap.get(source)))
return MOD_RES_PASSTHRU;
@@ -77,11 +84,28 @@ class ModuleNamesX : public Module
if (prefixes.length() <= 1)
return MOD_RES_PASSTHRU;
+ size_t flag_index = 5;
+ if (request.whox)
+ {
+ // We only need to fiddle with the flags if they are present.
+ if (!request.whox_fields['f'])
+ return MOD_RES_PASSTHRU;
+
+ // WHOX makes this a bit tricky as we need to work out the parameter which the flags are in.
+ flag_index = 0;
+ static const char* flags = "tcuihsn";
+ for (size_t i = 0; i < strlen(flags); ++i)
+ {
+ if (request.whox_fields[flags[i]])
+ flag_index += 1;
+ }
+ }
+
// #chan ident localhost insp22.test nick H@ :0 Attila
- if (numeric.GetParams().size() < 6)
+ if (numeric.GetParams().size() <= flag_index)
return MOD_RES_PASSTHRU;
- numeric.GetParams()[5].append(prefixes, 1, std::string::npos);
+ numeric.GetParams()[flag_index].append(prefixes, 1, std::string::npos);
return MOD_RES_PASSTHRU;
}
};