ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/channel.c
(Generate patch)

Comparing:
ircd-hybrid-8/src/channel.c (file contents), Revision 1330 by michael, Sun Apr 1 12:12:00 2012 UTC vs.
ircd-hybrid/trunk/src/channel.c (file contents), Revision 3140 by michael, Wed Mar 12 19:23:20 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 30 | Line 30
30   #include "channel_mode.h"
31   #include "client.h"
32   #include "hash.h"
33 + #include "conf.h"
34   #include "hostmask.h"
35   #include "irc_string.h"
35 #include "sprintf_irc.h"
36   #include "ircd.h"
37   #include "numeric.h"
38 < #include "s_serv.h"             /* captab */
39 < #include "s_user.h"
38 > #include "s_serv.h"
39   #include "send.h"
41 #include "conf.h"             /* ConfigFileEntry, ConfigChannel */
40   #include "event.h"
41   #include "memory.h"
42 < #include "balloc.h"
42 > #include "mempool.h"
43 > #include "s_misc.h"
44 > #include "resv.h"
45  
46 struct config_channel_entry ConfigChannel;
46   dlink_list global_channel_list = { NULL, NULL, 0 };
47 < BlockHeap *ban_heap;    /*! \todo ban_heap shouldn't be a global var */
47 > mp_pool_t *ban_pool;    /*! \todo ban_pool shouldn't be a global var */
48  
49 < static BlockHeap *member_heap = NULL;
50 < static BlockHeap *channel_heap = NULL;
49 > static mp_pool_t *member_pool = NULL;
50 > static mp_pool_t *channel_pool = NULL;
51  
52   static char buf[IRCD_BUFSIZE];
53   static char modebuf[MODEBUFLEN];
# Line 58 | Line 57 | static char parabuf[MODEBUFLEN];
57   /*! \brief Initializes the channel blockheap, adds known channel CAPAB
58   */
59   void
60 < init_channels(void)
60 > channel_init(void)
61   {
62    add_capability("EX", CAP_EX, 1);
63    add_capability("IE", CAP_IE, 1);
65  add_capability("CHW", CAP_CHW, 1);
64  
65 <  channel_heap = BlockHeapCreate("channel", sizeof(struct Channel), CHANNEL_HEAP_SIZE);
66 <  ban_heap = BlockHeapCreate("ban", sizeof(struct Ban), BAN_HEAP_SIZE);
67 <  member_heap = BlockHeapCreate("member", sizeof(struct Membership), CHANNEL_HEAP_SIZE*2);
65 >  channel_pool = mp_pool_new(sizeof(struct Channel), MP_CHUNK_SIZE_CHANNEL);
66 >  ban_pool = mp_pool_new(sizeof(struct Ban), MP_CHUNK_SIZE_BAN);
67 >  member_pool = mp_pool_new(sizeof(struct Membership), MP_CHUNK_SIZE_MEMBER);
68   }
69  
70   /*! \brief adds a user to a channel by adding another link to the
# Line 103 | Line 101 | add_user_to_channel(struct Channel *chpt
101        if (!IsSetJoinFloodNoticed(chptr))
102        {
103          SetJoinFloodNoticed(chptr);
104 <        sendto_realops_flags(UMODE_BOTS, L_ALL,
104 >        sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
105                               "Possible Join Flooder %s on %s target: %s",
106                               get_client_name(who, HIDE_IP),
107                               who->servptr->name, chptr->chname);
# Line 113 | Line 111 | add_user_to_channel(struct Channel *chpt
111      chptr->last_join_time = CurrentTime;
112    }
113  
114 <  ms = BlockHeapAlloc(member_heap);
114 >  ms = mp_pool_get(member_pool);
115 >  memset(ms, 0, sizeof(*ms));
116 >
117    ms->client_p = who;
118    ms->chptr = chptr;
119    ms->flags = flags;
# Line 135 | Line 135 | remove_user_from_channel(struct Membersh
135    dlinkDelete(&member->channode, &chptr->members);
136    dlinkDelete(&member->usernode, &client_p->channel);
137  
138 <  BlockHeapFree(member_heap, member);
138 >  mp_pool_release(member);
139  
140    if (chptr->members.head == NULL)
141      destroy_channel(chptr);
# Line 151 | Line 151 | static void
151   send_members(struct Client *client_p, struct Channel *chptr,
152               char *lmodebuf, char *lparabuf)
153   {
154 <  struct Membership *ms;
155 <  dlink_node *ptr;
154 >  const dlink_node *ptr = NULL;
155    int tlen;              /* length of text to append */
156    char *t, *start;       /* temp char pointer */
157  
158 <  start = t = buf + ircsprintf(buf, ":%s SJOIN %lu %s %s %s:",
159 <                               ID_or_name(&me, client_p),
160 <                               (unsigned long)chptr->channelts,
161 <                               chptr->chname, lmodebuf, lparabuf);
158 >  start = t = buf + snprintf(buf, sizeof(buf), ":%s SJOIN %lu %s %s %s:",
159 >                             ID_or_name(&me, client_p),
160 >                             (unsigned long)chptr->channelts,
161 >                             chptr->chname, lmodebuf, lparabuf);
162  
163    DLINK_FOREACH(ptr, chptr->members.head)
164    {
165 <    ms = ptr->data;
165 >    const struct Membership *ms = ptr->data;
166  
167 <    tlen = strlen(IsCapable(client_p, CAP_TS6) ?
169 <      ID(ms->client_p) : ms->client_p->name) + 1;  /* nick + space */
167 >    tlen = strlen(ID(ms->client_p)) + 1;  /* nick + space */
168  
169      if (ms->flags & CHFL_CHANOP)
170        tlen++;
171   #ifdef HALFOPS
172 <    else if (ms->flags & CHFL_HALFOP)
172 >    if (ms->flags & CHFL_HALFOP)
173        tlen++;
174   #endif
175      if (ms->flags & CHFL_VOICE)
# Line 187 | Line 185 | send_members(struct Client *client_p, st
185        t = start;
186      }
187  
188 <    if ((ms->flags & (CHFL_CHANOP | CHFL_HALFOP)))
189 <      *t++ = (!(ms->flags & CHFL_CHANOP) && IsCapable(client_p, CAP_HOPS)) ?
190 <        '%' : '@';
191 <    if ((ms->flags & CHFL_VOICE))
188 >    if (ms->flags & CHFL_CHANOP)
189 >      *t++ = '@';
190 >    if (ms->flags & CHFL_HALFOP)
191 >      *t++ = '%';
192 >    if (ms->flags & CHFL_VOICE)
193        *t++ = '+';
194  
195 <    if (IsCapable(client_p, CAP_TS6))
196 <      strcpy(t, ID(ms->client_p));
198 <    else
199 <      strcpy(t, ms->client_p->name);
195 >    strcpy(t, ID(ms->client_p));
196 >
197      t += strlen(t);
198      *t++ = ' ';
199    }
# Line 216 | Line 213 | send_members(struct Client *client_p, st
213   */
214   static void
215   send_mode_list(struct Client *client_p, struct Channel *chptr,
216 <               dlink_list *top, char flag)
216 >               const dlink_list *top, char flag)
217   {
218 <  int ts5 = !IsCapable(client_p, CAP_TS6);
222 <  dlink_node *lp;
223 <  struct Ban *banptr;
218 >  const dlink_node *lp = NULL;
219    char pbuf[IRCD_BUFSIZE];
220    int tlen, mlen, cur_len, count = 0;
221    char *mp = NULL, *pp = pbuf;
# Line 228 | Line 223 | send_mode_list(struct Client *client_p,
223    if (top == NULL || top->length == 0)
224      return;
225  
226 <  if (ts5)
227 <    mlen = ircsprintf(buf, ":%s MODE %s +", me.name, chptr->chname);
233 <  else
234 <    mlen = ircsprintf(buf, ":%s BMASK %lu %s %c :", me.id,
235 <                      (unsigned long)chptr->channelts, chptr->chname, flag);
226 >  mlen = snprintf(buf, sizeof(buf), ":%s BMASK %lu %s %c :", me.id,
227 >                  (unsigned long)chptr->channelts, chptr->chname, flag);
228  
229 <  /* MODE needs additional one byte for space between buf and pbuf */
238 <  cur_len = mlen + ts5;
229 >  cur_len = mlen;
230    mp = buf + mlen;
231  
232    DLINK_FOREACH(lp, top->head)
233    {
234 <    banptr = lp->data;
234 >    const struct Ban *banptr = lp->data;
235  
236 <    /* must add another b/e/I letter if we use MODE */
246 <    tlen = banptr->len + 3 + ts5;
236 >    tlen = banptr->len + 3;
237  
238      /*
239       * send buffer and start over if we cannot fit another ban,
240       * or if the target is non-ts6 and we have too many modes in
241       * in this line.
242       */
243 <    if (cur_len + (tlen - 1) > IRCD_BUFSIZE - 2 ||
254 <        (!IsCapable(client_p, CAP_TS6) &&
255 <         (count >= MAXMODEPARAMS || pp - pbuf >= MODEBUFLEN)))
243 >    if (cur_len + (tlen - 1) > IRCD_BUFSIZE - 2)
244      {
245        *(pp - 1) = '\0';  /* get rid of trailing space on buffer */
246 <      sendto_one(client_p, "%s%s%s", buf, ts5 ? " " : "", pbuf);
246 >      sendto_one(client_p, "%s%s", buf, pbuf);
247  
248 <      cur_len = mlen + ts5;
248 >      cur_len = mlen;
249        mp = buf + mlen;
250        pp = pbuf;
251        count = 0;
252      }
253  
254      count++;
255 <    if (ts5)
256 <    {
269 <      *mp++ = flag;
270 <      *mp = '\0';
271 <    }
272 <
273 <    pp += ircsprintf(pp, "%s!%s@%s ", banptr->name, banptr->username,
274 <                     banptr->host);
255 >    pp += sprintf(pp, "%s!%s@%s ", banptr->name, banptr->user,
256 >                  banptr->host);
257      cur_len += tlen;
258    }
259  
260    *(pp - 1) = '\0';  /* get rid of trailing space on buffer */
261 <  sendto_one(client_p, "%s%s%s", buf, ts5 ? " " : "", pbuf);
261 >  sendto_one(client_p, "%s%s", buf, pbuf);
262   }
263  
264   /*! \brief send "client_p" a full list of the modes for channel chptr
# Line 286 | Line 268 | send_mode_list(struct Client *client_p,
268   void
269   send_channel_modes(struct Client *client_p, struct Channel *chptr)
270   {
289  if (chptr->chname[0] != '#')
290    return;
291
271    *modebuf = *parabuf = '\0';
272    channel_modes(chptr, client_p, modebuf, parabuf);
273    send_members(client_p, chptr, modebuf, parabuf);
274  
275    send_mode_list(client_p, chptr, &chptr->banlist, 'b');
276 <
277 <  if (IsCapable(client_p, CAP_EX))
299 <    send_mode_list(client_p, chptr, &chptr->exceptlist, 'e');
300 <  if (IsCapable(client_p, CAP_IE))
301 <    send_mode_list(client_p, chptr, &chptr->invexlist, 'I');
276 >  send_mode_list(client_p, chptr, &chptr->exceptlist, 'e');
277 >  send_mode_list(client_p, chptr, &chptr->invexlist, 'I');
278   }
279  
280   /*! \brief check channel name for invalid characters
# Line 307 | Line 283 | send_channel_modes(struct Client *client
283   * \return 0 if invalid, 1 otherwise
284   */
285   int
286 < check_channel_name(const char *name, int local)
286 > check_channel_name(const char *name, const int local)
287   {
288    const char *p = name;
289 <  int max_length = local ? LOCAL_CHANNELLEN : CHANNELLEN;
289 >  const int max_length = local ? LOCAL_CHANNELLEN : CHANNELLEN;
290    assert(name != NULL);
291  
292    if (!IsChanPrefix(*p))
# Line 338 | Line 314 | remove_ban(struct Ban *bptr, dlink_list
314    dlinkDelete(&bptr->node, list);
315  
316    MyFree(bptr->name);
317 <  MyFree(bptr->username);
317 >  MyFree(bptr->user);
318    MyFree(bptr->host);
319    MyFree(bptr->who);
320  
321 <  BlockHeapFree(ban_heap, bptr);
321 >  mp_pool_release(bptr);
322   }
323  
324   /* free_channel_list()
# Line 374 | Line 350 | make_channel(const char *chname)
350  
351    assert(!EmptyString(chname));
352  
353 <  chptr = BlockHeapAlloc(channel_heap);
353 >  chptr = mp_pool_get(channel_pool);
354 >
355 >  memset(chptr, 0, sizeof(*chptr));
356  
357    /* doesn't hurt to set it here */
358    chptr->channelts = CurrentTime;
# Line 407 | Line 385 | destroy_channel(struct Channel *chptr)
385    dlinkDelete(&chptr->node, &global_channel_list);
386    hash_del_channel(chptr);
387  
388 <  BlockHeapFree(channel_heap, chptr);
388 >  mp_pool_release(chptr);
389   }
390  
391   /*!
# Line 434 | Line 412 | void
412   channel_member_names(struct Client *source_p, struct Channel *chptr,
413                       int show_eon)
414   {
415 <  struct Client *target_p = NULL;
438 <  struct Membership *ms = NULL;
439 <  dlink_node *ptr = NULL;
415 >  const dlink_node *ptr = NULL;
416    char lbuf[IRCD_BUFSIZE + 1];
417    char *t = NULL, *start = NULL;
418    int tlen = 0;
419    int is_member = IsMember(source_p, chptr);
420    int multi_prefix = HasCap(source_p, CAP_MULTI_PREFIX) != 0;
421 +  int uhnames = HasCap(source_p, CAP_UHNAMES) != 0;
422  
423    if (PubChannel(chptr) || is_member)
424    {
425 <    t = lbuf + ircsprintf(lbuf, form_str(RPL_NAMREPLY),
426 <                          me.name, source_p->name,
427 <                          channel_pub_or_secret(chptr),
451 <                          chptr->chname);
425 >    t = lbuf + snprintf(lbuf, sizeof(lbuf), numeric_form(RPL_NAMREPLY),
426 >                        me.name, source_p->name,
427 >                        channel_pub_or_secret(chptr), chptr->chname);
428      start = t;
429  
430      DLINK_FOREACH(ptr, chptr->members.head)
431      {
432 <      ms       = ptr->data;
457 <      target_p = ms->client_p;
432 >      const struct Membership *ms = ptr->data;
433  
434 <      if (HasUMode(target_p, UMODE_INVISIBLE) && !is_member)
434 >      if (HasUMode(ms->client_p, UMODE_INVISIBLE) && !is_member)
435          continue;
436  
437 <      tlen = strlen(target_p->name) + 1;  /* nick + space */
437 >      if (!uhnames)
438 >        tlen = strlen(ms->client_p->name) + 1;  /* nick + space */
439 >      else
440 >        tlen = strlen(ms->client_p->name) + strlen(ms->client_p->username) +
441 >               strlen(ms->client_p->host) + 3;
442  
443        if (!multi_prefix)
444        {
# Line 483 | Line 462 | channel_member_names(struct Client *sour
462          t = start;
463        }
464  
465 <      t += ircsprintf(t, "%s%s ", get_member_status(ms, multi_prefix),
466 <                      target_p->name);
465 >      if (!uhnames)
466 >        t += sprintf(t, "%s%s ", get_member_status(ms, multi_prefix),
467 >                     ms->client_p->name);
468 >      else
469 >        t += sprintf(t, "%s%s!%s@%s ", get_member_status(ms, multi_prefix),
470 >                     ms->client_p->name, ms->client_p->username,
471 >                     ms->client_p->host);
472      }
473  
474      if (tlen != 0)
# Line 495 | Line 479 | channel_member_names(struct Client *sour
479    }
480  
481    if (show_eon)
482 <    sendto_one(source_p, form_str(RPL_ENDOFNAMES),
499 <               me.name, source_p->name, chptr->chname);
482 >    sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, chptr->chname);
483   }
484  
485   /*! \brief adds client to invite list
# Line 551 | Line 534 | del_invite(struct Channel *chptr, struct
534   * (like in get_client_name)
535   */
536   const char *
537 < get_member_status(const struct Membership *ms, int combine)
537 > get_member_status(const struct Membership *ms, const int combine)
538   {
539    static char buffer[4];
540 <  char *p = NULL;
558 <
559 <  if (ms == NULL)
560 <    return "";
561 <  p = buffer;
540 >  char *p = buffer;
541  
542    if (ms->flags & CHFL_CHANOP)
543    {
# Line 596 | Line 575 | find_bmask(const struct Client *who, con
575  
576    DLINK_FOREACH(ptr, list->head)
577    {
578 <    struct Ban *bp = ptr->data;
578 >    const struct Ban *bp = ptr->data;
579  
580 <    if (match(bp->name, who->name) && match(bp->username, who->username))
580 >    if (!match(bp->name, who->name) && !match(bp->user, who->username))
581      {
582        switch (bp->type)
583        {
584          case HM_HOST:
585 <          if (match(bp->host, who->host) || match(bp->host, who->sockhost))
585 >          if (!match(bp->host, who->host) || !match(bp->host, who->sockhost))
586              return 1;
587            break;
588          case HM_IPV4:
# Line 636 | Line 615 | int
615   is_banned(const struct Channel *chptr, const struct Client *who)
616   {
617    if (find_bmask(who, &chptr->banlist))
618 <    if (!ConfigChannel.use_except || !find_bmask(who, &chptr->exceptlist))
618 >    if (!find_bmask(who, &chptr->exceptlist))
619        return 1;
620  
621    return 0;
# Line 644 | Line 623 | is_banned(const struct Channel *chptr, c
623  
624   /*!
625   * \param source_p pointer to client attempting to join
626 < * \param chptr    pointer to channel
626 > * \param chptr    pointer to channel
627   * \param key      key sent by client attempting to join if present
628   * \return ERR_BANNEDFROMCHAN, ERR_INVITEONLYCHAN, ERR_CHANNELISFULL
629   *         or 0 if allowed to join.
# Line 652 | Line 631 | is_banned(const struct Channel *chptr, c
631   int
632   can_join(struct Client *source_p, struct Channel *chptr, const char *key)
633   {
634 <  if (is_banned(chptr, source_p))
656 <    return ERR_BANNEDFROMCHAN;
657 <
658 < #ifdef HAVE_LIBCRYPTO
659 <  if ((chptr->mode.mode & MODE_SSLONLY) && !source_p->localClient->fd.ssl)
634 >  if ((chptr->mode.mode & MODE_SSLONLY) && !HasUMode(source_p, UMODE_SSL))
635      return ERR_SSLONLYCHAN;
661 #endif
636  
637    if ((chptr->mode.mode & MODE_REGONLY) && !HasUMode(source_p, UMODE_REGISTERED))
638      return ERR_NEEDREGGEDNICK;
# Line 668 | Line 642 | can_join(struct Client *source_p, struct
642  
643    if (chptr->mode.mode & MODE_INVITEONLY)
644      if (!dlinkFind(&source_p->localClient->invited, chptr))
645 <      if (!ConfigChannel.use_invex || !find_bmask(source_p, &chptr->invexlist))
645 >      if (!find_bmask(source_p, &chptr->invexlist))
646          return ERR_INVITEONLYCHAN;
647  
648 <  if (chptr->mode.key[0] && (!key || irccmp(chptr->mode.key, key)))
648 >  if (chptr->mode.key[0] && (!key || strcmp(chptr->mode.key, key)))
649      return ERR_BADCHANNELKEY;
650  
651    if (chptr->mode.limit && dlink_list_length(&chptr->members) >=
652        chptr->mode.limit)
653      return ERR_CHANNELISFULL;
654  
655 +  if (is_banned(chptr, source_p))
656 +    return ERR_BANNEDFROMCHAN;
657 +
658    return 0;
659   }
660  
661   int
662 < has_member_flags(struct Membership *ms, unsigned int flags)
662 > has_member_flags(const struct Membership *ms, const unsigned int flags)
663   {
664    if (ms != NULL)
665      return ms->flags & flags;
# Line 697 | Line 674 | find_channel_link(struct Client *client_
674    if (!IsClient(client_p))
675      return NULL;
676  
677 <  DLINK_FOREACH(ptr, client_p->channel.head)
678 <    if (((struct Membership *)ptr->data)->chptr == chptr)
679 <      return ptr->data;
677 >  if (dlink_list_length(&chptr->members) < dlink_list_length(&client_p->channel))
678 >  {
679 >    DLINK_FOREACH(ptr, chptr->members.head)
680 >      if (((struct Membership *)ptr->data)->client_p == client_p)
681 >        return ptr->data;
682 >  }
683 >  else
684 >  {
685 >    DLINK_FOREACH(ptr, client_p->channel.head)
686 >      if (((struct Membership *)ptr->data)->chptr == chptr)
687 >        return ptr->data;
688 >  }
689  
690    return NULL;
691   }
692  
693 + /*
694 + * Basically the same functionality as in bahamut
695 + */
696 + static int
697 + msg_has_ctrls(const char *message)
698 + {
699 +  const unsigned char *p = (const unsigned char *)message;
700 +
701 +  for (; *p; ++p)
702 +  {
703 +    if (*p > 31 || *p == 1)
704 +      continue;
705 +
706 +    if (*p == 27)
707 +    {
708 +      if (*(p + 1) == '$' ||
709 +          *(p + 1) == '(')
710 +      {
711 +        ++p;
712 +        continue;
713 +      }
714 +    }
715 +
716 +    return 1;
717 +  }
718 +
719 +  return 0;
720 + }
721 +
722   /*!
723   * \param chptr    pointer to Channel struct
724   * \param source_p pointer to Client struct
# Line 713 | Line 728 | find_channel_link(struct Client *client_
728   *         ERR_CANNOTSENDTOCHAN or ERR_NEEDREGGEDNICK if they cannot send to channel\n
729   */
730   int
731 < can_send(struct Channel *chptr, struct Client *source_p, struct Membership *ms)
731 > can_send(struct Channel *chptr, struct Client *source_p,
732 >         struct Membership *ms, const char *message)
733   {
734 +  struct MaskItem *conf = NULL;
735 +
736    if (IsServer(source_p) || HasFlag(source_p, FLAGS_SERVICE))
737      return CAN_SEND_OPV;
738  
739    if (MyClient(source_p) && !IsExemptResv(source_p))
740      if (!(HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.oper_pass_resv))
741 <      if (!hash_find_resv(chptr->chname) == ConfigChannel.restrict_channels)
741 >      if ((conf = match_find_resv(chptr->chname)) && !resv_find_exempt(source_p, conf))
742          return ERR_CANNOTSENDTOCHAN;
743  
744 <  if (ms != NULL || (ms = find_channel_link(source_p, chptr)))
745 <  {
744 >  if ((chptr->mode.mode & MODE_NOCTRL) && msg_has_ctrls(message))
745 >    return ERR_NOCTRLSONCHAN;
746 >  if (ms || (ms = find_channel_link(source_p, chptr)))
747      if (ms->flags & (CHFL_CHANOP|CHFL_HALFOP|CHFL_VOICE))
748        return CAN_SEND_OPV;
749 +  if (!ms && (chptr->mode.mode & MODE_NOPRIVMSGS))
750 +    return ERR_CANNOTSENDTOCHAN;
751 +  if (chptr->mode.mode & MODE_MODERATED)
752 +    return ERR_CANNOTSENDTOCHAN;
753 +  if ((chptr->mode.mode & MODE_MODREG) && !HasUMode(source_p, UMODE_REGISTERED))
754 +    return ERR_NEEDREGGEDNICK;
755  
756 <    /* cache can send if quiet_on_ban and banned */
757 <    if (ConfigChannel.quiet_on_ban && MyClient(source_p))
756 >  /* cache can send if banned */
757 >  if (MyClient(source_p))
758 >  {
759 >    if (ms)
760      {
761        if (ms->flags & CHFL_BAN_SILENCED)
762          return ERR_CANNOTSENDTOCHAN;
# Line 745 | Line 772 | can_send(struct Channel *chptr, struct C
772          ms->flags |= CHFL_BAN_CHECKED;
773        }
774      }
775 +    else if (is_banned(chptr, source_p))
776 +      return ERR_CANNOTSENDTOCHAN;
777    }
749  else if (chptr->mode.mode & MODE_NOPRIVMSGS)
750    return ERR_CANNOTSENDTOCHAN;
751
752  if (chptr->mode.mode & MODE_MODERATED)
753    return ERR_CANNOTSENDTOCHAN;
778  
779    return CAN_SEND_NONOP;
780   }
# Line 780 | Line 804 | check_spambot_warning(struct Client *sou
804      {
805        /* Its already known as a possible spambot */
806        if (name != NULL)
807 <        sendto_realops_flags(UMODE_BOTS, L_ALL,
807 >        sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
808                               "User %s (%s@%s) trying to join %s is a possible spambot",
809                               source_p->name, source_p->username,
810                               source_p->host, name);
811        else
812 <        sendto_realops_flags(UMODE_BOTS, L_ALL,
812 >        sendto_realops_flags(UMODE_BOTS, L_ALL, SEND_NOTICE,
813                               "User %s (%s@%s) is a possible spambot",
814                               source_p->name, source_p->username,
815                               source_p->host);
# Line 836 | Line 860 | check_splitmode(void *unused)
860      {
861        splitmode = 1;
862  
863 <      sendto_realops_flags(UMODE_ALL,L_ALL,
863 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
864                             "Network split, activating splitmode");
865        eventAddIsh("check_splitmode", check_splitmode, NULL, 10);
866      }
# Line 844 | Line 868 | check_splitmode(void *unused)
868      {
869        splitmode = 0;
870  
871 <      sendto_realops_flags(UMODE_ALL, L_ALL,
871 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
872                             "Network rejoined, deactivating splitmode");
873        eventDelete(check_splitmode, NULL);
874      }
# Line 859 | Line 883 | check_splitmode(void *unused)
883   */
884   void
885   set_channel_topic(struct Channel *chptr, const char *topic,
886 <                  const char *topic_info, time_t topicts)
886 >                  const char *topic_info, time_t topicts, int local)
887   {
888 <  strlcpy(chptr->topic, topic, sizeof(chptr->topic));
888 >  if (local)
889 >    strlcpy(chptr->topic, topic, IRCD_MIN(sizeof(chptr->topic), ServerInfo.max_topic_length + 1));
890 >  else
891 >    strlcpy(chptr->topic, topic, sizeof(chptr->topic));
892 >
893    strlcpy(chptr->topic_info, topic_info, sizeof(chptr->topic_info));
894 <  chptr->topic_time = topicts;
894 >  chptr->topic_time = topicts;
895   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)