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

Comparing:
ircd-hybrid/modules/m_userhost.c (file contents), Revision 33 by knight, Sun Oct 2 20:50:00 2005 UTC vs.
ircd-hybrid/trunk/modules/m_userhost.c (file contents), Revision 1793 by michael, Sun Mar 31 14:06:08 2013 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 – #include "handlers.h"
26   #include "client.h"
27   #include "ircd.h"
28   #include "numeric.h"
29   #include "s_serv.h"
30   #include "send.h"
31   #include "irc_string.h"
33 – #include "sprintf_irc.h"
34 – #include "msg.h"
32   #include "parse.h"
33   #include "modules.h"
37 – #include "s_conf.h"
34  
35  
40 – static void m_userhost(struct Client *, struct Client *, int, char *[]);
41 –
42 – struct Message userhost_msgtab = {
43 –  "USERHOST", 0, 0, 1, 0, MFLG_SLOW, 0,
44 –  {m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore}
45 – };
46 –
47 – #ifndef STATIC_MODULES
48 – void
49 – _modinit(void)
50 – {
51 –  mod_add_cmd(&userhost_msgtab);
52 – }
53 –
54 – void
55 – _moddeinit(void)
56 – {
57 –  mod_del_cmd(&userhost_msgtab);
58 – }
59 –
60 – const char *_version = "$Revision$";
61 – #endif
62 –
36   /*
37   * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
38   * the need for complicated requests like WHOIS. It returns user/host
# Line 72 | Line 45 | m_userhost(struct Client *client_p, stru
45    struct Client *target_p;
46    char buf[IRCD_BUFSIZE];
47    char response[NICKLEN*2+USERLEN+HOSTLEN+30];
48 <  char *t;
49 <  int i, n;               /* loop counter */
48 >  char *t = NULL, *p = NULL, *nick = NULL;
49 >  int i = 0;               /* loop counter */
50    int cur_len;
51    int rl;
52  
53 <  cur_len = ircsprintf(buf,form_str(RPL_USERHOST),me.name, parv[0], "");
53 >  cur_len = snprintf(buf, sizeof(buf), form_str(RPL_USERHOST), me.name, source_p->name, "");
54    t = buf + cur_len;
55  
56 <  for (i = 0; i < 5; i++)
56 >  for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
57 >       nick = strtoken(&p,    NULL, " "))
58    {
59 <    if (parv[i+1] == NULL)
86 <      break;
87 <
88 <    if ((target_p = find_person(client_p, parv[i+1])) != NULL)
59 >    if ((target_p = find_person(client_p, nick)) != NULL)
60      {
61 <          /*
62 <           * Show real IP for USERHOST on yourself.
63 <           * This is needed for things like mIRC, which do a server-based
64 <           * lookup (USERHOST) to figure out what the clients' local IP
65 <           * is.  Useful for things like NAT, and dynamic dial-up users.
66 <           */
67 <          /*
68 <           * If a lazyleaf relayed us this request, we don't know
69 <           * the clients real IP.
70 <           * So, if you're on a lazyleaf, and you send a userhost
71 <           * including your nick and the nick of someone not known to
72 <           * the leaf, you'll get your spoofed IP.  tough.
73 <           */
74 <          if (MyClient(target_p) && (target_p == source_p))
75 <          {
76 <            rl = ircsprintf(response, "%s%s=%c%s@%s ",
77 <                            target_p->name,
78 <                            IsOper(target_p) ? "*" : "",
79 <                            (target_p->away) ? '-' : '+',
80 <                            target_p->username,
81 <                            target_p->sockhost);
82 <          }
83 <          else
84 <          {
85 <            rl = ircsprintf(response, "%s%s=%c%s@%s ",
86 <                            target_p->name,
87 <                            IsOper(target_p) ? "*" : "",
88 <                            (target_p->away) ? '-' : '+',
89 <                            target_p->username,
90 <                            target_p->host);
91 <          }
92 <
93 <          if ((rl + cur_len) < (IRCD_BUFSIZE-10))
94 <          {
124 <              ircsprintf(t,"%s",response);
125 <              t += rl;
126 <              cur_len += rl;
127 <          }
128 <          else
129 <            break;
130 <        }
131 <      else if ( !ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) )
132 <        {
133 <          t = buf;
134 <          for( n = 0; n < 5; n++ )
135 <          {
136 <            if( parv[n+1] )
137 <            {
138 <              rl = ircsprintf(t, "%s ", parv[n+1]);
139 <              t += rl;
140 <            }
141 <            else
142 <              break;
143 <          }
144 <          /* Relay upstream, and let hub reply */
145 <          sendto_one(uplink, ":%s USERHOST %s", parv[0], buf );
146 <          return;
147 <        }
61 >      /*
62 >       * Show real IP for USERHOST on yourself.
63 >       * This is needed for things like mIRC, which do a server-based
64 >       * lookup (USERHOST) to figure out what the clients' local IP
65 >       * is.  Useful for things like NAT, and dynamic dial-up users.
66 >       */
67 >      if (MyClient(target_p) && (target_p == source_p))
68 >      {
69 >        rl = sprintf(response, "%s%s=%c%s@%s ",
70 >                     target_p->name,
71 >                     HasUMode(target_p, UMODE_OPER) ? "*" : "",
72 >                     (target_p->away[0]) ? '-' : '+',
73 >                     target_p->username,
74 >                     target_p->sockhost);
75 >      }
76 >      else
77 >      {
78 >        rl = sprintf(response, "%s%s=%c%s@%s ",
79 >                     target_p->name, (HasUMode(target_p, UMODE_OPER) &&
80 >                                      (!HasUMode(target_p, UMODE_HIDDEN) ||
81 >                                        HasUMode(source_p, UMODE_OPER))) ? "*" : "",
82 >                     (target_p->away[0]) ? '-' : '+',
83 >                     target_p->username,
84 >                     target_p->host);
85 >      }
86 >
87 >      if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
88 >      {
89 >        sprintf(t, "%s", response);
90 >        t += rl;
91 >        cur_len += rl;
92 >      }
93 >      else
94 >        break;
95      }
96 +  }
97  
98    sendto_one(source_p, "%s", buf);
99   }
100 +
101 + static struct Message userhost_msgtab = {
102 +  "USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0,
103 +  {m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore}
104 + };
105 +
106 + static void
107 + module_init(void)
108 + {
109 +  mod_add_cmd(&userhost_msgtab);
110 + }
111 +
112 + static void
113 + module_exit(void)
114 + {
115 +  mod_del_cmd(&userhost_msgtab);
116 + }
117 +
118 + struct module module_entry = {
119 +  .node    = { NULL, NULL, NULL },
120 +  .name    = NULL,
121 +  .version = "$Revision$",
122 +  .handle  = NULL,
123 +  .modinit = module_init,
124 +  .modexit = module_exit,
125 +  .flags   = 0
126 + };

Diff Legend

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