summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-10-15 16:19:03 +0100
committerPeter Powell <petpow@saberuk.com>2017-10-15 17:19:29 +0100
commit8fb067d2cca22c3568c352a2b6f98084916fafb3 (patch)
tree7f0dd8e3366d23fb531b6fc05072c29b78793946
parent52727673077afcb7377cef7491d3bdf9ab1c372e (diff)
Show the gateway, realhost, and realip in WHOIS for cgiirc clients.
This mirrors a similar feature in ircd-hybrid but using a different numeric that is not already taken in InspIRCd.
-rw-r--r--src/modules/m_cgiirc.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index 87cd86000..51638855c 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -27,6 +27,11 @@
#include "xline.h"
#include "modules/dns.h"
+enum
+{
+ RPL_WHOISGATEWAY = 350
+};
+
// We need this method up here so that it can be accessed from anywhere
static void ChangeIP(User* user, const std::string& newip)
{
@@ -205,7 +210,7 @@ class CGIResolver : public DNS::Request
}
};
-class ModuleCgiIRC : public Module
+class ModuleCgiIRC : public Module, public Whois::EventListener
{
CommandWebIRC cmd;
LocalIntExt waiting;
@@ -251,7 +256,8 @@ class ModuleCgiIRC : public Module
public:
ModuleCgiIRC()
- : cmd(this)
+ : Whois::EventListener(this)
+ , cmd(this)
, waiting("cgiirc-delay", ExtensionItem::EXT_USER, this)
, DNS(this, "DNS")
{
@@ -360,6 +366,24 @@ public:
return MOD_RES_PASSTHRU;
}
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
+ {
+ if (!whois.IsSelfWhois() && !whois.GetSource()->HasPrivPermission("users/auspex"))
+ return;
+
+ // If these fields are not set then the client is not using a gateway.
+ const std::string* realhost = cmd.realhost.get(whois.GetTarget());
+ const std::string* realip = cmd.realip.get(whois.GetTarget());
+ if (!realhost || !realip)
+ return;
+
+ const std::string* gateway = cmd.gateway.get(whois.GetTarget());
+ if (gateway)
+ whois.SendLine(RPL_WHOISGATEWAY, *realhost, *realip, "is connected via the " + *gateway + " WebIRC gateway");
+ else
+ whois.SendLine(RPL_WHOISGATEWAY, *realhost, *realip, "is connected via an ident gateway");
+ }
+
bool CheckIdent(LocalUser* user)
{
const char* ident;