+class CommandStartTLS : public Command
+{
+ Module* Caller;
+ public:
+ /* Command 'dalinfo', takes no parameters and needs no special modes */
+ CommandStartTLS (InspIRCd* Instance, Module* mod) : Command(Instance,"STARTTLS", 0, 0, true), Caller(mod)
+ {
+ this->source = "m_ssl_gnutls.so";
+ }
+
+ CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
+ {
+ if (user->registered == REG_ALL)
+ {
+ ServerInstance->Users->QuitUser(user, "STARTTLS not allowed after client registration");
+ }
+ else
+ {
+ if (!user->io)
+ {
+ user->WriteNumeric(670, "%s :STARTTLS successful, go ahead with TLS handshake", user->nick.c_str());
+ user->io = Caller;
+ Caller->OnRawSocketAccept(user->GetFd(), user->GetIPString(), user->GetPort());
+ }
+ else
+ user->WriteNumeric(671, "%s :STARTTLS failure", user->nick.c_str());
+ }
+
+ return CMD_FAILURE;
+ }
+};
+