summaryrefslogtreecommitdiff
path: root/src/modules/m_sasl.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2017-05-17 23:44:34 +0200
committerGitHub <noreply@github.com>2017-05-17 23:44:34 +0200
commitad8625919378ffbdbf0993d56e16a75a47c4715e (patch)
tree7f5fc54f57a4016fe6643c3ab280481c737ec8ca /src/modules/m_sasl.cpp
parentdf8015951b622363ec34a3ddc002199bd588551c (diff)
parentfc46f1790f17414536c4a0f4c8417079317ae5db (diff)
Merge pull request #1269 from Adam-/insp20+saslhost
m_sasl: send host/ip info
Diffstat (limited to 'src/modules/m_sasl.cpp')
-rw-r--r--src/modules/m_sasl.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 649c21809..5afab9502 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -51,10 +51,63 @@ class SaslAuthenticator
SaslResult result;
bool state_announced;
+ /* taken from m_services_account */
+ static bool ReadCGIIRCExt(const char* extname, User* user, std::string& out)
+ {
+ ExtensionItem* wiext = ServerInstance->Extensions.GetItem(extname);
+ if (!wiext)
+ return false;
+
+ if (wiext->creator->ModuleSourceFile != "m_cgiirc.so")
+ return false;
+
+ StringExtItem* stringext = static_cast<StringExtItem*>(wiext);
+ std::string* addr = stringext->get(user);
+ if (!addr)
+ return false;
+
+ out = *addr;
+ return true;
+ }
+
+
+ void SendHostIP()
+ {
+ std::string host, ip;
+
+ if (!ReadCGIIRCExt("cgiirc_webirc_hostname", user, host))
+ {
+ host = user->host;
+ }
+ if (!ReadCGIIRCExt("cgiirc_webirc_ip", user, ip))
+ {
+ ip = user->GetIPString();
+ }
+ else
+ {
+ /* IP addresses starting with a : on irc are a Bad Thing (tm) */
+ if (ip.c_str()[0] == ':')
+ ip.insert(ip.begin(),1,'0');
+ }
+
+ parameterlist params;
+ params.push_back(sasl_target);
+ params.push_back("SASL");
+ params.push_back(user->uuid);
+ params.push_back("*");
+ params.push_back("H");
+ params.push_back(host);
+ params.push_back(ip);
+
+ SendSASL(params);
+ }
+
public:
SaslAuthenticator(User* user_, const std::string& method)
: user(user_), state(SASL_INIT), state_announced(false)
{
+ SendHostIP();
+
parameterlist params;
params.push_back(sasl_target);
params.push_back("SASL");