1 |
/* |
2 |
* Copyright © 2005 William Pitcock, et al. |
3 |
* Rights to this code are as documented in doc/pod/license.pod. |
4 |
* |
5 |
* Protocol handlers, both generic and the actual declarations themselves. |
6 |
* |
7 |
* $Id: phandler.h,v 1.3 2007-07-21 13:23:18 pippijn Exp $ |
8 |
*/ |
9 |
|
10 |
#ifndef PHANDLER_H |
11 |
#define PHANDLER_H |
12 |
|
13 |
#include <ermyth/factory.h> |
14 |
|
15 |
namespace protocol |
16 |
{ |
17 |
struct ircd_t |
18 |
{ |
19 |
char const * const ircdname; |
20 |
char const * const tldprefix; |
21 |
bool uses_uid; // changed in protocol modules |
22 |
bool const uses_rcommand; |
23 |
bool uses_owner; // changed in contrib/ircd_noowner |
24 |
bool uses_protect; // changed in contrib/ircd_noprotect |
25 |
bool uses_halfops; // changed in contrib/ircd_nohalfops |
26 |
bool const uses_p10; /* Parser hackhack. */ |
27 |
bool const uses_vhost; /* Do we use vHosts? */ |
28 |
unsigned const oper_only_modes; |
29 |
unsigned const owner_mode; |
30 |
unsigned const protect_mode; |
31 |
unsigned const halfops_mode; |
32 |
char const * const owner_mchar; |
33 |
char const * const protect_mchar; |
34 |
char const * const halfops_mchar; |
35 |
unsigned const type; |
36 |
unsigned const perm_mode; /* Modes to not disappear when empty */ |
37 |
char const * const ban_like_modes; /* e.g. "beI" */ |
38 |
char const except_mchar; |
39 |
char const invex_mchar; |
40 |
int const flags; |
41 |
}; |
42 |
|
43 |
/* values for type */ |
44 |
/* -- what the HELL are these used for? A grep reveals nothing.. --w00t |
45 |
* -- they are used to provide a hint to third-party module coders about what |
46 |
* ircd they are working with. --nenolod |
47 |
*/ |
48 |
#define PROTOCOL_ASUKA 1 |
49 |
#define PROTOCOL_BAHAMUT 2 |
50 |
#define PROTOCOL_CHARYBDIS 3 |
51 |
#define PROTOCOL_DREAMFORGE 4 |
52 |
#define PROTOCOL_HYPERION 5 |
53 |
#define PROTOCOL_INSPIRCD 6 |
54 |
#define PROTOCOL_IRCNET 7 |
55 |
#define PROTOCOL_MONKEY 8 /* obsolete */ |
56 |
#define PROTOCOL_PLEXUS 9 |
57 |
#define PROTOCOL_PTLINK 10 |
58 |
#define PROTOCOL_RATBOX 11 |
59 |
#define PROTOCOL_SCYLLA 12 |
60 |
#define PROTOCOL_SHADOWIRCD 13 |
61 |
#define PROTOCOL_SORCERY 14 |
62 |
#define PROTOCOL_ULTIMATE3 15 |
63 |
#define PROTOCOL_UNDERNET 16 |
64 |
#define PROTOCOL_UNREAL 17 |
65 |
#define PROTOCOL_SOLIDIRCD 18 |
66 |
#define PROTOCOL_NEFARIOUS 19 |
67 |
#define PROTOCOL_OFFICEIRC 20 |
68 |
|
69 |
#define PROTOCOL_OTHER 255 |
70 |
|
71 |
/* values for flags */ |
72 |
#define IRCD_CIDR_BANS 1 |
73 |
|
74 |
/* forced nick change types */ |
75 |
#define FNC_REGAIN 0 /* give a registered user their nick back */ |
76 |
#define FNC_FORCE 1 /* force a user off their nick (kill if unsupported) */ |
77 |
|
78 |
struct handler |
79 |
{ |
80 |
/* pmodule.C */ |
81 |
static bool loaded; |
82 |
|
83 |
handler () |
84 |
{ |
85 |
loaded = true; |
86 |
} |
87 |
|
88 |
virtual ~handler () |
89 |
{ |
90 |
loaded = false; |
91 |
} |
92 |
|
93 |
/* server login, usually sends PASS, CAPAB, SERVER and SVINFO |
94 |
* you can still change ircd->uses_uid at this point |
95 |
* set me.bursting = true |
96 |
* return 1 if sts() failed (by returning 1), otherwise 0 */ |
97 |
virtual unsigned int server_login (void); |
98 |
/* introduce a client on the services server */ |
99 |
virtual void introduce_nick (user_t *u); |
100 |
/* send an invite for a given user to a channel |
101 |
* the source may not be on the channel */ |
102 |
virtual void invite_sts (user_t *source, user_t *target, channel_t *channel); |
103 |
/* quit a client on the services server with the given message */ |
104 |
virtual void quit_sts (user_t *u, char const * const reason); |
105 |
/* send wallops |
106 |
* use something that only opers can see if easily possible */ |
107 |
virtual void wallops_sts (char const * const text); |
108 |
/* join a channel with a client on the services server |
109 |
* the client should be introduced opped |
110 |
* isnew indicates the channel modes (and bans XXX) should be bursted |
111 |
* note that the channelts can still be old in this case (e.g. kills) |
112 |
* modes is a convenience argument giving the simple modes with parameters |
113 |
* do not rely upon chanuser_find(c,u) */ |
114 |
virtual void join_sts (channel_t *c, user_t *u, bool isnew, char const * const modes); |
115 |
/* lower the TS of a channel, joining it with the given client on the |
116 |
* services server (opped), replacing the current simple modes with the |
117 |
* ones stored in the channel_t and clearing all other statuses |
118 |
* if bans are timestamped on this ircd, call chanban_clear() |
119 |
* if the topic is timestamped on this ircd, clear it */ |
120 |
virtual void chan_lowerts (channel_t *c, user_t *u); |
121 |
/* kick a user from a channel |
122 |
* from is a client on the services server which may or may not be |
123 |
* on the channel */ |
124 |
virtual void kick (char const * const from, char const * const channel, char const * const to, char const * const reason); |
125 |
/* change ircd metadata */ |
126 |
virtual void mdchange (char const * const target, char const * const key, char const * const value); |
127 |
/* send a privmsg |
128 |
* here it's ok to assume the source is able to send */ |
129 |
virtual void privmsg (char const * const from, char const * const target, char const * const fmt, ...); |
130 |
/* send a notice to a user |
131 |
* from can be a client on the services server or the services server |
132 |
* itself (NULL) */ |
133 |
virtual void notice_user_sts (user_t *from, user_t *target, char const * const text); |
134 |
/* send a global notice to all users on servers matching the mask |
135 |
* from is a client on the services server |
136 |
* mask is either "*" or it has a non-wildcard TLD */ |
137 |
virtual void notice_global_sts (user_t *from, char const * const mask, char const * const text); |
138 |
/* send a notice to a channel |
139 |
* from can be a client on the services server or the services server |
140 |
* itself (NULL) |
141 |
* if the source cannot send because it is not on the channel, send the |
142 |
* notice from the server or join for a moment */ |
143 |
virtual void notice_channel_sts (user_t *from, channel_t *target, char const * const text); |
144 |
/* send a notice to ops in a channel |
145 |
* source may or may not be on channel |
146 |
* generic_wallchops() sends an individual notice to each channel operator */ |
147 |
virtual void wallchops (user_t *source, channel_t *target, char const * const message); |
148 |
/* send a numeric from must be me.name or ME */ |
149 |
virtual void numeric_sts (char const * const from, int numeric, char const * const target, char const * const fmt, ...); |
150 |
/* kill a user |
151 |
* from can be a client on the services server or the services server |
152 |
* itself (me.name or ME) |
153 |
* it is recommended to change an invalid source to ME */ |
154 |
virtual void skill (char const * const from, char const * const nick, char const * const fmt, ...); |
155 |
/* part a channel with a client on the services server */ |
156 |
virtual void part_sts (channel_t *c, user_t *u); |
157 |
/* add a kline on the servers matching the given mask |
158 |
* duration is in seconds, 0 for a permanent kline |
159 |
* if the ircd requires klines to be sent from users, use opersvs */ |
160 |
virtual void kline_sts (char const * const server, char const * const user, char const * const host, long duration, char const * const reason); |
161 |
/* remove a kline on the servers matching the given mask |
162 |
* if the ircd requires unklines to be sent from users, use opersvs */ |
163 |
virtual void unkline_sts (char const * const server, char const * const user, char const * const host); |
164 |
/* make chanserv set a topic on a channel |
165 |
* setter and ts should be used if the ircd supports topics to be set |
166 |
* with a given topicsetter and topicts; ts is not a channelts |
167 |
* prevts is the topicts of the old topic or 0 if there was no topic, |
168 |
* useful in optimizing which form of topic change to use |
169 |
* if the given topicts was not set and topicts is used on the ircd, |
170 |
* set c->topicts to the value used */ |
171 |
virtual void topic_sts (channel_t *c, char const * const setter, time_t ts, time_t prevts, char const * const topic); |
172 |
/* set modes on a channel by the given sender; sender must be a client |
173 |
* on the services server; sender may or may not be on channel */ |
174 |
virtual void mode_sts (char const * const sender, channel_t *target, char const * const modes); |
175 |
/* ping the uplink |
176 |
* first check if me.connected is true and bail if not */ |
177 |
virtual void ping_sts (void); |
178 |
/* mark user 'origin' as logged in as 'user' |
179 |
* wantedhost is currently not used |
180 |
* first check if me.connected is true and bail if not */ |
181 |
virtual void ircd_on_login (char const * const origin, char const * const user, char const * const wantedhost); |
182 |
/* mark user 'origin' as logged out |
183 |
* first check if me.connected is true and bail if not |
184 |
* return false if successful or logins are not supported |
185 |
* return true if the user was killed to force logout (P10) */ |
186 |
virtual bool ircd_on_logout (char const * const origin, char const * const user, char const * const wantedhost); |
187 |
/* introduce a fake server |
188 |
* it is ok to use opersvs to squit the old server |
189 |
* if SQUIT uses kill semantics (e.g. charybdis), server_delete() the server |
190 |
* and continue |
191 |
* if SQUIT uses unconnect semantics (e.g. bahamut), set SF_JUPE_PENDING on |
192 |
* the server and return; you will be called again when the server is really |
193 |
* deleted */ |
194 |
virtual void jupe (char const * const server, char const * const reason); |
195 |
/* set a dynamic spoof on a user |
196 |
* if the ircd does not notify the user of this, do |
197 |
* notice(source, target, "Setting your host to \2%s\2.", host); */ |
198 |
virtual void sethost_sts (char const * const source, char const * const target, char const * const host); |
199 |
/* force a nickchange for a user |
200 |
* possible values for type: |
201 |
* FNC_REGAIN: give a registered user their nick back |
202 |
* FNC_FORCE: force a user off their nick (kill if unsupported) |
203 |
*/ |
204 |
virtual void fnc_sts (user_t *source, user_t *u, char const * const newnick, int type); |
205 |
/* temporarily make a nick unavailable to users |
206 |
* source is the responsible service |
207 |
* duration is in seconds, 0 to remove the effect of a previous call |
208 |
* account is an account that may still use the nick, or NULL */ |
209 |
virtual void holdnick_sts (user_t *source, int duration, char const * const nick, myuser_t *account); |
210 |
/* change nick, user, host and/or services login name for a user |
211 |
* target may also be a not yet fully introduced UID (for SASL) */ |
212 |
virtual void svslogin_sts (char const * const target, char const * const nick, char const * const user, char const * const host, char const * const login); |
213 |
/* send sasl message */ |
214 |
virtual void sasl_sts (char const * const target, char const mode, char const * const data); |
215 |
/* find next channel ban (or other ban-like mode) matching user */ |
216 |
virtual node_t *next_matching_ban (channel_t *c, user_t *u, int type, node_t *first); |
217 |
/* find next host channel access matching user */ |
218 |
virtual node_t *next_matching_host_chanacs (mychan_t *mc, user_t *u, node_t *first); |
219 |
}; |
220 |
} // namespace protocol |
221 |
|
222 |
#define FACREG_TYPE protocol::handler |
223 |
#define FACREG_TYPE_NAME "protocol handler" |
224 |
#define FACREG_TYPE_IS_ABSTRACT |
225 |
#include <ermyth/factory_reg.h> |
226 |
|
227 |
E protocol::handler *phandler; |
228 |
E protocol::ircd_t *ircd; |
229 |
|
230 |
E cmode_t *mode_list; |
231 |
E extmode *ignore_mode_list; |
232 |
E cmode_t *status_mode_list; |
233 |
E cmode_t *prefix_mode_list; |
234 |
|
235 |
#endif |