]> jfr.im git - solanum.git/blob - src/channel.c
Tweak previous commit to avoid problems with OMODE.
[solanum.git] / src / channel.c
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * channel.c: Controls channels.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 * $Id: channel.c 3580 2007-11-07 23:45:14Z jilles $
25 */
26
27 #include "stdinc.h"
28 #include "channel.h"
29 #include "chmode.h"
30 #include "client.h"
31 #include "common.h"
32 #include "hash.h"
33 #include "hook.h"
34 #include "match.h"
35 #include "ircd.h"
36 #include "numeric.h"
37 #include "s_serv.h" /* captab */
38 #include "s_user.h"
39 #include "send.h"
40 #include "whowas.h"
41 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
42 #include "s_newconf.h"
43 #include "logger.h"
44
45 struct config_channel_entry ConfigChannel;
46 rb_dlink_list global_channel_list;
47 static rb_bh *channel_heap;
48 static rb_bh *ban_heap;
49 static rb_bh *topic_heap;
50 static rb_bh *member_heap;
51
52 static int channel_capabs[] = { CAP_EX, CAP_IE,
53 CAP_SERVICE,
54 CAP_TS6
55 };
56
57 #define NCHCAPS (sizeof(channel_capabs)/sizeof(int))
58 #define NCHCAP_COMBOS (1 << NCHCAPS)
59
60 static struct ChCapCombo chcap_combos[NCHCAP_COMBOS];
61
62 static void free_topic(struct Channel *chptr);
63
64 static int h_can_join;
65 static int h_can_send;
66 int h_get_channel_access;
67
68 /* init_channels()
69 *
70 * input -
71 * output -
72 * side effects - initialises the various blockheaps
73 */
74 void
75 init_channels(void)
76 {
77 channel_heap = rb_bh_create(sizeof(struct Channel), CHANNEL_HEAP_SIZE, "channel_heap");
78 ban_heap = rb_bh_create(sizeof(struct Ban), BAN_HEAP_SIZE, "ban_heap");
79 topic_heap = rb_bh_create(TOPICLEN + 1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE, "topic_heap");
80 member_heap = rb_bh_create(sizeof(struct membership), MEMBER_HEAP_SIZE, "member_heap");
81
82 h_can_join = register_hook("can_join");
83 h_can_send = register_hook("can_send");
84 h_get_channel_access = register_hook("get_channel_access");
85 }
86
87 /*
88 * allocate_channel - Allocates a channel
89 */
90 struct Channel *
91 allocate_channel(const char *chname)
92 {
93 struct Channel *chptr;
94 chptr = rb_bh_alloc(channel_heap);
95 chptr->chname = rb_strdup(chname);
96 return (chptr);
97 }
98
99 void
100 free_channel(struct Channel *chptr)
101 {
102 rb_free(chptr->chname);
103 rb_free(chptr->mode_lock);
104 rb_bh_free(channel_heap, chptr);
105 }
106
107 struct Ban *
108 allocate_ban(const char *banstr, const char *who)
109 {
110 struct Ban *bptr;
111 bptr = rb_bh_alloc(ban_heap);
112 bptr->banstr = rb_strdup(banstr);
113 bptr->who = rb_strdup(who);
114
115 return (bptr);
116 }
117
118 void
119 free_ban(struct Ban *bptr)
120 {
121 rb_free(bptr->banstr);
122 rb_free(bptr->who);
123 rb_bh_free(ban_heap, bptr);
124 }
125
126 /*
127 * send_channel_join()
128 *
129 * input - channel to join, client joining.
130 * output - none
131 * side effects - none
132 */
133 void
134 send_channel_join(struct Channel *chptr, struct Client *client_p)
135 {
136 if (!IsClient(client_p))
137 return;
138
139 sendto_channel_local_with_capability(ALL_MEMBERS, NOCAPS, CLICAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN %s",
140 client_p->name, client_p->username, client_p->host, chptr->chname);
141
142 sendto_channel_local_with_capability(ALL_MEMBERS, CLICAP_EXTENDED_JOIN, NOCAPS, chptr, ":%s!%s@%s JOIN %s %s %ld :%s",
143 client_p->name, client_p->username, client_p->host, chptr->chname,
144 EmptyString(client_p->user->suser) ? "*" : client_p->user->suser,
145 client_p->tsinfo, client_p->info);
146 }
147
148 /* find_channel_membership()
149 *
150 * input - channel to find them in, client to find
151 * output - membership of client in channel, else NULL
152 * side effects -
153 */
154 struct membership *
155 find_channel_membership(struct Channel *chptr, struct Client *client_p)
156 {
157 struct membership *msptr;
158 rb_dlink_node *ptr;
159
160 if(!IsClient(client_p))
161 return NULL;
162
163 /* Pick the most efficient list to use to be nice to things like
164 * CHANSERV which could be in a large number of channels
165 */
166 if(rb_dlink_list_length(&chptr->members) < rb_dlink_list_length(&client_p->user->channel))
167 {
168 RB_DLINK_FOREACH(ptr, chptr->members.head)
169 {
170 msptr = ptr->data;
171
172 if(msptr->client_p == client_p)
173 return msptr;
174 }
175 }
176 else
177 {
178 RB_DLINK_FOREACH(ptr, client_p->user->channel.head)
179 {
180 msptr = ptr->data;
181
182 if(msptr->chptr == chptr)
183 return msptr;
184 }
185 }
186
187 return NULL;
188 }
189
190 /* find_channel_status()
191 *
192 * input - membership to get status for, whether we can combine flags
193 * output - flags of user on channel
194 * side effects -
195 */
196 const char *
197 find_channel_status(struct membership *msptr, int combine)
198 {
199 static char buffer[3];
200 char *p;
201
202 p = buffer;
203
204 if(is_chanop(msptr))
205 {
206 if(!combine)
207 return "@";
208 *p++ = '@';
209 }
210
211 if(is_voiced(msptr))
212 *p++ = '+';
213
214 *p = '\0';
215 return buffer;
216 }
217
218 /* add_user_to_channel()
219 *
220 * input - channel to add client to, client to add, channel flags
221 * output -
222 * side effects - user is added to channel
223 */
224 void
225 add_user_to_channel(struct Channel *chptr, struct Client *client_p, int flags)
226 {
227 struct membership *msptr;
228
229 s_assert(client_p->user != NULL);
230 if(client_p->user == NULL)
231 return;
232
233 msptr = rb_bh_alloc(member_heap);
234
235 msptr->chptr = chptr;
236 msptr->client_p = client_p;
237 msptr->flags = flags;
238
239 rb_dlinkAdd(msptr, &msptr->usernode, &client_p->user->channel);
240 rb_dlinkAdd(msptr, &msptr->channode, &chptr->members);
241
242 if(MyClient(client_p))
243 rb_dlinkAdd(msptr, &msptr->locchannode, &chptr->locmembers);
244 }
245
246 /* remove_user_from_channel()
247 *
248 * input - membership pointer to remove from channel
249 * output -
250 * side effects - membership (thus user) is removed from channel
251 */
252 void
253 remove_user_from_channel(struct membership *msptr)
254 {
255 struct Client *client_p;
256 struct Channel *chptr;
257 s_assert(msptr != NULL);
258 if(msptr == NULL)
259 return;
260
261 client_p = msptr->client_p;
262 chptr = msptr->chptr;
263
264 rb_dlinkDelete(&msptr->usernode, &client_p->user->channel);
265 rb_dlinkDelete(&msptr->channode, &chptr->members);
266
267 if(client_p->servptr == &me)
268 rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers);
269
270 if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
271 destroy_channel(chptr);
272
273 rb_bh_free(member_heap, msptr);
274
275 return;
276 }
277
278 /* remove_user_from_channels()
279 *
280 * input - user to remove from all channels
281 * output -
282 * side effects - user is removed from all channels
283 */
284 void
285 remove_user_from_channels(struct Client *client_p)
286 {
287 struct Channel *chptr;
288 struct membership *msptr;
289 rb_dlink_node *ptr;
290 rb_dlink_node *next_ptr;
291
292 if(client_p == NULL)
293 return;
294
295 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->user->channel.head)
296 {
297 msptr = ptr->data;
298 chptr = msptr->chptr;
299
300 rb_dlinkDelete(&msptr->channode, &chptr->members);
301
302 if(client_p->servptr == &me)
303 rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers);
304
305 if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
306 destroy_channel(chptr);
307
308 rb_bh_free(member_heap, msptr);
309 }
310
311 client_p->user->channel.head = client_p->user->channel.tail = NULL;
312 client_p->user->channel.length = 0;
313 }
314
315 /* invalidate_bancache_user()
316 *
317 * input - user to invalidate ban cache for
318 * output -
319 * side effects - ban cache is invalidated for all memberships of that user
320 * to be used after a nick change
321 */
322 void
323 invalidate_bancache_user(struct Client *client_p)
324 {
325 struct membership *msptr;
326 rb_dlink_node *ptr;
327
328 if(client_p == NULL)
329 return;
330
331 RB_DLINK_FOREACH(ptr, client_p->user->channel.head)
332 {
333 msptr = ptr->data;
334 msptr->bants = 0;
335 msptr->flags &= ~CHFL_BANNED;
336 }
337 }
338
339 /* check_channel_name()
340 *
341 * input - channel name
342 * output - 1 if valid channel name, else 0
343 * side effects -
344 */
345 int
346 check_channel_name(const char *name)
347 {
348 s_assert(name != NULL);
349 if(name == NULL)
350 return 0;
351
352 for (; *name; ++name)
353 {
354 if(!IsChanChar(*name))
355 return 0;
356 }
357
358 return 1;
359 }
360
361 /* free_channel_list()
362 *
363 * input - rb_dlink list to free
364 * output -
365 * side effects - list of b/e/I modes is cleared
366 */
367 void
368 free_channel_list(rb_dlink_list * list)
369 {
370 rb_dlink_node *ptr;
371 rb_dlink_node *next_ptr;
372 struct Ban *actualBan;
373
374 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
375 {
376 actualBan = ptr->data;
377 free_ban(actualBan);
378 }
379
380 list->head = list->tail = NULL;
381 list->length = 0;
382 }
383
384 /* destroy_channel()
385 *
386 * input - channel to destroy
387 * output -
388 * side effects - channel is obliterated
389 */
390 void
391 destroy_channel(struct Channel *chptr)
392 {
393 rb_dlink_node *ptr, *next_ptr;
394
395 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head)
396 {
397 del_invite(chptr, ptr->data);
398 }
399
400 /* free all bans/exceptions/denies */
401 free_channel_list(&chptr->banlist);
402 free_channel_list(&chptr->exceptlist);
403 free_channel_list(&chptr->invexlist);
404 free_channel_list(&chptr->quietlist);
405
406 /* Free the topic */
407 free_topic(chptr);
408
409 rb_dlinkDelete(&chptr->node, &global_channel_list);
410 del_from_channel_hash(chptr->chname, chptr);
411 free_channel(chptr);
412 }
413
414 /* channel_pub_or_secret()
415 *
416 * input - channel
417 * output - "=" if public, "@" if secret, else "*"
418 * side effects -
419 */
420 static const char *
421 channel_pub_or_secret(struct Channel *chptr)
422 {
423 if(PubChannel(chptr))
424 return ("=");
425 else if(SecretChannel(chptr))
426 return ("@");
427 return ("*");
428 }
429
430 /* channel_member_names()
431 *
432 * input - channel to list, client to list to, show endofnames
433 * output -
434 * side effects - client is given list of users on channel
435 */
436 void
437 channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eon)
438 {
439 struct membership *msptr;
440 struct Client *target_p;
441 rb_dlink_node *ptr;
442 char lbuf[BUFSIZE];
443 char *t;
444 int mlen;
445 int tlen;
446 int cur_len;
447 int is_member;
448 int stack = IsCapable(client_p, CLICAP_MULTI_PREFIX);
449
450 if(ShowChannel(client_p, chptr))
451 {
452 is_member = IsMember(client_p, chptr);
453
454 cur_len = mlen = rb_sprintf(lbuf, form_str(RPL_NAMREPLY),
455 me.name, client_p->name,
456 channel_pub_or_secret(chptr), chptr->chname);
457
458 t = lbuf + cur_len;
459
460 RB_DLINK_FOREACH(ptr, chptr->members.head)
461 {
462 msptr = ptr->data;
463 target_p = msptr->client_p;
464
465 if(IsInvisible(target_p) && !is_member)
466 continue;
467
468 /* space, possible "@+" prefix */
469 if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3)
470 {
471 *(t - 1) = '\0';
472 sendto_one(client_p, "%s", lbuf);
473 cur_len = mlen;
474 t = lbuf + mlen;
475 }
476
477 tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
478 target_p->name);
479
480 cur_len += tlen;
481 t += tlen;
482 }
483
484 /* The old behaviour here was to always output our buffer,
485 * even if there are no clients we can show. This happens
486 * when a client does "NAMES" with no parameters, and all
487 * the clients on a -sp channel are +i. I dont see a good
488 * reason for keeping that behaviour, as it just wastes
489 * bandwidth. --anfl
490 */
491 if(cur_len != mlen)
492 {
493 *(t - 1) = '\0';
494 sendto_one(client_p, "%s", lbuf);
495 }
496 }
497
498 if(show_eon)
499 sendto_one(client_p, form_str(RPL_ENDOFNAMES),
500 me.name, client_p->name, chptr->chname);
501 }
502
503 /* del_invite()
504 *
505 * input - channel to remove invite from, client to remove
506 * output -
507 * side effects - user is removed from invite list, if exists
508 */
509 void
510 del_invite(struct Channel *chptr, struct Client *who)
511 {
512 rb_dlinkFindDestroy(who, &chptr->invites);
513 rb_dlinkFindDestroy(chptr, &who->user->invited);
514 }
515
516 /* is_banned()
517 *
518 * input - channel to check bans for, user to check bans against
519 * optional prebuilt buffers
520 * output - 1 if banned, else 0
521 * side effects -
522 */
523 int
524 is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
525 const char *s, const char *s2)
526 {
527 char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
528 char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
529 char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
530 char *s3 = NULL;
531 rb_dlink_node *ptr;
532 struct Ban *actualBan = NULL;
533 struct Ban *actualExcept = NULL;
534
535 if(!MyClient(who))
536 return 0;
537
538 /* if the buffers havent been built, do it here */
539 if(s == NULL)
540 {
541 rb_sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
542 rb_sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
543
544 s = src_host;
545 s2 = src_iphost;
546 }
547 if(who->localClient->mangledhost != NULL)
548 {
549 /* if host mangling mode enabled, also check their real host */
550 if(!strcmp(who->host, who->localClient->mangledhost))
551 {
552 rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
553 s3 = src_althost;
554 }
555 /* if host mangling mode not enabled and no other spoof,
556 * also check the mangled form of their host */
557 else if (!IsDynSpoof(who))
558 {
559 rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
560 s3 = src_althost;
561 }
562 }
563
564 RB_DLINK_FOREACH(ptr, chptr->banlist.head)
565 {
566 actualBan = ptr->data;
567 if(match(actualBan->banstr, s) ||
568 match(actualBan->banstr, s2) ||
569 match_cidr(actualBan->banstr, s2) ||
570 match_extban(actualBan->banstr, who, chptr, CHFL_BAN) ||
571 (s3 != NULL && match(actualBan->banstr, s3)))
572 break;
573 else
574 actualBan = NULL;
575 }
576
577 if((actualBan != NULL) && ConfigChannel.use_except)
578 {
579 RB_DLINK_FOREACH(ptr, chptr->exceptlist.head)
580 {
581 actualExcept = ptr->data;
582
583 /* theyre exempted.. */
584 if(match(actualExcept->banstr, s) ||
585 match(actualExcept->banstr, s2) ||
586 match_cidr(actualExcept->banstr, s2) ||
587 match_extban(actualExcept->banstr, who, chptr, CHFL_EXCEPTION) ||
588 (s3 != NULL && match(actualExcept->banstr, s3)))
589 {
590 /* cache the fact theyre not banned */
591 if(msptr != NULL)
592 {
593 msptr->bants = chptr->bants;
594 msptr->flags &= ~CHFL_BANNED;
595 }
596
597 return CHFL_EXCEPTION;
598 }
599 }
600 }
601
602 /* cache the banned/not banned status */
603 if(msptr != NULL)
604 {
605 msptr->bants = chptr->bants;
606
607 if(actualBan != NULL)
608 {
609 msptr->flags |= CHFL_BANNED;
610 return CHFL_BAN;
611 }
612 else
613 {
614 msptr->flags &= ~CHFL_BANNED;
615 return 0;
616 }
617 }
618
619 return ((actualBan ? CHFL_BAN : 0));
620 }
621
622 /* is_quieted()
623 *
624 * input - channel to check bans for, user to check bans against
625 * optional prebuilt buffers
626 * output - 1 if banned, else 0
627 * side effects -
628 */
629 int
630 is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
631 const char *s, const char *s2)
632 {
633 char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
634 char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
635 char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
636 char *s3 = NULL;
637 rb_dlink_node *ptr;
638 struct Ban *actualBan = NULL;
639 struct Ban *actualExcept = NULL;
640
641 if(!MyClient(who))
642 return 0;
643
644 /* if the buffers havent been built, do it here */
645 if(s == NULL)
646 {
647 rb_sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
648 rb_sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
649
650 s = src_host;
651 s2 = src_iphost;
652 }
653 if(who->localClient->mangledhost != NULL)
654 {
655 /* if host mangling mode enabled, also check their real host */
656 if(!strcmp(who->host, who->localClient->mangledhost))
657 {
658 rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
659 s3 = src_althost;
660 }
661 /* if host mangling mode not enabled and no other spoof,
662 * also check the mangled form of their host */
663 else if (!IsDynSpoof(who))
664 {
665 rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
666 s3 = src_althost;
667 }
668 }
669
670 RB_DLINK_FOREACH(ptr, chptr->quietlist.head)
671 {
672 actualBan = ptr->data;
673 if(match(actualBan->banstr, s) ||
674 match(actualBan->banstr, s2) ||
675 match_cidr(actualBan->banstr, s2) ||
676 match_extban(actualBan->banstr, who, chptr, CHFL_QUIET) ||
677 (s3 != NULL && match(actualBan->banstr, s3)))
678 break;
679 else
680 actualBan = NULL;
681 }
682
683 if((actualBan != NULL) && ConfigChannel.use_except)
684 {
685 RB_DLINK_FOREACH(ptr, chptr->exceptlist.head)
686 {
687 actualExcept = ptr->data;
688
689 /* theyre exempted.. */
690 if(match(actualExcept->banstr, s) ||
691 match(actualExcept->banstr, s2) ||
692 match_cidr(actualExcept->banstr, s2) ||
693 match_extban(actualExcept->banstr, who, chptr, CHFL_EXCEPTION) ||
694 (s3 != NULL && match(actualExcept->banstr, s3)))
695 {
696 /* cache the fact theyre not banned */
697 if(msptr != NULL)
698 {
699 msptr->bants = chptr->bants;
700 msptr->flags &= ~CHFL_BANNED;
701 }
702
703 return CHFL_EXCEPTION;
704 }
705 }
706 }
707
708 /* cache the banned/not banned status */
709 if(msptr != NULL)
710 {
711 msptr->bants = chptr->bants;
712
713 if(actualBan != NULL)
714 {
715 msptr->flags |= CHFL_BANNED;
716 return CHFL_BAN;
717 }
718 else
719 {
720 msptr->flags &= ~CHFL_BANNED;
721 return 0;
722 }
723 }
724
725 return ((actualBan ? CHFL_BAN : 0));
726 }
727
728 /* can_join()
729 *
730 * input - client to check, channel to check for, key
731 * output - reason for not being able to join, else 0
732 * side effects -
733 * caveats - this function should only be called on a local user.
734 */
735 int
736 can_join(struct Client *source_p, struct Channel *chptr, char *key)
737 {
738 rb_dlink_node *invite = NULL;
739 rb_dlink_node *ptr;
740 struct Ban *invex = NULL;
741 char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
742 char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
743 char src_althost[NICKLEN + USERLEN + HOSTLEN + 6];
744 int use_althost = 0;
745 int i = 0;
746 hook_data_channel moduledata;
747
748 s_assert(source_p->localClient != NULL);
749
750 moduledata.client = source_p;
751 moduledata.chptr = chptr;
752 moduledata.approved = 0;
753
754 rb_sprintf(src_host, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
755 rb_sprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username, source_p->sockhost);
756 if(source_p->localClient->mangledhost != NULL)
757 {
758 /* if host mangling mode enabled, also check their real host */
759 if(!strcmp(source_p->host, source_p->localClient->mangledhost))
760 {
761 rb_sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->orighost);
762 use_althost = 1;
763 }
764 /* if host mangling mode not enabled and no other spoof,
765 * also check the mangled form of their host */
766 else if (!IsDynSpoof(source_p))
767 {
768 rb_sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->localClient->mangledhost);
769 use_althost = 1;
770 }
771 }
772
773 if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN)
774 {
775 moduledata.approved = ERR_BANNEDFROMCHAN;
776 goto finish_join_check;
777 }
778
779 if(chptr->mode.mode & MODE_INVITEONLY)
780 {
781 RB_DLINK_FOREACH(invite, source_p->user->invited.head)
782 {
783 if(invite->data == chptr)
784 break;
785 }
786 if(invite == NULL)
787 {
788 if(!ConfigChannel.use_invex)
789 moduledata.approved = ERR_INVITEONLYCHAN;
790 RB_DLINK_FOREACH(ptr, chptr->invexlist.head)
791 {
792 invex = ptr->data;
793 if(match(invex->banstr, src_host)
794 || match(invex->banstr, src_iphost)
795 || match_cidr(invex->banstr, src_iphost)
796 || match_extban(invex->banstr, source_p, chptr, CHFL_INVEX)
797 || (use_althost && match(invex->banstr, src_althost)))
798 break;
799 }
800 if(ptr == NULL)
801 moduledata.approved = ERR_INVITEONLYCHAN;
802 }
803 }
804
805 if(*chptr->mode.key && (EmptyString(key) || irccmp(chptr->mode.key, key)))
806 moduledata.approved = ERR_BADCHANNELKEY;
807
808 if(chptr->mode.limit &&
809 rb_dlink_list_length(&chptr->members) >= (unsigned long) chptr->mode.limit)
810 i = ERR_CHANNELISFULL;
811 if(chptr->mode.mode & MODE_REGONLY && EmptyString(source_p->user->suser))
812 i = ERR_NEEDREGGEDNICK;
813 /* join throttling stuff --nenolod */
814 else if(chptr->mode.join_num > 0 && chptr->mode.join_time > 0)
815 {
816 if ((rb_current_time() - chptr->join_delta <=
817 chptr->mode.join_time) && (chptr->join_count >=
818 chptr->mode.join_num))
819 i = ERR_THROTTLE;
820 }
821
822 /* allow /invite to override +l/+r/+j also -- jilles */
823 if (i != 0 && invite == NULL)
824 {
825 RB_DLINK_FOREACH(invite, source_p->user->invited.head)
826 {
827 if(invite->data == chptr)
828 break;
829 }
830 if (invite == NULL)
831 moduledata.approved = i;
832 }
833
834 finish_join_check:
835 call_hook(h_can_join, &moduledata);
836
837 return moduledata.approved;
838 }
839
840 /* can_send()
841 *
842 * input - user to check in channel, membership pointer
843 * output - whether can explicitly send or not, else CAN_SEND_NONOP
844 * side effects -
845 */
846 int
847 can_send(struct Channel *chptr, struct Client *source_p, struct membership *msptr)
848 {
849 hook_data_channel_approval moduledata;
850
851 moduledata.approved = CAN_SEND_NONOP;
852
853 if(IsServer(source_p) || IsService(source_p))
854 return CAN_SEND_OPV;
855
856 if(MyClient(source_p) && hash_find_resv(chptr->chname) &&
857 !IsOper(source_p) && !IsExemptResv(source_p))
858 moduledata.approved = CAN_SEND_NO;
859
860 if(msptr == NULL)
861 {
862 msptr = find_channel_membership(chptr, source_p);
863
864 if(msptr == NULL)
865 {
866 /* if its +m or +n and theyre not in the channel,
867 * they cant send. we dont check bans here because
868 * theres no possibility of caching them --fl
869 */
870 if(chptr->mode.mode & MODE_NOPRIVMSGS || chptr->mode.mode & MODE_MODERATED)
871 moduledata.approved = CAN_SEND_NO;
872 else
873 moduledata.approved = CAN_SEND_NONOP;
874
875 return moduledata.approved;
876 }
877 }
878
879 if(chptr->mode.mode & MODE_MODERATED)
880 moduledata.approved = CAN_SEND_NO;
881
882 if(MyClient(source_p))
883 {
884 /* cached can_send */
885 if(msptr->bants == chptr->bants)
886 {
887 if(can_send_banned(msptr))
888 moduledata.approved = CAN_SEND_NO;
889 }
890 else if(is_banned(chptr, source_p, msptr, NULL, NULL) == CHFL_BAN
891 || is_quieted(chptr, source_p, msptr, NULL, NULL) == CHFL_BAN)
892 moduledata.approved = CAN_SEND_NO;
893 }
894
895 if(is_chanop_voiced(msptr))
896 moduledata.approved = CAN_SEND_OPV;
897
898 call_hook(h_can_send, &moduledata);
899
900 return moduledata.approved;
901 }
902
903 /*
904 * flood_attack_channel
905 * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
906 * says NOTICE must not auto reply
907 * - pointer to source Client
908 * - pointer to target channel
909 * output - 1 if target is under flood attack
910 * side effects - check for flood attack on target chptr
911 */
912 int
913 flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, char *chname)
914 {
915 int delta;
916
917 if(GlobalSetOptions.floodcount && MyClient(source_p))
918 {
919 if((chptr->first_received_message_time + 1) < rb_current_time())
920 {
921 delta = rb_current_time() - chptr->first_received_message_time;
922 chptr->received_number_of_privmsgs -= delta;
923 chptr->first_received_message_time = rb_current_time();
924 if(chptr->received_number_of_privmsgs <= 0)
925 {
926 chptr->received_number_of_privmsgs = 0;
927 chptr->flood_noticed = 0;
928 }
929 }
930
931 if((chptr->received_number_of_privmsgs >= GlobalSetOptions.floodcount)
932 || chptr->flood_noticed)
933 {
934 if(chptr->flood_noticed == 0)
935 {
936 sendto_realops_snomask(SNO_BOTS, *chptr->chname == '&' ? L_ALL : L_NETWIDE,
937 "Possible Flooder %s[%s@%s] on %s target: %s",
938 source_p->name, source_p->username,
939 source_p->orighost,
940 source_p->servptr->name, chptr->chname);
941 chptr->flood_noticed = 1;
942
943 /* Add a bit of penalty */
944 chptr->received_number_of_privmsgs += 2;
945 }
946 if(MyClient(source_p) && (p_or_n != 1))
947 sendto_one(source_p,
948 ":%s NOTICE %s :*** Message to %s throttled due to flooding",
949 me.name, source_p->name, chptr->chname);
950 return 1;
951 }
952 else
953 chptr->received_number_of_privmsgs++;
954 }
955
956 return 0;
957 }
958
959 /* find_bannickchange_channel()
960 * Input: client to check
961 * Output: channel preventing nick change
962 */
963 struct Channel *
964 find_bannickchange_channel(struct Client *client_p)
965 {
966 struct Channel *chptr;
967 struct membership *msptr;
968 rb_dlink_node *ptr;
969 char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
970 char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
971
972 if (!MyClient(client_p))
973 return NULL;
974
975 rb_sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
976 rb_sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);
977
978 RB_DLINK_FOREACH(ptr, client_p->user->channel.head)
979 {
980 msptr = ptr->data;
981 chptr = msptr->chptr;
982 if (is_chanop_voiced(msptr))
983 continue;
984 /* cached can_send */
985 if (msptr->bants == chptr->bants)
986 {
987 if (can_send_banned(msptr))
988 return chptr;
989 }
990 else if (is_banned(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN
991 || is_quieted(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN)
992 return chptr;
993 }
994 return NULL;
995 }
996
997 /* void check_spambot_warning(struct Client *source_p)
998 * Input: Client to check, channel name or NULL if this is a part.
999 * Output: none
1000 * Side-effects: Updates the client's oper_warn_count_down, warns the
1001 * IRC operators if necessary, and updates join_leave_countdown as
1002 * needed.
1003 */
1004 void
1005 check_spambot_warning(struct Client *source_p, const char *name)
1006 {
1007 int t_delta;
1008 int decrement_count;
1009 if((GlobalSetOptions.spam_num &&
1010 (source_p->localClient->join_leave_count >= GlobalSetOptions.spam_num)))
1011 {
1012 if(source_p->localClient->oper_warn_count_down > 0)
1013 source_p->localClient->oper_warn_count_down--;
1014 else
1015 source_p->localClient->oper_warn_count_down = 0;
1016 if(source_p->localClient->oper_warn_count_down == 0 &&
1017 name != NULL)
1018 {
1019 /* Its already known as a possible spambot */
1020 sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
1021 "User %s (%s@%s) trying to join %s is a possible spambot",
1022 source_p->name,
1023 source_p->username, source_p->orighost, name);
1024 source_p->localClient->oper_warn_count_down = OPER_SPAM_COUNTDOWN;
1025 }
1026 }
1027 else
1028 {
1029 if((t_delta =
1030 (rb_current_time() - source_p->localClient->last_leave_time)) >
1031 JOIN_LEAVE_COUNT_EXPIRE_TIME)
1032 {
1033 decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
1034 if(name != NULL)
1035 ;
1036 else if(decrement_count > source_p->localClient->join_leave_count)
1037 source_p->localClient->join_leave_count = 0;
1038 else
1039 source_p->localClient->join_leave_count -= decrement_count;
1040 }
1041 else
1042 {
1043 if((rb_current_time() -
1044 (source_p->localClient->last_join_time)) < GlobalSetOptions.spam_time)
1045 {
1046 /* oh, its a possible spambot */
1047 source_p->localClient->join_leave_count++;
1048 }
1049 }
1050 if(name != NULL)
1051 source_p->localClient->last_join_time = rb_current_time();
1052 else
1053 source_p->localClient->last_leave_time = rb_current_time();
1054 }
1055 }
1056
1057 /* check_splitmode()
1058 *
1059 * input -
1060 * output -
1061 * side effects - compares usercount and servercount against their split
1062 * values and adjusts splitmode accordingly
1063 */
1064 void
1065 check_splitmode(void *unused)
1066 {
1067 if(splitchecking && (ConfigChannel.no_join_on_split || ConfigChannel.no_create_on_split))
1068 {
1069 /* not split, we're being asked to check now because someone
1070 * has left
1071 */
1072 if(!splitmode)
1073 {
1074 if(eob_count < split_servers || Count.total < split_users)
1075 {
1076 splitmode = 1;
1077 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1078 "Network split, activating splitmode");
1079 check_splitmode_ev = rb_event_addish("check_splitmode", check_splitmode, NULL, 2);
1080 }
1081 }
1082 /* in splitmode, check whether its finished */
1083 else if(eob_count >= split_servers && Count.total >= split_users)
1084 {
1085 splitmode = 0;
1086
1087 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1088 "Network rejoined, deactivating splitmode");
1089
1090 rb_event_delete(check_splitmode_ev);
1091 check_splitmode_ev = NULL;
1092 }
1093 }
1094 }
1095
1096
1097 /* allocate_topic()
1098 *
1099 * input - channel to allocate topic for
1100 * output - 1 on success, else 0
1101 * side effects - channel gets a topic allocated
1102 */
1103 static void
1104 allocate_topic(struct Channel *chptr)
1105 {
1106 void *ptr;
1107
1108 if(chptr == NULL)
1109 return;
1110
1111 ptr = rb_bh_alloc(topic_heap);
1112
1113 /* Basically we allocate one large block for the topic and
1114 * the topic info. We then split it up into two and shove it
1115 * in the chptr
1116 */
1117 chptr->topic = ptr;
1118 chptr->topic_info = (char *) ptr + TOPICLEN + 1;
1119 *chptr->topic = '\0';
1120 *chptr->topic_info = '\0';
1121 }
1122
1123 /* free_topic()
1124 *
1125 * input - channel which has topic to free
1126 * output -
1127 * side effects - channels topic is free'd
1128 */
1129 static void
1130 free_topic(struct Channel *chptr)
1131 {
1132 void *ptr;
1133
1134 if(chptr == NULL || chptr->topic == NULL)
1135 return;
1136
1137 /* This is safe for now - If you change allocate_topic you
1138 * MUST change this as well
1139 */
1140 ptr = chptr->topic;
1141 rb_bh_free(topic_heap, ptr);
1142 chptr->topic = NULL;
1143 chptr->topic_info = NULL;
1144 }
1145
1146 /* set_channel_topic()
1147 *
1148 * input - channel, topic to set, topic info and topic ts
1149 * output -
1150 * side effects - channels topic, topic info and TS are set.
1151 */
1152 void
1153 set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_info, time_t topicts)
1154 {
1155 if(strlen(topic) > 0)
1156 {
1157 if(chptr->topic == NULL)
1158 allocate_topic(chptr);
1159 rb_strlcpy(chptr->topic, topic, TOPICLEN + 1);
1160 rb_strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN);
1161 chptr->topic_time = topicts;
1162 }
1163 else
1164 {
1165 if(chptr->topic != NULL)
1166 free_topic(chptr);
1167 chptr->topic_time = 0;
1168 }
1169 }
1170
1171 /* channel_modes()
1172 *
1173 * inputs - pointer to channel
1174 * - pointer to client
1175 * output - string with simple modes
1176 * side effects - result from previous calls overwritten
1177 *
1178 * Stolen from ShadowIRCd 4 --nenolod
1179 */
1180 const char *
1181 channel_modes(struct Channel *chptr, struct Client *client_p)
1182 {
1183 int i;
1184 char buf1[BUFSIZE];
1185 char buf2[BUFSIZE];
1186 static char final[BUFSIZE];
1187 char *mbuf = buf1;
1188 char *pbuf = buf2;
1189
1190 *mbuf++ = '+';
1191 *pbuf = '\0';
1192
1193 for (i = 0; i < 256; i++)
1194 if(chptr->mode.mode & chmode_flags[i])
1195 *mbuf++ = i;
1196
1197 if(chptr->mode.limit)
1198 {
1199 *mbuf++ = 'l';
1200
1201 if(!IsClient(client_p) || IsMember(client_p, chptr))
1202 pbuf += rb_sprintf(pbuf, " %d", chptr->mode.limit);
1203 }
1204
1205 if(*chptr->mode.key)
1206 {
1207 *mbuf++ = 'k';
1208
1209 if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
1210 pbuf += rb_sprintf(pbuf, " %s", chptr->mode.key);
1211 }
1212
1213 if(chptr->mode.join_num)
1214 {
1215 *mbuf++ = 'j';
1216
1217 if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
1218 pbuf += rb_sprintf(pbuf, " %d:%d", chptr->mode.join_num,
1219 chptr->mode.join_time);
1220 }
1221
1222 if(*chptr->mode.forward && (ConfigChannel.use_forward || !IsClient(client_p)))
1223 {
1224 *mbuf++ = 'f';
1225
1226 if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
1227 pbuf += rb_sprintf(pbuf, " %s", chptr->mode.forward);
1228 }
1229
1230 *mbuf = '\0';
1231
1232 rb_strlcpy(final, buf1, sizeof final);
1233 rb_strlcat(final, buf2, sizeof final);
1234 return final;
1235 }
1236
1237 /* Now lets do some stuff to keep track of what combinations of
1238 * servers exist...
1239 * Note that the number of combinations doubles each time you add
1240 * something to this list. Each one is only quick if no servers use that
1241 * combination, but if the numbers get too high here MODE will get too
1242 * slow. I suggest if you get more than 7 here, you consider getting rid
1243 * of some and merging or something. If it wasn't for irc+cs we would
1244 * probably not even need to bother about most of these, but unfortunately
1245 * we do. -A1kmm
1246 */
1247
1248 /* void init_chcap_usage_counts(void)
1249 *
1250 * Inputs - none
1251 * Output - none
1252 * Side-effects - Initialises the usage counts to zero. Fills in the
1253 * chcap_yes and chcap_no combination tables.
1254 */
1255 void
1256 init_chcap_usage_counts(void)
1257 {
1258 unsigned long m, c, y, n;
1259
1260 memset(chcap_combos, 0, sizeof(chcap_combos));
1261
1262 /* For every possible combination */
1263 for (m = 0; m < NCHCAP_COMBOS; m++)
1264 {
1265 /* Check each capab */
1266 for (c = y = n = 0; c < NCHCAPS; c++)
1267 {
1268 if((m & (1 << c)) == 0)
1269 n |= channel_capabs[c];
1270 else
1271 y |= channel_capabs[c];
1272 }
1273 chcap_combos[m].cap_yes = y;
1274 chcap_combos[m].cap_no = n;
1275 }
1276 }
1277
1278 /* void set_chcap_usage_counts(struct Client *serv_p)
1279 * Input: serv_p; The client whose capabs to register.
1280 * Output: none
1281 * Side-effects: Increments the usage counts for the correct capab
1282 * combination.
1283 */
1284 void
1285 set_chcap_usage_counts(struct Client *serv_p)
1286 {
1287 int n;
1288
1289 for (n = 0; n < NCHCAP_COMBOS; n++)
1290 {
1291 if(IsCapable(serv_p, chcap_combos[n].cap_yes) &&
1292 NotCapable(serv_p, chcap_combos[n].cap_no))
1293 {
1294 chcap_combos[n].count++;
1295 return;
1296 }
1297 }
1298
1299 /* This should be impossible -A1kmm. */
1300 s_assert(0);
1301 }
1302
1303 /* void set_chcap_usage_counts(struct Client *serv_p)
1304 *
1305 * Inputs - serv_p; The client whose capabs to register.
1306 * Output - none
1307 * Side-effects - Decrements the usage counts for the correct capab
1308 * combination.
1309 */
1310 void
1311 unset_chcap_usage_counts(struct Client *serv_p)
1312 {
1313 int n;
1314
1315 for (n = 0; n < NCHCAP_COMBOS; n++)
1316 {
1317 if(IsCapable(serv_p, chcap_combos[n].cap_yes) &&
1318 NotCapable(serv_p, chcap_combos[n].cap_no))
1319 {
1320 /* Hopefully capabs can't change dynamically or anything... */
1321 s_assert(chcap_combos[n].count > 0);
1322
1323 if(chcap_combos[n].count > 0)
1324 chcap_combos[n].count--;
1325 return;
1326 }
1327 }
1328
1329 /* This should be impossible -A1kmm. */
1330 s_assert(0);
1331 }
1332
1333 /* void send_cap_mode_changes(struct Client *client_p,
1334 * struct Client *source_p,
1335 * struct Channel *chptr, int cap, int nocap)
1336 * Input: The client sending(client_p), the source client(source_p),
1337 * the channel to send mode changes for(chptr)
1338 * Output: None.
1339 * Side-effects: Sends the appropriate mode changes to capable servers.
1340 *
1341 * Reverted back to my original design, except that we now keep a count
1342 * of the number of servers which each combination as an optimisation, so
1343 * the capabs combinations which are not needed are not worked out. -A1kmm
1344 */
1345 void
1346 send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
1347 struct Channel *chptr, struct ChModeChange mode_changes[], int mode_count)
1348 {
1349 static char modebuf[BUFSIZE];
1350 static char parabuf[BUFSIZE];
1351 int i, mbl, pbl, nc, mc, preflen, len;
1352 char *pbuf;
1353 const char *arg;
1354 int dir;
1355 int j;
1356 int cap;
1357 int nocap;
1358 int arglen;
1359
1360 /* Now send to servers... */
1361 for (j = 0; j < NCHCAP_COMBOS; j++)
1362 {
1363 if(chcap_combos[j].count == 0)
1364 continue;
1365
1366 mc = 0;
1367 nc = 0;
1368 pbl = 0;
1369 parabuf[0] = 0;
1370 pbuf = parabuf;
1371 dir = MODE_QUERY;
1372
1373 cap = chcap_combos[j].cap_yes;
1374 nocap = chcap_combos[j].cap_no;
1375
1376 mbl = preflen = rb_sprintf(modebuf, ":%s TMODE %ld %s ",
1377 use_id(source_p), (long) chptr->channelts,
1378 chptr->chname);
1379
1380 /* loop the list of - modes we have */
1381 for (i = 0; i < mode_count; i++)
1382 {
1383 /* if they dont support the cap we need, or they do support a cap they
1384 * cant have, then dont add it to the modebuf.. that way they wont see
1385 * the mode
1386 */
1387 if((mode_changes[i].letter == 0) ||
1388 ((cap & mode_changes[i].caps) != mode_changes[i].caps)
1389 || ((nocap & mode_changes[i].nocaps) != mode_changes[i].nocaps))
1390 continue;
1391
1392 if(!EmptyString(mode_changes[i].id))
1393 arg = mode_changes[i].id;
1394 else
1395 arg = mode_changes[i].arg;
1396
1397 if(arg)
1398 {
1399 arglen = strlen(arg);
1400
1401 /* dont even think about it! --fl */
1402 if(arglen > MODEBUFLEN - 5)
1403 continue;
1404 }
1405
1406 /* if we're creeping past the buf size, we need to send it and make
1407 * another line for the other modes
1408 * XXX - this could give away server topology with uids being
1409 * different lengths, but not much we can do, except possibly break
1410 * them as if they were the longest of the nick or uid at all times,
1411 * which even then won't work as we don't always know the uid -A1kmm.
1412 */
1413 if(arg && ((mc == MAXMODEPARAMSSERV) ||
1414 ((mbl + pbl + arglen + 4) > (BUFSIZE - 3))))
1415 {
1416 if(nc != 0)
1417 sendto_server(client_p, chptr, cap, nocap,
1418 "%s %s", modebuf, parabuf);
1419 nc = 0;
1420 mc = 0;
1421
1422 mbl = preflen;
1423 pbl = 0;
1424 pbuf = parabuf;
1425 parabuf[0] = 0;
1426 dir = MODE_QUERY;
1427 }
1428
1429 if(dir != mode_changes[i].dir)
1430 {
1431 modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
1432 dir = mode_changes[i].dir;
1433 }
1434
1435 modebuf[mbl++] = mode_changes[i].letter;
1436 modebuf[mbl] = 0;
1437 nc++;
1438
1439 if(arg != NULL)
1440 {
1441 len = rb_sprintf(pbuf, "%s ", arg);
1442 pbuf += len;
1443 pbl += len;
1444 mc++;
1445 }
1446 }
1447
1448 if(pbl && parabuf[pbl - 1] == ' ')
1449 parabuf[pbl - 1] = 0;
1450
1451 if(nc != 0)
1452 sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
1453 }
1454 }
1455
1456 void
1457 resv_chan_forcepart(const char *name, const char *reason, int temp_time)
1458 {
1459 rb_dlink_node *ptr;
1460 rb_dlink_node *next_ptr;
1461 struct Channel *chptr;
1462 struct membership *msptr;
1463 struct Client *target_p;
1464
1465 if(!ConfigChannel.resv_forcepart)
1466 return;
1467
1468 /* for each user on our server in the channel list
1469 * send them a PART, and notify opers.
1470 */
1471 chptr = find_channel(name);
1472 if(chptr != NULL)
1473 {
1474 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
1475 {
1476 msptr = ptr->data;
1477 target_p = msptr->client_p;
1478
1479 if(IsExemptResv(target_p))
1480 continue;
1481
1482 sendto_server(target_p, chptr, CAP_TS6, NOCAPS,
1483 ":%s PART %s", target_p->id, chptr->chname);
1484
1485 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s",
1486 target_p->name, target_p->username,
1487 target_p->host, chptr->chname, target_p->name);
1488
1489 remove_user_from_channel(msptr);
1490
1491 /* notify opers & user they were removed from the channel */
1492 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1493 "Forced PART for %s!%s@%s from %s (%s)",
1494 target_p->name, target_p->username,
1495 target_p->host, name, reason);
1496
1497 if(temp_time > 0)
1498 sendto_one_notice(target_p, ":*** Channel %s is temporarily unavailable on this server.",
1499 name);
1500 else
1501 sendto_one_notice(target_p, ":*** Channel %s is no longer available on this server.",
1502 name);
1503 }
1504 }
1505 }