1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 #include "treeserver.h"
21 #include "treesocket.h"
24 CommandRSQuit::CommandRSQuit (Module* Creator, SpanningTreeUtilities* Util)
25 : Command(Creator, "RSQUIT", 1), Utils(Util)
28 syntax = "<target-server-mask> [reason]";
31 CmdResult CommandRSQuit::Handle (const std::vector<std::string>& parameters, User *user)
33 TreeServer *server_target; // Server to squit
34 TreeServer *server_linked; // Server target is linked to
36 server_target = Utils->FindServerMask(parameters[0]);
39 user->WriteServ("NOTICE %s :*** RSQUIT: Server \002%s\002 isn't connected to the network!", user->nick.c_str(), parameters[0].c_str());
43 if (server_target == Utils->TreeRoot)
45 NoticeUser(user, "*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! ("+parameters[0]+" matches local server name)");
49 server_linked = server_target->GetParent();
51 if (server_linked == Utils->TreeRoot)
53 // We have been asked to remove server_target.
54 TreeSocket* sock = server_target->GetSocket();
57 const char *reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason";
58 ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0].c_str(), user->nick.c_str(), reason);
59 sock->Squit(server_target, std::string("Server quit by ") + user->GetFullRealHost() + " (" + reason + ")");
67 RouteDescriptor CommandRSQuit::GetRouting(User* user, const std::vector<std::string>& parameters)
69 return ROUTE_UNICAST(parameters[0]);
72 // XXX use protocol interface instead of rolling our own :)
73 void CommandRSQuit::NoticeUser(User* user, const std::string &msg)
77 user->WriteServ("NOTICE %s :%s",user->nick.c_str(),msg.c_str());
82 params.push_back(user->nick);
83 params.push_back("NOTICE "+ConvToStr(user->nick)+" :"+msg);
84 Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", params, user->server);