summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-12-01 10:59:06 -0500
committerAdam <Adam@anope.org>2016-12-01 11:01:19 -0500
commitd95bc84eda5c131374b7097f9de7f59418bd9b6a (patch)
tree3433830c1ea4babbf0c80b8bf961ae5c5cb0cc38 /src
parent9a87674a95cf8153e343d89ec1a686fc43781a3c (diff)
Allow encap handlers to recall message processing, make protocol/inspircd do this
Diffstat (limited to 'src')
-rw-r--r--src/process.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/process.cpp b/src/process.cpp
index 356a3b695..0d463b8d1 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -55,25 +55,38 @@ void Anope::Process(const Anope::string &buffer)
return;
}
- static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : "";
-
MessageSource src(source);
EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::Message::OnMessage, src, command, params);
+ ProcessCommand(src, command, params);
+}
+
+void Anope::ProcessCommand(MessageSource &src, const Anope::string &command, const std::vector<Anope::string> &params)
+{
+ static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : "";
+
ServiceReference<IRCDMessage> m(proto_name + "/" + command.lower());
if (!m)
{
- Log(LOG_DEBUG) << "unknown message from server (" << buffer << ")";
+ Anope::string buffer = "[" + src.GetSource() + "] " + command;
+ if (!params.empty())
+ {
+ for (unsigned int i = 0; i < params.size() - 1; ++i)
+ buffer += " " + params[i];
+ buffer += " :" + params[params.size() - 1];
+ }
+
+ Log(LOG_DEBUG) << "unknown command from server (" << buffer << ")";
return;
}
if (m->HasFlag(IRCDMESSAGE_SOFT_LIMIT) ? (params.size() < m->GetParamCount()) : (params.size() != m->GetParamCount()))
Log(LOG_DEBUG) << "invalid parameters for " << command << ": " << params.size() << " != " << m->GetParamCount();
else if (m->HasFlag(IRCDMESSAGE_REQUIRE_USER) && !src.GetUser())
- Log(LOG_DEBUG) << "unexpected non-user source " << source << " for " << command;
- else if (m->HasFlag(IRCDMESSAGE_REQUIRE_SERVER) && !source.empty() && !src.GetServer())
- Log(LOG_DEBUG) << "unexpected non-server source " << source << " for " << command;
+ Log(LOG_DEBUG) << "unexpected non-user source " << src.GetSource() << " for " << command;
+ else if (m->HasFlag(IRCDMESSAGE_REQUIRE_SERVER) && !src.GetServer())
+ Log(LOG_DEBUG) << "unexpected non-server source " << src.GetSource() << " for " << command;
else
m->Run(src, params);
}