]> jfr.im git - solanum.git/blob - src/channel.c
Remove a stale comment.
[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 :%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->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 moduledata.client = source_p;
899 moduledata.chptr = msptr->chptr;
900 moduledata.msptr = msptr;
901 moduledata.target = NULL;
902
903 call_hook(h_can_send, &moduledata);
904
905 return moduledata.approved;
906 }
907
908 /*
909 * flood_attack_channel
910 * inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
911 * says NOTICE must not auto reply
912 * - pointer to source Client
913 * - pointer to target channel
914 * output - 1 if target is under flood attack
915 * side effects - check for flood attack on target chptr
916 */
917 int
918 flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, char *chname)
919 {
920 int delta;
921
922 if(GlobalSetOptions.floodcount && MyClient(source_p))
923 {
924 if((chptr->first_received_message_time + 1) < rb_current_time())
925 {
926 delta = rb_current_time() - chptr->first_received_message_time;
927 chptr->received_number_of_privmsgs -= delta;
928 chptr->first_received_message_time = rb_current_time();
929 if(chptr->received_number_of_privmsgs <= 0)
930 {
931 chptr->received_number_of_privmsgs = 0;
932 chptr->flood_noticed = 0;
933 }
934 }
935
936 if((chptr->received_number_of_privmsgs >= GlobalSetOptions.floodcount)
937 || chptr->flood_noticed)
938 {
939 if(chptr->flood_noticed == 0)
940 {
941 sendto_realops_snomask(SNO_BOTS, *chptr->chname == '&' ? L_ALL : L_NETWIDE,
942 "Possible Flooder %s[%s@%s] on %s target: %s",
943 source_p->name, source_p->username,
944 source_p->orighost,
945 source_p->servptr->name, chptr->chname);
946 chptr->flood_noticed = 1;
947
948 /* Add a bit of penalty */
949 chptr->received_number_of_privmsgs += 2;
950 }
951 if(MyClient(source_p) && (p_or_n != 1))
952 sendto_one(source_p,
953 ":%s NOTICE %s :*** Message to %s throttled due to flooding",
954 me.name, source_p->name, chptr->chname);
955 return 1;
956 }
957 else
958 chptr->received_number_of_privmsgs++;
959 }
960
961 return 0;
962 }
963
964 /* find_bannickchange_channel()
965 * Input: client to check
966 * Output: channel preventing nick change
967 */
968 struct Channel *
969 find_bannickchange_channel(struct Client *client_p)
970 {
971 struct Channel *chptr;
972 struct membership *msptr;
973 rb_dlink_node *ptr;
974 char src_host[NICKLEN + USERLEN + HOSTLEN + 6];
975 char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6];
976
977 if (!MyClient(client_p))
978 return NULL;
979
980 rb_sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
981 rb_sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);
982
983 RB_DLINK_FOREACH(ptr, client_p->user->channel.head)
984 {
985 msptr = ptr->data;
986 chptr = msptr->chptr;
987 if (is_chanop_voiced(msptr))
988 continue;
989 /* cached can_send */
990 if (msptr->bants == chptr->bants)
991 {
992 if (can_send_banned(msptr))
993 return chptr;
994 }
995 else if (is_banned(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN
996 || is_quieted(chptr, client_p, msptr, src_host, src_iphost) == CHFL_BAN)
997 return chptr;
998 }
999 return NULL;
1000 }
1001
1002 /* void check_spambot_warning(struct Client *source_p)
1003 * Input: Client to check, channel name or NULL if this is a part.
1004 * Output: none
1005 * Side-effects: Updates the client's oper_warn_count_down, warns the
1006 * IRC operators if necessary, and updates join_leave_countdown as
1007 * needed.
1008 */
1009 void
1010 check_spambot_warning(struct Client *source_p, const char *name)
1011 {
1012 int t_delta;
1013 int decrement_count;
1014 if((GlobalSetOptions.spam_num &&
1015 (source_p->localClient->join_leave_count >= GlobalSetOptions.spam_num)))
1016 {
1017 if(source_p->localClient->oper_warn_count_down > 0)
1018 source_p->localClient->oper_warn_count_down--;
1019 else
1020 source_p->localClient->oper_warn_count_down = 0;
1021 if(source_p->localClient->oper_warn_count_down == 0 &&
1022 name != NULL)
1023 {
1024 /* Its already known as a possible spambot */
1025 sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
1026 "User %s (%s@%s) trying to join %s is a possible spambot",
1027 source_p->name,
1028 source_p->username, source_p->orighost, name);
1029 source_p->localClient->oper_warn_count_down = OPER_SPAM_COUNTDOWN;
1030 }
1031 }
1032 else
1033 {
1034 if((t_delta =
1035 (rb_current_time() - source_p->localClient->last_leave_time)) >
1036 JOIN_LEAVE_COUNT_EXPIRE_TIME)
1037 {
1038 decrement_count = (t_delta / JOIN_LEAVE_COUNT_EXPIRE_TIME);
1039 if(name != NULL)
1040 ;
1041 else if(decrement_count > source_p->localClient->join_leave_count)
1042 source_p->localClient->join_leave_count = 0;
1043 else
1044 source_p->localClient->join_leave_count -= decrement_count;
1045 }
1046 else
1047 {
1048 if((rb_current_time() -
1049 (source_p->localClient->last_join_time)) < GlobalSetOptions.spam_time)
1050 {
1051 /* oh, its a possible spambot */
1052 source_p->localClient->join_leave_count++;
1053 }
1054 }
1055 if(name != NULL)
1056 source_p->localClient->last_join_time = rb_current_time();
1057 else
1058 source_p->localClient->last_leave_time = rb_current_time();
1059 }
1060 }
1061
1062 /* check_splitmode()
1063 *
1064 * input -
1065 * output -
1066 * side effects - compares usercount and servercount against their split
1067 * values and adjusts splitmode accordingly
1068 */
1069 void
1070 check_splitmode(void *unused)
1071 {
1072 if(splitchecking && (ConfigChannel.no_join_on_split || ConfigChannel.no_create_on_split))
1073 {
1074 /* not split, we're being asked to check now because someone
1075 * has left
1076 */
1077 if(!splitmode)
1078 {
1079 if(eob_count < split_servers || Count.total < split_users)
1080 {
1081 splitmode = 1;
1082 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1083 "Network split, activating splitmode");
1084 check_splitmode_ev = rb_event_addish("check_splitmode", check_splitmode, NULL, 2);
1085 }
1086 }
1087 /* in splitmode, check whether its finished */
1088 else if(eob_count >= split_servers && Count.total >= split_users)
1089 {
1090 splitmode = 0;
1091
1092 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1093 "Network rejoined, deactivating splitmode");
1094
1095 rb_event_delete(check_splitmode_ev);
1096 check_splitmode_ev = NULL;
1097 }
1098 }
1099 }
1100
1101
1102 /* allocate_topic()
1103 *
1104 * input - channel to allocate topic for
1105 * output - 1 on success, else 0
1106 * side effects - channel gets a topic allocated
1107 */
1108 static void
1109 allocate_topic(struct Channel *chptr)
1110 {
1111 void *ptr;
1112
1113 if(chptr == NULL)
1114 return;
1115
1116 ptr = rb_bh_alloc(topic_heap);
1117
1118 /* Basically we allocate one large block for the topic and
1119 * the topic info. We then split it up into two and shove it
1120 * in the chptr
1121 */
1122 chptr->topic = ptr;
1123 chptr->topic_info = (char *) ptr + TOPICLEN + 1;
1124 *chptr->topic = '\0';
1125 *chptr->topic_info = '\0';
1126 }
1127
1128 /* free_topic()
1129 *
1130 * input - channel which has topic to free
1131 * output -
1132 * side effects - channels topic is free'd
1133 */
1134 static void
1135 free_topic(struct Channel *chptr)
1136 {
1137 void *ptr;
1138
1139 if(chptr == NULL || chptr->topic == NULL)
1140 return;
1141
1142 /* This is safe for now - If you change allocate_topic you
1143 * MUST change this as well
1144 */
1145 ptr = chptr->topic;
1146 rb_bh_free(topic_heap, ptr);
1147 chptr->topic = NULL;
1148 chptr->topic_info = NULL;
1149 }
1150
1151 /* set_channel_topic()
1152 *
1153 * input - channel, topic to set, topic info and topic ts
1154 * output -
1155 * side effects - channels topic, topic info and TS are set.
1156 */
1157 void
1158 set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_info, time_t topicts)
1159 {
1160 if(strlen(topic) > 0)
1161 {
1162 if(chptr->topic == NULL)
1163 allocate_topic(chptr);
1164 rb_strlcpy(chptr->topic, topic, TOPICLEN + 1);
1165 rb_strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN);
1166 chptr->topic_time = topicts;
1167 }
1168 else
1169 {
1170 if(chptr->topic != NULL)
1171 free_topic(chptr);
1172 chptr->topic_time = 0;
1173 }
1174 }
1175
1176 /* channel_modes()
1177 *
1178 * inputs - pointer to channel
1179 * - pointer to client
1180 * output - string with simple modes
1181 * side effects - result from previous calls overwritten
1182 *
1183 * Stolen from ShadowIRCd 4 --nenolod
1184 */
1185 const char *
1186 channel_modes(struct Channel *chptr, struct Client *client_p)
1187 {
1188 int i;
1189 char buf1[BUFSIZE];
1190 char buf2[BUFSIZE];
1191 static char final[BUFSIZE];
1192 char *mbuf = buf1;
1193 char *pbuf = buf2;
1194
1195 *mbuf++ = '+';
1196 *pbuf = '\0';
1197
1198 for (i = 0; i < 256; i++)
1199 if(chptr->mode.mode & chmode_flags[i])
1200 *mbuf++ = i;
1201
1202 if(chptr->mode.limit)
1203 {
1204 *mbuf++ = 'l';
1205
1206 if(!IsClient(client_p) || IsMember(client_p, chptr))
1207 pbuf += rb_sprintf(pbuf, " %d", chptr->mode.limit);
1208 }
1209
1210 if(*chptr->mode.key)
1211 {
1212 *mbuf++ = 'k';
1213
1214 if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
1215 pbuf += rb_sprintf(pbuf, " %s", chptr->mode.key);
1216 }
1217
1218 if(chptr->mode.join_num)
1219 {
1220 *mbuf++ = 'j';
1221
1222 if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
1223 pbuf += rb_sprintf(pbuf, " %d:%d", chptr->mode.join_num,
1224 chptr->mode.join_time);
1225 }
1226
1227 if(*chptr->mode.forward && (ConfigChannel.use_forward || !IsClient(client_p)))
1228 {
1229 *mbuf++ = 'f';
1230
1231 if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
1232 pbuf += rb_sprintf(pbuf, " %s", chptr->mode.forward);
1233 }
1234
1235 *mbuf = '\0';
1236
1237 rb_strlcpy(final, buf1, sizeof final);
1238 rb_strlcat(final, buf2, sizeof final);
1239 return final;
1240 }
1241
1242 /* Now lets do some stuff to keep track of what combinations of
1243 * servers exist...
1244 * Note that the number of combinations doubles each time you add
1245 * something to this list. Each one is only quick if no servers use that
1246 * combination, but if the numbers get too high here MODE will get too
1247 * slow. I suggest if you get more than 7 here, you consider getting rid
1248 * of some and merging or something. If it wasn't for irc+cs we would
1249 * probably not even need to bother about most of these, but unfortunately
1250 * we do. -A1kmm
1251 */
1252
1253 /* void init_chcap_usage_counts(void)
1254 *
1255 * Inputs - none
1256 * Output - none
1257 * Side-effects - Initialises the usage counts to zero. Fills in the
1258 * chcap_yes and chcap_no combination tables.
1259 */
1260 void
1261 init_chcap_usage_counts(void)
1262 {
1263 unsigned long m, c, y, n;
1264
1265 memset(chcap_combos, 0, sizeof(chcap_combos));
1266
1267 /* For every possible combination */
1268 for (m = 0; m < NCHCAP_COMBOS; m++)
1269 {
1270 /* Check each capab */
1271 for (c = y = n = 0; c < NCHCAPS; c++)
1272 {
1273 if((m & (1 << c)) == 0)
1274 n |= channel_capabs[c];
1275 else
1276 y |= channel_capabs[c];
1277 }
1278 chcap_combos[m].cap_yes = y;
1279 chcap_combos[m].cap_no = n;
1280 }
1281 }
1282
1283 /* void set_chcap_usage_counts(struct Client *serv_p)
1284 * Input: serv_p; The client whose capabs to register.
1285 * Output: none
1286 * Side-effects: Increments the usage counts for the correct capab
1287 * combination.
1288 */
1289 void
1290 set_chcap_usage_counts(struct Client *serv_p)
1291 {
1292 int n;
1293
1294 for (n = 0; n < NCHCAP_COMBOS; n++)
1295 {
1296 if(IsCapable(serv_p, chcap_combos[n].cap_yes) &&
1297 NotCapable(serv_p, chcap_combos[n].cap_no))
1298 {
1299 chcap_combos[n].count++;
1300 return;
1301 }
1302 }
1303
1304 /* This should be impossible -A1kmm. */
1305 s_assert(0);
1306 }
1307
1308 /* void set_chcap_usage_counts(struct Client *serv_p)
1309 *
1310 * Inputs - serv_p; The client whose capabs to register.
1311 * Output - none
1312 * Side-effects - Decrements the usage counts for the correct capab
1313 * combination.
1314 */
1315 void
1316 unset_chcap_usage_counts(struct Client *serv_p)
1317 {
1318 int n;
1319
1320 for (n = 0; n < NCHCAP_COMBOS; n++)
1321 {
1322 if(IsCapable(serv_p, chcap_combos[n].cap_yes) &&
1323 NotCapable(serv_p, chcap_combos[n].cap_no))
1324 {
1325 /* Hopefully capabs can't change dynamically or anything... */
1326 s_assert(chcap_combos[n].count > 0);
1327
1328 if(chcap_combos[n].count > 0)
1329 chcap_combos[n].count--;
1330 return;
1331 }
1332 }
1333
1334 /* This should be impossible -A1kmm. */
1335 s_assert(0);
1336 }
1337
1338 /* void send_cap_mode_changes(struct Client *client_p,
1339 * struct Client *source_p,
1340 * struct Channel *chptr, int cap, int nocap)
1341 * Input: The client sending(client_p), the source client(source_p),
1342 * the channel to send mode changes for(chptr)
1343 * Output: None.
1344 * Side-effects: Sends the appropriate mode changes to capable servers.
1345 *
1346 * Reverted back to my original design, except that we now keep a count
1347 * of the number of servers which each combination as an optimisation, so
1348 * the capabs combinations which are not needed are not worked out. -A1kmm
1349 */
1350 void
1351 send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
1352 struct Channel *chptr, struct ChModeChange mode_changes[], int mode_count)
1353 {
1354 static char modebuf[BUFSIZE];
1355 static char parabuf[BUFSIZE];
1356 int i, mbl, pbl, nc, mc, preflen, len;
1357 char *pbuf;
1358 const char *arg;
1359 int dir;
1360 int j;
1361 int cap;
1362 int nocap;
1363 int arglen;
1364
1365 /* Now send to servers... */
1366 for (j = 0; j < NCHCAP_COMBOS; j++)
1367 {
1368 if(chcap_combos[j].count == 0)
1369 continue;
1370
1371 mc = 0;
1372 nc = 0;
1373 pbl = 0;
1374 parabuf[0] = 0;
1375 pbuf = parabuf;
1376 dir = MODE_QUERY;
1377
1378 cap = chcap_combos[j].cap_yes;
1379 nocap = chcap_combos[j].cap_no;
1380
1381 mbl = preflen = rb_sprintf(modebuf, ":%s TMODE %ld %s ",
1382 use_id(source_p), (long) chptr->channelts,
1383 chptr->chname);
1384
1385 /* loop the list of - modes we have */
1386 for (i = 0; i < mode_count; i++)
1387 {
1388 /* if they dont support the cap we need, or they do support a cap they
1389 * cant have, then dont add it to the modebuf.. that way they wont see
1390 * the mode
1391 */
1392 if((mode_changes[i].letter == 0) ||
1393 ((cap & mode_changes[i].caps) != mode_changes[i].caps)
1394 || ((nocap & mode_changes[i].nocaps) != mode_changes[i].nocaps))
1395 continue;
1396
1397 if(!EmptyString(mode_changes[i].id))
1398 arg = mode_changes[i].id;
1399 else
1400 arg = mode_changes[i].arg;
1401
1402 if(arg)
1403 {
1404 arglen = strlen(arg);
1405
1406 /* dont even think about it! --fl */
1407 if(arglen > MODEBUFLEN - 5)
1408 continue;
1409 }
1410
1411 /* if we're creeping past the buf size, we need to send it and make
1412 * another line for the other modes
1413 * XXX - this could give away server topology with uids being
1414 * different lengths, but not much we can do, except possibly break
1415 * them as if they were the longest of the nick or uid at all times,
1416 * which even then won't work as we don't always know the uid -A1kmm.
1417 */
1418 if(arg && ((mc == MAXMODEPARAMSSERV) ||
1419 ((mbl + pbl + arglen + 4) > (BUFSIZE - 3))))
1420 {
1421 if(nc != 0)
1422 sendto_server(client_p, chptr, cap, nocap,
1423 "%s %s", modebuf, parabuf);
1424 nc = 0;
1425 mc = 0;
1426
1427 mbl = preflen;
1428 pbl = 0;
1429 pbuf = parabuf;
1430 parabuf[0] = 0;
1431 dir = MODE_QUERY;
1432 }
1433
1434 if(dir != mode_changes[i].dir)
1435 {
1436 modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
1437 dir = mode_changes[i].dir;
1438 }
1439
1440 modebuf[mbl++] = mode_changes[i].letter;
1441 modebuf[mbl] = 0;
1442 nc++;
1443
1444 if(arg != NULL)
1445 {
1446 len = rb_sprintf(pbuf, "%s ", arg);
1447 pbuf += len;
1448 pbl += len;
1449 mc++;
1450 }
1451 }
1452
1453 if(pbl && parabuf[pbl - 1] == ' ')
1454 parabuf[pbl - 1] = 0;
1455
1456 if(nc != 0)
1457 sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
1458 }
1459 }
1460
1461 void
1462 resv_chan_forcepart(const char *name, const char *reason, int temp_time)
1463 {
1464 rb_dlink_node *ptr;
1465 rb_dlink_node *next_ptr;
1466 struct Channel *chptr;
1467 struct membership *msptr;
1468 struct Client *target_p;
1469
1470 if(!ConfigChannel.resv_forcepart)
1471 return;
1472
1473 /* for each user on our server in the channel list
1474 * send them a PART, and notify opers.
1475 */
1476 chptr = find_channel(name);
1477 if(chptr != NULL)
1478 {
1479 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
1480 {
1481 msptr = ptr->data;
1482 target_p = msptr->client_p;
1483
1484 if(IsExemptResv(target_p))
1485 continue;
1486
1487 sendto_server(target_p, chptr, CAP_TS6, NOCAPS,
1488 ":%s PART %s", target_p->id, chptr->chname);
1489
1490 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s",
1491 target_p->name, target_p->username,
1492 target_p->host, chptr->chname, target_p->name);
1493
1494 remove_user_from_channel(msptr);
1495
1496 /* notify opers & user they were removed from the channel */
1497 sendto_realops_snomask(SNO_GENERAL, L_ALL,
1498 "Forced PART for %s!%s@%s from %s (%s)",
1499 target_p->name, target_p->username,
1500 target_p->host, name, reason);
1501
1502 if(temp_time > 0)
1503 sendto_one_notice(target_p, ":*** Channel %s is temporarily unavailable on this server.",
1504 name);
1505 else
1506 sendto_one_notice(target_p, ":*** Channel %s is no longer available on this server.",
1507 name);
1508 }
1509 }
1510 }