1 |
adx |
30 |
/* |
2 |
michael |
2916 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2916 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
adx |
30 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
michael |
4564 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
adx |
30 |
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
michael |
2916 |
/*! \file send.c |
23 |
|
|
* \brief Functions for sending messages. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
|
|
|
27 |
adx |
30 |
#include "stdinc.h" |
28 |
michael |
1011 |
#include "list.h" |
29 |
adx |
30 |
#include "send.h" |
30 |
|
|
#include "channel.h" |
31 |
|
|
#include "client.h" |
32 |
|
|
#include "dbuf.h" |
33 |
|
|
#include "irc_string.h" |
34 |
|
|
#include "ircd.h" |
35 |
|
|
#include "numeric.h" |
36 |
|
|
#include "fdlist.h" |
37 |
|
|
#include "s_bsd.h" |
38 |
michael |
3347 |
#include "server.h" |
39 |
michael |
1309 |
#include "conf.h" |
40 |
|
|
#include "log.h" |
41 |
adx |
30 |
#include "memory.h" |
42 |
|
|
#include "packet.h" |
43 |
|
|
|
44 |
|
|
|
45 |
michael |
4779 |
static uint64_t current_serial; |
46 |
adx |
30 |
|
47 |
|
|
|
48 |
|
|
/* send_format() |
49 |
|
|
* |
50 |
michael |
3120 |
* inputs |
51 |
|
|
* - buffer |
52 |
adx |
30 |
* - format pattern to use |
53 |
|
|
* - var args |
54 |
|
|
* output - number of bytes formatted output |
55 |
|
|
* side effects - modifies sendbuf |
56 |
|
|
*/ |
57 |
michael |
3107 |
static void |
58 |
|
|
send_format(struct dbuf_block *buffer, const char *pattern, va_list args) |
59 |
adx |
30 |
{ |
60 |
|
|
/* |
61 |
|
|
* from rfc1459 |
62 |
|
|
* |
63 |
|
|
* IRC messages are always lines of characters terminated with a CR-LF |
64 |
|
|
* (Carriage Return - Line Feed) pair, and these messages shall not |
65 |
michael |
2638 |
* exceed 512 characters in length, counting all characters |
66 |
adx |
30 |
* including the trailing CR-LF. |
67 |
|
|
* Thus, there are 510 characters maximum allowed |
68 |
|
|
* for the command and its parameters. There is no provision for |
69 |
|
|
* continuation message lines. See section 7 for more details about |
70 |
|
|
* current implementations. |
71 |
|
|
*/ |
72 |
michael |
3107 |
dbuf_put_args(buffer, pattern, args); |
73 |
adx |
30 |
|
74 |
michael |
4621 |
if (buffer->size > IRCD_BUFSIZE - 2) |
75 |
|
|
buffer->size = IRCD_BUFSIZE - 2; |
76 |
michael |
3107 |
|
77 |
|
|
buffer->data[buffer->size++] = '\r'; |
78 |
|
|
buffer->data[buffer->size++] = '\n'; |
79 |
adx |
30 |
} |
80 |
|
|
|
81 |
|
|
/* |
82 |
|
|
** send_message |
83 |
|
|
** Internal utility which appends given buffer to the sockets |
84 |
|
|
** sendq. |
85 |
|
|
*/ |
86 |
|
|
static void |
87 |
michael |
3107 |
send_message(struct Client *to, struct dbuf_block *buf) |
88 |
adx |
30 |
{ |
89 |
michael |
439 |
assert(!IsMe(to)); |
90 |
michael |
438 |
assert(to != &me); |
91 |
michael |
4802 |
assert(MyConnect(to)); |
92 |
adx |
30 |
|
93 |
michael |
4589 |
if (dbuf_length(&to->connection->buf_sendq) + buf->size > get_sendq(&to->connection->confs)) |
94 |
adx |
30 |
{ |
95 |
|
|
if (IsServer(to)) |
96 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
97 |
michael |
1761 |
"Max SendQ limit exceeded for %s: %lu > %u", |
98 |
adx |
30 |
get_client_name(to, HIDE_IP), |
99 |
michael |
4589 |
(unsigned long)(dbuf_length(&to->connection->buf_sendq) + buf->size), |
100 |
|
|
get_sendq(&to->connection->confs)); |
101 |
adx |
30 |
if (IsClient(to)) |
102 |
|
|
SetSendQExceeded(to); |
103 |
michael |
3215 |
|
104 |
adx |
30 |
dead_link_on_write(to, 0); |
105 |
|
|
return; |
106 |
|
|
} |
107 |
michael |
2638 |
|
108 |
michael |
4589 |
dbuf_add(&to->connection->buf_sendq, buf); |
109 |
adx |
30 |
|
110 |
|
|
/* |
111 |
michael |
3215 |
* Update statistics. The following is slightly incorrect because |
112 |
|
|
* it counts messages even if queued, but bytes only really sent. |
113 |
|
|
* Queued bytes get updated in send_queued_write(). |
114 |
adx |
30 |
*/ |
115 |
michael |
4589 |
++to->connection->send.messages; |
116 |
|
|
++me.connection->send.messages; |
117 |
adx |
30 |
|
118 |
michael |
2881 |
send_queued_write(to); |
119 |
adx |
30 |
} |
120 |
|
|
|
121 |
|
|
/* send_message_remote() |
122 |
|
|
* |
123 |
|
|
* inputs - pointer to client from message is being sent |
124 |
|
|
* - pointer to client to send to |
125 |
michael |
3120 |
* - pointer to buffer |
126 |
adx |
30 |
* output - none |
127 |
|
|
* side effects - Despite the function name, this only sends to directly |
128 |
|
|
* connected clients. |
129 |
michael |
2916 |
* |
130 |
adx |
30 |
*/ |
131 |
|
|
static void |
132 |
michael |
3107 |
send_message_remote(struct Client *to, struct Client *from, struct dbuf_block *buf) |
133 |
adx |
30 |
{ |
134 |
michael |
4802 |
assert(MyConnect(to)); |
135 |
michael |
2793 |
|
136 |
adx |
30 |
/* Optimize by checking if (from && to) before everything */ |
137 |
|
|
/* we set to->from up there.. */ |
138 |
|
|
|
139 |
|
|
if (!MyClient(from) && IsClient(to) && (to == from->from)) |
140 |
|
|
{ |
141 |
|
|
if (IsServer(from)) |
142 |
|
|
{ |
143 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
144 |
adx |
30 |
"Send message to %s [%s] dropped from %s(Fake Dir)", |
145 |
|
|
to->name, to->from->name, from->name); |
146 |
|
|
return; |
147 |
|
|
} |
148 |
|
|
|
149 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
150 |
adx |
30 |
"Ghosted: %s[%s@%s] from %s[%s@%s] (%s)", |
151 |
|
|
to->name, to->username, to->host, |
152 |
|
|
from->name, from->username, from->host, |
153 |
|
|
to->from->name); |
154 |
|
|
|
155 |
michael |
3135 |
sendto_server(NULL, NOCAPS, NOCAPS, |
156 |
adx |
30 |
":%s KILL %s :%s (%s[%s@%s] Ghosted %s)", |
157 |
michael |
3174 |
me.id, to->id, me.name, to->name, |
158 |
adx |
30 |
to->username, to->host, to->from->name); |
159 |
|
|
|
160 |
michael |
1219 |
AddFlag(to, FLAGS_KILLED); |
161 |
adx |
30 |
|
162 |
|
|
if (IsClient(from)) |
163 |
michael |
3109 |
sendto_one_numeric(from, &me, ERR_GHOSTEDCLIENT, to->name, |
164 |
|
|
to->username, to->host, to->from); |
165 |
adx |
30 |
|
166 |
michael |
3171 |
exit_client(to, "Ghosted client"); |
167 |
adx |
30 |
return; |
168 |
michael |
2638 |
} |
169 |
adx |
30 |
|
170 |
michael |
3107 |
send_message(to, buf); |
171 |
adx |
30 |
} |
172 |
|
|
|
173 |
|
|
/* |
174 |
|
|
** sendq_unblocked |
175 |
|
|
** Called when a socket is ready for writing. |
176 |
|
|
*/ |
177 |
|
|
void |
178 |
michael |
4462 |
sendq_unblocked(fde_t *fd, void *data) |
179 |
adx |
30 |
{ |
180 |
michael |
4462 |
struct Client *client_p = data; |
181 |
michael |
4589 |
assert(fd == &client_p->connection->fd); |
182 |
michael |
3312 |
|
183 |
|
|
DelFlag(client_p, FLAGS_BLOCKED); |
184 |
michael |
2881 |
send_queued_write(client_p); |
185 |
adx |
30 |
} |
186 |
|
|
|
187 |
|
|
/* |
188 |
|
|
** send_queued_write |
189 |
|
|
** This is called when there is a chance that some output would |
190 |
|
|
** be possible. This attempts to empty the send queue as far as |
191 |
|
|
** possible, and then if any data is left, a write is rescheduled. |
192 |
|
|
*/ |
193 |
|
|
void |
194 |
|
|
send_queued_write(struct Client *to) |
195 |
|
|
{ |
196 |
michael |
3311 |
int retlen = 0; |
197 |
adx |
30 |
|
198 |
|
|
/* |
199 |
michael |
3311 |
** Once socket is marked dead, we cannot start writing to it, |
200 |
|
|
** even if the error is removed... |
201 |
adx |
30 |
*/ |
202 |
michael |
3312 |
if (IsDead(to) || HasFlag(to, FLAGS_BLOCKED)) |
203 |
michael |
3311 |
return; /* no use calling send() now */ |
204 |
adx |
30 |
|
205 |
michael |
3311 |
/* Next, lets try to write some data */ |
206 |
michael |
4589 |
if (dbuf_length(&to->connection->buf_sendq)) |
207 |
adx |
30 |
{ |
208 |
michael |
3311 |
do |
209 |
|
|
{ |
210 |
michael |
4589 |
struct dbuf_block *first = to->connection->buf_sendq.blocks.head->data; |
211 |
adx |
30 |
|
212 |
michael |
3311 |
#ifdef HAVE_LIBCRYPTO |
213 |
michael |
4589 |
if (to->connection->fd.ssl) |
214 |
michael |
3311 |
{ |
215 |
michael |
4589 |
retlen = SSL_write(to->connection->fd.ssl, first->data + to->connection->buf_sendq.pos, first->size - to->connection->buf_sendq.pos); |
216 |
michael |
3241 |
|
217 |
michael |
3311 |
/* translate openssl error codes, sigh */ |
218 |
|
|
if (retlen < 0) |
219 |
|
|
{ |
220 |
michael |
4589 |
switch (SSL_get_error(to->connection->fd.ssl, retlen)) |
221 |
michael |
3311 |
{ |
222 |
|
|
case SSL_ERROR_WANT_READ: |
223 |
|
|
return; /* retry later, don't register for write events */ |
224 |
|
|
case SSL_ERROR_WANT_WRITE: |
225 |
|
|
errno = EWOULDBLOCK; |
226 |
|
|
case SSL_ERROR_SYSCALL: |
227 |
|
|
break; |
228 |
|
|
case SSL_ERROR_SSL: |
229 |
|
|
if (errno == EAGAIN) |
230 |
|
|
break; |
231 |
|
|
default: |
232 |
|
|
retlen = errno = 0; /* either an SSL-specific error or EOF */ |
233 |
|
|
} |
234 |
|
|
} |
235 |
|
|
} |
236 |
|
|
else |
237 |
|
|
#endif |
238 |
michael |
4589 |
retlen = send(to->connection->fd.fd, first->data + to->connection->buf_sendq.pos, first->size - to->connection->buf_sendq.pos, 0); |
239 |
michael |
3241 |
|
240 |
michael |
3311 |
if (retlen <= 0) |
241 |
|
|
break; |
242 |
michael |
3241 |
|
243 |
michael |
4589 |
dbuf_delete(&to->connection->buf_sendq, retlen); |
244 |
adx |
30 |
|
245 |
michael |
3311 |
/* We have some data written .. update counters */ |
246 |
michael |
4589 |
to->connection->send.bytes += retlen; |
247 |
|
|
me.connection->send.bytes += retlen; |
248 |
|
|
} while (dbuf_length(&to->connection->buf_sendq)); |
249 |
adx |
30 |
|
250 |
michael |
3335 |
if (retlen < 0 && ignoreErrno(errno)) |
251 |
michael |
3311 |
{ |
252 |
michael |
3312 |
AddFlag(to, FLAGS_BLOCKED); |
253 |
michael |
3335 |
|
254 |
michael |
3311 |
/* we have a non-fatal error, reschedule a write */ |
255 |
michael |
4589 |
comm_setselect(&to->connection->fd, COMM_SELECT_WRITE, |
256 |
michael |
4462 |
sendq_unblocked, to, 0); |
257 |
michael |
3311 |
} |
258 |
|
|
else if (retlen <= 0) |
259 |
|
|
{ |
260 |
|
|
dead_link_on_write(to, errno); |
261 |
|
|
return; |
262 |
|
|
} |
263 |
adx |
30 |
} |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
/* send_queued_all() |
267 |
|
|
* |
268 |
|
|
* input - NONE |
269 |
|
|
* output - NONE |
270 |
|
|
* side effects - try to flush sendq of each client |
271 |
|
|
*/ |
272 |
|
|
void |
273 |
|
|
send_queued_all(void) |
274 |
|
|
{ |
275 |
|
|
dlink_node *ptr; |
276 |
|
|
|
277 |
|
|
/* Servers are processed first, mainly because this can generate |
278 |
|
|
* a notice to opers, which is to be delivered by this function. |
279 |
|
|
*/ |
280 |
michael |
4212 |
DLINK_FOREACH(ptr, local_server_list.head) |
281 |
michael |
2638 |
send_queued_write(ptr->data); |
282 |
adx |
30 |
|
283 |
|
|
DLINK_FOREACH(ptr, unknown_list.head) |
284 |
michael |
2638 |
send_queued_write(ptr->data); |
285 |
adx |
30 |
|
286 |
|
|
DLINK_FOREACH(ptr, local_client_list.head) |
287 |
michael |
2638 |
send_queued_write(ptr->data); |
288 |
adx |
30 |
|
289 |
|
|
/* NOTE: This can still put clients on aborted_list; unfortunately, |
290 |
|
|
* exit_aborted_clients takes precedence over send_queued_all, |
291 |
|
|
* because exiting clients can generate server/oper traffic. |
292 |
|
|
* The easiest approach is dealing with aborted clients in the next I/O lap. |
293 |
|
|
* -adx |
294 |
|
|
*/ |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
/* sendto_one() |
298 |
|
|
* |
299 |
|
|
* inputs - pointer to destination client |
300 |
|
|
* - var args message |
301 |
|
|
* output - NONE |
302 |
|
|
* side effects - send message to single client |
303 |
|
|
*/ |
304 |
|
|
void |
305 |
|
|
sendto_one(struct Client *to, const char *pattern, ...) |
306 |
|
|
{ |
307 |
|
|
va_list args; |
308 |
michael |
3189 |
struct dbuf_block *buffer = NULL; |
309 |
adx |
30 |
|
310 |
michael |
3189 |
if (IsDead(to->from)) |
311 |
michael |
3107 |
return; /* This socket has already been marked as dead */ |
312 |
adx |
30 |
|
313 |
michael |
3107 |
buffer = dbuf_alloc(); |
314 |
|
|
|
315 |
adx |
30 |
va_start(args, pattern); |
316 |
michael |
3107 |
send_format(buffer, pattern, args); |
317 |
adx |
30 |
va_end(args); |
318 |
|
|
|
319 |
michael |
3189 |
send_message(to->from, buffer); |
320 |
michael |
3107 |
|
321 |
|
|
dbuf_ref_free(buffer); |
322 |
adx |
30 |
} |
323 |
|
|
|
324 |
michael |
3109 |
void |
325 |
|
|
sendto_one_numeric(struct Client *to, struct Client *from, enum irc_numerics numeric, ...) |
326 |
|
|
{ |
327 |
michael |
3189 |
struct dbuf_block *buffer = NULL; |
328 |
michael |
3574 |
const char *dest = NULL, *numstr = NULL; |
329 |
michael |
3109 |
va_list args; |
330 |
|
|
|
331 |
michael |
3189 |
if (IsDead(to->from)) |
332 |
michael |
3109 |
return; |
333 |
|
|
|
334 |
|
|
dest = ID_or_name(to, to); |
335 |
michael |
3335 |
|
336 |
michael |
3109 |
if (EmptyString(dest)) |
337 |
|
|
dest = "*"; |
338 |
|
|
|
339 |
|
|
buffer = dbuf_alloc(); |
340 |
|
|
|
341 |
michael |
3574 |
dbuf_put_fmt(buffer, ":%s %03d %s ", ID_or_name(from, to), numeric & ~SND_EXPLICIT, dest); |
342 |
michael |
3109 |
|
343 |
|
|
va_start(args, numeric); |
344 |
michael |
3574 |
|
345 |
|
|
if (numeric & SND_EXPLICIT) |
346 |
|
|
numstr = va_arg(args, const char *); |
347 |
|
|
else |
348 |
|
|
numstr = numeric_form(numeric); |
349 |
michael |
4790 |
|
350 |
michael |
3574 |
send_format(buffer, numstr, args); |
351 |
michael |
3109 |
va_end(args); |
352 |
|
|
|
353 |
michael |
3189 |
send_message(to->from, buffer); |
354 |
michael |
3109 |
|
355 |
|
|
dbuf_ref_free(buffer); |
356 |
|
|
} |
357 |
|
|
|
358 |
michael |
3110 |
void |
359 |
|
|
sendto_one_notice(struct Client *to, struct Client *from, const char *pattern, ...) |
360 |
|
|
{ |
361 |
michael |
3189 |
struct dbuf_block *buffer = NULL; |
362 |
|
|
const char *dest = NULL; |
363 |
michael |
3110 |
va_list args; |
364 |
|
|
|
365 |
michael |
3189 |
if (IsDead(to->from)) |
366 |
michael |
3110 |
return; |
367 |
|
|
|
368 |
|
|
dest = ID_or_name(to, to); |
369 |
michael |
3335 |
|
370 |
michael |
3110 |
if (EmptyString(dest)) |
371 |
|
|
dest = "*"; |
372 |
|
|
|
373 |
|
|
buffer = dbuf_alloc(); |
374 |
|
|
|
375 |
michael |
3113 |
dbuf_put_fmt(buffer, ":%s NOTICE %s ", ID_or_name(from, to), dest); |
376 |
michael |
3110 |
|
377 |
|
|
va_start(args, pattern); |
378 |
|
|
send_format(buffer, pattern, args); |
379 |
|
|
va_end(args); |
380 |
|
|
|
381 |
michael |
3189 |
send_message(to->from, buffer); |
382 |
michael |
3110 |
|
383 |
|
|
dbuf_ref_free(buffer); |
384 |
|
|
} |
385 |
|
|
|
386 |
adx |
30 |
/* sendto_channel_butone() |
387 |
|
|
* |
388 |
|
|
* inputs - pointer to client(server) to NOT send message to |
389 |
|
|
* - pointer to client that is sending this message |
390 |
|
|
* - pointer to channel being sent to |
391 |
|
|
* - vargs message |
392 |
|
|
* output - NONE |
393 |
|
|
* side effects - message as given is sent to given channel members. |
394 |
|
|
* |
395 |
|
|
* WARNING - +D clients are ignored |
396 |
|
|
*/ |
397 |
|
|
void |
398 |
|
|
sendto_channel_butone(struct Client *one, struct Client *from, |
399 |
michael |
1479 |
struct Channel *chptr, unsigned int type, |
400 |
adx |
30 |
const char *pattern, ...) |
401 |
|
|
{ |
402 |
michael |
3136 |
va_list alocal, aremote; |
403 |
|
|
struct dbuf_block *local_buf, *remote_buf; |
404 |
michael |
1078 |
dlink_node *ptr = NULL, *ptr_next = NULL; |
405 |
adx |
30 |
|
406 |
michael |
3136 |
local_buf = dbuf_alloc(), remote_buf = dbuf_alloc(); |
407 |
michael |
3107 |
|
408 |
michael |
3804 |
if (IsClient(from)) |
409 |
|
|
dbuf_put_fmt(local_buf, ":%s!%s@%s ", from->name, from->username, from->host); |
410 |
|
|
else |
411 |
michael |
3113 |
dbuf_put_fmt(local_buf, ":%s ", from->name); |
412 |
adx |
30 |
|
413 |
michael |
3186 |
dbuf_put_fmt(remote_buf, ":%s ", from->id); |
414 |
michael |
3107 |
|
415 |
adx |
285 |
va_start(alocal, pattern); |
416 |
|
|
va_start(aremote, pattern); |
417 |
michael |
3107 |
send_format(local_buf, pattern, alocal); |
418 |
|
|
send_format(remote_buf, pattern, aremote); |
419 |
michael |
3136 |
|
420 |
adx |
285 |
va_end(aremote); |
421 |
|
|
va_end(alocal); |
422 |
adx |
30 |
|
423 |
|
|
++current_serial; |
424 |
|
|
|
425 |
|
|
DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->members.head) |
426 |
|
|
{ |
427 |
michael |
1479 |
struct Membership *ms = ptr->data; |
428 |
|
|
struct Client *target_p = ms->client_p; |
429 |
adx |
30 |
|
430 |
michael |
1078 |
assert(IsClient(target_p)); |
431 |
|
|
|
432 |
michael |
3164 |
if (IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF) || |
433 |
|
|
(one && target_p->from == one->from)) |
434 |
adx |
30 |
continue; |
435 |
|
|
|
436 |
michael |
3243 |
if (type && (ms->flags & type) == 0) |
437 |
michael |
1479 |
continue; |
438 |
|
|
|
439 |
michael |
1078 |
if (MyConnect(target_p)) |
440 |
michael |
3103 |
send_message(target_p, local_buf); |
441 |
michael |
4589 |
else if (target_p->from->connection->serial != current_serial) |
442 |
michael |
3103 |
send_message_remote(target_p->from, from, remote_buf); |
443 |
michael |
4589 |
target_p->from->connection->serial = current_serial; |
444 |
adx |
30 |
} |
445 |
michael |
3107 |
|
446 |
|
|
dbuf_ref_free(local_buf); |
447 |
|
|
dbuf_ref_free(remote_buf); |
448 |
adx |
30 |
} |
449 |
|
|
|
450 |
|
|
/* sendto_server() |
451 |
michael |
2916 |
* |
452 |
adx |
30 |
* inputs - pointer to client to NOT send to |
453 |
db |
939 |
* - pointer to channel |
454 |
adx |
30 |
* - caps or'd together which must ALL be present |
455 |
|
|
* - caps or'd together which must ALL NOT be present |
456 |
|
|
* - printf style format string |
457 |
|
|
* - args to format string |
458 |
|
|
* output - NONE |
459 |
|
|
* side effects - Send a message to all connected servers, except the |
460 |
|
|
* client 'one' (if non-NULL), as long as the servers |
461 |
|
|
* support ALL capabs in 'caps', and NO capabs in 'nocaps'. |
462 |
michael |
2916 |
* |
463 |
adx |
30 |
* This function was written in an attempt to merge together the other |
464 |
|
|
* billion sendto_*serv*() functions, which sprung up with capabs, |
465 |
|
|
* lazylinks, uids, etc. |
466 |
|
|
* -davidt |
467 |
|
|
*/ |
468 |
michael |
2638 |
void |
469 |
michael |
1474 |
sendto_server(struct Client *one, |
470 |
michael |
1015 |
const unsigned int caps, |
471 |
|
|
const unsigned int nocaps, |
472 |
adx |
30 |
const char *format, ...) |
473 |
|
|
{ |
474 |
|
|
va_list args; |
475 |
michael |
885 |
dlink_node *ptr = NULL; |
476 |
michael |
3107 |
struct dbuf_block *buffer; |
477 |
adx |
30 |
|
478 |
michael |
3107 |
buffer = dbuf_alloc(); |
479 |
|
|
|
480 |
adx |
30 |
va_start(args, format); |
481 |
michael |
3107 |
send_format(buffer, format, args); |
482 |
adx |
30 |
va_end(args); |
483 |
|
|
|
484 |
michael |
4212 |
DLINK_FOREACH(ptr, local_server_list.head) |
485 |
adx |
30 |
{ |
486 |
michael |
885 |
struct Client *client_p = ptr->data; |
487 |
adx |
30 |
|
488 |
|
|
/* If dead already skip */ |
489 |
|
|
if (IsDead(client_p)) |
490 |
|
|
continue; |
491 |
|
|
/* check against 'one' */ |
492 |
michael |
3243 |
if (one && (client_p == one->from)) |
493 |
adx |
30 |
continue; |
494 |
|
|
/* check we have required capabs */ |
495 |
michael |
4589 |
if ((client_p->connection->caps & caps) != caps) |
496 |
adx |
30 |
continue; |
497 |
|
|
/* check we don't have any forbidden capabs */ |
498 |
michael |
4589 |
if ((client_p->connection->caps & nocaps)) |
499 |
adx |
30 |
continue; |
500 |
|
|
|
501 |
michael |
3107 |
send_message(client_p, buffer); |
502 |
adx |
30 |
} |
503 |
michael |
3107 |
|
504 |
|
|
dbuf_ref_free(buffer); |
505 |
adx |
30 |
} |
506 |
|
|
|
507 |
|
|
/* sendto_common_channels_local() |
508 |
|
|
* |
509 |
|
|
* inputs - pointer to client |
510 |
|
|
* - pattern to send |
511 |
|
|
* output - NONE |
512 |
|
|
* side effects - Sends a message to all people on local server who are |
513 |
michael |
2916 |
* in same channel with user. |
514 |
adx |
30 |
* used by m_nick.c and exit_one_client. |
515 |
|
|
*/ |
516 |
|
|
void |
517 |
michael |
1734 |
sendto_common_channels_local(struct Client *user, int touser, unsigned int cap, |
518 |
adx |
30 |
const char *pattern, ...) |
519 |
|
|
{ |
520 |
|
|
va_list args; |
521 |
|
|
dlink_node *uptr; |
522 |
|
|
dlink_node *cptr; |
523 |
|
|
struct Channel *chptr; |
524 |
|
|
struct Membership *ms; |
525 |
|
|
struct Client *target_p; |
526 |
michael |
3107 |
struct dbuf_block *buffer; |
527 |
adx |
30 |
|
528 |
michael |
3107 |
buffer = dbuf_alloc(); |
529 |
|
|
|
530 |
adx |
30 |
va_start(args, pattern); |
531 |
michael |
3107 |
send_format(buffer, pattern, args); |
532 |
adx |
30 |
va_end(args); |
533 |
|
|
|
534 |
|
|
++current_serial; |
535 |
|
|
|
536 |
|
|
DLINK_FOREACH(cptr, user->channel.head) |
537 |
|
|
{ |
538 |
michael |
2638 |
chptr = ((struct Membership *)cptr->data)->chptr; |
539 |
adx |
30 |
|
540 |
michael |
4171 |
DLINK_FOREACH(uptr, chptr->locmembers.head) |
541 |
adx |
30 |
{ |
542 |
|
|
ms = uptr->data; |
543 |
|
|
target_p = ms->client_p; |
544 |
|
|
|
545 |
michael |
4171 |
if (target_p == user || IsDefunct(target_p) || |
546 |
michael |
4589 |
target_p->connection->serial == current_serial) |
547 |
adx |
30 |
continue; |
548 |
|
|
|
549 |
michael |
1734 |
if (HasCap(target_p, cap) != cap) |
550 |
|
|
continue; |
551 |
|
|
|
552 |
michael |
4589 |
target_p->connection->serial = current_serial; |
553 |
michael |
3107 |
send_message(target_p, buffer); |
554 |
adx |
30 |
} |
555 |
|
|
} |
556 |
|
|
|
557 |
|
|
if (touser && MyConnect(user) && !IsDead(user) && |
558 |
michael |
4589 |
user->connection->serial != current_serial) |
559 |
michael |
1844 |
if (HasCap(user, cap) == cap) |
560 |
michael |
3107 |
send_message(user, buffer); |
561 |
|
|
|
562 |
|
|
dbuf_ref_free(buffer); |
563 |
adx |
30 |
} |
564 |
|
|
|
565 |
|
|
/* sendto_channel_local() |
566 |
|
|
* |
567 |
|
|
* inputs - member status mask, e.g. CHFL_CHANOP | CHFL_VOICE |
568 |
|
|
* - pointer to channel to send to |
569 |
|
|
* - var args pattern |
570 |
|
|
* output - NONE |
571 |
|
|
* side effects - Send a message to all members of a channel that are |
572 |
|
|
* locally connected to this server. |
573 |
|
|
*/ |
574 |
|
|
void |
575 |
michael |
4794 |
sendto_channel_local(unsigned int type, struct Channel *chptr, |
576 |
adx |
30 |
const char *pattern, ...) |
577 |
|
|
{ |
578 |
|
|
va_list args; |
579 |
michael |
2638 |
dlink_node *ptr = NULL; |
580 |
michael |
3107 |
struct dbuf_block *buffer; |
581 |
adx |
30 |
|
582 |
michael |
3107 |
buffer = dbuf_alloc(); |
583 |
|
|
|
584 |
adx |
30 |
va_start(args, pattern); |
585 |
michael |
3107 |
send_format(buffer, pattern, args); |
586 |
adx |
30 |
va_end(args); |
587 |
|
|
|
588 |
michael |
4171 |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
589 |
adx |
30 |
{ |
590 |
michael |
2638 |
struct Membership *ms = ptr->data; |
591 |
|
|
struct Client *target_p = ms->client_p; |
592 |
adx |
30 |
|
593 |
michael |
3243 |
if (type && (ms->flags & type) == 0) |
594 |
adx |
30 |
continue; |
595 |
|
|
|
596 |
michael |
4794 |
if (IsDefunct(target_p)) |
597 |
adx |
30 |
continue; |
598 |
|
|
|
599 |
michael |
3107 |
send_message(target_p, buffer); |
600 |
adx |
30 |
} |
601 |
michael |
3107 |
|
602 |
|
|
dbuf_ref_free(buffer); |
603 |
adx |
30 |
} |
604 |
|
|
|
605 |
|
|
/* sendto_channel_local_butone() |
606 |
|
|
* |
607 |
|
|
* inputs - pointer to client to NOT send message to |
608 |
|
|
* - member status mask, e.g. CHFL_CHANOP | CHFL_VOICE |
609 |
|
|
* - pointer to channel to send to |
610 |
|
|
* - var args pattern |
611 |
|
|
* output - NONE |
612 |
|
|
* side effects - Send a message to all members of a channel that are |
613 |
|
|
* locally connected to this server except one. |
614 |
|
|
* |
615 |
|
|
* WARNING - +D clients are omitted |
616 |
|
|
*/ |
617 |
michael |
2638 |
void |
618 |
michael |
4793 |
sendto_channel_local_butone(struct Client *one, unsigned int poscap, unsigned int negcap, |
619 |
michael |
2638 |
struct Channel *chptr, const char *pattern, ...) |
620 |
adx |
30 |
{ |
621 |
|
|
va_list args; |
622 |
michael |
2638 |
dlink_node *ptr = NULL; |
623 |
michael |
4793 |
struct dbuf_block *buffer = dbuf_alloc(); |
624 |
adx |
30 |
|
625 |
michael |
2638 |
va_start(args, pattern); |
626 |
michael |
3107 |
send_format(buffer, pattern, args); |
627 |
adx |
30 |
va_end(args); |
628 |
|
|
|
629 |
michael |
4171 |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
630 |
michael |
2638 |
{ |
631 |
|
|
struct Membership *ms = ptr->data; |
632 |
|
|
struct Client *target_p = ms->client_p; |
633 |
adx |
30 |
|
634 |
michael |
4171 |
if (one && target_p == one->from) |
635 |
adx |
30 |
continue; |
636 |
michael |
1734 |
|
637 |
michael |
4794 |
if (IsDefunct(target_p)) |
638 |
michael |
3170 |
continue; |
639 |
|
|
|
640 |
michael |
4793 |
if (poscap && HasCap(target_p, poscap) != poscap) |
641 |
michael |
2638 |
continue; |
642 |
|
|
|
643 |
michael |
4793 |
if (negcap && HasCap(target_p, negcap)) |
644 |
|
|
continue; |
645 |
|
|
|
646 |
michael |
3107 |
send_message(target_p, buffer); |
647 |
adx |
30 |
} |
648 |
michael |
3107 |
|
649 |
|
|
dbuf_ref_free(buffer); |
650 |
adx |
30 |
} |
651 |
|
|
|
652 |
|
|
/* |
653 |
|
|
** match_it() and sendto_match_butone() ARE only used |
654 |
|
|
** to send a msg to all ppl on servers/hosts that match a specified mask |
655 |
|
|
** (used for enhanced PRIVMSGs) for opers |
656 |
|
|
** |
657 |
|
|
** addition -- Armin, 8jun90 (gruner@informatik.tu-muenchen.de) |
658 |
|
|
** |
659 |
|
|
*/ |
660 |
|
|
|
661 |
|
|
/* match_it() |
662 |
|
|
* |
663 |
|
|
* inputs - client pointer to match on |
664 |
|
|
* - actual mask to match |
665 |
|
|
* - what to match on, HOST or SERVER |
666 |
|
|
* output - 1 or 0 if match or not |
667 |
|
|
* side effects - NONE |
668 |
|
|
*/ |
669 |
|
|
static int |
670 |
michael |
2867 |
match_it(const struct Client *one, const char *mask, unsigned int what) |
671 |
adx |
30 |
{ |
672 |
|
|
if (what == MATCH_HOST) |
673 |
michael |
1652 |
return !match(mask, one->host); |
674 |
adx |
30 |
|
675 |
michael |
1652 |
return !match(mask, one->servptr->name); |
676 |
adx |
30 |
} |
677 |
|
|
|
678 |
|
|
/* sendto_match_butone() |
679 |
|
|
* |
680 |
|
|
* Send to all clients which match the mask in a way defined on 'what'; |
681 |
|
|
* either by user hostname or user servername. |
682 |
|
|
* |
683 |
|
|
* ugh. ONLY used by m_message.c to send an "oper magic" message. ugh. |
684 |
|
|
*/ |
685 |
|
|
void |
686 |
michael |
3170 |
sendto_match_butone(struct Client *one, struct Client *from, const char *mask, |
687 |
adx |
30 |
int what, const char *pattern, ...) |
688 |
|
|
{ |
689 |
adx |
285 |
va_list alocal, aremote; |
690 |
michael |
3107 |
dlink_node *ptr = NULL, *ptr_next = NULL; |
691 |
|
|
struct dbuf_block *local_buf, *remote_buf; |
692 |
adx |
30 |
|
693 |
michael |
3107 |
local_buf = dbuf_alloc(), remote_buf = dbuf_alloc(); |
694 |
|
|
|
695 |
michael |
3113 |
dbuf_put_fmt(local_buf, ":%s!%s@%s ", from->name, from->username, from->host); |
696 |
michael |
3186 |
dbuf_put_fmt(remote_buf, ":%s ", from->id); |
697 |
michael |
3107 |
|
698 |
adx |
285 |
va_start(alocal, pattern); |
699 |
|
|
va_start(aremote, pattern); |
700 |
michael |
3107 |
send_format(local_buf, pattern, alocal); |
701 |
|
|
send_format(remote_buf, pattern, aremote); |
702 |
adx |
285 |
va_end(aremote); |
703 |
|
|
va_end(alocal); |
704 |
adx |
30 |
|
705 |
|
|
/* scan the local clients */ |
706 |
|
|
DLINK_FOREACH(ptr, local_client_list.head) |
707 |
|
|
{ |
708 |
michael |
3107 |
struct Client *client_p = ptr->data; |
709 |
adx |
30 |
|
710 |
michael |
3174 |
if ((!one || client_p != one->from) && !IsDefunct(client_p) && |
711 |
adx |
30 |
match_it(client_p, mask, what)) |
712 |
michael |
3107 |
send_message(client_p, local_buf); |
713 |
adx |
30 |
} |
714 |
|
|
|
715 |
|
|
/* Now scan servers */ |
716 |
michael |
4212 |
DLINK_FOREACH_SAFE(ptr, ptr_next, local_server_list.head) |
717 |
adx |
30 |
{ |
718 |
michael |
3107 |
struct Client *client_p = ptr->data; |
719 |
adx |
30 |
|
720 |
|
|
/* |
721 |
|
|
* The old code looped through every client on the |
722 |
|
|
* network for each server to check if the |
723 |
|
|
* server (client_p) has at least 1 client matching |
724 |
|
|
* the mask, using something like: |
725 |
|
|
* |
726 |
|
|
* for (target_p = GlobalClientList; target_p; target_p = target_p->next) |
727 |
|
|
* if (IsRegisteredUser(target_p) && |
728 |
|
|
* match_it(target_p, mask, what) && |
729 |
|
|
* (target_p->from == client_p)) |
730 |
|
|
* vsendto_prefix_one(client_p, from, pattern, args); |
731 |
|
|
* |
732 |
|
|
* That way, we wouldn't send the message to |
733 |
|
|
* a server who didn't have a matching client. |
734 |
|
|
* However, on a network such as EFNet, that |
735 |
|
|
* code would have looped through about 50 |
736 |
|
|
* servers, and in each loop, loop through |
737 |
|
|
* about 50k clients as well, calling match() |
738 |
|
|
* in each nested loop. That is a very bad |
739 |
|
|
* thing cpu wise - just send the message |
740 |
|
|
* to every connected server and let that |
741 |
|
|
* server deal with it. |
742 |
|
|
* -wnder |
743 |
|
|
*/ |
744 |
michael |
3170 |
if ((!one || client_p != one->from) && !IsDefunct(client_p)) |
745 |
michael |
3107 |
send_message_remote(client_p, from, remote_buf); |
746 |
adx |
30 |
} |
747 |
michael |
3107 |
|
748 |
|
|
dbuf_ref_free(local_buf); |
749 |
|
|
dbuf_ref_free(remote_buf); |
750 |
adx |
30 |
} |
751 |
|
|
|
752 |
|
|
/* sendto_match_servs() |
753 |
|
|
* |
754 |
|
|
* inputs - source client |
755 |
|
|
* - mask to send to |
756 |
|
|
* - capab needed |
757 |
|
|
* - data |
758 |
|
|
* outputs - none |
759 |
|
|
* side effects - data sent to servers matching with capab |
760 |
|
|
*/ |
761 |
|
|
void |
762 |
michael |
2543 |
sendto_match_servs(struct Client *source_p, const char *mask, unsigned int cap, |
763 |
adx |
30 |
const char *pattern, ...) |
764 |
|
|
{ |
765 |
|
|
va_list args; |
766 |
michael |
3801 |
dlink_node *ptr = NULL, *ptr_next = NULL; |
767 |
michael |
4797 |
struct dbuf_block *buffer = dbuf_alloc(); |
768 |
adx |
30 |
|
769 |
michael |
3946 |
dbuf_put_fmt(buffer, ":%s ", source_p->id); |
770 |
adx |
30 |
va_start(args, pattern); |
771 |
michael |
3946 |
send_format(buffer, pattern, args); |
772 |
adx |
30 |
va_end(args); |
773 |
|
|
|
774 |
michael |
948 |
++current_serial; |
775 |
adx |
30 |
|
776 |
michael |
4208 |
DLINK_FOREACH_SAFE(ptr, ptr_next, global_server_list.head) |
777 |
adx |
30 |
{ |
778 |
michael |
2638 |
struct Client *target_p = ptr->data; |
779 |
adx |
30 |
|
780 |
|
|
/* Do not attempt to send to ourselves, or the source */ |
781 |
|
|
if (IsMe(target_p) || target_p->from == source_p->from) |
782 |
|
|
continue; |
783 |
|
|
|
784 |
michael |
4589 |
if (target_p->from->connection->serial == current_serial) |
785 |
adx |
30 |
continue; |
786 |
|
|
|
787 |
michael |
4797 |
if (match(mask, target_p->name)) |
788 |
|
|
continue; |
789 |
adx |
30 |
|
790 |
michael |
4797 |
/* |
791 |
|
|
* If we set the serial here, then we'll never do a |
792 |
|
|
* match() again, if !IsCapable() |
793 |
|
|
*/ |
794 |
|
|
target_p->from->connection->serial = current_serial; |
795 |
adx |
30 |
|
796 |
michael |
4797 |
if (!IsCapable(target_p->from, cap)) |
797 |
|
|
continue; |
798 |
|
|
|
799 |
|
|
send_message_remote(target_p->from, source_p, buffer); |
800 |
adx |
30 |
} |
801 |
michael |
3107 |
|
802 |
michael |
3946 |
dbuf_ref_free(buffer); |
803 |
adx |
30 |
} |
804 |
|
|
|
805 |
|
|
/* sendto_anywhere() |
806 |
|
|
* |
807 |
|
|
* inputs - pointer to dest client |
808 |
|
|
* - pointer to from client |
809 |
|
|
* - varags |
810 |
|
|
* output - NONE |
811 |
|
|
* side effects - less efficient than sendto_remote and sendto_one |
812 |
|
|
* but useful when one does not know where target "lives" |
813 |
|
|
*/ |
814 |
|
|
void |
815 |
|
|
sendto_anywhere(struct Client *to, struct Client *from, |
816 |
michael |
2793 |
const char *command, |
817 |
adx |
30 |
const char *pattern, ...) |
818 |
|
|
{ |
819 |
|
|
va_list args; |
820 |
michael |
3189 |
struct dbuf_block *buffer = NULL; |
821 |
adx |
30 |
|
822 |
michael |
2793 |
if (IsDead(to->from)) |
823 |
adx |
30 |
return; |
824 |
|
|
|
825 |
michael |
3107 |
buffer = dbuf_alloc(); |
826 |
|
|
|
827 |
michael |
3189 |
if (MyClient(to) && IsClient(from)) |
828 |
|
|
dbuf_put_fmt(buffer, ":%s!%s@%s %s %s ", from->name, from->username, |
829 |
|
|
from->host, command, to->name); |
830 |
michael |
2634 |
else |
831 |
michael |
3189 |
dbuf_put_fmt(buffer, ":%s %s %s ", ID_or_name(from, to), |
832 |
|
|
command, ID_or_name(to, to)); |
833 |
adx |
30 |
|
834 |
|
|
va_start(args, pattern); |
835 |
michael |
3107 |
send_format(buffer, pattern, args); |
836 |
adx |
30 |
va_end(args); |
837 |
|
|
|
838 |
michael |
4805 |
if (MyConnect(to)) |
839 |
michael |
3107 |
send_message(to, buffer); |
840 |
adx |
30 |
else |
841 |
michael |
4802 |
send_message_remote(to->from, from, buffer); |
842 |
michael |
3107 |
|
843 |
|
|
dbuf_ref_free(buffer); |
844 |
adx |
30 |
} |
845 |
|
|
|
846 |
|
|
/* sendto_realops_flags() |
847 |
|
|
* |
848 |
|
|
* inputs - flag types of messages to show to real opers |
849 |
|
|
* - flag indicating opers/admins |
850 |
|
|
* - var args input message |
851 |
|
|
* output - NONE |
852 |
|
|
* side effects - Send to *local* ops only but NOT +s nonopers. |
853 |
|
|
*/ |
854 |
|
|
void |
855 |
michael |
1618 |
sendto_realops_flags(unsigned int flags, int level, int type, const char *pattern, ...) |
856 |
adx |
30 |
{ |
857 |
michael |
1618 |
const char *ntype = NULL; |
858 |
michael |
1078 |
dlink_node *ptr = NULL; |
859 |
michael |
3215 |
char nbuf[IRCD_BUFSIZE] = ""; |
860 |
adx |
30 |
va_list args; |
861 |
|
|
|
862 |
|
|
va_start(args, pattern); |
863 |
michael |
1618 |
vsnprintf(nbuf, sizeof(nbuf), pattern, args); |
864 |
adx |
30 |
va_end(args); |
865 |
|
|
|
866 |
michael |
1618 |
switch (type) |
867 |
adx |
30 |
{ |
868 |
michael |
1618 |
case SEND_NOTICE: |
869 |
|
|
ntype = "Notice"; |
870 |
|
|
break; |
871 |
|
|
case SEND_GLOBAL: |
872 |
|
|
ntype = "Global"; |
873 |
|
|
break; |
874 |
|
|
case SEND_LOCOPS: |
875 |
|
|
ntype = "LocOps"; |
876 |
|
|
break; |
877 |
|
|
default: |
878 |
|
|
assert(0); |
879 |
adx |
30 |
} |
880 |
|
|
|
881 |
michael |
1206 |
DLINK_FOREACH(ptr, oper_list.head) |
882 |
|
|
{ |
883 |
|
|
struct Client *client_p = ptr->data; |
884 |
michael |
1618 |
assert(HasUMode(client_p, UMODE_OPER)); |
885 |
michael |
1206 |
|
886 |
michael |
1618 |
/* |
887 |
|
|
* If we're sending it to opers and they're an admin, skip. |
888 |
|
|
* If we're sending it to admins, and they're not, skip. |
889 |
michael |
1206 |
*/ |
890 |
michael |
1219 |
if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) || |
891 |
michael |
2638 |
((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN))) |
892 |
michael |
1206 |
continue; |
893 |
|
|
|
894 |
michael |
1219 |
if (HasUMode(client_p, flags)) |
895 |
michael |
1618 |
sendto_one(client_p, ":%s NOTICE %s :*** %s -- %s", |
896 |
|
|
me.name, client_p->name, ntype, nbuf); |
897 |
michael |
1206 |
} |
898 |
|
|
} |
899 |
|
|
|
900 |
michael |
3215 |
/* ts_warn() |
901 |
|
|
* |
902 |
|
|
* inputs - var args message |
903 |
|
|
* output - NONE |
904 |
|
|
* side effects - Call sendto_realops_flags, with some flood checking |
905 |
|
|
* (at most 5 warnings every 5 seconds) |
906 |
|
|
*/ |
907 |
|
|
void |
908 |
michael |
4430 |
sendto_realops_flags_ratelimited(time_t *rate, const char *pattern, ...) |
909 |
michael |
3215 |
{ |
910 |
|
|
va_list args; |
911 |
|
|
char buffer[IRCD_BUFSIZE] = ""; |
912 |
|
|
|
913 |
michael |
4430 |
if ((CurrentTime - *rate) < 20) |
914 |
|
|
return; |
915 |
|
|
*rate = CurrentTime; |
916 |
michael |
3215 |
|
917 |
|
|
va_start(args, pattern); |
918 |
|
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
919 |
|
|
va_end(args); |
920 |
|
|
|
921 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s", buffer); |
922 |
|
|
ilog(LOG_TYPE_IRCD, "%s", buffer); |
923 |
|
|
} |
924 |
|
|
|
925 |
adx |
30 |
/* sendto_wallops_flags() |
926 |
|
|
* |
927 |
|
|
* inputs - flag types of messages to show to real opers |
928 |
|
|
* - client sending request |
929 |
|
|
* - var args input message |
930 |
|
|
* output - NONE |
931 |
|
|
* side effects - Send a wallops to local opers |
932 |
|
|
*/ |
933 |
|
|
void |
934 |
|
|
sendto_wallops_flags(unsigned int flags, struct Client *source_p, |
935 |
|
|
const char *pattern, ...) |
936 |
|
|
{ |
937 |
michael |
1078 |
dlink_node *ptr = NULL; |
938 |
adx |
30 |
va_list args; |
939 |
michael |
3107 |
struct dbuf_block *buffer; |
940 |
adx |
30 |
|
941 |
michael |
3107 |
buffer = dbuf_alloc(); |
942 |
|
|
|
943 |
adx |
30 |
if (IsClient(source_p)) |
944 |
michael |
3113 |
dbuf_put_fmt(buffer, ":%s!%s@%s WALLOPS :", source_p->name, source_p->username, source_p->host); |
945 |
adx |
30 |
else |
946 |
michael |
3113 |
dbuf_put_fmt(buffer, ":%s WALLOPS :", source_p->name); |
947 |
adx |
30 |
|
948 |
|
|
va_start(args, pattern); |
949 |
michael |
3107 |
send_format(buffer, pattern, args); |
950 |
adx |
30 |
va_end(args); |
951 |
|
|
|
952 |
|
|
DLINK_FOREACH(ptr, oper_list.head) |
953 |
|
|
{ |
954 |
michael |
1078 |
struct Client *client_p = ptr->data; |
955 |
adx |
30 |
assert(client_p->umodes & UMODE_OPER); |
956 |
|
|
|
957 |
michael |
1219 |
if (HasUMode(client_p, flags) && !IsDefunct(client_p)) |
958 |
michael |
3107 |
send_message(client_p, buffer); |
959 |
adx |
30 |
} |
960 |
michael |
3107 |
|
961 |
|
|
dbuf_ref_free(buffer); |
962 |
adx |
30 |
} |