Fix multiple ERROR messages being sent to unregistered users by removing the "Exiting with status..." message
static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2);
static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0);
- /** Send an error notice to all local users, opered and unopered
- * @param s The error string to send
- */
- void SendError(const std::string &s);
-
/** Return true if a nickname is valid
* @param n A nickname to verify
* @return True if the nick is valid
/** Return true if a nickname is valid
* @param n A nickname to verify
* @return True if the nick is valid
ServerInstance->Users.QuitUser(list.front(), quitmsg);
}
ServerInstance->Users.QuitUser(list.front(), quitmsg);
}
+void DieRestart::SendError(const std::string& message)
+{
+ const std::string unregline = "ERROR :" + message;
+ const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+ for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
+ {
+ LocalUser* user = *i;
+ if (user->registered == REG_ALL)
+ {
+ user->WriteNotice(message);
+ }
+ else
+ {
+ // Unregistered connections receive ERROR, not a NOTICE
+ user->Write(unregline);
+ }
+ }
+}
+
/** Handle /DIE
*/
CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *user)
/** Handle /DIE
*/
CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
ServerInstance->Logs->Log("COMMAND", LOG_SPARSE, diebuf);
{
std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
ServerInstance->Logs->Log("COMMAND", LOG_SPARSE, diebuf);
- ServerInstance->SendError(diebuf);
+ DieRestart::SendError(diebuf);
{
ServerInstance->SNO->WriteGlobalSno('a', "RESTART command from %s, restarting server.", user->GetFullRealHost().c_str());
{
ServerInstance->SNO->WriteGlobalSno('a', "RESTART command from %s, restarting server.", user->GetFullRealHost().c_str());
- ServerInstance->SendError("Server restarting.");
+ DieRestart::SendError("Server restarting.");
#ifndef _WIN32
/* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execv() below succeeds.
#ifndef _WIN32
/* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execv() below succeeds.
* @return True if the given password was correct, false if it was not
*/
bool CheckPass(User* user, const std::string& inputpass, const char* confkey);
* @return True if the given password was correct, false if it was not
*/
bool CheckPass(User* user, const std::string& inputpass, const char* confkey);
+
+ /** Send an ERROR to unregistered users and a NOTICE to all registered local users
+ * @param message Message to send
+ */
+ void SendError(const std::string& message);
-/* Send an error notice to all users, registered or not */
-void InspIRCd::SendError(const std::string &s)
-{
- const UserManager::LocalList& list = Users.GetLocalUsers();
- for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
- {
- User* u = *i;
- if (u->registered == REG_ALL)
- {
- u->WriteNotice(s);
- }
- else
- {
- /* Unregistered connections receive ERROR, not a NOTICE */
- u->Write("ERROR :" + s);
- }
- }
-}
-
bool InspIRCd::IsValidMask(const std::string &mask)
{
const char* dest = mask.c_str();
bool InspIRCd::IsValidMask(const std::string &mask)
{
const char* dest = mask.c_str();
#ifdef _WIN32
SetServiceStopped(status);
#endif
#ifdef _WIN32
SetServiceStopped(status);
#endif
- this->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
this->Cleanup();
ServerInstance = NULL;
delete this;
this->Cleanup();
ServerInstance = NULL;
delete this;