1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "servercommand.h"
#include "commandbuilder.h"
/** Handle /RCONNECT
*/
class CommandRConnect : public Command
{
public:
CommandRConnect(Module* Creator);
CmdResult Handle(const std::vector<std::string>& parameters, User* user);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandRSQuit : public Command
{
public:
CommandRSQuit(Module* Creator);
CmdResult Handle(const std::vector<std::string>& parameters, User* user);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandMap : public Command
{
public:
CommandMap(Module* Creator);
CmdResult Handle(const std::vector<std::string>& parameters, User* user);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandSVSJoin : public ServerCommand
{
public:
CommandSVSJoin(Module* Creator) : ServerCommand(Creator, "SVSJOIN", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandSVSPart : public ServerCommand
{
public:
CommandSVSPart(Module* Creator) : ServerCommand(Creator, "SVSPART", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandSVSNick : public ServerCommand
{
public:
CommandSVSNick(Module* Creator) : ServerCommand(Creator, "SVSNICK", 3) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandMetadata : public ServerCommand
{
public:
CommandMetadata(Module* Creator) : ServerCommand(Creator, "METADATA", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
class Builder : public CmdBuilder
{
public:
Builder(User* user, const std::string& key, const std::string& val);
Builder(Channel* chan, const std::string& key, const std::string& val);
Builder(const std::string& key, const std::string& val);
};
};
class CommandUID : public ServerOnlyServerCommand<CommandUID>
{
public:
CommandUID(Module* Creator) : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10) { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& params);
class Builder : public CmdBuilder
{
public:
Builder(User* user);
};
};
class CommandOpertype : public UserOnlyServerCommand<CommandOpertype>
{
public:
CommandOpertype(Module* Creator) : UserOnlyServerCommand<CommandOpertype>(Creator, "OPERTYPE", 1) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
class Builder : public CmdBuilder
{
public:
Builder(User* user);
};
};
class TreeSocket;
class CommandFJoin : public ServerCommand
{
/** Remove all modes from a channel, including statusmodes (+qaovh etc), simplemodes, parameter modes.
* This does not update the timestamp of the target channel, this must be done seperately.
*/
static void RemoveStatus(Channel* c);
/**
* Lowers the TS on the given channel: removes all modes, unsets all extensions,
* clears the topic and removes all pending invites.
* @param chan The target channel whose TS to lower
* @param TS The new TS to set
* @param newname The new name of the channel; must be the same or a case change of the current name
*/
static void LowerTS(Channel* chan, time_t TS, const std::string& newname);
void ProcessModeUUIDPair(const std::string& item, TreeServer* sourceserver, Channel* chan, Modes::ChangeList* modechangelist);
public:
CommandFJoin(Module* Creator) : ServerCommand(Creator, "FJOIN", 3) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
class Builder : public CmdBuilder
{
/** Maximum possible Membership::Id length in decimal digits, used for determining whether a user will fit into
* a message or not
*/
static const size_t membid_max_digits = 20;
static const size_t maxline = 480;
std::string::size_type pos;
protected:
void add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend);
bool has_room(std::string::size_type nummodes) const;
public:
Builder(Channel* chan, TreeServer* source = Utils->TreeRoot);
void add(Membership* memb)
{
add(memb, memb->modes.begin(), memb->modes.end());
}
bool has_room(Membership* memb) const
{
return has_room(memb->modes.size());
}
void clear();
const std::string& finalize();
};
};
class CommandFMode : public ServerCommand
{
public:
CommandFMode(Module* Creator) : ServerCommand(Creator, "FMODE", 3) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
};
class CommandFTopic : public ServerCommand
{
public:
CommandFTopic(Module* Creator) : ServerCommand(Creator, "FTOPIC", 4, 5) { }
CmdResult Handle(User* user, std::vector<std::string>& params);
class Builder : public CmdBuilder
{
public:
Builder(Channel* chan);
Builder(User* user, Channel* chan);
};
};
class CommandFHost : public UserOnlyServerCommand<CommandFHost>
{
public:
CommandFHost(Module* Creator) : UserOnlyServerCommand<CommandFHost>(Creator, "FHOST", 1) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
};
class CommandFIdent : public UserOnlyServerCommand<CommandFIdent>
{
public:
CommandFIdent(Module* Creator) : UserOnlyServerCommand<CommandFIdent>(Creator, "FIDENT", 1) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
};
class CommandFName : public UserOnlyServerCommand<CommandFName>
{
public:
CommandFName(Module* Creator) : UserOnlyServerCommand<CommandFName>(Creator, "FNAME", 1) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
};
class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
{
public:
CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 2) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
};
class CommandResync : public ServerOnlyServerCommand<CommandResync>
{
public:
CommandResync(Module* Creator) : ServerOnlyServerCommand<CommandResync>(Creator, "RESYNC", 1) { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_LOCALONLY; }
};
class CommandAway : public UserOnlyServerCommand<CommandAway>
{
public:
CommandAway(Module* Creator) : UserOnlyServerCommand<CommandAway>(Creator, "AWAY", 0, 2) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
class Builder : public CmdBuilder
{
public:
Builder(User* user);
Builder(User* user, const std::string& msg);
};
};
class XLine;
class CommandAddLine : public ServerCommand
{
public:
CommandAddLine(Module* Creator) : ServerCommand(Creator, "ADDLINE", 6, 6) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
class Builder : public CmdBuilder
{
public:
Builder(XLine* xline, User* user = ServerInstance->FakeClient);
};
};
class CommandDelLine : public ServerCommand
{
public:
CommandDelLine(Module* Creator) : ServerCommand(Creator, "DELLINE", 2, 2) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
};
class CommandEncap : public ServerCommand
{
public:
CommandEncap(Module* Creator) : ServerCommand(Creator, "ENCAP", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
};
class CommandIdle : public UserOnlyServerCommand<CommandIdle>
{
public:
CommandIdle(Module* Creator) : UserOnlyServerCommand<CommandIdle>(Creator, "IDLE", 1) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
};
class CommandNick : public UserOnlyServerCommand<CommandNick>
{
public:
CommandNick(Module* Creator) : UserOnlyServerCommand<CommandNick>(Creator, "NICK", 2) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& parameters);
};
class CommandPing : public ServerCommand
{
public:
CommandPing(Module* Creator) : ServerCommand(Creator, "PING", 1) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
};
class CommandPong : public ServerOnlyServerCommand<CommandPong>
{
public:
CommandPong(Module* Creator) : ServerOnlyServerCommand<CommandPong>(Creator, "PONG", 1) { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
};
class CommandPush : public ServerCommand
{
public:
CommandPush(Module* Creator) : ServerCommand(Creator, "PUSH", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) { return ROUTE_UNICAST(parameters[0]); }
};
class CommandSave : public ServerCommand
{
public:
/** Timestamp of the uuid nick of all users who collided and got their nick changed to uuid
*/
static const time_t SavedTimestamp = 100;
CommandSave(Module* Creator) : ServerCommand(Creator, "SAVE", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
};
class CommandServer : public ServerOnlyServerCommand<CommandServer>
{
static void HandleExtra(TreeServer* newserver, const std::vector<std::string>& params);
public:
CommandServer(Module* Creator) : ServerOnlyServerCommand<CommandServer>(Creator, "SERVER", 3) { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
class Builder : public CmdBuilder
{
void push_property(const char* key, const std::string& val)
{
push(key).push_raw('=').push_raw(val);
}
public:
Builder(TreeServer* server);
};
};
class CommandSQuit : public ServerOnlyServerCommand<CommandSQuit>
{
public:
CommandSQuit(Module* Creator) : ServerOnlyServerCommand<CommandSQuit>(Creator, "SQUIT", 2) { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
};
class CommandSNONotice : public ServerCommand
{
public:
CommandSNONotice(Module* Creator) : ServerCommand(Creator, "SNONOTICE", 2) { }
CmdResult Handle(User* user, std::vector<std::string>& parameters);
};
class CommandEndBurst : public ServerOnlyServerCommand<CommandEndBurst>
{
public:
CommandEndBurst(Module* Creator) : ServerOnlyServerCommand<CommandEndBurst>(Creator, "ENDBURST") { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
};
class CommandSInfo : public ServerOnlyServerCommand<CommandSInfo>
{
public:
CommandSInfo(Module* Creator) : ServerOnlyServerCommand<CommandSInfo>(Creator, "SINFO", 2) { }
CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
class Builder : public CmdBuilder
{
public:
Builder(TreeServer* server, const char* type, const std::string& value);
};
};
class SpanningTreeCommands
{
public:
CommandSVSJoin svsjoin;
CommandSVSPart svspart;
CommandSVSNick svsnick;
CommandMetadata metadata;
CommandUID uid;
CommandOpertype opertype;
CommandFJoin fjoin;
CommandIJoin ijoin;
CommandResync resync;
CommandFMode fmode;
CommandFTopic ftopic;
CommandFHost fhost;
CommandFIdent fident;
CommandFName fname;
CommandAway away;
CommandAddLine addline;
CommandDelLine delline;
CommandEncap encap;
CommandIdle idle;
CommandNick nick;
CommandPing ping;
CommandPong pong;
CommandPush push;
CommandSave save;
CommandServer server;
CommandSQuit squit;
CommandSNONotice snonotice;
CommandEndBurst endburst;
CommandSInfo sinfo;
SpanningTreeCommands(ModuleSpanningTree* module);
};
|