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: 3377
Committed: Thu Apr 24 16:15:51 2014 UTC (9 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 4006 byte(s)
Log Message:
- Create 8.2.x branch

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_userhost.c
23 * \brief Includes required functions for processing the USERHOST command.
24 * \version $Id$
25 */
26
27 #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 /*! \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 */
48 static int
49 m_userhost(struct Client *source_p, int parc, char *parv[])
50 {
51 struct Client *target_p;
52 char buf[IRCD_BUFSIZE];
53 char response[NICKLEN*2+USERLEN+HOSTLEN+30];
54 char *t = NULL, *p = NULL, *nick = NULL;
55 int i = 0;
56 int cur_len;
57 int rl;
58
59 cur_len = snprintf(buf, sizeof(buf), numeric_form(RPL_USERHOST), me.name, source_p->name, "");
60 t = buf + cur_len;
61
62 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
63 nick = strtoken(&p, NULL, " "))
64 {
65 if ((target_p = find_person(source_p, nick)))
66 {
67 /*
68 * Show real IP for USERHOST on yourself.
69 * This is needed for things like mIRC, which do a server-based
70 * lookup (USERHOST) to figure out what the clients' local IP
71 * is. Useful for things like NAT, and dynamic dial-up users.
72 */
73 if (MyClient(target_p) && (target_p == source_p))
74 {
75 rl = sprintf(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 }
82 else
83 {
84 rl = sprintf(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 }
92
93 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
94 {
95 sprintf(t, "%s", response);
96 t += rl;
97 cur_len += rl;
98 }
99 else
100 break;
101 }
102 }
103
104 sendto_one(source_p, "%s", buf);
105 return 0;
106 }
107
108 static struct Message userhost_msgtab =
109 {
110 "USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0,
111 { m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore }
112 };
113
114 static void
115 module_init(void)
116 {
117 mod_add_cmd(&userhost_msgtab);
118 }
119
120 static void
121 module_exit(void)
122 {
123 mod_del_cmd(&userhost_msgtab);
124 }
125
126 struct module module_entry =
127 {
128 .node = { NULL, NULL, NULL },
129 .name = NULL,
130 .version = "$Revision$",
131 .handle = NULL,
132 .modinit = module_init,
133 .modexit = module_exit,
134 .flags = 0
135 };

Properties

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