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

Comparing ircd-hybrid/trunk/src/s_user.c (file contents):
Revision 3079 by michael, Sat Mar 1 17:22:03 2014 UTC vs.
Revision 3156 by michael, Fri Mar 14 19:57:38 2014 UTC

# Line 31 | Line 31
31   #include "channel.h"
32   #include "channel_mode.h"
33   #include "client.h"
34 – #include "fdlist.h"
34   #include "hash.h"
35   #include "irc_string.h"
37 – #include "s_bsd.h"
36   #include "ircd.h"
37   #include "listener.h"
38   #include "motd.h"
# Line 44 | Line 42
42   #include "s_serv.h"
43   #include "send.h"
44   #include "supported.h"
47 – #include "whowas.h"
45   #include "memory.h"
46   #include "packet.h"
47   #include "rng_mt.h"
48   #include "userhost.h"
52 – #include "hook.h"
49   #include "s_misc.h"
50   #include "parse.h"
51   #include "watch.h"
# Line 173 | Line 169 | assemble_umode_buffer(void)
169   void
170   show_lusers(struct Client *source_p)
171   {
176 –  const char *from, *to;
177 –
178 –  if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
179 –  {
180 –    from = me.id;
181 –    to = source_p->id;
182 –  }
183 –  else
184 –  {
185 –    from = me.name;
186 –    to = source_p->name;
187 –  }
188 –
172    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
173 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT),
174 <               from, to, (Count.total-Count.invisi),
192 <               Count.invisi, dlink_list_length(&global_serv_list));
173 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi),
174 >                       Count.invisi, dlink_list_length(&global_serv_list));
175    else
176 <    sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
177 <               (Count.total-Count.invisi), Count.invisi, 1);
176 >    sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT,
177 >                       (Count.total-Count.invisi), Count.invisi, 1);
178  
179    if (Count.oper > 0)
180 <    sendto_one(source_p, form_str(RPL_LUSEROP),
199 <               from, to, Count.oper);
180 >    sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper);
181  
182    if (dlink_list_length(&unknown_list) > 0)
183 <    sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
203 <               from, to, dlink_list_length(&unknown_list));
183 >    sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list));
184  
185    if (dlink_list_length(&global_channel_list) > 0)
186 <    sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
207 <               from, to, dlink_list_length(&global_channel_list));
186 >    sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list));
187  
188    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
189    {
190 <    sendto_one(source_p, form_str(RPL_LUSERME),
191 <               from, to, Count.local, Count.myserver);
213 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
214 <               from, to, Count.local, Count.max_loc);
190 >    sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.local, Count.myserver);
191 >    sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.local, Count.max_loc);
192    }
193    else
194    {
195 <    sendto_one(source_p, form_str(RPL_LUSERME),
196 <               from, to, Count.total, 0);
220 <    sendto_one(source_p, form_str(RPL_LOCALUSERS),
221 <               from, to, Count.total, Count.max_tot);
195 >    sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.total, 0);
196 >    sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.total, Count.max_tot);
197    }
198  
199 <  sendto_one(source_p, form_str(RPL_GLOBALUSERS),
225 <             from, to, Count.total, Count.max_tot);
199 >  sendto_one_numeric(source_p, &me, RPL_GLOBALUSERS, Count.total, Count.max_tot);
200  
201    if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER))
202 <    sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
203 <               Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount);
202 >    sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con,
203 >                       Count.max_loc_cli, Count.totalrestartcount);
204  
205    if (Count.local > Count.max_loc_cli)
206      Count.max_loc_cli = Count.local;
# Line 247 | Line 221 | show_isupport(struct Client *source_p)
221    const dlink_node *ptr = NULL;
222  
223    DLINK_FOREACH(ptr, support_list_lines.head)
224 <    sendto_one(source_p, form_str(RPL_ISUPPORT), me.name,
251 <               source_p->name, ptr->data);
224 >    sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data);
225   }
226  
227   /*
# Line 314 | Line 287 | register_local_user(struct Client *sourc
287  
288    if (!valid_hostname(source_p->host))
289    {
290 <    sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal "
291 <               "character in your hostname", me.name, source_p->name);
290 >    sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal "
291 >                      "character in your hostname");
292      strlcpy(source_p->host, source_p->sockhost,
293              sizeof(source_p->host));
294    }
# Line 331 | Line 304 | register_local_user(struct Client *sourc
304      if (IsNeedIdentd(conf))
305      {
306        ++ServerStats.is_ref;
307 <      sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
308 <                 "identd to use this server", me.name, source_p->name);
307 >      sendto_one_notice(source_p, &me, ":*** Notice -- You need to install "
308 >                        "identd to use this server");
309        exit_client(source_p, &me, "Install identd");
310        return;
311      }
# Line 357 | Line 330 | register_local_user(struct Client *sourc
330      if (!match_conf_password(pass, conf))
331      {
332        ++ServerStats.is_ref;
333 <      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
334 <                 me.name, source_p->name);
333 >
334 >      sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH);
335        exit_client(source_p, &me, "Bad Password");
336        return;
337      }
# Line 586 | Line 559 | introduce_client(struct Client *source_p
559          continue;
560  
561      if (IsCapable(server, CAP_SVS))
562 <    {
563 <      if (IsCapable(server, CAP_TS6) && HasID(source_p))
564 <        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
565 <                   source_p->servptr->id,
566 <                   source_p->name, source_p->hopcount+1,
567 <                   (unsigned long)source_p->tsinfo,
568 <                   ubuf, source_p->username, source_p->host,
569 <                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
570 <                   "0" : source_p->sockhost, source_p->id,
598 <                   source_p->svid,
599 <                   source_p->info);
600 <      else
601 <        sendto_one(server, "NICK %s %d %lu %s %s %s %s %s :%s",
602 <                   source_p->name, source_p->hopcount+1,
603 <                   (unsigned long)source_p->tsinfo,
604 <                   ubuf, source_p->username, source_p->host,
605 <                   source_p->servptr->name, source_p->svid,
606 <                   source_p->info);
607 <
608 <    }
562 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s",
563 >                 source_p->servptr->id,
564 >                 source_p->name, source_p->hopcount+1,
565 >                 (unsigned long)source_p->tsinfo,
566 >                 ubuf, source_p->username, source_p->host,
567 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
568 >                 "0" : source_p->sockhost, source_p->id,
569 >                 source_p->svid,
570 >                 source_p->info);
571      else
572 <    {
573 <      if (IsCapable(server, CAP_TS6) && HasID(source_p))
574 <        sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
575 <                   source_p->servptr->id,
576 <                   source_p->name, source_p->hopcount+1,
577 <                   (unsigned long)source_p->tsinfo,
578 <                   ubuf, source_p->username, source_p->host,
617 <                   (MyClient(source_p) && IsIPSpoof(source_p)) ?
618 <                   "0" : source_p->sockhost, source_p->id, source_p->info);
619 <      else
620 <        sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
621 <                   source_p->name, source_p->hopcount+1,
622 <                   (unsigned long)source_p->tsinfo,
623 <                   ubuf, source_p->username, source_p->host,
624 <                   source_p->servptr->name, source_p->info);
625 <    }
572 >      sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
573 >                 source_p->servptr->id,
574 >                 source_p->name, source_p->hopcount+1,
575 >                 (unsigned long)source_p->tsinfo,
576 >                 ubuf, source_p->username, source_p->host,
577 >                 (MyClient(source_p) && IsIPSpoof(source_p)) ?
578 >                 "0" : source_p->sockhost, source_p->id, source_p->info);
579  
580      if (!EmptyString(source_p->certfp))
581        sendto_one(server, ":%s CERTFP %s", ID(source_p), source_p->certfp);
# Line 748 | Line 701 | report_and_set_user_flags(struct Client
701   {
702    /* If this user is being spoofed, tell them so */
703    if (IsConfDoSpoofIp(conf))
704 <    sendto_one(source_p,
752 <               ":%s NOTICE %s :*** Spoofing your IP. Congrats.",
753 <               me.name, source_p->name);
704 >    sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats.");
705  
706    /* If this user is in the exception class, Set it "E lined" */
707    if (IsConfExemptKline(conf))
708    {
709      SetExemptKline(source_p);
710 <    sendto_one(source_p,
760 <               ":%s NOTICE %s :*** You are exempt from K/D/G lines. Congrats.",
761 <               me.name, source_p->name);
710 >    sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats.");
711    }
712  
713    /*
# Line 768 | Line 717 | report_and_set_user_flags(struct Client
717    else if (IsConfExemptGline(conf))
718    {
719      SetExemptGline(source_p);
720 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines. Congrats.",
772 <               me.name, source_p->name);
720 >    sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats.");
721    }
722  
723    if (IsConfExemptResv(conf))
724    {
725      SetExemptResv(source_p);
726 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs. Congrats.",
779 <               me.name, source_p->name);
726 >    sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats.");
727    }
728  
729    /* If this user is exempt from user limits set it "F lined" */
730    if (IsConfExemptLimits(conf))
731    {
732      SetExemptLimits(source_p);
733 <    sendto_one(source_p,
787 <               ":%s NOTICE %s :*** You are exempt from user limits. Congrats.",
788 <               me.name, source_p->name);
733 >    sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats.");
734    }
735  
736    if (IsConfCanFlood(conf))
737    {
738      SetCanFlood(source_p);
739 <    sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
740 <               "protection, aren't you fearsome.",
796 <               me.name, source_p->name);
739 >    sendto_one_notice(source_p, &me, ":*** You are exempt from flood "
740 >                      "protection, aren't you fearsome.");
741    }
742   }
743  
744   /* set_user_mode()
745   *
746   * added 15/10/91 By Darren Reed.
747 < * parv[0] - sender
747 > * parv[0] - command
748   * parv[1] - username to change mode for
749   * parv[2] - modes to change
750   */
751   void
752 < set_user_mode(struct Client *client_p, struct Client *source_p,
809 <              const int parc, char *parv[])
752 > set_user_mode(struct Client *source_p, const int parc, char *parv[])
753   {
754    unsigned int flag, setflags;
755    char **p, *m, buf[IRCD_BUFSIZE];
# Line 815 | Line 758 | set_user_mode(struct Client *client_p, s
758  
759    assert(!(parc < 2));
760  
761 <  if ((target_p = find_person(client_p, parv[1])) == NULL)
761 >  if ((target_p = find_person(source_p, parv[1])) == NULL)
762    {
763      if (MyConnect(source_p))
764 <      sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
822 <                 me.name, source_p->name, parv[1]);
764 >      sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[1]);
765      return;
766    }
767  
768    if (source_p != target_p)
769    {
770 <     sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
829 <                me.name, source_p->name);
770 >     sendto_one_numeric(source_p, &me, ERR_USERSDONTMATCH);
771       return;
772    }
773  
# Line 840 | Line 781 | set_user_mode(struct Client *client_p, s
781          *m++ = (char)i;
782      *m = '\0';
783  
784 <    sendto_one(source_p, form_str(RPL_UMODEIS),
844 <               me.name, source_p->name, buf);
784 >    sendto_one_numeric(source_p, &me, RPL_UMODEIS, buf);
785      return;
786    }
787  
# Line 864 | Line 804 | set_user_mode(struct Client *client_p, s
804          case 'o':
805            if (what == MODE_ADD)
806            {
807 <            if (IsServer(client_p) && !HasUMode(source_p, UMODE_OPER))
807 >            if (IsServer(source_p->from) && !HasUMode(source_p, UMODE_OPER))
808              {
809                ++Count.oper;
810                SetOper(source_p);
# Line 922 | Line 862 | set_user_mode(struct Client *client_p, s
862    }
863  
864    if (badflag)
865 <    sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
926 <               me.name, source_p->name);
865 >    sendto_one_numeric(source_p, &me, ERR_UMODEUNKNOWNFLAG);
866  
867    if (MyConnect(source_p) && HasUMode(source_p, UMODE_ADMIN) &&
868        !HasOFlag(source_p, OPER_FLAG_ADMIN))
869    {
870 <    sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
932 <               me.name, source_p->name);
870 >    sendto_one_notice(source_p, &me, ":*** You have no admin flag;");
871      DelUMode(source_p, UMODE_ADMIN);
872    }
873  
# Line 942 | Line 880 | set_user_mode(struct Client *client_p, s
880     * compare new flags with old flags and send string which
881     * will cause servers to update correctly.
882     */
883 <  send_umode_out(client_p, source_p, setflags);
883 >  send_umode_out(source_p, source_p, setflags);
884   }
885  
886   /* send_umode()
# Line 1026 | Line 964 | send_umode_out(struct Client *client_p,
964    send_umode(NULL, source_p, old, SEND_UMODES, buf);
965  
966    if (buf[0])
967 <  {
968 <    DLINK_FOREACH(ptr, serv_list.head)
1031 <    {
1032 <      struct Client *target_p = ptr->data;
1033 <
1034 <      if ((target_p != client_p) && (target_p != source_p))
1035 <        sendto_one(target_p, ":%s MODE %s :%s",
1036 <                   ID_or_name(source_p, target_p),
1037 <                   ID_or_name(source_p, target_p), buf);
1038 <    }
1039 <  }
967 >    sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s",
968 >                  ID(source_p), ID(source_p), buf);
969  
970    if (client_p && MyClient(client_p))
971      send_umode(client_p, source_p, old, 0xffffffff, buf);
# Line 1079 | Line 1008 | user_set_hostmask(struct Client *target_
1008  
1009    if (MyClient(target_p))
1010    {
1011 <    sendto_one(target_p, form_str(RPL_NEWHOSTIS), me.name,
1083 <               target_p->name, target_p->host);
1011 >    sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host);
1012      clear_ban_cache_client(target_p);
1013    }
1014  
# Line 1150 | Line 1078 | user_welcome(struct Client *source_p)
1078    if (HasFlag(source_p, FLAGS_SSL))
1079    {
1080      AddUMode(source_p, UMODE_SSL);
1081 <    sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s",
1082 <               me.name, source_p->name,
1155 <               ssl_get_cipher(source_p->localClient->fd.ssl));
1081 >    sendto_one_notice(source_p, &me, ":*** Connected securely via %s",
1082 >                      ssl_get_cipher(source_p->localClient->fd.ssl));
1083    }
1084   #endif
1085  
1086 <  sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1087 <             ServerInfo.network_name, source_p->name);
1088 <  sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1089 <             get_listener_name(source_p->localClient->listener), ircd_version);
1090 <  sendto_one(source_p, form_str(RPL_CREATED),
1091 <             me.name, source_p->name, built_date);
1165 <  sendto_one(source_p, form_str(RPL_MYINFO),
1166 <             me.name, source_p->name, me.name, ircd_version, umode_buffer);
1086 >  sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name,
1087 >                     source_p->name);
1088 >  sendto_one_numeric(source_p, &me, RPL_YOURHOST,
1089 >                     get_listener_name(source_p->localClient->listener), ircd_version);
1090 >  sendto_one_numeric(source_p, &me, RPL_CREATED, built_date);
1091 >  sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer);
1092    show_isupport(source_p);
1093  
1094    if (source_p->id[0] != '\0')
1095 <    sendto_one(source_p, form_str(RPL_YOURID), me.name,
1171 <               source_p->name, source_p->id);
1095 >    sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id);
1096  
1097    show_lusers(source_p);
1098    motd_signon(source_p);
# Line 1249 | Line 1173 | oper_up(struct Client *source_p)
1173    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator",
1174                         get_oper_name(source_p));
1175    send_umode_out(source_p, source_p, old);
1176 <  sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1176 >  sendto_one_numeric(source_p, &me, RPL_YOUREOPER);
1177   }
1178  
1179   static char new_uid[TOTALSIDUID + 1];     /* allow for \0 */
# Line 1450 | Line 1374 | rebuild_isupport_message_line(void)
1374    int n = 0;
1375    int tokens = 0;
1376    size_t len = 0;
1377 <  size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1377 >  size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT));
1378  
1379    DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head)
1380    {

Diff Legend

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