summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-12-27 13:06:12 +0000
committerPeter Powell <petpow@saberuk.com>2017-12-27 13:15:43 +0000
commit592dd0e818aa58a31e620ec21f4860a0f992ed9c (patch)
tree38b918488dfdef24732f424cc17f5fc705fbc989
parente73b78ca679281608eedcda0f697fc4b1cd030b3 (diff)
Fix various issues with the cgiirc module.
- Respect the value of <cgiirc:opernotice> when sending snotices to operators. - Write to the log file if opernotice is disabled. - Log to the correct snomask in all cases. This was caused by an oversight when merging insp20 into master. - Replace the full user mask in log messages with a uuid/ip. The WEBIRC command is sent as the first command so there will not be a nickname or username at this point.
-rw-r--r--src/modules/m_cgiirc.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index 4c57c6fdf..984c3da04 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -24,11 +24,11 @@
#include "inspircd.h"
-#include "modules/dns.h"
#include "modules/ssl.h"
enum
{
+ // InspIRCd-specific.
RPL_WHOISGATEWAY = 350
};
@@ -118,7 +118,8 @@ class CommandWebIRC : public SplitCommand
if (!irc::sockets::aptosa(parameters[3], 0, ipaddr))
{
user->CommandFloodPenalty += 5000;
- ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s tried to use WEBIRC but gave an invalid IP address.", user->GetFullRealHost().c_str());
+ WriteLog("Connecting user %s (%s) tried to use WEBIRC but gave an invalid IP address.",
+ user->uuid.c_str(), user->GetIPString().c_str());
return CMD_FAILURE;
}
@@ -133,9 +134,8 @@ class CommandWebIRC : public SplitCommand
realhost.set(user, user->GetRealHost());
realip.set(user, user->GetIPString());
- if (notify)
- ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s is using a WebIRC gateway; changing their IP from %s to %s.",
- user->nick.c_str(), user->GetIPString().c_str(), parameters[3].c_str());
+ WriteLog("Connecting user %s is using a WebIRC gateway; changing their IP from %s to %s.",
+ user->uuid.c_str(), user->GetIPString().c_str(), parameters[3].c_str());
// Set the IP address sent via WEBIRC. We ignore the hostname and lookup
// instead do our own DNS lookups because of unreliable gateways.
@@ -144,9 +144,23 @@ class CommandWebIRC : public SplitCommand
}
user->CommandFloodPenalty += 5000;
- ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s tried to use WEBIRC but didn't match any configured WebIRC hosts.", user->GetFullRealHost().c_str());
+ WriteLog("Connecting user %s (%s) tried to use WEBIRC but didn't match any configured WebIRC hosts.",
+ user->uuid.c_str(), user->GetIPString().c_str());
return CMD_FAILURE;
}
+
+ void WriteLog(const char* message, ...) CUSTOM_PRINTF(2, 3)
+ {
+ std::string buffer;
+ VAFORMAT(buffer, message, message);
+
+ // If we are sending a snotice then the message will already be
+ // written to the logfile.
+ if (notify)
+ ServerInstance->SNO->WriteGlobalSno('w', buffer);
+ else
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, buffer);
+ }
};
class ModuleCgiIRC : public Module, public Whois::EventListener
@@ -166,10 +180,8 @@ class ModuleCgiIRC : public Module, public Whois::EventListener
cmd.realhost.set(user, user->GetRealHost());
cmd.realip.set(user, user->GetIPString());
- if (cmd.notify)
- ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s is using an ident gateway; changing their IP from %s to %s.",
- user->nick.c_str(), user->GetIPString().c_str(), newip.c_str());
-
+ cmd.WriteLog("Connecting user %s is using an ident gateway; changing their IP from %s to %s.",
+ user->uuid.c_str(), user->GetIPString().c_str(), newip.c_str());
ChangeIP(user, newip);
RecheckClass(user);
}