X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sasl.cpp;h=0ef93ec5ae66476923dfe7eaded192dba54711df;hb=a5d110282a864fd2e91b51ce360a977cd0643657;hp=649c218098ad682fef9016c6e5bde70b5961e35f;hpb=27b5df44ec546f9b9f3b2783a7505c920f101aad;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 649c21809..0ef93ec5a 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -51,10 +51,72 @@ 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(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); + + LocalUser* lu = IS_LOCAL(user); + if (lu) + { + // NOTE: SaslAuthenticator instances are only created for local + // users so this parameter will always be appended. + SocketCertificateRequest req(&lu->eh, ServerInstance->Modules->Find("m_sasl.so")); + params.push_back(req.cert ? "S" : "P"); + } + + 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");