/[svn]/branches/newio/modules/m_userhost.c
ViewVC logotype

Diff of /branches/newio/modules/m_userhost.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2428 by michael, Sun Jul 21 18:11:50 2013 UTC revision 2429 by michael, Wed Jul 31 16:43:22 2013 UTC
# Line 31  Line 31 
31  #include "irc_string.h"  #include "irc_string.h"
32  #include "parse.h"  #include "parse.h"
33  #include "modules.h"  #include "modules.h"
34    #include "s_user.h"
35    #include "msgq.h"
36    
37    
38    static void
39    userhost_formatter(struct Client *target_p,
40                       struct Client *source_p, struct MsgBuf *mb)
41    {
42      assert(IsClient(target_p));
43    
44      /*
45       * Show real IP for USERHOST on yourself.
46       * This is needed for things like mIRC, which do a server-based
47       * lookup (USERHOST) to figure out what the clients' local IP
48       * is.  Useful for things like NAT, and dynamic dial-up users.
49       */
50      if (MyClient(target_p) && (target_p == source_p))
51        msgq_append(NULL, mb, "%s%s=%c%s@%s", target_p->name,
52                    HasUMode(target_p, UMODE_OPER) ? "*" : "",
53                    (target_p->away[0]) ? '-' : '+',
54                    target_p->username,
55                    target_p->sockhost);
56      else
57        msgq_append(NULL, mb, "%s%s=%c%s@%s", target_p->name,
58                    (HasUMode(target_p, UMODE_OPER) &&
59                     (!HasUMode(target_p, UMODE_HIDDEN) ||
60                       HasUMode(source_p, UMODE_OPER))) ? "*" : "",
61                    (target_p->away[0]) ? '-' : '+',
62                    target_p->username,
63                    target_p->host);
64    }
65    
66  /*  /*
67   * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce   * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
68   * the need for complicated requests like WHOIS. It returns user/host   * the need for complicated requests like WHOIS. It returns user/host
# Line 42  static int Line 72  static int
72  m_userhost(struct Client *client_p, struct Client *source_p,  m_userhost(struct Client *client_p, struct Client *source_p,
73             int parc, char *parv[])             int parc, char *parv[])
74  {  {
75    struct Client *target_p;    send_user_info(source_p, parv[1], RPL_USERHOST, userhost_formatter);
   char buf[IRCD_BUFSIZE];  
   char response[NICKLEN*2+USERLEN+HOSTLEN+30];  
   char *t = NULL, *p = NULL, *nick = NULL;  
   int i = 0;               /* loop counter */  
   int cur_len;  
   int rl;  
   
   cur_len = snprintf(buf, sizeof(buf), form_str(RPL_USERHOST), me.name, source_p->name, "");  
   t = buf + cur_len;  
   
   for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;  
        nick = strtoken(&p,    NULL, " "))  
   {  
     if ((target_p = find_person(client_p, nick)) != NULL)  
     {  
       /*  
        * Show real IP for USERHOST on yourself.  
        * This is needed for things like mIRC, which do a server-based  
        * lookup (USERHOST) to figure out what the clients' local IP  
        * is.  Useful for things like NAT, and dynamic dial-up users.  
        */  
       if (MyClient(target_p) && (target_p == source_p))  
       {  
         rl = sprintf(response, "%s%s=%c%s@%s ",  
                      target_p->name,  
                      HasUMode(target_p, UMODE_OPER) ? "*" : "",  
                      (target_p->away[0]) ? '-' : '+',  
                      target_p->username,  
                      target_p->sockhost);  
       }  
       else  
       {  
         rl = sprintf(response, "%s%s=%c%s@%s ",  
                      target_p->name, (HasUMode(target_p, UMODE_OPER) &&  
                                       (!HasUMode(target_p, UMODE_HIDDEN) ||  
                                         HasUMode(source_p, UMODE_OPER))) ? "*" : "",  
                      (target_p->away[0]) ? '-' : '+',  
                      target_p->username,  
                      target_p->host);  
       }  
   
       if ((rl + cur_len) < (IRCD_BUFSIZE - 10))  
       {  
         sprintf(t, "%s", response);  
         t += rl;  
         cur_len += rl;  
       }  
       else  
         break;  
     }  
   }  
   
   sendto_one(source_p, "%s", buf);  
76    return 0;    return 0;
77  }  }
78    

Legend:
Removed from v.2428  
changed lines
  Added in v.2429

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28