]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/rconnect.cpp
460f8567420c815ad9d19dfc8beba431c57b5f3d
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / rconnect.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "socket.h"
16 #include "xline.h"
17
18 #include "resolvers.h"
19 #include "main.h"
20 #include "utils.h"
21 #include "treeserver.h"
22 #include "link.h"
23 #include "treesocket.h"
24 #include "commands.h"
25
26 CommandRConnect::CommandRConnect (Module* Creator, SpanningTreeUtilities* Util)
27         : Command(Creator, "RCONNECT", 2), Utils(Util)
28 {
29         flags_needed = 'o';
30         syntax = "<remote-server-mask> <target-server-mask>";
31 }
32
33 CmdResult CommandRConnect::Handle (const std::vector<std::string>& parameters, User *user)
34 {
35         if (IS_LOCAL(user))
36         {
37                 if (!Utils->FindServerMask(parameters[0]))
38                 {
39                         user->WriteServ("NOTICE %s :*** RCONNECT: Server \002%s\002 isn't connected to the network!", user->nick.c_str(), parameters[0].c_str());
40                         return CMD_FAILURE;
41                 }
42                 user->WriteServ("NOTICE %s :*** RCONNECT: Sending remote connect to \002%s\002 to connect server \002%s\002.",user->nick.c_str(),parameters[0].c_str(),parameters[1].c_str());
43         }
44
45         /* Is this aimed at our server? */
46         if (InspIRCd::Match(ServerInstance->Config->ServerName,parameters[0]))
47         {
48                 /* Yes, initiate the given connect */
49                 ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick.c_str(),parameters[0].c_str(),parameters[1].c_str());
50                 std::vector<std::string> para;
51                 para.push_back(parameters[1]);
52                 std::string cmd("CONNECT");
53                 std::string original_command = cmd + " " + parameters[1];
54                 creator->OnPreCommand(cmd, para, user, true, original_command);
55         }
56         return CMD_SUCCESS;
57 }
58
59 RouteDescriptor CommandRConnect::GetRouting(User* user, const std::vector<std::string>& parameters)
60 {
61         return ROUTE_UNICAST(parameters[0]);
62 }