53 |
|
static void send_message(struct Client *, char *, int); |
54 |
|
static void send_message_remote(struct Client *, struct Client *, char *, int); |
55 |
|
|
56 |
< |
static unsigned long current_serial = 0L; |
56 |
> |
static unsigned int current_serial = 0; |
57 |
|
|
58 |
|
/* send_format() |
59 |
|
* |
112 |
|
static void |
113 |
|
send_message(struct Client *to, char *buf, int len) |
114 |
|
{ |
115 |
< |
assert(!IsMe(to)) |
115 |
> |
assert(!IsMe(to)); |
116 |
|
assert(to != &me); |
117 |
|
|
118 |
|
if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(to)) |
167 |
|
return; |
168 |
|
} |
169 |
|
|
170 |
– |
if (ServerInfo.hub && IsCapable(to, CAP_LL)) |
171 |
– |
{ |
172 |
– |
if (((from->lazyLinkClientExists & |
173 |
– |
to->localClient->serverMask) == 0)) |
174 |
– |
client_burst_if_needed(to, from); |
175 |
– |
} |
176 |
– |
|
170 |
|
/* Optimize by checking if (from && to) before everything */ |
171 |
|
/* we set to->from up there.. */ |
172 |
|
|
186 |
|
from->name, from->username, from->host, |
187 |
|
to->from->name); |
188 |
|
|
189 |
< |
sendto_server(NULL, to, NULL, CAP_TS6, NOCAPS, NOFLAGS, |
189 |
> |
sendto_server(NULL, NULL, CAP_TS6, NOCAPS, |
190 |
|
":%s KILL %s :%s (%s[%s@%s] Ghosted %s)", |
191 |
|
me.id, to->name, me.name, to->name, |
192 |
|
to->username, to->host, to->from->name); |
193 |
< |
sendto_server(NULL, to, NULL, NOCAPS, CAP_TS6, NOFLAGS, |
193 |
> |
sendto_server(NULL, NULL, NOCAPS, CAP_TS6, |
194 |
|
":%s KILL %s :%s (%s[%s@%s] Ghosted %s)", |
195 |
|
me.name, to->name, me.name, to->name, |
196 |
|
to->username, to->host, to->from->name); |
534 |
|
/* sendto_server() |
535 |
|
* |
536 |
|
* inputs - pointer to client to NOT send to |
537 |
< |
* - pointer to source client required by LL (if any) |
545 |
< |
* - pointer to channel required by LL (if any) |
537 |
> |
* - pointer to channel |
538 |
|
* - caps or'd together which must ALL be present |
539 |
|
* - caps or'd together which must ALL NOT be present |
548 |
– |
* - LL flags: LL_ICLIENT | LL_ICHAN |
540 |
|
* - printf style format string |
541 |
|
* - args to format string |
542 |
|
* output - NONE |
543 |
|
* side effects - Send a message to all connected servers, except the |
544 |
|
* client 'one' (if non-NULL), as long as the servers |
545 |
|
* support ALL capabs in 'caps', and NO capabs in 'nocaps'. |
555 |
– |
* If the server is a lazylink client, then it must know |
556 |
– |
* about source_p if non-NULL (unless LL_ICLIENT is specified, |
557 |
– |
* when source_p will be introduced where required) and |
558 |
– |
* chptr if non-NULL (unless LL_ICHANNEL is specified, when |
559 |
– |
* chptr will be introduced where required). |
560 |
– |
* Note: nothing will be introduced to a LazyLeaf unless |
561 |
– |
* the message is actually sent. |
546 |
|
* |
547 |
|
* This function was written in an attempt to merge together the other |
548 |
|
* billion sendto_*serv*() functions, which sprung up with capabs, |
550 |
|
* -davidt |
551 |
|
*/ |
552 |
|
void |
553 |
< |
sendto_server(struct Client *one, struct Client *source_p, |
553 |
> |
sendto_server(struct Client *one, |
554 |
|
struct Channel *chptr, unsigned long caps, |
555 |
< |
unsigned long nocaps, unsigned long llflags, |
555 |
> |
unsigned long nocaps, |
556 |
|
const char *format, ...) |
557 |
|
{ |
558 |
|
va_list args; |
559 |
< |
struct Client *client_p; |
576 |
< |
dlink_node *ptr; |
559 |
> |
dlink_node *ptr = NULL; |
560 |
|
char buffer[IRCD_BUFSIZE]; |
561 |
< |
int len; |
561 |
> |
int len = 0; |
562 |
|
|
563 |
< |
if (chptr != NULL) |
564 |
< |
{ |
582 |
< |
if (chptr->chname[0] != '#') |
583 |
< |
return; |
584 |
< |
} |
563 |
> |
if (chptr && chptr->chname[0] != '#') |
564 |
> |
return; |
565 |
|
|
566 |
|
va_start(args, format); |
567 |
|
len = send_format(buffer, IRCD_BUFSIZE, format, args); |
569 |
|
|
570 |
|
DLINK_FOREACH(ptr, serv_list.head) |
571 |
|
{ |
572 |
< |
client_p = ptr->data; |
572 |
> |
struct Client *client_p = ptr->data; |
573 |
|
|
574 |
|
/* If dead already skip */ |
575 |
|
if (IsDead(client_p)) |
584 |
|
if ((client_p->localClient->caps & nocaps) != 0) |
585 |
|
continue; |
586 |
|
|
607 |
– |
if (ServerInfo.hub && IsCapable(client_p, CAP_LL)) |
608 |
– |
{ |
609 |
– |
/* check LL channel */ |
610 |
– |
if (chptr != NULL && |
611 |
– |
((chptr->lazyLinkChannelExists & |
612 |
– |
client_p->localClient->serverMask) == 0)) |
613 |
– |
{ |
614 |
– |
/* Only introduce the channel if we really will send this message */ |
615 |
– |
if (!(llflags & LL_ICLIENT) && source_p && |
616 |
– |
((source_p->lazyLinkClientExists & |
617 |
– |
client_p->localClient->serverMask) == 0)) |
618 |
– |
continue; /* we can't introduce the unknown source_p, skip */ |
619 |
– |
|
620 |
– |
if (llflags & LL_ICHAN) |
621 |
– |
burst_channel(client_p, chptr); |
622 |
– |
else |
623 |
– |
continue; /* we can't introduce the unknown chptr, skip */ |
624 |
– |
} |
625 |
– |
/* check LL client */ |
626 |
– |
if (source_p && |
627 |
– |
((source_p->lazyLinkClientExists & |
628 |
– |
client_p->localClient->serverMask) == 0)) |
629 |
– |
{ |
630 |
– |
if (llflags & LL_ICLIENT) |
631 |
– |
client_burst_if_needed(client_p,source_p); |
632 |
– |
else |
633 |
– |
continue; /* we can't introduce the unknown source_p, skip */ |
634 |
– |
} |
635 |
– |
} |
587 |
|
send_message(client_p, buffer, len); |
588 |
|
} |
589 |
|
} |
621 |
|
chptr = ((struct Membership *) cptr->data)->chptr; |
622 |
|
assert(chptr != NULL); |
623 |
|
|
624 |
< |
DLINK_FOREACH(uptr, chptr->locmembers.head) |
624 |
> |
DLINK_FOREACH(uptr, chptr->members.head) |
625 |
|
{ |
626 |
|
ms = uptr->data; |
627 |
|
target_p = ms->client_p; |
628 |
|
assert(target_p != NULL); |
629 |
|
|
630 |
< |
if (target_p == user || IsDefunct(target_p) || |
630 |
> |
if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) || |
631 |
|
target_p->serial == current_serial) |
632 |
|
continue; |
633 |
|
|
666 |
|
len = send_format(buffer, IRCD_BUFSIZE, pattern, args); |
667 |
|
va_end(args); |
668 |
|
|
669 |
< |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
669 |
> |
DLINK_FOREACH(ptr, chptr->members.head) |
670 |
|
{ |
671 |
|
ms = ptr->data; |
672 |
|
target_p = ms->client_p; |
674 |
|
if (type != 0 && (ms->flags & type) == 0) |
675 |
|
continue; |
676 |
|
|
677 |
< |
if (IsDefunct(target_p) || (nodeaf && IsDeaf(target_p))) |
677 |
> |
if (!MyConnect(target_p) || IsDefunct(target_p) || |
678 |
> |
(nodeaf && IsDeaf(target_p))) |
679 |
|
continue; |
680 |
|
|
681 |
|
send_message(target_p, buffer, len); |
709 |
|
len = send_format(buffer, IRCD_BUFSIZE, pattern, args); |
710 |
|
va_end(args); |
711 |
|
|
712 |
< |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
712 |
> |
DLINK_FOREACH(ptr, chptr->members.head) |
713 |
|
{ |
714 |
|
ms = ptr->data; |
715 |
|
target_p = ms->client_p; |
717 |
|
if (type != 0 && (ms->flags & type) == 0) |
718 |
|
continue; |
719 |
|
|
720 |
< |
if (target_p == one || IsDefunct(target_p) || IsDeaf(target_p)) |
720 |
> |
if (!MyConnect(target_p) || target_p == one || |
721 |
> |
IsDefunct(target_p) || IsDeaf(target_p)) |
722 |
|
continue; |
723 |
|
send_message(target_p, buffer, len); |
724 |
|
} |
898 |
|
vsnprintf(buffer, sizeof(buffer), pattern, args); |
899 |
|
va_end(args); |
900 |
|
|
901 |
< |
current_serial++; |
901 |
> |
++current_serial; |
902 |
|
|
903 |
|
DLINK_FOREACH(ptr, global_serv_list.head) |
904 |
|
{ |
1138 |
|
{ |
1139 |
|
va_list args; |
1140 |
|
int have_uid = 0; |
1141 |
< |
struct Client *client_p; |
1189 |
< |
dlink_node *ptr; |
1141 |
> |
dlink_node *ptr = NULL; |
1142 |
|
char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE]; |
1143 |
< |
int len_uid = 0, len_nick; |
1143 |
> |
int len_uid = 0, len_nick = 0; |
1144 |
|
|
1145 |
|
if (HasID(source_p) && (me.id[0] != '\0')) |
1146 |
|
{ |
1160 |
|
|
1161 |
|
DLINK_FOREACH(ptr, serv_list.head) |
1162 |
|
{ |
1163 |
< |
client_p = ptr->data; |
1163 |
> |
struct Client *client_p = ptr->data; |
1164 |
|
|
1165 |
|
if (one != NULL && (client_p == one->from)) |
1166 |
|
continue; |
1167 |
|
if (IsDefunct(client_p)) |
1168 |
|
continue; |
1169 |
|
|
1170 |
< |
/* XXX perhaps IsCapable should test for localClient itself ? -db */ |
1171 |
< |
if (client_p->localClient == NULL || !IsCapable(client_p, CAP_LL) || |
1172 |
< |
!ServerInfo.hub || |
1173 |
< |
(source_p->lazyLinkClientExists & client_p->localClient->serverMask)) |
1222 |
< |
{ |
1223 |
< |
if (have_uid && IsCapable(client_p, CAP_TS6)) |
1224 |
< |
send_message(client_p, buf_uid, len_uid); |
1225 |
< |
else |
1226 |
< |
send_message(client_p, buf_nick, len_nick); |
1227 |
< |
} |
1170 |
> |
if (have_uid && IsCapable(client_p, CAP_TS6)) |
1171 |
> |
send_message(client_p, buf_uid, len_uid); |
1172 |
> |
else |
1173 |
> |
send_message(client_p, buf_nick, len_nick); |
1174 |
|
} |
1175 |
|
} |