]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_stub.cpp
Fix a bunch of weird indentation and spacing issues.
[user/henk/code/inspircd.git] / src / coremods / core_stub.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2019 Robby <robby@chatbelgie.be>
5  *   Copyright (C) 2017-2020 Sadie Powell <sadie@witchery.services>
6  *   Copyright (C) 2014-2016 Attila Molnar <attilamolnar@hush.com>
7  *
8  * This file is part of InspIRCd.  InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21
22 #include "inspircd.h"
23
24 enum
25 {
26         // From RFC 1459.
27         ERR_SUMMONDISABLED = 445,
28         ERR_USERSDISABLED = 446
29 };
30
31 class CommandCapab : public Command
32 {
33  public:
34         CommandCapab(Module* parent)
35                 : Command(parent, "CAPAB")
36         {
37                 works_before_reg = true;
38         }
39
40         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
41         {
42                 if (user->registered == REG_NONE)
43                 {
44                         // The CAPAB command is used in the server protocol for negotiating
45                         // the protocol version when initiating a server connection. There
46                         // is no legitimate reason for a user to send this so we disconnect
47                         // users who sent it in order to help out server admins who have
48                         // misconfigured their server.
49                         ServerInstance->Users->QuitUser(user, "You can not connect a server to a client port. Read " INSPIRCD_DOCS "modules/spanningtree for docs on how to link a server.");
50                 }
51                 return CMD_FAILURE;
52         }
53 };
54
55 /** Handle /CONNECT.
56  */
57 class CommandConnect : public Command
58 {
59  public:
60         /** Constructor for connect.
61          */
62         CommandConnect(Module* parent)
63                 : Command(parent, "CONNECT", 1)
64         {
65                 flags_needed = 'o';
66                 syntax = "<servermask>";
67         }
68
69         /** Handle command.
70          * @param parameters The parameters to the command
71          * @param user The user issuing the command
72          * @return A value from CmdResult to indicate command success or failure.
73          */
74         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
75         {
76                 /*
77                  * This is handled by the server linking module, if necessary. Do not remove this stub.
78                  */
79                 user->WriteNotice("Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.");
80                 return CMD_SUCCESS;
81         }
82 };
83
84 /** Handle /LINKS.
85  */
86 class CommandLinks : public Command
87 {
88  public:
89         /** Constructor for links.
90          */
91         CommandLinks(Module* parent)
92                 : Command(parent, "LINKS", 0, 0)
93         {
94         }
95
96         /** Handle command.
97          * @param parameters The parameters to the command
98          * @param user The user issuing the command
99          * @return A value from CmdResult to indicate command success or failure.
100          */
101         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
102         {
103                 user->WriteNumeric(RPL_LINKS, ServerInstance->Config->GetServerName(), ServerInstance->Config->GetServerName(), InspIRCd::Format("0 %s", ServerInstance->Config->GetServerDesc().c_str()));
104                 user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
105                 return CMD_SUCCESS;
106         }
107 };
108
109 /** Handle /SQUIT.
110  */
111 class CommandSquit : public Command
112 {
113  public:
114         /** Constructor for squit.
115          */
116         CommandSquit(Module* parent)
117                 : Command(parent, "SQUIT", 1, 2)
118         {
119                 flags_needed = 'o';
120                 syntax = "<servermask>";
121         }
122
123         /** Handle command.
124          * @param parameters The parameters to the command
125          * @param user The user issuing the command
126          * @return A value from CmdResult to indicate command success or failure.
127          */
128         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
129         {
130                 user->WriteNotice("Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.");
131                 return CMD_FAILURE;
132         }
133 };
134
135 class CommandSummon
136         : public SplitCommand
137 {
138  public:
139         CommandSummon(Module* Creator)
140                 : SplitCommand(Creator, "SUMMON", 1)
141         {
142         }
143
144         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
145         {
146                 user->WriteNumeric(ERR_SUMMONDISABLED, "SUMMON has been disabled");
147                 return CMD_SUCCESS;
148         }
149 };
150
151 class CommandUsers
152         : public SplitCommand
153 {
154  public:
155         CommandUsers(Module* Creator)
156                 : SplitCommand(Creator, "USERS")
157         {
158         }
159
160         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
161         {
162                 user->WriteNumeric(ERR_USERSDISABLED, "USERS has been disabled");
163                 return CMD_SUCCESS;
164         }
165 };
166
167 class CoreModStub : public Module
168 {
169  private:
170         CommandCapab cmdcapab;
171         CommandConnect cmdconnect;
172         CommandLinks cmdlinks;
173         CommandSquit cmdsquit;
174         CommandSummon cmdsummon;
175         CommandUsers cmdusers;
176
177  public:
178         CoreModStub()
179                 : cmdcapab(this)
180                 , cmdconnect(this)
181                 , cmdlinks(this)
182                 , cmdsquit(this)
183                 , cmdsummon(this)
184                 , cmdusers(this)
185         {
186         }
187
188         Version GetVersion() CXX11_OVERRIDE
189         {
190                 return Version("Provides stubs for unimplemented commands", VF_VENDOR|VF_CORE);
191         }
192 };
193
194 MODULE_INIT(CoreModStub)