ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_userhost.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 4046 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_userhost.c: Shows a user's host.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "client.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "s_serv.h"
31     #include "send.h"
32     #include "msg.h"
33     #include "parse.h"
34     #include "modules.h"
35     #include "s_conf.h"
36    
37    
38     static void m_userhost(struct Client *, struct Client *, int, char *[]);
39    
40     struct Message userhost_msgtab = {
41     "USERHOST", 0, 0, 1, 0, MFLG_SLOW, 0,
42     {m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore}
43     };
44    
45     #ifndef STATIC_MODULES
46     void
47     _modinit(void)
48     {
49     mod_add_cmd(&userhost_msgtab);
50     }
51    
52     void
53     _moddeinit(void)
54     {
55     mod_del_cmd(&userhost_msgtab);
56     }
57    
58 knight 31 const char *_version = "$Revision$";
59 adx 30 #endif
60    
61     /*
62     * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
63     * the need for complicated requests like WHOIS. It returns user/host
64     * information only (no spurious AWAY labels or channels).
65     */
66     static void
67     m_userhost(struct Client *client_p, struct Client *source_p,
68     int parc, char *parv[])
69     {
70     struct Client *target_p;
71     char buf[IRCD_BUFSIZE];
72     char response[NICKLEN*2+USERLEN+HOSTLEN+30];
73     char *t;
74     int i, n; /* loop counter */
75     int cur_len;
76     int rl;
77    
78     cur_len = ircsprintf(buf,form_str(RPL_USERHOST),me.name, parv[0], "");
79     t = buf + cur_len;
80    
81     for (i = 0; i < 5; i++)
82     {
83     if (parv[i+1] == NULL)
84     break;
85    
86     if ((target_p = find_person(client_p, parv[i+1])) != NULL)
87     {
88     /*
89     * Show real IP for USERHOST on yourself.
90     * This is needed for things like mIRC, which do a server-based
91     * lookup (USERHOST) to figure out what the clients' local IP
92     * is. Useful for things like NAT, and dynamic dial-up users.
93     */
94     /*
95     * If a lazyleaf relayed us this request, we don't know
96     * the clients real IP.
97     * So, if you're on a lazyleaf, and you send a userhost
98     * including your nick and the nick of someone not known to
99     * the leaf, you'll get your spoofed IP. tough.
100     */
101     if (MyClient(target_p) && (target_p == source_p))
102     {
103     rl = ircsprintf(response, "%s%s=%c%s@%s ",
104     target_p->name,
105     IsOper(target_p) ? "*" : "",
106     (target_p->away) ? '-' : '+',
107     target_p->username,
108     target_p->sockhost);
109     }
110     else
111     {
112     rl = ircsprintf(response, "%s%s=%c%s@%s ",
113     target_p->name,
114     IsOper(target_p) ? "*" : "",
115     (target_p->away) ? '-' : '+',
116     target_p->username,
117     target_p->host);
118     }
119    
120     if ((rl + cur_len) < (IRCD_BUFSIZE-10))
121     {
122     ircsprintf(t,"%s",response);
123     t += rl;
124     cur_len += rl;
125     }
126     else
127     break;
128     }
129     else if ( !ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL) )
130     {
131     t = buf;
132     for( n = 0; n < 5; n++ )
133     {
134     if( parv[n+1] )
135     {
136     rl = ircsprintf(t, "%s ", parv[n+1]);
137     t += rl;
138     }
139     else
140     break;
141     }
142     /* Relay upstream, and let hub reply */
143     sendto_one(uplink, ":%s USERHOST %s", parv[0], buf );
144     return;
145     }
146     }
147    
148     sendto_one(source_p, "%s", buf);
149     }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision