summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-19 04:43:19 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-19 04:43:19 +0000
commitaeded4708c515bcc255b2947e67f076855fead14 (patch)
tree50726e059684c1af4325d777b4eccd86c319fa39
parent0429d86a7afa7d5c1e27e48f27db0687d2688d87 (diff)
Fix MOTD and RULES to work remotely (remove the old hacks for MOTD)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12301 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/users.h8
-rw-r--r--src/commands/cmd_motd.cpp39
-rw-r--r--src/commands/cmd_rules.cpp38
-rw-r--r--src/modules/m_spanningtree/main.h4
-rw-r--r--src/modules/m_spanningtree/motd.cpp72
-rw-r--r--src/modules/m_spanningtree/override_motd.cpp50
-rw-r--r--src/modules/m_spanningtree/precommand.cpp4
-rw-r--r--src/modules/m_spanningtree/treesocket.h3
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
-rw-r--r--src/users.cpp46
10 files changed, 55 insertions, 213 deletions
diff --git a/include/users.h b/include/users.h
index 104b8f843..51230431a 100644
--- a/include/users.h
+++ b/include/users.h
@@ -704,14 +704,6 @@ class CoreExport User : public Extensible
*/
virtual ConnectClass* GetClass();
- /** Show the message of the day to this user
- */
- void ShowMOTD();
-
- /** Show the server RULES file to this user
- */
- void ShowRULES();
-
/** Default destructor
*/
virtual ~User();
diff --git a/src/commands/cmd_motd.cpp b/src/commands/cmd_motd.cpp
index 0e1792320..9468eb2f3 100644
--- a/src/commands/cmd_motd.cpp
+++ b/src/commands/cmd_motd.cpp
@@ -13,17 +13,6 @@
#include "inspircd.h"
-#ifndef __CMD_MOTD_H__
-#define __CMD_MOTD_H__
-
-// include the common header files
-
-#include <string>
-#include <vector>
-#include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-
/** Handle /MOTD. These command handlers can be reloaded by the core,
* and handle basic RFC1459 commands. Commands within modules work
* the same way, however, they can be fully unloaded, where these
@@ -42,16 +31,34 @@ class CommandMotd : public Command
* @return A value from CmdResult to indicate command success or failure.
*/
CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+ {
+ if (parameters.size() > 0)
+ return ROUTE_UNICAST(parameters[0]);
+ return ROUTE_LOCALONLY;
+ }
};
-#endif
-
-
/** Handle /MOTD
*/
-CmdResult CommandMotd::Handle (const std::vector<std::string>&, User *user)
+CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User *user)
{
- user->ShowMOTD();
+ if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
+ return CMD_SUCCESS;
+ if (!ServerInstance->Config->MOTD.size())
+ {
+ user->SendText(":%s %03d %s :Message of the day file is missing.",
+ ServerInstance->Config->ServerName.c_str(), ERR_NOMOTD, user->nick.c_str());
+ return CMD_SUCCESS;
+ }
+ user->SendText(":%s %03d %s :%s message of the day", ServerInstance->Config->ServerName.c_str(),
+ RPL_MOTDSTART, user->nick.c_str(), ServerInstance->Config->ServerName.c_str());
+
+ for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
+ user->SendText(":%s %03d %s :- %s", ServerInstance->Config->ServerName.c_str(), RPL_MOTD, user->nick.c_str(),i->c_str());
+
+ user->SendText(":%s %03d %s :End of message of the day.", ServerInstance->Config->ServerName.c_str(), RPL_ENDOFMOTD, user->nick.c_str());
+
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_rules.cpp b/src/commands/cmd_rules.cpp
index e01ca2a3e..78b3235fb 100644
--- a/src/commands/cmd_rules.cpp
+++ b/src/commands/cmd_rules.cpp
@@ -13,17 +13,6 @@
#include "inspircd.h"
-#ifndef __CMD_RULES_H__
-#define __CMD_RULES_H__
-
-// include the common header files
-
-#include <string>
-#include <vector>
-#include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-
/** Handle /RULES. These command handlers can be reloaded by the core,
* and handle basic RFC1459 commands. Commands within modules work
* the same way, however, they can be fully unloaded, where these
@@ -42,14 +31,33 @@ class CommandRules : public Command
* @return A value from CmdResult to indicate command success or failure.
*/
CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+ {
+ if (parameters.size() > 0)
+ return ROUTE_UNICAST(parameters[0]);
+ return ROUTE_LOCALONLY;
+ }
};
-#endif
-
-
CmdResult CommandRules::Handle (const std::vector<std::string>& parameters, User *user)
{
- user->ShowRULES();
+ if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
+ return CMD_SUCCESS;
+
+ if (!ServerInstance->Config->RULES.size())
+ {
+ user->SendText(":%s %03d %s :RULES file is missing.",
+ ServerInstance->Config->ServerName.c_str(), ERR_NORULES, user->nick.c_str());
+ return CMD_SUCCESS;
+ }
+ user->SendText(":%s %03d %s :%s server rules:", ServerInstance->Config->ServerName.c_str(),
+ RPL_RULESTART, user->nick.c_str(), ServerInstance->Config->ServerName.c_str());
+
+ for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
+ user->SendText(":%s %03d %s :- %s", ServerInstance->Config->ServerName.c_str(), RPL_RULES, user->nick.c_str(),i->c_str());
+
+ user->SendText(":%s %03d %s :End of RULES command.", ServerInstance->Config->ServerName.c_str(), RPL_RULESEND, user->nick.c_str());
+
return CMD_SUCCESS;
}
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index b2bff960a..4467b243f 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -75,10 +75,6 @@ class ModuleSpanningTree : public Module
*/
void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
- /** Handle remote MOTD
- */
- ModResult HandleMotd(const std::vector<std::string>& parameters, User* user);
-
/** Handle remote ADMIN
*/
ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user);
diff --git a/src/modules/m_spanningtree/motd.cpp b/src/modules/m_spanningtree/motd.cpp
deleted file mode 100644
index 03d40a812..000000000
--- a/src/modules/m_spanningtree/motd.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#include "inspircd.h"
-#include "xline.h"
-
-#include "treesocket.h"
-#include "treeserver.h"
-#include "utils.h"
-
-/* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
-
-
-
-/** remote MOTD. leet, huh? */
-bool TreeSocket::Motd(const std::string &prefix, parameterlist &params)
-{
- if (params.size() > 0)
- {
- if (InspIRCd::Match(ServerInstance->Config->ServerName, params[0]))
- {
- /* It's for our server */
- string_list results;
- User* source = ServerInstance->FindNick(prefix);
-
- if (source)
- {
- parameterlist par;
- par.push_back(prefix);
- par.push_back("");
-
- if (!ServerInstance->Config->MOTD.size())
- {
- par[1] = std::string("::")+ServerInstance->Config->ServerName+" 422 "+source->nick+" :Message of the day file is missing.";
- Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
- return true;
- }
-
- par[1] = std::string("::")+ServerInstance->Config->ServerName+" 375 "+source->nick+" :"+ServerInstance->Config->ServerName+" message of the day";
- Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
-
- for (unsigned int i = 0; i < ServerInstance->Config->MOTD.size(); i++)
- {
- par[1] = std::string("::")+ServerInstance->Config->ServerName+" 372 "+source->nick+" :- "+ServerInstance->Config->MOTD[i];
- Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
- }
-
- par[1] = std::string("::")+ServerInstance->Config->ServerName+" 376 "+source->nick+" :End of message of the day.";
- Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
- }
- }
- else
- {
- /* Pass it on */
- User* source = ServerInstance->FindNick(prefix);
- if (source)
- Utils->DoOneToOne(prefix, "MOTD", params, params[0]);
- }
- }
- return true;
-}
-
diff --git a/src/modules/m_spanningtree/override_motd.cpp b/src/modules/m_spanningtree/override_motd.cpp
deleted file mode 100644
index 24a9b0a72..000000000
--- a/src/modules/m_spanningtree/override_motd.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-/* $ModDesc: Provides a spanning tree server link protocol */
-
-#include "inspircd.h"
-#include "socket.h"
-#include "xline.h"
-
-#include "main.h"
-#include "utils.h"
-#include "treeserver.h"
-#include "treesocket.h"
-
-/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
-
-ModResult ModuleSpanningTree::HandleMotd(const std::vector<std::string>& parameters, User* user)
-{
- if (parameters.size() > 0)
- {
- if (InspIRCd::Match(ServerInstance->Config->ServerName, parameters[0]))
- return MOD_RES_PASSTHRU;
-
- /* Remote MOTD, the server is within the 1st parameter */
- parameterlist params;
- params.push_back(parameters[0]);
- /* Send it out remotely, generate no reply yet */
- TreeServer* s = Utils->FindServerMask(parameters[0]);
- if (s)
- {
- params[0] = s->GetName();
- Utils->DoOneToOne(user->uuid, "MOTD", params, s->GetName());
- }
- else
- user->WriteNumeric(ERR_NOSUCHSERVER, "%s %s :No such server", user->nick.c_str(), parameters[0].c_str());
- return MOD_RES_DENY;
- }
- return MOD_RES_PASSTHRU;
-}
-
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index dbef35cb7..15456f276 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -38,10 +38,6 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std
{
return this->HandleStats(parameters,user);
}
- else if (command == "MOTD")
- {
- return this->HandleMotd(parameters,user);
- }
else if (command == "ADMIN")
{
return this->HandleAdmin(parameters,user);
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index c1678ea5e..a329f0ec0 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -251,9 +251,6 @@ class TreeSocket : public BufferedSocket
/** Handle ERROR command */
void Error(parameterlist &params);
- /** remote MOTD. */
- bool Motd(const std::string &prefix, parameterlist &params);
-
/** remote ADMIN. */
bool Admin(const std::string &prefix, parameterlist &params);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index fc58862d7..d10ec612c 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -294,10 +294,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
{
this->Stats(prefix, params);
}
- else if (command == "MOTD")
- {
- this->Motd(prefix, params);
- }
else if (command == "ADMIN")
{
this->Admin(prefix, params);
diff --git a/src/users.cpp b/src/users.cpp
index c2890f9f7..b9d454c8b 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -829,18 +829,21 @@ void LocalUser::FullConnect()
ServerInstance->Config->Send005(this);
this->WriteNumeric(RPL_YOURUUID, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str());
-
- this->ShowMOTD();
-
/* Now registered */
if (ServerInstance->Users->unregistered_count)
ServerInstance->Users->unregistered_count--;
- /* Trigger LUSERS output, give modules a chance too */
+ /* Trigger MOTD and LUSERS output, give modules a chance too */
ModResult MOD_RESULT;
- std::string command("LUSERS");
+ std::string command("MOTD");
std::vector<std::string> parameters;
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, "LUSERS"));
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
+ if (!MOD_RESULT)
+ ServerInstance->CallCommandHandler(command, parameters, this);
+
+ MOD_RESULT = MOD_RES_PASSTHRU;
+ command = "LUSERS";
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
if (!MOD_RESULT)
ServerInstance->CallCommandHandler(command, parameters, this);
@@ -1626,37 +1629,6 @@ void User::PurgeEmptyChannels()
this->UnOper();
}
-void User::ShowMOTD()
-{
- if (!ServerInstance->Config->MOTD.size())
- {
- this->WriteNumeric(ERR_NOMOTD, "%s :Message of the day file is missing.",this->nick.c_str());
- return;
- }
- this->WriteNumeric(RPL_MOTDSTART, "%s :%s message of the day", this->nick.c_str(), ServerInstance->Config->ServerName.c_str());
-
- for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++)
- this->WriteNumeric(RPL_MOTD, "%s :- %s",this->nick.c_str(),i->c_str());
-
- this->WriteNumeric(RPL_ENDOFMOTD, "%s :End of message of the day.", this->nick.c_str());
-}
-
-void User::ShowRULES()
-{
- if (!ServerInstance->Config->RULES.size())
- {
- this->WriteNumeric(ERR_NORULES, "%s :RULES File is missing",this->nick.c_str());
- return;
- }
-
- this->WriteNumeric(RPL_RULESTART, "%s :- %s Server Rules -",this->nick.c_str(),ServerInstance->Config->ServerName.c_str());
-
- for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++)
- this->WriteNumeric(RPL_RULES, "%s :- %s",this->nick.c_str(),i->c_str());
-
- this->WriteNumeric(RPL_RULESEND, "%s :End of RULES command.",this->nick.c_str());
-}
-
const std::string& FakeUser::GetFullHost()
{
if (!ServerInstance->Config->HideWhoisServer.empty())