112 |
|
static void |
113 |
|
send_message(struct Client *to, char *buf, int len) |
114 |
|
{ |
115 |
< |
#ifdef INVARIANTS |
116 |
< |
if (IsMe(to)) |
117 |
< |
{ |
118 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
119 |
< |
"Trying to send message to myself!"); |
120 |
< |
return; |
121 |
< |
} |
122 |
< |
#endif |
115 |
> |
assert(!IsMe(to)); |
116 |
> |
assert(to != &me); |
117 |
|
|
118 |
|
if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(to)) |
119 |
|
{ |
167 |
|
return; |
168 |
|
} |
169 |
|
|
176 |
– |
if (ServerInfo.hub && IsCapable(to, CAP_LL)) |
177 |
– |
{ |
178 |
– |
if (((from->lazyLinkClientExists & |
179 |
– |
to->localClient->serverMask) == 0)) |
180 |
– |
client_burst_if_needed(to, from); |
181 |
– |
} |
182 |
– |
|
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); |
282 |
|
errno = EWOULDBLOCK; |
283 |
|
case SSL_ERROR_SYSCALL: |
284 |
|
break; |
285 |
< |
|
285 |
> |
case SSL_ERROR_SSL: |
286 |
> |
if (errno == EAGAIN) |
287 |
> |
break; |
288 |
|
default: |
289 |
|
retlen = errno = 0; /* either an SSL-specific error or EOF */ |
290 |
|
} |
538 |
|
* - pointer to channel required by LL (if any) |
539 |
|
* - caps or'd together which must ALL be present |
540 |
|
* - caps or'd together which must ALL NOT be present |
552 |
– |
* - LL flags: LL_ICLIENT | LL_ICHAN |
541 |
|
* - printf style format string |
542 |
|
* - args to format string |
543 |
|
* output - NONE |
544 |
|
* side effects - Send a message to all connected servers, except the |
545 |
|
* client 'one' (if non-NULL), as long as the servers |
546 |
|
* support ALL capabs in 'caps', and NO capabs in 'nocaps'. |
559 |
– |
* If the server is a lazylink client, then it must know |
560 |
– |
* about source_p if non-NULL (unless LL_ICLIENT is specified, |
561 |
– |
* when source_p will be introduced where required) and |
562 |
– |
* chptr if non-NULL (unless LL_ICHANNEL is specified, when |
563 |
– |
* chptr will be introduced where required). |
564 |
– |
* Note: nothing will be introduced to a LazyLeaf unless |
565 |
– |
* the message is actually sent. |
547 |
|
* |
548 |
|
* This function was written in an attempt to merge together the other |
549 |
|
* billion sendto_*serv*() functions, which sprung up with capabs, |
551 |
|
* -davidt |
552 |
|
*/ |
553 |
|
void |
554 |
< |
sendto_server(struct Client *one, struct Client *source_p, |
554 |
> |
sendto_server(struct Client *one, |
555 |
|
struct Channel *chptr, unsigned long caps, |
556 |
< |
unsigned long nocaps, unsigned long llflags, |
556 |
> |
unsigned long nocaps, |
557 |
|
const char *format, ...) |
558 |
|
{ |
559 |
|
va_list args; |
560 |
< |
struct Client *client_p; |
580 |
< |
dlink_node *ptr; |
560 |
> |
dlink_node *ptr = NULL; |
561 |
|
char buffer[IRCD_BUFSIZE]; |
562 |
< |
int len; |
562 |
> |
int len = 0; |
563 |
|
|
564 |
< |
if (chptr != NULL) |
565 |
< |
{ |
586 |
< |
if (chptr->chname[0] != '#') |
587 |
< |
return; |
588 |
< |
} |
564 |
> |
if (chptr && chptr->chname[0] != '#') |
565 |
> |
return; |
566 |
|
|
567 |
|
va_start(args, format); |
568 |
|
len = send_format(buffer, IRCD_BUFSIZE, format, args); |
570 |
|
|
571 |
|
DLINK_FOREACH(ptr, serv_list.head) |
572 |
|
{ |
573 |
< |
client_p = ptr->data; |
573 |
> |
struct Client *client_p = ptr->data; |
574 |
|
|
575 |
|
/* If dead already skip */ |
576 |
|
if (IsDead(client_p)) |
585 |
|
if ((client_p->localClient->caps & nocaps) != 0) |
586 |
|
continue; |
587 |
|
|
611 |
– |
if (ServerInfo.hub && IsCapable(client_p, CAP_LL)) |
612 |
– |
{ |
613 |
– |
/* check LL channel */ |
614 |
– |
if (chptr != NULL && |
615 |
– |
((chptr->lazyLinkChannelExists & |
616 |
– |
client_p->localClient->serverMask) == 0)) |
617 |
– |
{ |
618 |
– |
/* Only introduce the channel if we really will send this message */ |
619 |
– |
if (!(llflags & LL_ICLIENT) && source_p && |
620 |
– |
((source_p->lazyLinkClientExists & |
621 |
– |
client_p->localClient->serverMask) == 0)) |
622 |
– |
continue; /* we can't introduce the unknown source_p, skip */ |
623 |
– |
|
624 |
– |
if (llflags & LL_ICHAN) |
625 |
– |
burst_channel(client_p, chptr); |
626 |
– |
else |
627 |
– |
continue; /* we can't introduce the unknown chptr, skip */ |
628 |
– |
} |
629 |
– |
/* check LL client */ |
630 |
– |
if (source_p && |
631 |
– |
((source_p->lazyLinkClientExists & |
632 |
– |
client_p->localClient->serverMask) == 0)) |
633 |
– |
{ |
634 |
– |
if (llflags & LL_ICLIENT) |
635 |
– |
client_burst_if_needed(client_p,source_p); |
636 |
– |
else |
637 |
– |
continue; /* we can't introduce the unknown source_p, skip */ |
638 |
– |
} |
639 |
– |
} |
588 |
|
send_message(client_p, buffer, len); |
589 |
|
} |
590 |
|
} |
622 |
|
chptr = ((struct Membership *) cptr->data)->chptr; |
623 |
|
assert(chptr != NULL); |
624 |
|
|
625 |
< |
DLINK_FOREACH(uptr, chptr->locmembers.head) |
625 |
> |
DLINK_FOREACH(uptr, chptr->members.head) |
626 |
|
{ |
627 |
|
ms = uptr->data; |
628 |
|
target_p = ms->client_p; |
629 |
|
assert(target_p != NULL); |
630 |
|
|
631 |
< |
if (target_p == user || IsDefunct(target_p) || |
631 |
> |
if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) || |
632 |
|
target_p->serial == current_serial) |
633 |
|
continue; |
634 |
|
|
667 |
|
len = send_format(buffer, IRCD_BUFSIZE, pattern, args); |
668 |
|
va_end(args); |
669 |
|
|
670 |
< |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
670 |
> |
DLINK_FOREACH(ptr, chptr->members.head) |
671 |
|
{ |
672 |
|
ms = ptr->data; |
673 |
|
target_p = ms->client_p; |
675 |
|
if (type != 0 && (ms->flags & type) == 0) |
676 |
|
continue; |
677 |
|
|
678 |
< |
if (IsDefunct(target_p) || (nodeaf && IsDeaf(target_p))) |
678 |
> |
if (!MyConnect(target_p) || IsDefunct(target_p) || |
679 |
> |
(nodeaf && IsDeaf(target_p))) |
680 |
|
continue; |
681 |
|
|
682 |
|
send_message(target_p, buffer, len); |
710 |
|
len = send_format(buffer, IRCD_BUFSIZE, pattern, args); |
711 |
|
va_end(args); |
712 |
|
|
713 |
< |
DLINK_FOREACH(ptr, chptr->locmembers.head) |
713 |
> |
DLINK_FOREACH(ptr, chptr->members.head) |
714 |
|
{ |
715 |
|
ms = ptr->data; |
716 |
|
target_p = ms->client_p; |
718 |
|
if (type != 0 && (ms->flags & type) == 0) |
719 |
|
continue; |
720 |
|
|
721 |
< |
if (target_p == one || IsDefunct(target_p) || IsDeaf(target_p)) |
721 |
> |
if (!MyConnect(target_p) || target_p == one || |
722 |
> |
IsDefunct(target_p) || IsDeaf(target_p)) |
723 |
|
continue; |
724 |
|
send_message(target_p, buffer, len); |
725 |
|
} |
1139 |
|
{ |
1140 |
|
va_list args; |
1141 |
|
int have_uid = 0; |
1142 |
< |
struct Client *client_p; |
1193 |
< |
dlink_node *ptr; |
1142 |
> |
dlink_node *ptr = NULL; |
1143 |
|
char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE]; |
1144 |
< |
int len_uid = 0, len_nick; |
1144 |
> |
int len_uid = 0, len_nick = 0; |
1145 |
|
|
1146 |
|
if (HasID(source_p) && (me.id[0] != '\0')) |
1147 |
|
{ |
1161 |
|
|
1162 |
|
DLINK_FOREACH(ptr, serv_list.head) |
1163 |
|
{ |
1164 |
< |
client_p = ptr->data; |
1164 |
> |
struct Client *client_p = ptr->data; |
1165 |
|
|
1166 |
|
if (one != NULL && (client_p == one->from)) |
1167 |
|
continue; |
1168 |
|
if (IsDefunct(client_p)) |
1169 |
|
continue; |
1170 |
|
|
1171 |
< |
/* XXX perhaps IsCapable should test for localClient itself ? -db */ |
1172 |
< |
if (client_p->localClient == NULL || !IsCapable(client_p, CAP_LL) || |
1173 |
< |
!ServerInfo.hub || |
1174 |
< |
(source_p->lazyLinkClientExists & client_p->localClient->serverMask)) |
1226 |
< |
{ |
1227 |
< |
if (have_uid && IsCapable(client_p, CAP_TS6)) |
1228 |
< |
send_message(client_p, buf_uid, len_uid); |
1229 |
< |
else |
1230 |
< |
send_message(client_p, buf_nick, len_nick); |
1231 |
< |
} |
1171 |
> |
if (have_uid && IsCapable(client_p, CAP_TS6)) |
1172 |
> |
send_message(client_p, buf_uid, len_uid); |
1173 |
> |
else |
1174 |
> |
send_message(client_p, buf_nick, len_nick); |
1175 |
|
} |
1176 |
|
} |