summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands/cmd_rehash.cpp70
-rw-r--r--src/modules/m_spanningtree/main.cpp17
-rw-r--r--src/modules/m_spanningtree/rehash.cpp48
-rw-r--r--src/modules/m_spanningtree/treesocket.h4
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
5 files changed, 56 insertions, 87 deletions
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index 32cd43569..41b6936f6 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -25,34 +25,60 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User *user)
{
user->WriteNumeric(382, "%s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
- std::string parameter;
std::string old_disabled = ServerInstance->Config->DisabledCommands;
- if (pcnt)
+
+ ServerInstance->Logs->Log("fuckingrehash", DEBUG, "parc %d p0 %s", pcnt, parameters[0]);
+ if (pcnt && parameters[0][0] != '-')
{
- parameter = parameters[0];
+ if (!ServerInstance->MatchText(ServerInstance->Config->ServerName, parameters[0]))
+ {
+ ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a server, and not for us");
+ FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0]));
+ return CMD_SUCCESS; // rehash for a server, and not for us
+ }
}
- else
+ else if (pcnt)
{
- ServerInstance->SNO->WriteToSnoMask('A', "%s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
- ServerInstance->Logs->CloseLogs();
- if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
- user->WriteServ("NOTICE %s :*** ERROR: Could not open logfile %s: %s", user->nick, ServerInstance->Config->logpath.c_str(), strerror(errno));
- ServerInstance->RehashUsersAndChans();
- FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
- if (!ServerInstance->ConfigThread)
- {
- ServerInstance->Config->RehashUser = user;
- ServerInstance->Config->RehashParameter = parameter;
+ ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a subsystem, ignoring");
+ FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0]));
+ return CMD_SUCCESS;
+ }
- ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
- ServerInstance->Threads->Create(ServerInstance->ConfigThread);
- }
- else
- {
- /* A rehash is already in progress! ahh shit. */
+ // Rehash for me.
+ FOREACH_MOD(I_OnRehash,OnRehash(user, ""));
+
+ std::string m = std::string(user->nick) + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName);
+ ServerInstance->SNO->WriteToSnoMask('A', m);
+ ServerInstance->PI->SendSNONotice("A", m);
+ ServerInstance->Logs->CloseLogs();
+
+ if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
+ {
+ m = std::string("ERROR: Could not open logfile ") + ServerInstance->Config->logpath + ":" + strerror(errno);
+ ServerInstance->SNO->WriteToSnoMask('A', m);
+ ServerInstance->PI->SendSNONotice("A", m);
+ }
+
+ ServerInstance->RehashUsersAndChans();
+ FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+
+ if (!ServerInstance->ConfigThread)
+ {
+ ServerInstance->Config->RehashUser = user;
+ ServerInstance->Config->RehashParameter = pcnt ? parameters[0] : "";
+
+ ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
+ ServerInstance->Threads->Create(ServerInstance->ConfigThread);
+ }
+ else
+ {
+ /* A rehash is already in progress! ahh shit. */
+ if (IS_LOCAL(user))
user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick);
- return CMD_FAILURE;
- }
+ else
+ ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress.");
+
+ return CMD_FAILURE;
}
return CMD_SUCCESS;
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 92df0c468..102fc4b13 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -741,20 +741,19 @@ void ModuleSpanningTree::OnRemoteKill(User* source, User* dest, const std::strin
void ModuleSpanningTree::OnRehash(User* user, const std::string &parameter)
{
- if (!parameter.empty())
+ ServerInstance->Logs->Log("remoterehash", DEBUG, "called with param %s", parameter.c_str());
+
+ // Send out to other servers
+ if (!parameter.empty() && parameter[0] != '-')
{
+ ServerInstance->Logs->Log("remoterehash", DEBUG, "sending out lol");
std::deque<std::string> params;
params.push_back(parameter);
- Utils->DoOneToMany(user ? user->nick : ServerInstance->Config->GetSID(), "REHASH", params);
- // check for self
- if (ServerInstance->MatchText(ServerInstance->Config->ServerName,parameter))
- {
- ServerInstance->SNO->WriteToSnoMask('A', "Remote rehash initiated locally by \002%s\002", user ? user->nick : ServerInstance->Config->ServerName);
- ServerInstance->RehashServer();
- }
+ Utils->DoOneToAllButSender(user ? user->uuid : ServerInstance->Config->GetSID(), "REHASH", params, user ? user->server : ServerInstance->Config->GetSID()); /// Can this take SID?
}
+
+ // Re-read config stuff
Utils->ReadConfiguration(true);
- InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);
}
// note: the protocol does not allow direct umode +o except
diff --git a/src/modules/m_spanningtree/rehash.cpp b/src/modules/m_spanningtree/rehash.cpp
deleted file mode 100644
index 6707b897a..000000000
--- a/src/modules/m_spanningtree/rehash.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "commands/cmd_whois.h"
-#include "commands/cmd_stats.h"
-#include "socket.h"
-#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-#include "socketengine.h"
-
-#include "m_spanningtree/main.h"
-#include "m_spanningtree/utils.h"
-#include "m_spanningtree/treeserver.h"
-#include "m_spanningtree/link.h"
-#include "m_spanningtree/treesocket.h"
-#include "m_spanningtree/resolvers.h"
-#include "m_spanningtree/handshaketimer.h"
-
-/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
-
-bool TreeSocket::RemoteRehash(const std::string &prefix, std::deque<std::string> &params)
-{
- if (params.size() < 1)
- return false;
-
- std::string servermask = params[0];
-
- if (this->Instance->MatchText(this->Instance->Config->ServerName,servermask))
- {
- this->Instance->SNO->WriteToSnoMask('l',"Remote rehash initiated by \002"+prefix+"\002.");
- this->Instance->RehashServer();
- }
- Utils->DoOneToAllButSender(prefix,"REHASH",params,prefix);
- return true;
-}
-
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index a33e33c88..324203f11 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -312,10 +312,6 @@ class TreeSocket : public BufferedSocket
*/
bool ServicePart(const std::string &prefix, std::deque<std::string> &params);
- /** REHASH
- */
- bool RemoteRehash(const std::string &prefix, std::deque<std::string> &params);
-
/** KILL
*/
bool RemoteKill(const std::string &prefix, std::deque<std::string> &params);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index c99402af0..aa7d2b2af 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -392,10 +392,6 @@ bool TreeSocket::ProcessLine(std::string &line)
{
return this->ForceTopic(prefix,params);
}
- else if (command == "REHASH")
- {
- return this->RemoteRehash(prefix,params);
- }
else if (command == "METADATA")
{
return this->MetaData(prefix,params);