23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "send.h" |
28 |
|
#include "channel.h" |
29 |
|
#include "client.h" |
30 |
– |
#include "common.h" |
30 |
|
#include "dbuf.h" |
31 |
|
#include "irc_string.h" |
32 |
|
#include "ircd.h" |
34 |
– |
#include "handlers.h" |
33 |
|
#include "numeric.h" |
34 |
|
#include "fdlist.h" |
35 |
|
#include "s_bsd.h" |
36 |
|
#include "s_serv.h" |
37 |
< |
#include "sprintf_irc.h" |
38 |
< |
#include "s_conf.h" |
41 |
< |
#include "list.h" |
42 |
< |
#include "s_log.h" |
37 |
> |
#include "conf.h" |
38 |
> |
#include "log.h" |
39 |
|
#include "memory.h" |
44 |
– |
#include "hook.h" |
45 |
– |
#include "irc_getnameinfo.h" |
40 |
|
#include "packet.h" |
41 |
|
|
48 |
– |
#define LOG_BUFSIZE 2048 |
49 |
– |
|
50 |
– |
struct Callback *iosend_cb = NULL; |
51 |
– |
struct Callback *iosendctrl_cb = NULL; |
42 |
|
|
43 |
< |
static void send_message(struct Client *, char *, int); |
54 |
< |
static void send_message_remote(struct Client *, struct Client *, char *, int); |
43 |
> |
static unsigned int current_serial = 0; |
44 |
|
|
56 |
– |
static unsigned long current_serial = 0L; |
45 |
|
|
46 |
|
/* send_format() |
47 |
|
* |
75 |
|
|
76 |
|
lsendbuf[len++] = '\r'; |
77 |
|
lsendbuf[len++] = '\n'; |
78 |
< |
return (len); |
91 |
< |
} |
92 |
< |
|
93 |
< |
/* |
94 |
< |
* iosend_default - append a packet to the client's sendq. |
95 |
< |
*/ |
96 |
< |
void * |
97 |
< |
iosend_default(va_list args) |
98 |
< |
{ |
99 |
< |
struct Client *to = va_arg(args, struct Client *); |
100 |
< |
int length = va_arg(args, int); |
101 |
< |
char *buf = va_arg(args, char *); |
102 |
< |
|
103 |
< |
dbuf_put(&to->localClient->buf_sendq, buf, length); |
104 |
< |
return NULL; |
78 |
> |
return len; |
79 |
|
} |
80 |
|
|
81 |
|
/* |
89 |
|
assert(!IsMe(to)); |
90 |
|
assert(to != &me); |
91 |
|
|
92 |
< |
if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(to)) |
92 |
> |
if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(&to->localClient->confs)) |
93 |
|
{ |
94 |
|
if (IsServer(to)) |
95 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
96 |
< |
"Max SendQ limit exceeded for %s: %lu > %lu", |
95 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
96 |
> |
"Max SendQ limit exceeded for %s: %lu > %u", |
97 |
|
get_client_name(to, HIDE_IP), |
98 |
|
(unsigned long)(dbuf_length(&to->localClient->buf_sendq) + len), |
99 |
< |
get_sendq(to)); |
99 |
> |
get_sendq(&to->localClient->confs)); |
100 |
|
if (IsClient(to)) |
101 |
|
SetSendQExceeded(to); |
102 |
|
dead_link_on_write(to, 0); |
103 |
|
return; |
104 |
|
} |
105 |
< |
|
106 |
< |
execute_callback(iosend_cb, to, len, buf); |
105 |
> |
|
106 |
> |
dbuf_put(&to->localClient->buf_sendq, buf, len); |
107 |
|
|
108 |
|
/* |
109 |
|
** Update statistics. The following is slightly incorrect |
135 |
|
{ |
136 |
|
if (!MyConnect(to)) |
137 |
|
{ |
138 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
138 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
139 |
|
"server send message to %s [%s] dropped from %s(Not local server)", |
140 |
|
to->name, to->from->name, from->name); |
141 |
|
return; |
148 |
|
{ |
149 |
|
if (IsServer(from)) |
150 |
|
{ |
151 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
151 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
152 |
|
"Send message to %s [%s] dropped from %s(Fake Dir)", |
153 |
|
to->name, to->from->name, from->name); |
154 |
|
return; |
155 |
|
} |
156 |
|
|
157 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
157 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
158 |
|
"Ghosted: %s[%s@%s] from %s[%s@%s] (%s)", |
159 |
|
to->name, to->username, to->host, |
160 |
|
from->name, from->username, from->host, |
161 |
|
to->from->name); |
162 |
|
|
163 |
< |
sendto_server(NULL, NULL, CAP_TS6, NOCAPS, |
163 |
> |
sendto_server(NULL, CAP_TS6, NOCAPS, |
164 |
|
":%s KILL %s :%s (%s[%s@%s] Ghosted %s)", |
165 |
|
me.id, to->name, me.name, to->name, |
166 |
|
to->username, to->host, to->from->name); |
167 |
< |
sendto_server(NULL, NULL, NOCAPS, CAP_TS6, |
167 |
> |
sendto_server(NULL, NOCAPS, CAP_TS6, |
168 |
|
":%s KILL %s :%s (%s[%s@%s] Ghosted %s)", |
169 |
|
me.name, to->name, me.name, to->name, |
170 |
|
to->username, to->host, to->from->name); |
171 |
|
|
172 |
< |
SetKilled(to); |
172 |
> |
AddFlag(to, FLAGS_KILLED); |
173 |
|
|
174 |
|
if (IsClient(from)) |
175 |
|
sendto_one(from, form_str(ERR_GHOSTEDCLIENT), |
204 |
|
} |
205 |
|
|
206 |
|
/* |
233 |
– |
** slinkq_unblocked |
234 |
– |
** Called when a server control socket is ready for writing. |
235 |
– |
*/ |
236 |
– |
static void |
237 |
– |
slinkq_unblocked(fde_t *fd, struct Client *client_p) |
238 |
– |
{ |
239 |
– |
ClearSlinkqBlocked(client_p); |
240 |
– |
send_queued_slink_write(client_p); |
241 |
– |
} |
242 |
– |
|
243 |
– |
/* |
207 |
|
** send_queued_write |
208 |
|
** This is called when there is a chance that some output would |
209 |
|
** be possible. This attempts to empty the send queue as far as |
257 |
|
retlen = send(to->localClient->fd.fd, first->data, first->size, 0); |
258 |
|
|
259 |
|
if (retlen <= 0) |
297 |
– |
{ |
298 |
– |
#ifdef _WIN32 |
299 |
– |
errno = WSAGetLastError(); |
300 |
– |
#endif |
260 |
|
break; |
302 |
– |
} |
261 |
|
|
262 |
|
dbuf_delete(&to->localClient->buf_sendq, retlen); |
263 |
|
|
281 |
|
} |
282 |
|
} |
283 |
|
|
326 |
– |
/* |
327 |
– |
** send_queued_slink_write |
328 |
– |
** This is called when there is a chance the some output would |
329 |
– |
** be possible. This attempts to empty the send queue as far as |
330 |
– |
** possible, and then if any data is left, a write is rescheduled. |
331 |
– |
*/ |
332 |
– |
void |
333 |
– |
send_queued_slink_write(struct Client *to) |
334 |
– |
{ |
335 |
– |
int retlen; |
336 |
– |
|
337 |
– |
/* |
338 |
– |
** Once socket is marked dead, we cannot start writing to it, |
339 |
– |
** even if the error is removed... |
340 |
– |
*/ |
341 |
– |
if (IsDead(to) || IsSlinkqBlocked(to)) |
342 |
– |
return; /* no use calling send() now */ |
343 |
– |
|
344 |
– |
/* Next, lets try to write some data */ |
345 |
– |
if (to->localClient->slinkq != NULL) |
346 |
– |
{ |
347 |
– |
retlen = send(to->localClient->ctrlfd.fd, |
348 |
– |
to->localClient->slinkq + to->localClient->slinkq_ofs, |
349 |
– |
to->localClient->slinkq_len, 0); |
350 |
– |
if (retlen < 0) |
351 |
– |
{ |
352 |
– |
/* If we have a fatal error */ |
353 |
– |
if (!ignoreErrno(errno)) |
354 |
– |
{ |
355 |
– |
dead_link_on_write(to, errno); |
356 |
– |
return; |
357 |
– |
} |
358 |
– |
} |
359 |
– |
else if (retlen == 0) |
360 |
– |
{ |
361 |
– |
/* 0 bytes is an EOF .. */ |
362 |
– |
dead_link_on_write(to, 0); |
363 |
– |
return; |
364 |
– |
} |
365 |
– |
else |
366 |
– |
{ |
367 |
– |
execute_callback(iosendctrl_cb, to, retlen, |
368 |
– |
to->localClient->slinkq + to->localClient->slinkq_ofs); |
369 |
– |
to->localClient->slinkq_len -= retlen; |
370 |
– |
|
371 |
– |
assert(to->localClient->slinkq_len >= 0); |
372 |
– |
if (to->localClient->slinkq_len) |
373 |
– |
to->localClient->slinkq_ofs += retlen; |
374 |
– |
else |
375 |
– |
{ |
376 |
– |
to->localClient->slinkq_ofs = 0; |
377 |
– |
MyFree(to->localClient->slinkq); |
378 |
– |
to->localClient->slinkq = NULL; |
379 |
– |
} |
380 |
– |
} |
381 |
– |
|
382 |
– |
/* Finally, if we have any more data, reschedule a write */ |
383 |
– |
if (to->localClient->slinkq_len) |
384 |
– |
{ |
385 |
– |
SetSlinkqBlocked(to); |
386 |
– |
comm_setselect(&to->localClient->ctrlfd, COMM_SELECT_WRITE, |
387 |
– |
(PF *)slinkq_unblocked, (void *)to, 0); |
388 |
– |
} |
389 |
– |
} |
390 |
– |
} |
391 |
– |
|
284 |
|
/* send_queued_all() |
285 |
|
* |
286 |
|
* input - NONE |
351 |
|
*/ |
352 |
|
void |
353 |
|
sendto_channel_butone(struct Client *one, struct Client *from, |
354 |
< |
struct Channel *chptr, const char *command, |
354 |
> |
struct Channel *chptr, unsigned int type, |
355 |
|
const char *pattern, ...) |
356 |
|
{ |
357 |
|
va_list alocal, aremote, auid; |
359 |
|
char remote_buf[IRCD_BUFSIZE]; |
360 |
|
char uid_buf[IRCD_BUFSIZE]; |
361 |
|
int local_len, remote_len, uid_len; |
362 |
< |
dlink_node *ptr; |
471 |
< |
dlink_node *ptr_next; |
472 |
< |
struct Client *target_p; |
362 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
363 |
|
|
364 |
|
if (IsServer(from)) |
365 |
< |
local_len = ircsprintf(local_buf, ":%s %s %s ", |
366 |
< |
from->name, command, chptr->chname); |
365 |
> |
local_len = snprintf(local_buf, sizeof(local_buf), ":%s ", |
366 |
> |
from->name); |
367 |
|
else |
368 |
< |
local_len = ircsprintf(local_buf, ":%s!%s@%s %s %s ", |
369 |
< |
from->name, from->username, from->host, |
370 |
< |
command, chptr->chname); |
371 |
< |
remote_len = ircsprintf(remote_buf, ":%s %s %s ", |
372 |
< |
from->name, command, chptr->chname); |
483 |
< |
uid_len = ircsprintf(uid_buf, ":%s %s %s ", |
484 |
< |
ID(from), command, chptr->chname); |
368 |
> |
local_len = snprintf(local_buf, sizeof(local_buf), ":%s!%s@%s ", |
369 |
> |
from->name, from->username, from->host); |
370 |
> |
remote_len = snprintf(remote_buf, sizeof(remote_buf), ":%s ", |
371 |
> |
from->name); |
372 |
> |
uid_len = snprintf(uid_buf, sizeof(uid_buf), ":%s ", ID(from)); |
373 |
|
|
374 |
|
va_start(alocal, pattern); |
375 |
|
va_start(aremote, pattern); |
388 |
|
|
389 |
|
DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->members.head) |
390 |
|
{ |
391 |
< |
target_p = ((struct Membership *)ptr->data)->client_p; |
392 |
< |
assert(target_p != NULL); |
391 |
> |
struct Membership *ms = ptr->data; |
392 |
> |
struct Client *target_p = ms->client_p; |
393 |
> |
|
394 |
> |
assert(IsClient(target_p)); |
395 |
|
|
396 |
< |
if (IsDefunct(target_p) || IsDeaf(target_p) || target_p->from == one) |
396 |
> |
if (IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF) || target_p->from == one) |
397 |
|
continue; |
398 |
|
|
399 |
< |
if (MyClient(target_p)) |
399 |
> |
if (type != 0 && (ms->flags & type) == 0) |
400 |
> |
continue; |
401 |
> |
|
402 |
> |
if (MyConnect(target_p)) |
403 |
|
{ |
404 |
< |
if (target_p->serial != current_serial) |
404 |
> |
if (target_p->localClient->serial != current_serial) |
405 |
|
{ |
406 |
|
send_message(target_p, local_buf, local_len); |
407 |
< |
target_p->serial = current_serial; |
407 |
> |
target_p->localClient->serial = current_serial; |
408 |
|
} |
409 |
|
} |
410 |
|
else |
412 |
|
/* Now check whether a message has been sent to this |
413 |
|
* remote link already |
414 |
|
*/ |
415 |
< |
if (target_p->from->serial != current_serial) |
415 |
> |
if (target_p->from->localClient->serial != current_serial) |
416 |
|
{ |
417 |
|
if (IsCapable(target_p->from, CAP_TS6)) |
418 |
|
send_message_remote(target_p->from, from, uid_buf, uid_len); |
419 |
|
else |
420 |
|
send_message_remote(target_p->from, from, remote_buf, remote_len); |
421 |
< |
target_p->from->serial = current_serial; |
421 |
> |
target_p->from->localClient->serial = current_serial; |
422 |
|
} |
423 |
|
} |
424 |
|
} |
427 |
|
/* sendto_server() |
428 |
|
* |
429 |
|
* inputs - pointer to client to NOT send to |
430 |
< |
* - pointer to source client required by LL (if any) |
538 |
< |
* - pointer to channel required by LL (if any) |
430 |
> |
* - pointer to channel |
431 |
|
* - caps or'd together which must ALL be present |
432 |
|
* - caps or'd together which must ALL NOT be present |
433 |
|
* - printf style format string |
444 |
|
*/ |
445 |
|
void |
446 |
|
sendto_server(struct Client *one, |
447 |
< |
struct Channel *chptr, unsigned long caps, |
448 |
< |
unsigned long nocaps, |
447 |
> |
const unsigned int caps, |
448 |
> |
const unsigned int nocaps, |
449 |
|
const char *format, ...) |
450 |
|
{ |
451 |
|
va_list args; |
453 |
|
char buffer[IRCD_BUFSIZE]; |
454 |
|
int len = 0; |
455 |
|
|
564 |
– |
if (chptr && chptr->chname[0] != '#') |
565 |
– |
return; |
566 |
– |
|
456 |
|
va_start(args, format); |
457 |
|
len = send_format(buffer, IRCD_BUFSIZE, format, args); |
458 |
|
va_end(args); |
488 |
|
* used by m_nick.c and exit_one_client. |
489 |
|
*/ |
490 |
|
void |
491 |
< |
sendto_common_channels_local(struct Client *user, int touser, |
491 |
> |
sendto_common_channels_local(struct Client *user, int touser, unsigned int cap, |
492 |
|
const char *pattern, ...) |
493 |
|
{ |
494 |
|
va_list args; |
518 |
|
assert(target_p != NULL); |
519 |
|
|
520 |
|
if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) || |
521 |
< |
target_p->serial == current_serial) |
521 |
> |
target_p->localClient->serial == current_serial) |
522 |
|
continue; |
523 |
|
|
524 |
< |
target_p->serial = current_serial; |
524 |
> |
if (HasCap(target_p, cap) != cap) |
525 |
> |
continue; |
526 |
> |
|
527 |
> |
target_p->localClient->serial = current_serial; |
528 |
|
send_message(target_p, buffer, len); |
529 |
|
} |
530 |
|
} |
531 |
|
|
532 |
|
if (touser && MyConnect(user) && !IsDead(user) && |
533 |
< |
user->serial != current_serial) |
534 |
< |
send_message(user, buffer, len); |
533 |
> |
user->localClient->serial != current_serial) |
534 |
> |
if (HasCap(user, cap) == cap) |
535 |
> |
send_message(user, buffer, len); |
536 |
|
} |
537 |
|
|
538 |
|
/* sendto_channel_local() |
546 |
|
* locally connected to this server. |
547 |
|
*/ |
548 |
|
void |
549 |
< |
sendto_channel_local(int type, int nodeaf, struct Channel *chptr, |
549 |
> |
sendto_channel_local(unsigned int type, int nodeaf, struct Channel *chptr, |
550 |
|
const char *pattern, ...) |
551 |
|
{ |
552 |
|
va_list args; |
569 |
|
continue; |
570 |
|
|
571 |
|
if (!MyConnect(target_p) || IsDefunct(target_p) || |
572 |
< |
(nodeaf && IsDeaf(target_p))) |
572 |
> |
(nodeaf && HasUMode(target_p, UMODE_DEAF))) |
573 |
|
continue; |
574 |
|
|
575 |
|
send_message(target_p, buffer, len); |
589 |
|
* WARNING - +D clients are omitted |
590 |
|
*/ |
591 |
|
void |
592 |
< |
sendto_channel_local_butone(struct Client *one, int type, |
592 |
> |
sendto_channel_local_butone(struct Client *one, unsigned int type, unsigned int cap, |
593 |
|
struct Channel *chptr, const char *pattern, ...) |
594 |
|
{ |
595 |
|
va_list args; |
612 |
|
continue; |
613 |
|
|
614 |
|
if (!MyConnect(target_p) || target_p == one || |
615 |
< |
IsDefunct(target_p) || IsDeaf(target_p)) |
615 |
> |
IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF)) |
616 |
|
continue; |
617 |
+ |
|
618 |
+ |
if (HasCap(target_p, cap) != cap) |
619 |
+ |
continue; |
620 |
|
send_message(target_p, buffer, len); |
621 |
|
} |
622 |
|
} |
634 |
|
* remote to this server. |
635 |
|
*/ |
636 |
|
void |
637 |
< |
sendto_channel_remote(struct Client *one, struct Client *from, int type, int caps, |
638 |
< |
int nocaps, struct Channel *chptr, const char *pattern, ...) |
637 |
> |
sendto_channel_remote(struct Client *one, struct Client *from, unsigned int type, |
638 |
> |
const unsigned int caps, const unsigned int nocaps, |
639 |
> |
struct Channel *chptr, const char *pattern, ...) |
640 |
|
{ |
641 |
|
va_list args; |
642 |
|
char buffer[IRCD_BUFSIZE]; |
667 |
|
((target_p->from->localClient->caps & caps) != caps) || |
668 |
|
((target_p->from->localClient->caps & nocaps) != 0)) |
669 |
|
continue; |
670 |
< |
if (target_p->from->serial != current_serial) |
670 |
> |
if (target_p->from->localClient->serial != current_serial) |
671 |
|
{ |
672 |
|
send_message(target_p, buffer, len); |
673 |
< |
target_p->from->serial = current_serial; |
673 |
> |
target_p->from->localClient->serial = current_serial; |
674 |
|
} |
675 |
|
} |
676 |
|
} |
696 |
|
match_it(const struct Client *one, const char *mask, int what) |
697 |
|
{ |
698 |
|
if (what == MATCH_HOST) |
699 |
< |
return(match(mask, one->host)); |
699 |
> |
return !match(mask, one->host); |
700 |
|
|
701 |
< |
return(match(mask, one->servptr->name)); |
701 |
> |
return !match(mask, one->servptr->name); |
702 |
|
} |
703 |
|
|
704 |
|
/* sendto_match_butone() |
716 |
|
struct Client *client_p; |
717 |
|
dlink_node *ptr, *ptr_next; |
718 |
|
char local_buf[IRCD_BUFSIZE], remote_buf[IRCD_BUFSIZE]; |
719 |
< |
int local_len = ircsprintf(local_buf, ":%s!%s@%s ", from->name, |
720 |
< |
from->username, from->host); |
721 |
< |
int remote_len = ircsprintf(remote_buf, ":%s ", from->name); |
719 |
> |
int local_len = snprintf(local_buf, sizeof(local_buf), ":%s!%s@%s ", |
720 |
> |
from->name, from->username, from->host); |
721 |
> |
int remote_len = snprintf(remote_buf, sizeof(remote_buf), ":%s ", |
722 |
> |
from->name); |
723 |
|
|
724 |
|
va_start(alocal, pattern); |
725 |
|
va_start(aremote, pattern); |
784 |
|
* side effects - data sent to servers matching with capab |
785 |
|
*/ |
786 |
|
void |
787 |
< |
sendto_match_servs(struct Client *source_p, const char *mask, int cap, |
787 |
> |
sendto_match_servs(struct Client *source_p, const char *mask, unsigned int cap, |
788 |
|
const char *pattern, ...) |
789 |
|
{ |
790 |
|
va_list args; |
797 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
798 |
|
va_end(args); |
799 |
|
|
800 |
< |
current_serial++; |
800 |
> |
++current_serial; |
801 |
|
|
802 |
|
DLINK_FOREACH(ptr, global_serv_list.head) |
803 |
|
{ |
807 |
|
if (IsMe(target_p) || target_p->from == source_p->from) |
808 |
|
continue; |
809 |
|
|
810 |
< |
if (target_p->from->serial == current_serial) |
810 |
> |
if (target_p->from->localClient->serial == current_serial) |
811 |
|
continue; |
812 |
|
|
813 |
< |
if (match(mask, target_p->name)) |
813 |
> |
if (!match(mask, target_p->name)) |
814 |
|
{ |
815 |
|
/* |
816 |
|
* if we set the serial here, then we'll never do a |
817 |
|
* match() again, if !IsCapable() |
818 |
|
*/ |
819 |
< |
target_p->from->serial = current_serial; |
819 |
> |
target_p->from->localClient->serial = current_serial; |
820 |
|
found++; |
821 |
|
|
822 |
|
if (!IsCapable(target_p->from, cap)) |
851 |
|
if (MyClient(to)) |
852 |
|
{ |
853 |
|
if (IsServer(from)) |
854 |
< |
{ |
957 |
< |
if (IsCapable(to, CAP_TS6) && HasID(from)) |
958 |
< |
len = ircsprintf(buffer, ":%s ", from->id); |
959 |
< |
else |
960 |
< |
len = ircsprintf(buffer, ":%s ", from->name); |
961 |
< |
} |
854 |
> |
len = snprintf(buffer, sizeof(buffer), ":%s ", from->name); |
855 |
|
else |
856 |
< |
len = ircsprintf(buffer, ":%s!%s@%s ", |
857 |
< |
from->name, from->username, from->host); |
856 |
> |
len = snprintf(buffer, sizeof(buffer), ":%s!%s@%s ", |
857 |
> |
from->name, from->username, from->host); |
858 |
|
} |
859 |
< |
else len = ircsprintf(buffer, ":%s ", ID_or_name(from, send_to)); |
859 |
> |
else |
860 |
> |
len = snprintf(buffer, sizeof(buffer), ":%s ", ID_or_name(from, send_to)); |
861 |
|
|
862 |
|
va_start(args, pattern); |
863 |
|
len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args); |
864 |
|
va_end(args); |
865 |
|
|
866 |
< |
if(MyClient(to)) |
866 |
> |
if (MyClient(to)) |
867 |
|
send_message(send_to, buffer, len); |
868 |
|
else |
869 |
|
send_message_remote(send_to, from, buffer, len); |
878 |
|
* side effects - Send to *local* ops only but NOT +s nonopers. |
879 |
|
*/ |
880 |
|
void |
881 |
< |
sendto_realops_flags(unsigned int flags, int level, const char *pattern, ...) |
881 |
> |
sendto_realops_flags(unsigned int flags, int level, int type, const char *pattern, ...) |
882 |
|
{ |
883 |
< |
struct Client *client_p; |
883 |
> |
const char *ntype = NULL; |
884 |
> |
dlink_node *ptr = NULL; |
885 |
|
char nbuf[IRCD_BUFSIZE]; |
991 |
– |
dlink_node *ptr; |
886 |
|
va_list args; |
887 |
|
|
888 |
|
va_start(args, pattern); |
889 |
< |
vsnprintf(nbuf, IRCD_BUFSIZE, pattern, args); |
889 |
> |
vsnprintf(nbuf, sizeof(nbuf), pattern, args); |
890 |
|
va_end(args); |
891 |
|
|
892 |
+ |
switch (type) |
893 |
+ |
{ |
894 |
+ |
case SEND_NOTICE: |
895 |
+ |
ntype = "Notice"; |
896 |
+ |
break; |
897 |
+ |
case SEND_GLOBAL: |
898 |
+ |
ntype = "Global"; |
899 |
+ |
break; |
900 |
+ |
case SEND_LOCOPS: |
901 |
+ |
ntype = "LocOps"; |
902 |
+ |
break; |
903 |
+ |
default: |
904 |
+ |
assert(0); |
905 |
+ |
} |
906 |
+ |
|
907 |
|
DLINK_FOREACH(ptr, oper_list.head) |
908 |
|
{ |
909 |
< |
client_p = ptr->data; |
910 |
< |
assert(client_p->umodes & UMODE_OPER); |
909 |
> |
struct Client *client_p = ptr->data; |
910 |
> |
assert(HasUMode(client_p, UMODE_OPER)); |
911 |
|
|
912 |
< |
/* If we're sending it to opers and theyre an admin, skip. |
913 |
< |
* If we're sending it to admins, and theyre not, skip. |
912 |
> |
/* |
913 |
> |
* If we're sending it to opers and they're an admin, skip. |
914 |
> |
* If we're sending it to admins, and they're not, skip. |
915 |
|
*/ |
916 |
< |
if (((level == L_ADMIN) && !IsAdmin(client_p)) || |
917 |
< |
((level == L_OPER) && IsAdmin(client_p))) |
916 |
> |
if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) || |
917 |
> |
((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN))) |
918 |
|
continue; |
919 |
|
|
920 |
< |
if (client_p->umodes & flags) |
921 |
< |
sendto_one(client_p, ":%s NOTICE %s :*** Notice -- %s", |
922 |
< |
me.name, client_p->name, nbuf); |
920 |
> |
if (HasUMode(client_p, flags)) |
921 |
> |
sendto_one(client_p, ":%s NOTICE %s :*** %s -- %s", |
922 |
> |
me.name, client_p->name, ntype, nbuf); |
923 |
|
} |
924 |
|
} |
925 |
|
|
935 |
|
sendto_wallops_flags(unsigned int flags, struct Client *source_p, |
936 |
|
const char *pattern, ...) |
937 |
|
{ |
938 |
< |
struct Client *client_p; |
1029 |
< |
dlink_node *ptr; |
938 |
> |
dlink_node *ptr = NULL; |
939 |
|
va_list args; |
940 |
|
char buffer[IRCD_BUFSIZE]; |
941 |
|
int len; |
942 |
|
|
943 |
|
if (IsClient(source_p)) |
944 |
< |
len = ircsprintf(buffer, ":%s!%s@%s WALLOPS :", |
945 |
< |
source_p->name, source_p->username, source_p->host); |
944 |
> |
len = snprintf(buffer, sizeof(buffer), ":%s!%s@%s WALLOPS :", |
945 |
> |
source_p->name, source_p->username, |
946 |
> |
source_p->host); |
947 |
|
else |
948 |
< |
len = ircsprintf(buffer, ":%s WALLOPS :", source_p->name); |
948 |
> |
len = snprintf(buffer, sizeof(buffer), ":%s WALLOPS :", |
949 |
> |
source_p->name); |
950 |
|
|
951 |
|
va_start(args, pattern); |
952 |
|
len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args); |
954 |
|
|
955 |
|
DLINK_FOREACH(ptr, oper_list.head) |
956 |
|
{ |
957 |
< |
client_p = ptr->data; |
957 |
> |
struct Client *client_p = ptr->data; |
958 |
|
assert(client_p->umodes & UMODE_OPER); |
959 |
|
|
960 |
< |
if ((client_p->umodes & flags) && !IsDefunct(client_p)) |
960 |
> |
if (HasUMode(client_p, flags) && !IsDefunct(client_p)) |
961 |
|
send_message(client_p, buffer, len); |
962 |
|
} |
963 |
|
} |
973 |
|
ts_warn(const char *pattern, ...) |
974 |
|
{ |
975 |
|
va_list args; |
976 |
< |
char buffer[LOG_BUFSIZE]; |
976 |
> |
char buffer[IRCD_BUFSIZE]; |
977 |
|
static time_t last = 0; |
978 |
|
static int warnings = 0; |
979 |
|
|
996 |
|
} |
997 |
|
|
998 |
|
va_start(args, pattern); |
999 |
< |
vsprintf_irc(buffer, pattern, args); |
999 |
> |
vsnprintf(buffer, sizeof(buffer), pattern, args); |
1000 |
|
va_end(args); |
1001 |
|
|
1002 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s", buffer); |
1003 |
< |
ilog(L_CRIT, "%s", buffer); |
1002 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s", buffer); |
1003 |
> |
ilog(LOG_TYPE_IRCD, "%s", buffer); |
1004 |
|
} |
1005 |
|
|
1006 |
|
/* kill_client() |
1024 |
|
if (IsDead(client_p)) |
1025 |
|
return; |
1026 |
|
|
1027 |
< |
len = ircsprintf(buffer, ":%s KILL %s :", ID_or_name(&me, client_p->from), |
1028 |
< |
ID_or_name(diedie, client_p)); |
1027 |
> |
len = snprintf(buffer, sizeof(buffer), ":%s KILL %s :", |
1028 |
> |
ID_or_name(&me, client_p->from), |
1029 |
> |
ID_or_name(diedie, client_p)); |
1030 |
|
|
1031 |
|
va_start(args, pattern); |
1032 |
|
len += send_format(&buffer[len], IRCD_BUFSIZE - len, pattern, args); |
1046 |
|
* client being unknown to leaf, as in lazylink... |
1047 |
|
*/ |
1048 |
|
void |
1049 |
< |
kill_client_ll_serv_butone(struct Client *one, struct Client *source_p, |
1050 |
< |
const char *pattern, ...) |
1049 |
> |
kill_client_serv_butone(struct Client *one, struct Client *source_p, |
1050 |
> |
const char *pattern, ...) |
1051 |
|
{ |
1052 |
|
va_list args; |
1053 |
|
int have_uid = 0; |
1055 |
|
char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE]; |
1056 |
|
int len_uid = 0, len_nick = 0; |
1057 |
|
|
1058 |
< |
if (HasID(source_p) && (me.id[0] != '\0')) |
1058 |
> |
if (HasID(source_p)) |
1059 |
|
{ |
1060 |
|
have_uid = 1; |
1061 |
|
va_start(args, pattern); |
1062 |
< |
len_uid = ircsprintf(buf_uid, ":%s KILL %s :", me.id, ID(source_p)); |
1062 |
> |
len_uid = snprintf(buf_uid, sizeof(buf_uid), ":%s KILL %s :", |
1063 |
> |
me.id, ID(source_p)); |
1064 |
|
len_uid += send_format(&buf_uid[len_uid], IRCD_BUFSIZE - len_uid, pattern, |
1065 |
|
args); |
1066 |
|
va_end(args); |
1067 |
|
} |
1068 |
|
|
1069 |
|
va_start(args, pattern); |
1070 |
< |
len_nick = ircsprintf(buf_nick, ":%s KILL %s :", me.name, source_p->name); |
1070 |
> |
len_nick = snprintf(buf_nick, sizeof(buf_nick), ":%s KILL %s :", |
1071 |
> |
me.name, source_p->name); |
1072 |
|
len_nick += send_format(&buf_nick[len_nick], IRCD_BUFSIZE - len_nick, pattern, |
1073 |
|
args); |
1074 |
|
va_end(args); |