ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_userhost.c
Revision: 7925
Committed: Sat Dec 31 13:57:24 2016 UTC (9 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4130 byte(s)
Log Message:
- Update copyright years

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 7925 * Copyright (c) 1997-2017 ircd-hybrid development team
5 adx 30 *
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
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_userhost.c
23     * \brief Includes required functions for processing the USERHOST command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "send.h"
32     #include "irc_string.h"
33     #include "parse.h"
34     #include "modules.h"
35    
36    
37 michael 3299 /*! \brief USERHOST command handler
38     *
39     * \param source_p Pointer to allocated Client struct from which the message
40     * originally comes from. This can be a local or remote client.
41     * \param parc Integer holding the number of supplied arguments.
42     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
43     * pointers.
44     * \note Valid arguments for this command are:
45     * - parv[0] = command
46     * - parv[1] = space-separated list of up to 5 nicknames
47 adx 30 */
48 michael 2820 static int
49 michael 3156 m_userhost(struct Client *source_p, int parc, char *parv[])
50 adx 30 {
51     struct Client *target_p;
52     char buf[IRCD_BUFSIZE];
53     char response[NICKLEN*2+USERLEN+HOSTLEN+30];
54 michael 1178 char *t = NULL, *p = NULL, *nick = NULL;
55 michael 3299 int i = 0;
56 adx 30 int cur_len;
57     int rl;
58    
59 michael 3109 cur_len = snprintf(buf, sizeof(buf), numeric_form(RPL_USERHOST), me.name, source_p->name, "");
60 adx 30 t = buf + cur_len;
61    
62 michael 6545 for (nick = strtok_r(parv[1], " ", &p); nick && i++ < 5;
63     nick = strtok_r(NULL, " ", &p))
64 adx 30 {
65 michael 3246 if ((target_p = find_person(source_p, nick)))
66 adx 30 {
67 adx 268 /*
68 michael 6626 * Show real IP address for USERHOST on yourself.
69 michael 885 * This is needed for things like mIRC, which do a server-based
70     * lookup (USERHOST) to figure out what the clients' local IP
71 michael 3299 * is. Useful for things like NAT, and dynamic dial-up users.
72 adx 268 */
73 michael 7047 if (MyConnect(target_p) && (target_p == source_p))
74 michael 885 {
75 michael 4827 rl = snprintf(response, sizeof(response), "%s%s=%c%s@%s ",
76     target_p->name,
77     HasUMode(target_p, UMODE_OPER) ? "*" : "",
78     (target_p->away[0]) ? '-' : '+',
79     target_p->username,
80     target_p->sockhost);
81 michael 885 }
82 adx 268 else
83 michael 885 {
84 michael 4827 rl = snprintf(response, sizeof(response), "%s%s=%c%s@%s ",
85     target_p->name, (HasUMode(target_p, UMODE_OPER) &&
86     (!HasUMode(target_p, UMODE_HIDDEN) ||
87     HasUMode(source_p, UMODE_OPER))) ? "*" : "",
88     (target_p->away[0]) ? '-' : '+',
89     target_p->username,
90     target_p->host);
91 michael 885 }
92 adx 30
93 michael 885 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
94 adx 268 {
95 michael 1793 sprintf(t, "%s", response);
96 adx 268 t += rl;
97     cur_len += rl;
98     }
99 michael 885 else
100     break;
101 adx 30 }
102 adx 268 }
103 adx 30
104     sendto_one(source_p, "%s", buf);
105 michael 2820 return 0;
106 adx 30 }
107 michael 1230
108 michael 2820 static struct Message userhost_msgtab =
109     {
110 michael 5880 .cmd = "USERHOST",
111     .args_min = 2,
112     .args_max = 1,
113     .handlers[UNREGISTERED_HANDLER] = m_unregistered,
114     .handlers[CLIENT_HANDLER] = m_userhost,
115     .handlers[SERVER_HANDLER] = m_ignore,
116     .handlers[ENCAP_HANDLER] = m_ignore,
117     .handlers[OPER_HANDLER] = m_userhost
118 michael 1230 };
119    
120     static void
121     module_init(void)
122     {
123     mod_add_cmd(&userhost_msgtab);
124     }
125    
126     static void
127     module_exit(void)
128     {
129     mod_del_cmd(&userhost_msgtab);
130     }
131    
132 michael 2820 struct module module_entry =
133     {
134 michael 1230 .version = "$Revision$",
135     .modinit = module_init,
136     .modexit = module_exit,
137     };

Properties

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