]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/rconnect.cpp
Strip SUPPORT_IP6LINKS #define
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / rconnect.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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 "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "xline.h"
19 #include "../transport.h"
20
21 #include "resolvers.h"
22 #include "main.h"
23 #include "utils.h"
24 #include "treeserver.h"
25 #include "link.h"
26 #include "treesocket.h"
27 #include "rconnect.h"
28
29 /* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h */
30
31 CommandRConnect::CommandRConnect (InspIRCd* Instance, Module* Callback, SpanningTreeUtilities* Util) : Command(Instance, "RCONNECT", "o", 2), Creator(Callback), Utils(Util)
32 {
33         this->source = "m_spanningtree.so";
34         syntax = "<remote-server-mask> <target-server-mask>";
35 }
36
37 CmdResult CommandRConnect::Handle (const std::vector<std::string>& parameters, User *user)
38 {
39         if (IS_LOCAL(user))
40         {
41                 if (!Utils->FindServerMask(parameters[0]))
42                 {
43                         user->WriteServ("NOTICE %s :*** RCONNECT: Server \002%s\002 isn't connected to the network!", user->nick.c_str(), parameters[0].c_str());
44                         return CMD_FAILURE;
45                 }
46                 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());
47         }
48
49         /* Is this aimed at our server? */
50         if (InspIRCd::Match(ServerInstance->Config->ServerName,parameters[0]))
51         {
52                 /* Yes, initiate the given connect */
53                 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());
54                 std::vector<std::string> para;
55                 para.push_back(parameters[1]);
56                 std::string cmd("CONNECT");
57                 std::string original_command = cmd + " " + parameters[1];
58                 Creator->OnPreCommand(cmd, para, user, true, original_command);
59         }
60         return CMD_SUCCESS;
61 }
62