Blame


1 024588db 2007-11-21 alex /*
2 024588db 2007-11-21 alex * ngIRCd -- The Next Generation IRC Daemon
3 a60465be 2008-09-23 alex * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
4 024588db 2007-11-21 alex *
5 024588db 2007-11-21 alex * This program is free software; you can redistribute it and/or modify
6 024588db 2007-11-21 alex * it under the terms of the GNU General Public License as published by
7 024588db 2007-11-21 alex * the Free Software Foundation; either version 2 of the License, or
8 024588db 2007-11-21 alex * (at your option) any later version.
9 024588db 2007-11-21 alex * Please read the file COPYING, README and AUTHORS for more information.
10 024588db 2007-11-21 alex *
11 024588db 2007-11-21 alex * Handlers for IRC numerics sent to the server
12 024588db 2007-11-21 alex */
13 024588db 2007-11-21 alex
14 024588db 2007-11-21 alex #include "portab.h"
15 024588db 2007-11-21 alex
16 024588db 2007-11-21 alex #include "imp.h"
17 024588db 2007-11-21 alex #include <assert.h>
18 024588db 2007-11-21 alex #include <stdio.h>
19 024588db 2007-11-21 alex #include <stdlib.h>
20 024588db 2007-11-21 alex #include <string.h>
21 024588db 2007-11-21 alex
22 024588db 2007-11-21 alex #include "defines.h"
23 024588db 2007-11-21 alex #include "resolve.h"
24 024588db 2007-11-21 alex #include "conn.h"
25 024588db 2007-11-21 alex #include "conf.h"
26 024588db 2007-11-21 alex #include "conn.h"
27 a60465be 2008-09-23 alex #include "conn-func.h"
28 024588db 2007-11-21 alex #include "client.h"
29 024588db 2007-11-21 alex #include "channel.h"
30 024588db 2007-11-21 alex #include "irc-write.h"
31 024588db 2007-11-21 alex #include "lists.h"
32 024588db 2007-11-21 alex #include "log.h"
33 024588db 2007-11-21 alex #include "messages.h"
34 024588db 2007-11-21 alex #include "parse.h"
35 024588db 2007-11-21 alex
36 024588db 2007-11-21 alex #include "exp.h"
37 024588db 2007-11-21 alex #include "numeric.h"
38 ec0b405d 2008-09-23 alex
39 ec0b405d 2008-09-23 alex
40 ec0b405d 2008-09-23 alex /**
41 ec0b405d 2008-09-23 alex * Announce a channel and its users in the network.
42 ec0b405d 2008-09-23 alex */
43 ec0b405d 2008-09-23 alex static bool
44 ec0b405d 2008-09-23 alex Announce_Channel(CLIENT *Client, CHANNEL *Chan)
45 ec0b405d 2008-09-23 alex {
46 ec0b405d 2008-09-23 alex CL2CHAN *cl2chan;
47 ec0b405d 2008-09-23 alex CLIENT *cl;
48 ec0b405d 2008-09-23 alex char str[LINE_LEN], *ptr;
49 ec0b405d 2008-09-23 alex bool njoin;
50 ec0b405d 2008-09-23 alex
51 ec0b405d 2008-09-23 alex if (Conn_Options(Client_Conn(Client)) & CONN_RFC1459)
52 ec0b405d 2008-09-23 alex njoin = false;
53 ec0b405d 2008-09-23 alex else
54 ec0b405d 2008-09-23 alex njoin = true;
55 ec0b405d 2008-09-23 alex
56 ec0b405d 2008-09-23 alex /* Get all the members of this channel */
57 ec0b405d 2008-09-23 alex cl2chan = Channel_FirstMember(Chan);
58 ec0b405d 2008-09-23 alex snprintf(str, sizeof(str), "NJOIN %s :", Channel_Name(Chan));
59 ec0b405d 2008-09-23 alex while (cl2chan) {
60 ec0b405d 2008-09-23 alex cl = Channel_GetClient(cl2chan);
61 ec0b405d 2008-09-23 alex assert(cl != NULL);
62 ec0b405d 2008-09-23 alex
63 ec0b405d 2008-09-23 alex if (njoin) {
64 ec0b405d 2008-09-23 alex /* RFC 2813: send NJOIN with nick names and modes
65 ec0b405d 2008-09-23 alex * (if user is channel operator or has voice) */
66 ec0b405d 2008-09-23 alex if (str[strlen(str) - 1] != ':')
67 ec0b405d 2008-09-23 alex strlcat(str, ",", sizeof(str));
68 ec0b405d 2008-09-23 alex if (strchr(Channel_UserModes(Chan, cl), 'v'))
69 ec0b405d 2008-09-23 alex strlcat(str, "+", sizeof(str));
70 ec0b405d 2008-09-23 alex if (strchr(Channel_UserModes(Chan, cl), 'o'))
71 ec0b405d 2008-09-23 alex strlcat(str, "@", sizeof(str));
72 ec0b405d 2008-09-23 alex strlcat(str, Client_ID(cl), sizeof(str));
73 ec0b405d 2008-09-23 alex
74 ec0b405d 2008-09-23 alex /* Send the data if the buffer is "full" */
75 ec0b405d 2008-09-23 alex if (strlen(str) > (LINE_LEN - CLIENT_NICK_LEN - 8)) {
76 ec0b405d 2008-09-23 alex if (!IRC_WriteStrClient(Client, "%s", str))
77 ec0b405d 2008-09-23 alex return DISCONNECTED;
78 ec0b405d 2008-09-23 alex snprintf(str, sizeof(str), "NJOIN %s :",
79 ec0b405d 2008-09-23 alex Channel_Name(Chan));
80 ec0b405d 2008-09-23 alex }
81 ec0b405d 2008-09-23 alex } else {
82 ec0b405d 2008-09-23 alex /* RFC 1459: no NJOIN, send JOIN and MODE */
83 ec0b405d 2008-09-23 alex if (!IRC_WriteStrClientPrefix(Client, cl, "JOIN %s",
84 ec0b405d 2008-09-23 alex Channel_Name(Chan)))
85 ec0b405d 2008-09-23 alex return DISCONNECTED;
86 ec0b405d 2008-09-23 alex ptr = Channel_UserModes(Chan, cl);
87 ec0b405d 2008-09-23 alex while (*ptr) {
88 ec0b405d 2008-09-23 alex if (!IRC_WriteStrClientPrefix(Client, cl,
89 ec0b405d 2008-09-23 alex "MODE %s +%c %s",
90 ec0b405d 2008-09-23 alex Channel_Name(Chan), ptr[0],
91 ec0b405d 2008-09-23 alex Client_ID(cl)))
92 ec0b405d 2008-09-23 alex return DISCONNECTED;
93 ec0b405d 2008-09-23 alex ptr++;
94 ec0b405d 2008-09-23 alex }
95 ec0b405d 2008-09-23 alex }
96 024588db 2007-11-21 alex
97 ec0b405d 2008-09-23 alex cl2chan = Channel_NextMember(Chan, cl2chan);
98 ec0b405d 2008-09-23 alex }
99 024588db 2007-11-21 alex
100 ec0b405d 2008-09-23 alex /* Data left in the buffer? */
101 ec0b405d 2008-09-23 alex if (str[strlen(str) - 1] != ':') {
102 ec0b405d 2008-09-23 alex /* Yes, send it ... */
103 ec0b405d 2008-09-23 alex if (!IRC_WriteStrClient(Client, "%s", str))
104 ec0b405d 2008-09-23 alex return DISCONNECTED;
105 ec0b405d 2008-09-23 alex }
106 ec0b405d 2008-09-23 alex
107 ec0b405d 2008-09-23 alex return CONNECTED;
108 ec0b405d 2008-09-23 alex } /* Announce_Channel */
109 ec0b405d 2008-09-23 alex
110 ec0b405d 2008-09-23 alex
111 024588db 2007-11-21 alex /**
112 024588db 2007-11-21 alex * Announce new server in the network
113 024588db 2007-11-21 alex * @param Client New server
114 024588db 2007-11-21 alex * @param Server Existing server in the network
115 024588db 2007-11-21 alex */
116 024588db 2007-11-21 alex static bool
117 024588db 2007-11-21 alex Announce_Server(CLIENT * Client, CLIENT * Server)
118 024588db 2007-11-21 alex {
119 024588db 2007-11-21 alex CLIENT *c;
120 024588db 2007-11-21 alex
121 024588db 2007-11-21 alex if (Client_Conn(Server) > NONE) {
122 024588db 2007-11-21 alex /* Announce the new server to the one already registered
123 024588db 2007-11-21 alex * which is directly connected to the local server */
124 024588db 2007-11-21 alex if (!IRC_WriteStrClient
125 024588db 2007-11-21 alex (Server, "SERVER %s %d %d :%s", Client_ID(Client),
126 024588db 2007-11-21 alex Client_Hops(Client) + 1, Client_MyToken(Client),
127 024588db 2007-11-21 alex Client_Info(Client)))
128 024588db 2007-11-21 alex return DISCONNECTED;
129 024588db 2007-11-21 alex }
130 024588db 2007-11-21 alex
131 024588db 2007-11-21 alex if (Client_Hops(Server) == 1)
132 024588db 2007-11-21 alex c = Client_ThisServer();
133 024588db 2007-11-21 alex else
134 024588db 2007-11-21 alex c = Client_Introducer(Server);
135 024588db 2007-11-21 alex
136 024588db 2007-11-21 alex /* Inform new server about the one already registered in the network */
137 024588db 2007-11-21 alex return IRC_WriteStrClientPrefix(Client, c, "SERVER %s %d %d :%s",
138 024588db 2007-11-21 alex Client_ID(Server), Client_Hops(Server) + 1,
139 024588db 2007-11-21 alex Client_MyToken(Server), Client_Info(Server));
140 024588db 2007-11-21 alex } /* Announce_Server */
141 024588db 2007-11-21 alex
142 024588db 2007-11-21 alex
143 024588db 2007-11-21 alex /**
144 024588db 2007-11-21 alex * Announce existing user to a new server
145 024588db 2007-11-21 alex * @param Client New server
146 024588db 2007-11-21 alex * @param User Existing user in the network
147 024588db 2007-11-21 alex */
148 024588db 2007-11-21 alex static bool
149 024588db 2007-11-21 alex Announce_User(CLIENT * Client, CLIENT * User)
150 024588db 2007-11-21 alex {
151 a60465be 2008-09-23 alex CONN_ID conn;
152 687784d2 2008-09-23 alex char *modes;
153 687784d2 2008-09-23 alex
154 a60465be 2008-09-23 alex conn = Client_Conn(Client);
155 a60465be 2008-09-23 alex if (Conn_Options(conn) & CONN_RFC1459) {
156 a60465be 2008-09-23 alex /* RFC 1459 mode: separate NICK and USER commands */
157 a60465be 2008-09-23 alex if (! Conn_WriteStr(conn, "NICK %s :%d",
158 a60465be 2008-09-23 alex Client_ID(User), Client_Hops(User) + 1))
159 a60465be 2008-09-23 alex return DISCONNECTED;
160 687784d2 2008-09-23 alex if (! Conn_WriteStr(conn, ":%s USER %s %s %s :%s",
161 a60465be 2008-09-23 alex Client_ID(User), Client_User(User),
162 a60465be 2008-09-23 alex Client_Hostname(User),
163 a60465be 2008-09-23 alex Client_ID(Client_Introducer(User)),
164 687784d2 2008-09-23 alex Client_Info(User)))
165 687784d2 2008-09-23 alex return DISCONNECTED;
166 687784d2 2008-09-23 alex modes = Client_Modes(User);
167 687784d2 2008-09-23 alex if (modes[0]) {
168 687784d2 2008-09-23 alex return Conn_WriteStr(conn, ":%s MODE %s +%s",
169 687784d2 2008-09-23 alex Client_ID(User), Client_ID(User),
170 687784d2 2008-09-23 alex modes);
171 687784d2 2008-09-23 alex }
172 687784d2 2008-09-23 alex return CONNECTED;
173 a60465be 2008-09-23 alex } else {
174 178f9cbd 2008-09-23 alex /* RFC 2813 mode: one combined NICK or SERVICE command */
175 178f9cbd 2008-09-23 alex if (Client_Type(User) == CLIENT_SERVICE
176 178f9cbd 2008-09-23 alex && strchr(Client_Flags(Client), 'S'))
177 178f9cbd 2008-09-23 alex return IRC_WriteStrClient(Client,
178 178f9cbd 2008-09-23 alex "SERVICE %s %d * +%s %d :%s", Client_Mask(User),
179 178f9cbd 2008-09-23 alex Client_MyToken(Client_Introducer(User)),
180 178f9cbd 2008-09-23 alex Client_Modes(User), Client_Hops(User) + 1,
181 178f9cbd 2008-09-23 alex Client_Info(User));
182 178f9cbd 2008-09-23 alex else
183 178f9cbd 2008-09-23 alex return IRC_WriteStrClient(Client,
184 178f9cbd 2008-09-23 alex "NICK %s %d %s %s %d +%s :%s",
185 a60465be 2008-09-23 alex Client_ID(User), Client_Hops(User) + 1,
186 a60465be 2008-09-23 alex Client_User(User), Client_Hostname(User),
187 a60465be 2008-09-23 alex Client_MyToken(Client_Introducer(User)),
188 a60465be 2008-09-23 alex Client_Modes(User), Client_Info(User));
189 a60465be 2008-09-23 alex }
190 024588db 2007-11-21 alex } /* Announce_User */
191 024588db 2007-11-21 alex
192 024588db 2007-11-21 alex
193 024588db 2007-11-21 alex #ifdef IRCPLUS
194 024588db 2007-11-21 alex
195 024588db 2007-11-21 alex /**
196 024588db 2007-11-21 alex * Synchronize invite and ban lists between servers
197 024588db 2007-11-21 alex * @param Client New server
198 024588db 2007-11-21 alex */
199 024588db 2007-11-21 alex static bool
200 024588db 2007-11-21 alex Synchronize_Lists(CLIENT * Client)
201 024588db 2007-11-21 alex {
202 024588db 2007-11-21 alex CHANNEL *c;
203 024588db 2007-11-21 alex struct list_head *head;
204 024588db 2007-11-21 alex struct list_elem *elem;
205 024588db 2007-11-21 alex
206 024588db 2007-11-21 alex assert(Client != NULL);
207 024588db 2007-11-21 alex
208 024588db 2007-11-21 alex c = Channel_First();
209 024588db 2007-11-21 alex while (c) {
210 024588db 2007-11-21 alex /* ban list */
211 024588db 2007-11-21 alex head = Channel_GetListBans(c);
212 024588db 2007-11-21 alex elem = Lists_GetFirst(head);
213 024588db 2007-11-21 alex while (elem) {
214 024588db 2007-11-21 alex if (!IRC_WriteStrClient(Client, "MODE %s +b %s",
215 024588db 2007-11-21 alex Channel_Name(c),
216 024588db 2007-11-21 alex Lists_GetMask(elem))) {
217 024588db 2007-11-21 alex return DISCONNECTED;
218 024588db 2007-11-21 alex }
219 024588db 2007-11-21 alex elem = Lists_GetNext(elem);
220 024588db 2007-11-21 alex }
221 024588db 2007-11-21 alex
222 024588db 2007-11-21 alex /* invite list */
223 024588db 2007-11-21 alex head = Channel_GetListInvites(c);
224 024588db 2007-11-21 alex elem = Lists_GetFirst(head);
225 024588db 2007-11-21 alex while (elem) {
226 024588db 2007-11-21 alex if (!IRC_WriteStrClient(Client, "MODE %s +I %s",
227 024588db 2007-11-21 alex Channel_Name(c),
228 024588db 2007-11-21 alex Lists_GetMask(elem))) {
229 024588db 2007-11-21 alex return DISCONNECTED;
230 024588db 2007-11-21 alex }
231 024588db 2007-11-21 alex elem = Lists_GetNext(elem);
232 024588db 2007-11-21 alex }
233 024588db 2007-11-21 alex
234 024588db 2007-11-21 alex c = Channel_Next(c);
235 024588db 2007-11-21 alex }
236 024588db 2007-11-21 alex return CONNECTED;
237 024588db 2007-11-21 alex }
238 024588db 2007-11-21 alex
239 024588db 2007-11-21 alex
240 024588db 2007-11-21 alex /**
241 024588db 2007-11-21 alex * Send CHANINFO commands to a new server (inform it about existing channels).
242 024588db 2007-11-21 alex * @param Client New server
243 024588db 2007-11-21 alex * @param Chan Channel
244 024588db 2007-11-21 alex */
245 024588db 2007-11-21 alex static bool
246 024588db 2007-11-21 alex Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
247 024588db 2007-11-21 alex {
248 024588db 2007-11-21 alex char *modes, *topic;
249 024588db 2007-11-21 alex bool has_k, has_l;
250 d070ec08 2008-09-23 alex
251 024588db 2007-11-21 alex #ifdef DEBUG
252 024588db 2007-11-21 alex Log(LOG_DEBUG, "Sending CHANINFO commands ...");
253 024588db 2007-11-21 alex #endif
254 d070ec08 2008-09-23 alex
255 024588db 2007-11-21 alex modes = Channel_Modes(Chan);
256 024588db 2007-11-21 alex topic = Channel_Topic(Chan);
257 d070ec08 2008-09-23 alex
258 024588db 2007-11-21 alex if (!*modes && !*topic)
259 024588db 2007-11-21 alex return CONNECTED;
260 d070ec08 2008-09-23 alex
261 024588db 2007-11-21 alex has_k = strchr(modes, 'k') != NULL;
262 024588db 2007-11-21 alex has_l = strchr(modes, 'l') != NULL;
263 d070ec08 2008-09-23 alex
264 024588db 2007-11-21 alex /* send CHANINFO */
265 024588db 2007-11-21 alex if (!has_k && !has_l) {
266 024588db 2007-11-21 alex if (!*topic) {
267 024588db 2007-11-21 alex /* "CHANINFO <chan> +<modes>" */
268 024588db 2007-11-21 alex return IRC_WriteStrClient(Client, "CHANINFO %s +%s",
269 024588db 2007-11-21 alex Channel_Name(Chan), modes);
270 024588db 2007-11-21 alex }
271 024588db 2007-11-21 alex /* "CHANINFO <chan> +<modes> :<topic>" */
272 024588db 2007-11-21 alex return IRC_WriteStrClient(Client, "CHANINFO %s +%s :%s",
273 024588db 2007-11-21 alex Channel_Name(Chan), modes, topic);
274 024588db 2007-11-21 alex }
275 024588db 2007-11-21 alex /* "CHANINFO <chan> +<modes> <key> <limit> :<topic>" */
276 024588db 2007-11-21 alex return IRC_WriteStrClient(Client, "CHANINFO %s +%s %s %lu :%s",
277 024588db 2007-11-21 alex Channel_Name(Chan), modes,
278 024588db 2007-11-21 alex has_k ? Channel_Key(Chan) : "*",
279 024588db 2007-11-21 alex has_l ? Channel_MaxUsers(Chan) : 0, topic);
280 024588db 2007-11-21 alex } /* Send_CHANINFO */
281 024588db 2007-11-21 alex
282 024588db 2007-11-21 alex #endif /* IRCPLUS */
283 024588db 2007-11-21 alex
284 024588db 2007-11-21 alex
285 024588db 2007-11-21 alex /**
286 024588db 2007-11-21 alex * Handle ENDOFMOTD (376) numeric and login remote server.
287 024588db 2007-11-21 alex * The peer is either an IRC server (no IRC+ protocol), or we got the
288 024588db 2007-11-21 alex * ENDOFMOTD numeric from an IRC+ server. We have to register the new server.
289 024588db 2007-11-21 alex */
290 024588db 2007-11-21 alex GLOBAL bool
291 024588db 2007-11-21 alex IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
292 024588db 2007-11-21 alex {
293 024588db 2007-11-21 alex int max_hops, i;
294 ec0b405d 2008-09-23 alex CLIENT *c;
295 024588db 2007-11-21 alex CHANNEL *chan;
296 024588db 2007-11-21 alex
297 024588db 2007-11-21 alex Client_SetType(Client, CLIENT_SERVER);
298 024588db 2007-11-21 alex
299 024588db 2007-11-21 alex Log(LOG_NOTICE | LOG_snotice,
300 024588db 2007-11-21 alex "Server \"%s\" registered (connection %d, 1 hop - direct link).",
301 024588db 2007-11-21 alex Client_ID(Client), Client_Conn(Client));
302 024588db 2007-11-21 alex
303 024588db 2007-11-21 alex /* Get highest hop count */
304 024588db 2007-11-21 alex max_hops = 0;
305 024588db 2007-11-21 alex c = Client_First();
306 024588db 2007-11-21 alex while (c) {
307 024588db 2007-11-21 alex if (Client_Hops(c) > max_hops)
308 024588db 2007-11-21 alex max_hops = Client_Hops(c);
309 024588db 2007-11-21 alex c = Client_Next(c);
310 024588db 2007-11-21 alex }
311 024588db 2007-11-21 alex
312 024588db 2007-11-21 alex /* Inform the new server about all other servers, and announce the
313 024588db 2007-11-21 alex * new server to all the already registered ones. Important: we have
314 024588db 2007-11-21 alex * to do this "in order" and can't introduce servers of which the
315 024588db 2007-11-21 alex * "toplevel server" isn't known already. */
316 024588db 2007-11-21 alex for (i = 0; i < (max_hops + 1); i++) {
317 024588db 2007-11-21 alex for (c = Client_First(); c != NULL; c = Client_Next(c)) {
318 024588db 2007-11-21 alex if (Client_Type(c) != CLIENT_SERVER)
319 024588db 2007-11-21 alex continue; /* not a server */
320 024588db 2007-11-21 alex if (Client_Hops(c) != i)
321 024588db 2007-11-21 alex continue; /* not actual "nesting level" */
322 024588db 2007-11-21 alex if (c == Client || c == Client_ThisServer())
323 024588db 2007-11-21 alex continue; /* that's us or the peer! */
324 024588db 2007-11-21 alex
325 024588db 2007-11-21 alex if (!Announce_Server(Client, c))
326 024588db 2007-11-21 alex return DISCONNECTED;
327 024588db 2007-11-21 alex }
328 024588db 2007-11-21 alex }
329 024588db 2007-11-21 alex
330 024588db 2007-11-21 alex /* Announce all the users to the new server */
331 024588db 2007-11-21 alex c = Client_First();
332 024588db 2007-11-21 alex while (c) {
333 d93030ad 2008-09-23 alex if (Client_Type(c) == CLIENT_USER ||
334 d93030ad 2008-09-23 alex Client_Type(c) == CLIENT_SERVICE) {
335 024588db 2007-11-21 alex if (!Announce_User(Client, c))
336 024588db 2007-11-21 alex return DISCONNECTED;
337 024588db 2007-11-21 alex }
338 024588db 2007-11-21 alex c = Client_Next(c);
339 024588db 2007-11-21 alex }
340 024588db 2007-11-21 alex
341 024588db 2007-11-21 alex /* Announce all channels to the new server */
342 024588db 2007-11-21 alex chan = Channel_First();
343 024588db 2007-11-21 alex while (chan) {
344 024588db 2007-11-21 alex #ifdef IRCPLUS
345 024588db 2007-11-21 alex /* Send CHANINFO if the peer supports it */
346 024588db 2007-11-21 alex if (strchr(Client_Flags(Client), 'C')) {
347 024588db 2007-11-21 alex if (!Send_CHANINFO(Client, chan))
348 024588db 2007-11-21 alex return DISCONNECTED;
349 024588db 2007-11-21 alex }
350 024588db 2007-11-21 alex #endif
351 024588db 2007-11-21 alex
352 ec0b405d 2008-09-23 alex if (!Announce_Channel(Client, chan))
353 ec0b405d 2008-09-23 alex return DISCONNECTED;
354 024588db 2007-11-21 alex
355 024588db 2007-11-21 alex /* Get next channel ... */
356 024588db 2007-11-21 alex chan = Channel_Next(chan);
357 024588db 2007-11-21 alex }
358 024588db 2007-11-21 alex
359 024588db 2007-11-21 alex #ifdef IRCPLUS
360 024588db 2007-11-21 alex if (strchr(Client_Flags(Client), 'L')) {
361 024588db 2007-11-21 alex LogDebug("Synchronizing INVITE- and BAN-lists ...");
362 024588db 2007-11-21 alex if (!Synchronize_Lists(Client))
363 024588db 2007-11-21 alex return DISCONNECTED;
364 024588db 2007-11-21 alex }
365 024588db 2007-11-21 alex #endif
366 024588db 2007-11-21 alex
367 024588db 2007-11-21 alex return CONNECTED;
368 024588db 2007-11-21 alex } /* IRC_Num_ENDOFMOTD */
369 024588db 2007-11-21 alex
370 024588db 2007-11-21 alex
371 024588db 2007-11-21 alex /**
372 024588db 2007-11-21 alex * Handle ISUPPORT (005) numeric.
373 024588db 2007-11-21 alex */
374 024588db 2007-11-21 alex GLOBAL bool
375 024588db 2007-11-21 alex IRC_Num_ISUPPORT(CLIENT * Client, REQUEST * Req)
376 024588db 2007-11-21 alex {
377 024588db 2007-11-21 alex int i;
378 024588db 2007-11-21 alex char *key, *value;
379 024588db 2007-11-21 alex
380 024588db 2007-11-21 alex for (i = 1; i < Req->argc - 1; i++) {
381 024588db 2007-11-21 alex key = Req->argv[i];
382 024588db 2007-11-21 alex value = strchr(key, '=');
383 024588db 2007-11-21 alex if (value)
384 024588db 2007-11-21 alex *value++ = '\0';
385 024588db 2007-11-21 alex else
386 024588db 2007-11-21 alex value = "";
387 024588db 2007-11-21 alex
388 024588db 2007-11-21 alex if (strcmp("NICKLEN", key) == 0) {
389 024588db 2007-11-21 alex if ((unsigned int)atol(value) == Conf_MaxNickLength - 1)
390 024588db 2007-11-21 alex continue;
391 024588db 2007-11-21 alex
392 024588db 2007-11-21 alex /* Nick name length settings are different! */
393 024588db 2007-11-21 alex Log(LOG_ERR,
394 024588db 2007-11-21 alex "Peer uses incompatible nick name length (%d/%d)! Disconnecting ...",
395 024588db 2007-11-21 alex Conf_MaxNickLength - 1, atoi(value));
396 024588db 2007-11-21 alex Conn_Close(Client_Conn(Client),
397 024588db 2007-11-21 alex "Incompatible nick name length",
398 024588db 2007-11-21 alex NULL, false);
399 024588db 2007-11-21 alex return DISCONNECTED;
400 024588db 2007-11-21 alex }
401 024588db 2007-11-21 alex }
402 024588db 2007-11-21 alex
403 024588db 2007-11-21 alex return CONNECTED;
404 024588db 2007-11-21 alex } /* IRC_Num_ISUPPORT */
405 024588db 2007-11-21 alex
406 024588db 2007-11-21 alex
407 024588db 2007-11-21 alex /* -eof- */