summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_oper/cmd_die.cpp21
-rw-r--r--src/coremods/core_oper/cmd_restart.cpp2
-rw-r--r--src/coremods/core_oper/core_oper.h5
-rw-r--r--src/helperfuncs.cpp19
-rw-r--r--src/server.cpp1
5 files changed, 26 insertions, 22 deletions
diff --git a/src/coremods/core_oper/cmd_die.cpp b/src/coremods/core_oper/cmd_die.cpp
index 5e7a6afcf..4bc6c25db 100644
--- a/src/coremods/core_oper/cmd_die.cpp
+++ b/src/coremods/core_oper/cmd_die.cpp
@@ -37,6 +37,25 @@ static void QuitAll()
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)
@@ -46,7 +65,7 @@ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User *
{
std::string diebuf = "*** DIE command from " + user->GetFullHost() + ". Terminating.";
ServerInstance->Logs->Log("COMMAND", LOG_SPARSE, diebuf);
- ServerInstance->SendError(diebuf);
+ DieRestart::SendError(diebuf);
}
QuitAll();
diff --git a/src/coremods/core_oper/cmd_restart.cpp b/src/coremods/core_oper/cmd_restart.cpp
index 4fad752a2..3e219727f 100644
--- a/src/coremods/core_oper/cmd_restart.cpp
+++ b/src/coremods/core_oper/cmd_restart.cpp
@@ -35,7 +35,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us
{
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.
diff --git a/src/coremods/core_oper/core_oper.h b/src/coremods/core_oper/core_oper.h
index 3b3dfd4b2..338a369f5 100644
--- a/src/coremods/core_oper/core_oper.h
+++ b/src/coremods/core_oper/core_oper.h
@@ -30,6 +30,11 @@ namespace DieRestart
* @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);
}
/** Handle /DIE.
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 5cde46246..d636e2d89 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -79,25 +79,6 @@ Channel* InspIRCd::FindChan(const std::string &chan)
return iter->second;
}
-/* 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();
diff --git a/src/server.cpp b/src/server.cpp
index 42dce1372..191a3d30f 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -46,7 +46,6 @@ void InspIRCd::Exit(int status)
#ifdef _WIN32
SetServiceStopped(status);
#endif
- this->SendError("Exiting with status " + ConvToStr(status) + " (" + std::string(ExitCodes[status]) + ")");
this->Cleanup();
ServerInstance = NULL;
delete this;