#include "modules/ssl.h"
#include "modules/webirc.h"
#include "modules/whois.h"
+#include "modules/who.h"
enum
{
: public Module
, public WebIRC::EventListener
, public Whois::EventListener
+ , public Who::EventListener
{
private:
CommandSSLInfo cmd;
+ bool MatchFP(ssl_cert* const cert, const std::string& fp) const
+ {
+ return irc::spacesepstream(fp).Contains(cert->GetFingerprint());
+ }
+
public:
ModuleSSLInfo()
: WebIRC::EventListener(this)
, Whois::EventListener(this)
+ , Who::EventListener(this)
, cmd(this)
{
}
}
}
+ ModResult OnWhoLine(const Who::Request& request, LocalUser* source, User* user, Membership* memb, Numeric::Numeric& numeric) CXX11_OVERRIDE
+ {
+ size_t flag_index;
+ if (!request.GetFieldIndex('f', flag_index))
+ return MOD_RES_PASSTHRU;
+
+ ssl_cert* cert = cmd.sslapi.GetCertificate(user);
+ if (cert)
+ numeric.GetParams()[flag_index].push_back('s');
+
+ return MOD_RES_PASSTHRU;
+ }
+
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if ((command == "OPER") && (validated))
}
std::string fingerprint;
- if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || cert->GetFingerprint() != fingerprint))
+ if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || !MatchFP(cert, fingerprint)))
{
user->WriteNumeric(ERR_NOOPERHOST, "This oper login requires a matching SSL certificate fingerprint.");
user->CommandFloodPenalty += 10000;
{
OperInfo* ifo = i->second;
std::string fp = ifo->oper_block->getString("fingerprint");
- if (fp == cert->fingerprint && ifo->oper_block->getBool("autologin"))
+ if (MatchFP(cert, fp) && ifo->oper_block->getBool("autologin"))
user->Oper(ifo);
}
}