From a7dedb347b7dcd26ce93d4af81e77cfa3cf82d0f Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 29 Mar 2016 16:28:01 +0200 Subject: m_spanningtree Add NUM command handler --- src/modules/m_spanningtree/num.cpp | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/modules/m_spanningtree/num.cpp (limited to 'src/modules/m_spanningtree/num.cpp') diff --git a/src/modules/m_spanningtree/num.cpp b/src/modules/m_spanningtree/num.cpp new file mode 100644 index 000000000..047dba432 --- /dev/null +++ b/src/modules/m_spanningtree/num.cpp @@ -0,0 +1,47 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2016 Attila Molnar + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include "inspircd.h" + +#include "utils.h" +#include "commands.h" + +CmdResult CommandNum::HandleServer(TreeServer* server, std::vector& params) +{ + User* const target = ServerInstance->FindUUID(params[1]); + if (!target) + return CMD_FAILURE; + + LocalUser* const localtarget = IS_LOCAL(target); + if (!localtarget) + return CMD_SUCCESS; + + Numeric::Numeric numeric(ConvToInt(params[2])); + // Passing NULL is ok, in that case the numeric source becomes this server + numeric.SetServer(Utils->FindServerID(params[0])); + numeric.GetParams().insert(numeric.GetParams().end(), params.begin()+3, params.end()); + + localtarget->WriteNumeric(numeric); + return CMD_SUCCESS; +} + +RouteDescriptor CommandNum::GetRouting(User* user, const std::vector& params) +{ + return ROUTE_UNICAST(params[1]); +} -- cgit v1.3.1-10-gc9f91 From 484b30f67b1479de72ff99532b7b91e775686e97 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 29 Mar 2016 16:39:06 +0200 Subject: m_spanningtree Add CommandNum::Builder --- src/modules/m_spanningtree/commands.h | 7 +++++++ src/modules/m_spanningtree/num.cpp | 15 +++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src/modules/m_spanningtree/num.cpp') diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index a65639434..4810e9d4b 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -21,6 +21,7 @@ #include "servercommand.h" #include "commandbuilder.h" +#include "remoteuser.h" /** Handle /RCONNECT */ @@ -375,6 +376,12 @@ class CommandNum : public ServerOnlyServerCommand CommandNum(Module* Creator) : ServerOnlyServerCommand(Creator, "NUM", 3) { } CmdResult HandleServer(TreeServer* server, std::vector& parameters); RouteDescriptor GetRouting(User* user, const std::vector& parameters); + + class Builder : public CmdBuilder + { + public: + Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric); + }; }; class SpanningTreeCommands diff --git a/src/modules/m_spanningtree/num.cpp b/src/modules/m_spanningtree/num.cpp index 047dba432..2c8697c9a 100644 --- a/src/modules/m_spanningtree/num.cpp +++ b/src/modules/m_spanningtree/num.cpp @@ -21,6 +21,7 @@ #include "utils.h" #include "commands.h" +#include "remoteuser.h" CmdResult CommandNum::HandleServer(TreeServer* server, std::vector& params) { @@ -45,3 +46,17 @@ RouteDescriptor CommandNum::GetRouting(User* user, const std::vector(numeric.GetServer())) : Utils->TreeRoot); + push(server->GetID()).push(target->uuid).push(InspIRCd::Format("%03u", numeric.GetNumeric())); + const std::vector& params = numeric.GetParams(); + if (!params.empty()) + { + for (std::vector::const_iterator i = params.begin(); i != params.end()-1; ++i) + push(*i); + push_last(params.back()); + } +} -- cgit v1.3.1-10-gc9f91