summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-04-14 17:01:11 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-04-14 17:01:11 +0200
commitee4262d276606649489db02007c7a34e8ac75bc4 (patch)
treeab2fbd0281a4f2b07d521374fb116a769975be00
parentc511bb56f5ceff1e395d82c4bfd78e5c23aabab6 (diff)
m_spanningtree Fix routing of unicast messages
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp26
-rw-r--r--src/modules/m_spanningtree/utils.cpp4
2 files changed, 19 insertions, 11 deletions
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 9f90f3458..0695ce632 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -39,23 +39,31 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
const bool encap = ((routing.type == ROUTE_TYPE_OPT_BCAST) || (routing.type == ROUTE_TYPE_OPT_UCAST));
CmdBuilder params(user, encap ? "ENCAP" : command.c_str());
+ TreeServer* sdest = NULL;
if (routing.type == ROUTE_TYPE_OPT_BCAST)
{
params.push('*');
params.push_back(command);
}
- else if (routing.type == ROUTE_TYPE_OPT_UCAST)
+ else if (routing.type == ROUTE_TYPE_UNICAST || routing.type == ROUTE_TYPE_OPT_UCAST)
{
- TreeServer* sdest = FindServer(routing.serverdest);
+ sdest = static_cast<TreeServer*>(routing.server);
if (!sdest)
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route ENCAP to nonexistant server %s",
- routing.serverdest.c_str());
- return;
+ sdest = FindServer(routing.serverdest);
+ if (!sdest)
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route %s%s to nonexistant server %s", (encap ? "ENCAP " : ""), command.c_str(), routing.serverdest.c_str());
+ return;
+ }
+ }
+
+ if (encap)
+ {
+ params.push_back(sdest->GetID());
+ params.push_back(command);
}
- params.push_back(sdest->GetID());
- params.push_back(command);
}
else
{
@@ -115,8 +123,6 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
}
else if (routing.type == ROUTE_TYPE_UNICAST || routing.type == ROUTE_TYPE_OPT_UCAST)
{
- if (origin && routing.serverdest == origin->GetName())
- return;
- params.Unicast(routing.serverdest);
+ params.Unicast(sdest->ServerUser);
}
}
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index eb1067ce0..d6dccba14 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -214,7 +214,9 @@ bool SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, const std::stri
void SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, Server* server)
{
TreeServer* ts = static_cast<TreeServer*>(server);
- ts->GetSocket()->WriteLine(params);
+ TreeSocket* sock = ts->GetSocket();
+ if (sock)
+ sock->WriteLine(params);
}
void SpanningTreeUtilities::RefreshIPCache()