Anope IRC Services  Version 2.0
protocol.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  */
12 
13 #ifndef PROTOCOL_H
14 #define PROTOCOL_H
15 
16 #include "services.h"
17 #include "anope.h"
18 #include "service.h"
19 
20 /* Encapsultes the IRCd protocol we are speaking. */
22 {
24 
25  protected:
26  IRCDProto(Module *creator, const Anope::string &proto_name);
27  public:
28  virtual ~IRCDProto();
29 
30  virtual void SendSVSKillInternal(const MessageSource &, User *, const Anope::string &);
31  virtual void SendModeInternal(const MessageSource &, const Channel *, const Anope::string &);
32  virtual void SendModeInternal(const MessageSource &, User *, const Anope::string &);
33  virtual void SendKickInternal(const MessageSource &, const Channel *, User *, const Anope::string &);
34  virtual void SendNoticeInternal(const MessageSource &, const Anope::string &dest, const Anope::string &msg);
35  virtual void SendPrivmsgInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf);
36  virtual void SendQuitInternal(User *, const Anope::string &buf);
37  virtual void SendPartInternal(User *, const Channel *chan, const Anope::string &buf);
38  virtual void SendGlobopsInternal(const MessageSource &, const Anope::string &buf);
39  virtual void SendCTCPInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf);
40  virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf);
41 
42  const Anope::string &GetProtocolName();
43  virtual void Parse(const Anope::string &, Anope::string &, Anope::string &, std::vector<Anope::string> &);
44  virtual Anope::string Format(const Anope::string &source, const Anope::string &message);
45 
46  /* Modes used by default by our clients */
48  /* Can we force change a users's nick? */
49  bool CanSVSNick;
50  /* Can we force join or part users? */
51  bool CanSVSJoin;
52  /* Can we set vhosts/vidents on users? */
53  bool CanSetVHost, CanSetVIdent;
54  /* Can we ban specific gecos from being used? */
55  bool CanSNLine;
56  /* Can we ban specific nicknames from being used? */
57  bool CanSQLine;
58  /* Can we ban sepcific channel names from being used? */
60  /* Can we ban by IP? */
61  bool CanSZLine;
62  /* Can we place temporary holds on specific nicknames? */
63  bool CanSVSHold;
64  /* See os_oline */
65  bool CanSVSO;
66  /* See ns_cert */
67  bool CanCertFP;
68  /* Whether this IRCd requires unique IDs for each user or server. See TS6/P10. */
69  bool RequiresID;
70  /* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */
72  /* The maximum number of modes we are allowed to set with one MODE command */
73  unsigned MaxModes;
74  /* The maximum number of bytes a line may have */
75  unsigned MaxLine;
76 
77  /* Retrieves the next free UID or SID */
78  virtual Anope::string UID_Retrieve();
79  virtual Anope::string SID_Retrieve();
80 
86  virtual void SendSVSNOOP(const Server *s, bool mode) { }
87 
92  virtual void SendTopic(const MessageSource &, Channel *);
93 
99  virtual void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost) { }
100  virtual void SendVhostDel(User *) { }
101 
108  virtual void SendAkill(User *, XLine *) = 0;
109  virtual void SendAkillDel(const XLine *) = 0;
110 
111  /* Realname ban */
112  virtual void SendSGLine(User *, const XLine *) { }
113  virtual void SendSGLineDel(const XLine *) { }
114 
115  /* IP ban */
116  virtual void SendSZLine(User *u, const XLine *) { }
117  virtual void SendSZLineDel(const XLine *) { }
118 
119  /* Nick ban (and sometimes channel) */
120  virtual void SendSQLine(User *, const XLine *x) { }
121  virtual void SendSQLineDel(const XLine *x) { }
122 
123  virtual void SendKill(const MessageSource &source, const Anope::string &target, const Anope::string &reason);
124 
130  virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...);
131 
132  virtual void SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...);
133  virtual void SendMode(const MessageSource &source, User *u, const char *fmt, ...);
134 
138  virtual void SendClientIntroduction(User *u) = 0;
139 
140  virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...);
141 
142  virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
143  virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
144  virtual void SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
145  virtual void SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
146 
147  virtual void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) = 0;
148  virtual void SendGlobalPrivmsg(BotInfo *bi, const Server *desc, const Anope::string &msg) = 0;
149 
150  virtual void SendQuit(User *u, const char *fmt, ...);
151  virtual void SendPing(const Anope::string &servname, const Anope::string &who);
152  virtual void SendPong(const Anope::string &servname, const Anope::string &who);
153 
161  virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) = 0;
162  virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...);
163 
170  virtual void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) { }
171 
178  virtual void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) { }
179 
180  virtual void SendInvite(const MessageSource &source, const Channel *c, User *u);
181  virtual void SendGlobops(const MessageSource &source, const char *fmt, ...);
182 
185  virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &) { }
186 
189  virtual void SendNickChange(User *u, const Anope::string &newnick);
190 
193  virtual void SendForceNickChange(User *u, const Anope::string &newnick, time_t when);
194 
198  virtual void SendConnect() = 0;
199 
203  virtual void SendBOB() { }
204  virtual void SendEOB() { }
205 
206  virtual void SendSVSHold(const Anope::string &, time_t) { }
207  virtual void SendSVSHoldDel(const Anope::string &) { }
208 
209  virtual void SendSWhois(const MessageSource &, const Anope::string &, const Anope::string &) { }
210 
213  virtual void SendServer(const Server *) = 0;
214  virtual void SendSquit(Server *, const Anope::string &message);
215 
216  virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
217 
218  virtual void SendLogin(User *u, NickAlias *na) = 0;
219  virtual void SendLogout(User *u) = 0;
220 
224  virtual void SendChannel(Channel *c) { }
225 
229  virtual void SendOper(User *u);
230 
231  virtual void SendSASLMessage(const SASL::Message &) { }
232  virtual void SendSVSLogin(const Anope::string &uid, const Anope::string &acc) { }
233 
234  virtual bool IsNickValid(const Anope::string &);
235  virtual bool IsChannelValid(const Anope::string &);
236  virtual bool IsIdentValid(const Anope::string &);
237  virtual bool IsHostValid(const Anope::string &);
238  virtual bool IsExtbanValid(const Anope::string &) { return false; }
239 
243  virtual unsigned GetMaxListFor(Channel *c);
244 
245  virtual Anope::string NormalizeMask(const Anope::string &mask);
246 };
247 
249 {
251  User *u;
253 
254  public:
255  MessageSource(const Anope::string &);
256  MessageSource(User *u);
257  MessageSource(Server *s);
258  const Anope::string &GetName() const;
259  const Anope::string &GetSource() const;
260  User *GetUser() const;
261  BotInfo *GetBot() const;
262  Server *GetServer() const;
263 };
264 
266 {
270 };
271 
273 {
275  unsigned param_count;
276  std::set<IRCDMessageFlag> flags;
277  public:
278  IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
279  unsigned GetParamCount() const;
280  virtual void Run(MessageSource &, const std::vector<Anope::string> &params) = 0;
281 
282  void SetFlag(IRCDMessageFlag f) { flags.insert(f); }
283  bool HasFlag(IRCDMessageFlag f) const { return flags.count(f); }
284 };
285 
286 extern CoreExport IRCDProto *IRCD;
287 
288 #endif // PROTOCOL_H
Definition: bots.h:24
virtual void SendSGLine(User *, const XLine *)
Definition: protocol.h:112
Anope::string source
Definition: protocol.h:250
bool CanSZLine
Definition: protocol.h:61
Definition: servers.h:42
bool AmbiguousID
Definition: protocol.h:71
bool CanSNLine
Definition: protocol.h:55
virtual void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost)
Definition: protocol.h:99
bool CanSQLineChannel
Definition: protocol.h:59
Anope::string desc
Definition: access.cpp:23
virtual void SendSVSHoldDel(const Anope::string &)
Definition: protocol.h:207
virtual void SendSGLineDel(const XLine *)
Definition: protocol.h:113
virtual void SendSVSO(BotInfo *, const Anope::string &, const Anope::string &)
Definition: protocol.h:185
Definition: users.h:34
Anope::string DefaultPseudoclientModes
Definition: protocol.h:47
virtual void SendSVSJoin(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param)
Definition: protocol.h:170
User * u
Definition: protocol.h:251
virtual void SendSQLine(User *, const XLine *x)
Definition: protocol.h:120
virtual void SendSQLineDel(const XLine *x)
Definition: protocol.h:121
bool RequiresID
Definition: protocol.h:69
unsigned param_count
Definition: protocol.h:275
virtual bool IsExtbanValid(const Anope::string &)
Definition: protocol.h:238
virtual void SendSWhois(const MessageSource &, const Anope::string &, const Anope::string &)
Definition: protocol.h:209
Anope::string proto_name
Definition: protocol.h:23
bool CanSetVIdent
Definition: protocol.h:53
IRCDMessageFlag
Definition: protocol.h:265
virtual void SendSASLMessage(const SASL::Message &)
Definition: protocol.h:231
bool CanSQLine
Definition: protocol.h:57
bool CanSVSNick
Definition: protocol.h:49
bool CanCertFP
Definition: protocol.h:67
unsigned MaxModes
Definition: protocol.h:73
void SetFlag(IRCDMessageFlag f)
Definition: protocol.h:282
virtual void SendBOB()
Definition: protocol.h:203
virtual void SendSVSNOOP(const Server *s, bool mode)
Definition: protocol.h:86
std::set< IRCDMessageFlag > flags
Definition: protocol.h:276
bool CanSVSO
Definition: protocol.h:65
virtual void SendSZLineDel(const XLine *)
Definition: protocol.h:117
Anope::string name
Definition: protocol.h:274
virtual void SendSVSHold(const Anope::string &, time_t)
Definition: protocol.h:206
Server * s
Definition: protocol.h:252
bool HasFlag(IRCDMessageFlag f) const
Definition: protocol.h:283
virtual void SendVhostDel(User *)
Definition: protocol.h:100
CoreExport IRCDProto * IRCD
Definition: protocol.cpp:23
virtual void SendSZLine(User *u, const XLine *)
Definition: protocol.h:116
bool CanSVSHold
Definition: protocol.h:63
#define CoreExport
Definition: services.h:62
virtual void SendChannel(Channel *c)
Definition: protocol.h:224
Definition: xline.h:18
virtual void SendEOB()
Definition: protocol.h:204
bool CanSVSJoin
Definition: protocol.h:51
unsigned MaxLine
Definition: protocol.h:75
virtual void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param)
Definition: protocol.h:178
virtual void SendSVSLogin(const Anope::string &uid, const Anope::string &acc)
Definition: protocol.h:232