]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_stub.cpp
0b7cfaa322a5ef014c43799765a5dfec98db9b89
[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-2019 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
32 /** Handle /CONNECT.
33  */
34 class CommandConnect : public Command
35 {
36  public:
37         /** Constructor for connect.
38          */
39         CommandConnect(Module* parent)
40                 : Command(parent, "CONNECT", 1)
41         {
42                 flags_needed = 'o';
43                 syntax = "<servermask>";
44         }
45
46         /** Handle command.
47          * @param parameters The parameters to the command
48          * @param user The user issuing the command
49          * @return A value from CmdResult to indicate command success or failure.
50          */
51         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
52         {
53                 /*
54                  * This is handled by the server linking module, if necessary. Do not remove this stub.
55                  */
56                 user->WriteNotice("Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.");
57                 return CMD_SUCCESS;
58         }
59 };
60
61 /** Handle /LINKS.
62  */
63 class CommandLinks : public Command
64 {
65  public:
66         /** Constructor for links.
67          */
68         CommandLinks(Module* parent)
69                 : Command(parent, "LINKS", 0, 0)
70         {
71         }
72
73         /** Handle command.
74          * @param parameters The parameters to the command
75          * @param user The user issuing the command
76          * @return A value from CmdResult to indicate command success or failure.
77          */
78         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
79         {
80                 user->WriteNumeric(RPL_LINKS, ServerInstance->Config->GetServerName(), ServerInstance->Config->GetServerName(), InspIRCd::Format("0 %s", ServerInstance->Config->GetServerDesc().c_str()));
81                 user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
82                 return CMD_SUCCESS;
83         }
84 };
85
86 /** Handle /SERVER.
87  */
88 class CommandServer : public Command
89 {
90  public:
91         /** Constructor for server.
92          */
93         CommandServer(Module* parent)
94                 : Command(parent, "SERVER")
95         {
96                 works_before_reg = true;
97         }
98
99         /** Handle command.
100          * @param parameters The parameters to the command
101          * @param user The user issuing the command
102          * @return A value from CmdResult to indicate command success or failure.
103          */
104         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
105         {
106                 if (user->registered == REG_ALL)
107                 {
108                         user->WriteNumeric(ERR_ALREADYREGISTERED, "You are already registered. (Perhaps your IRC client does not have a /SERVER command).");
109                 }
110                 else
111                 {
112                         user->WriteNumeric(ERR_NOTREGISTERED, "SERVER", "You may not register as a server (servers have separate ports from clients, change your config)");
113                 }
114                 return CMD_FAILURE;
115         }
116 };
117
118 /** Handle /SQUIT.
119  */
120 class CommandSquit : public Command
121 {
122  public:
123         /** Constructor for squit.
124          */
125         CommandSquit(Module* parent)
126                 : Command(parent, "SQUIT", 1, 2)
127         {
128                 flags_needed = 'o';
129                 syntax = "<servermask>";
130         }
131
132         /** Handle command.
133          * @param parameters The parameters to the command
134          * @param user The user issuing the command
135          * @return A value from CmdResult to indicate command success or failure.
136          */
137         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
138         {
139                 user->WriteNotice("Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.");
140                 return CMD_FAILURE;
141         }
142 };
143
144 class CommandSummon
145         : public SplitCommand
146 {
147  public:
148         CommandSummon(Module* Creator)
149                 : SplitCommand(Creator, "SUMMON", 1)
150         {
151         }
152
153         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
154         {
155                 user->WriteNumeric(ERR_SUMMONDISABLED, "SUMMON has been disabled");
156                 return CMD_SUCCESS;
157         }
158 };
159
160 class CommandUsers
161         : public SplitCommand
162 {
163  public:
164         CommandUsers(Module* Creator)
165                 : SplitCommand(Creator, "USERS")
166         {
167         }
168
169         CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
170         {
171                 user->WriteNumeric(ERR_USERSDISABLED, "USERS has been disabled");
172                 return CMD_SUCCESS;
173         }
174 };
175
176 class CoreModStub : public Module
177 {
178         CommandConnect cmdconnect;
179         CommandLinks cmdlinks;
180         CommandServer cmdserver;
181         CommandSquit cmdsquit;
182         CommandSummon cmdsummon;
183         CommandUsers cmdusers;
184
185  public:
186         CoreModStub()
187                 : cmdconnect(this)
188                 , cmdlinks(this)
189                 , cmdserver(this)
190                 , cmdsquit(this)
191                 , cmdsummon(this)
192                 , cmdusers(this)
193         {
194         }
195
196         Version GetVersion() CXX11_OVERRIDE
197         {
198                 return Version("Provides stubs for unimplemented commands", VF_VENDOR|VF_CORE);
199         }
200 };
201
202 MODULE_INIT(CoreModStub)