summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-19 12:11:36 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-19 12:13:18 +0100
commit875aa2d98d1eb25f4932fbd2ac5c2086d16ff6ea (patch)
treef261540785e7b83ddec848ae53a303cf9bfd707b /src/modules
parentc7dc34b6e08e41136594a86e172423f11ba5bfac (diff)
spanningtree: Never send a message to a raw UUID in CmdBuilder.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_spanningtree/commandbuilder.h4
-rw-r--r--src/modules/m_spanningtree/compat.cpp7
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp2
-rw-r--r--src/modules/m_spanningtree/idle.cpp2
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/modules/m_spanningtree/protocolinterface.cpp2
-rw-r--r--src/modules/m_spanningtree/server.cpp2
-rw-r--r--src/modules/m_spanningtree/sinfo.cpp2
-rw-r--r--src/modules/m_spanningtree/uid.cpp2
-rw-r--r--src/modules/m_spanningtree/utils.cpp4
-rw-r--r--src/modules/m_spanningtree/utils.h2
12 files changed, 21 insertions, 16 deletions
diff --git a/src/modules/m_spanningtree/commandbuilder.h b/src/modules/m_spanningtree/commandbuilder.h
index 4bbb60e47..ec9533f2e 100644
--- a/src/modules/m_spanningtree/commandbuilder.h
+++ b/src/modules/m_spanningtree/commandbuilder.h
@@ -36,10 +36,10 @@ class CmdBuilder
push(cmd);
}
- CmdBuilder(const std::string& src, const char* cmd)
+ CmdBuilder(TreeServer* src, const char* cmd)
: content(1, ':')
{
- content.append(src);
+ content.append(src->GetID());
push(cmd);
}
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index fc9700740..0d50b4325 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -286,7 +286,12 @@ void TreeSocket::WriteLine(const std::string& original_line)
// Synthesize a :<newserver> BURST <time> message
spcolon = line.find(" :");
- line = CmdBuilder(line.substr(spcolon-3, 3), "BURST").push_int(ServerInstance->Time()).str();
+
+ TreeServer* const source = Utils->FindServerID(line.substr(spcolon-3, 3));
+ if (!source)
+ return;
+
+ line = CmdBuilder(source, "BURST").push_int(ServerInstance->Time()).str();
}
}
else if (command == "NUM")
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index a6c52e41b..6305e5af8 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -295,7 +295,7 @@ void CommandFJoin::LowerTS(Channel* chan, time_t TS, const std::string& newname)
}
CommandFJoin::Builder::Builder(Channel* chan, TreeServer* source)
- : CmdBuilder(source->GetID(), "FJOIN")
+ : CmdBuilder(source, "FJOIN")
{
push(chan->name).push_int(chan->age).push_raw(" +");
pos = str().size();
diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp
index 11e665531..972707ca2 100644
--- a/src/modules/m_spanningtree/idle.cpp
+++ b/src/modules/m_spanningtree/idle.cpp
@@ -59,7 +59,7 @@ CmdResult CommandIdle::HandleRemote(RemoteUser* issuer, Params& params)
else
idle = ((unsigned int) (ServerInstance->Time() - localtarget->idle_lastmsg));
- CmdBuilder reply(params[0], "IDLE");
+ CmdBuilder reply(target, "IDLE");
reply.push_back(issuer->uuid);
reply.push_back(ConvToStr(target->signon));
reply.push_back(ConvToStr(idle));
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index f8531cb01..2651e1a4a 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -411,7 +411,7 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ
}
case MessageTarget::TYPE_CHANNEL:
{
- Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
+ Utils->SendChannelMessage(user, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
break;
}
case MessageTarget::TYPE_SERVER:
@@ -448,7 +448,7 @@ void ModuleSpanningTree::OnUserPostTagMessage(User* user, const MessageTarget& t
}
case MessageTarget::TYPE_CHANNEL:
{
- Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), "", target.status, details.tags_out, details.exemptions, "TAGMSG");
+ Utils->SendChannelMessage(user, target.Get<Channel>(), "", target.status, details.tags_out, details.exemptions, "TAGMSG");
break;
}
case MessageTarget::TYPE_SERVER:
@@ -625,7 +625,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string &parameter)
// Send out to other servers
if (!parameter.empty() && parameter[0] != '-')
{
- CmdBuilder params((user ? user->uuid : ServerInstance->Config->GetSID()), "REHASH");
+ CmdBuilder params(user ? user : ServerInstance->FakeClient, "REHASH");
params.push_back(parameter);
params.Forward(user ? TreeServer::Get(user)->GetRoute() : NULL);
}
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index d3eab825f..fe54abde2 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -104,7 +104,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
std::string message;
if (parameters.size() >= 2)
message.assign(parameters[1]);
- SendChannelMessage(user->uuid, c, message, pfx, parameters.GetTags(), exempts, command.c_str(), origin ? origin->GetSocket() : NULL);
+ SendChannelMessage(user, c, message, pfx, parameters.GetTags(), exempts, command.c_str(), origin ? origin->GetSocket() : NULL);
}
else if (dest[0] == '$')
{
diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp
index 56b9370ad..2af122010 100644
--- a/src/modules/m_spanningtree/protocolinterface.cpp
+++ b/src/modules/m_spanningtree/protocolinterface.cpp
@@ -112,7 +112,7 @@ void SpanningTreeProtocolInterface::SendMessage(Channel* target, char status, co
const char* cmd = (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
CUList exempt_list;
ClientProtocol::TagMap tags;
- Utils->SendChannelMessage(ServerInstance->Config->GetSID(), target, text, status, tags, exempt_list, cmd);
+ Utils->SendChannelMessage(ServerInstance->FakeClient, target, text, status, tags, exempt_list, cmd);
}
void SpanningTreeProtocolInterface::SendMessage(User* target, const std::string& text, MessageType msgtype)
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 13fd0b466..92ba69eda 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -225,7 +225,7 @@ bool TreeSocket::Inbound_Server(CommandBase::Params& params)
}
CommandServer::Builder::Builder(TreeServer* server)
- : CmdBuilder(server->GetParent()->GetID(), "SERVER")
+ : CmdBuilder(server->GetParent(), "SERVER")
{
push(server->GetName());
push(server->GetID());
diff --git a/src/modules/m_spanningtree/sinfo.cpp b/src/modules/m_spanningtree/sinfo.cpp
index a5dae783c..825429f2f 100644
--- a/src/modules/m_spanningtree/sinfo.cpp
+++ b/src/modules/m_spanningtree/sinfo.cpp
@@ -49,7 +49,7 @@ CmdResult CommandSInfo::HandleServer(TreeServer* server, CommandBase::Params& pa
}
CommandSInfo::Builder::Builder(TreeServer* server, const char* key, const std::string& val)
- : CmdBuilder(server->GetID(), "SINFO")
+ : CmdBuilder(server, "SINFO")
{
push(key).push_last(val);
}
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 0729065fc..bf99fb445 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -152,7 +152,7 @@ CmdResult CommandFName::HandleRemote(RemoteUser* src, Params& params)
}
CommandUID::Builder::Builder(User* user)
- : CmdBuilder(TreeServer::Get(user)->GetID(), "UID")
+ : CmdBuilder(TreeServer::Get(user), "UID")
{
push(user->uuid);
push_int(user->age);
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 5fbd16da0..2957b8c14 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -351,9 +351,9 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name)
return NULL;
}
-void SpanningTreeUtilities::SendChannelMessage(const std::string& prefix, Channel* target, const std::string& text, char status, const ClientProtocol::TagMap& tags, const CUList& exempt_list, const char* message_type, TreeSocket* omit)
+void SpanningTreeUtilities::SendChannelMessage(User* source, Channel* target, const std::string& text, char status, const ClientProtocol::TagMap& tags, const CUList& exempt_list, const char* message_type, TreeSocket* omit)
{
- CmdBuilder msg(prefix, message_type);
+ CmdBuilder msg(source, message_type);
msg.push_tags(tags);
msg.push_raw(' ');
if (status != 0)
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index c6f5822fe..bb189cb5e 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -172,7 +172,7 @@ class SpanningTreeUtilities : public classbase
/** Sends a PRIVMSG or a NOTICE to a channel obeying an exempt list and an optional prefix
*/
- void SendChannelMessage(const std::string& prefix, Channel* target, const std::string& text, char status, const ClientProtocol::TagMap& tags, const CUList& exempt_list, const char* message_type, TreeSocket* omit = NULL);
+ void SendChannelMessage(User* source, Channel* target, const std::string& text, char status, const ClientProtocol::TagMap& tags, const CUList& exempt_list, const char* message_type, TreeSocket* omit = NULL);
};
inline void SpanningTreeUtilities::DoOneToMany(const CmdBuilder& params)