summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/rsquit.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-07-19 13:10:18 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-22 13:42:20 +0200
commit5cc9614e73a783dec7a8e0887a0435cf577eaad4 (patch)
tree843e4ee2cf81f1ba818368512ca889281d128459 /src/modules/m_spanningtree/rsquit.cpp
parent39d34b604259b17e2517fcddb5ee15198d7cb412 (diff)
m_spanningtree Change TreeServer::GetSocket() to always return the socket that can be used to talk to the server
The only exception is the tree root (us) which has no associated socket (NULL) Add TreeServer::IsRoot() and IsLocal() helpers
Diffstat (limited to 'src/modules/m_spanningtree/rsquit.cpp')
-rw-r--r--src/modules/m_spanningtree/rsquit.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp
index 9437c174a..3b7468491 100644
--- a/src/modules/m_spanningtree/rsquit.cpp
+++ b/src/modules/m_spanningtree/rsquit.cpp
@@ -34,7 +34,6 @@ CommandRSQuit::CommandRSQuit(Module* Creator)
CmdResult CommandRSQuit::Handle (const std::vector<std::string>& parameters, User *user)
{
TreeServer *server_target; // Server to squit
- TreeServer *server_linked; // Server target is linked to
server_target = Utils->FindServerMask(parameters[0]);
if (!server_target)
@@ -43,25 +42,20 @@ CmdResult CommandRSQuit::Handle (const std::vector<std::string>& parameters, Use
return CMD_FAILURE;
}
- if (server_target == Utils->TreeRoot)
+ if (server_target->IsRoot())
{
((ModuleSpanningTree*)(Module*)creator)->RemoteMessage(user, "*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)", parameters[0].c_str());
return CMD_FAILURE;
}
- server_linked = server_target->GetParent();
-
- if (server_linked == Utils->TreeRoot)
+ if (server_target->IsLocal())
{
// We have been asked to remove server_target.
TreeSocket* sock = server_target->GetSocket();
- if (sock)
- {
- const char *reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason";
- ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0].c_str(), user->nick.c_str(), reason);
- sock->Squit(server_target, "Server quit by " + user->GetFullRealHost() + " (" + reason + ")");
- sock->Close();
- }
+ const char* reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason";
+ ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0].c_str(), user->nick.c_str(), reason);
+ sock->Squit(server_target, "Server quit by " + user->GetFullRealHost() + " (" + reason + ")");
+ sock->Close();
}
return CMD_SUCCESS;