#include "inspircd.h"
#include "modules/ssl.h"
+#include "modules/webirc.h"
#include "modules/whois.h"
enum
delete old;
}
+ void unset(Extensible* container)
+ {
+ void* old = unset_raw(container);
+ delete static_cast<std::string*>(old);
+ }
+
std::string serialize(SerializeFormat format, const Extensible* container, void* item) const CXX11_OVERRIDE
{
return static_cast<ssl_cert*>(item)->GetMetaLine();
}
}
- void free(void* item) CXX11_OVERRIDE
+ void free(Extensible* container, void* item) CXX11_OVERRIDE
{
ssl_cert* old = static_cast<ssl_cert*>(item);
if (old && old->refcount_dec())
this->syntax = "<nick>";
}
- CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
+ CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
{
User* target = ServerInstance->FindNickOnly(parameters[0]);
{
return ext.get(user);
}
+
+ void SetCertificate(User* user, ssl_cert* cert) CXX11_OVERRIDE
+ {
+ ext.set(user, cert);
+ }
};
-class ModuleSSLInfo : public Module, public Whois::EventListener
+class ModuleSSLInfo
+ : public Module
+ , public WebIRC::EventListener
+ , public Whois::EventListener
{
CommandSSLInfo cmd;
UserCertificateAPIImpl APIImpl;
public:
ModuleSSLInfo()
- : Whois::EventListener(this)
+ : WebIRC::EventListener(this)
+ , Whois::EventListener(this)
, cmd(this)
, APIImpl(this, cmd.CertExt)
{
}
}
- ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE
+ ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if ((command == "OPER") && (validated))
{
return MOD_RES_DENY;
return MOD_RES_PASSTHRU;
}
+
+ void OnWebIRCAuth(LocalUser* user, const WebIRC::FlagMap* flags) CXX11_OVERRIDE
+ {
+ // We are only interested in connection flags. If none have been
+ // given then we have nothing to do.
+ if (!flags)
+ return;
+
+ // We only care about the tls connection flag if the connection
+ // between the gateway and the server is secure.
+ if (!cmd.CertExt.get(user))
+ return;
+
+ WebIRC::FlagMap::const_iterator iter = flags->find("secure");
+ if (iter == flags->end())
+ {
+ // If this is not set then the connection between the client and
+ // the gateway is not secure.
+ cmd.CertExt.unset(user);
+ return;
+ }
+
+ // Create a fake ssl_cert for the user.
+ ssl_cert* cert = new ssl_cert;
+ cert->error = "WebIRC users can not specify valid certs yet";
+ cert->invalid = true;
+ cert->revoked = true;
+ cert->trusted = false;
+ cert->unknownsigner = true;
+ cmd.CertExt.set(user, cert);
+ }
};
MODULE_INIT(ModuleSSLInfo)