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 "client.h" |
27 |
|
|
#include "ircd.h" |
28 |
|
|
#include "numeric.h" |
29 |
|
|
#include "s_serv.h" |
30 |
|
|
#include "send.h" |
31 |
|
|
#include "irc_string.h" |
32 |
|
|
#include "sprintf_irc.h" |
33 |
|
|
#include "parse.h" |
34 |
|
|
#include "modules.h" |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
/* |
38 |
|
|
* m_userhost added by Darren Reed 13/8/91 to aid clients and reduce |
39 |
|
|
* the need for complicated requests like WHOIS. It returns user/host |
40 |
|
|
* information only (no spurious AWAY labels or channels). |
41 |
|
|
*/ |
42 |
|
|
static void |
43 |
|
|
m_userhost(struct Client *client_p, struct Client *source_p, |
44 |
|
|
int parc, char *parv[]) |
45 |
|
|
{ |
46 |
|
|
struct Client *target_p; |
47 |
|
|
char buf[IRCD_BUFSIZE]; |
48 |
|
|
char response[NICKLEN*2+USERLEN+HOSTLEN+30]; |
49 |
michael |
1178 |
char *t = NULL, *p = NULL, *nick = NULL; |
50 |
|
|
int i = 0; /* loop counter */ |
51 |
adx |
30 |
int cur_len; |
52 |
|
|
int rl; |
53 |
|
|
|
54 |
michael |
1233 |
cur_len = snprintf(buf, sizeof(buf), form_str(RPL_USERHOST), me.name, source_p->name, ""); |
55 |
adx |
30 |
t = buf + cur_len; |
56 |
|
|
|
57 |
michael |
1178 |
for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5; |
58 |
|
|
nick = strtoken(&p, NULL, " ")) |
59 |
adx |
30 |
{ |
60 |
michael |
1178 |
if ((target_p = find_person(client_p, nick)) != NULL) |
61 |
adx |
30 |
{ |
62 |
adx |
268 |
/* |
63 |
michael |
885 |
* Show real IP for USERHOST on yourself. |
64 |
|
|
* This is needed for things like mIRC, which do a server-based |
65 |
|
|
* lookup (USERHOST) to figure out what the clients' local IP |
66 |
|
|
* is. Useful for things like NAT, and dynamic dial-up users. |
67 |
adx |
268 |
*/ |
68 |
michael |
885 |
if (MyClient(target_p) && (target_p == source_p)) |
69 |
|
|
{ |
70 |
|
|
rl = ircsprintf(response, "%s%s=%c%s@%s ", |
71 |
|
|
target_p->name, |
72 |
michael |
1219 |
HasUMode(target_p, UMODE_OPER) ? "*" : "", |
73 |
michael |
1483 |
(target_p->away[0]) ? '-' : '+', |
74 |
michael |
885 |
target_p->username, |
75 |
|
|
target_p->sockhost); |
76 |
|
|
} |
77 |
adx |
268 |
else |
78 |
michael |
885 |
{ |
79 |
|
|
rl = ircsprintf(response, "%s%s=%c%s@%s ", |
80 |
michael |
1405 |
target_p->name, (HasUMode(target_p, UMODE_OPER) && |
81 |
|
|
(!HasUMode(target_p, UMODE_HIDDEN) || |
82 |
|
|
HasUMode(source_p, UMODE_OPER))) ? "*" : "", |
83 |
michael |
1483 |
(target_p->away[0]) ? '-' : '+', |
84 |
michael |
885 |
target_p->username, |
85 |
|
|
target_p->host); |
86 |
|
|
} |
87 |
adx |
30 |
|
88 |
michael |
885 |
if ((rl + cur_len) < (IRCD_BUFSIZE - 10)) |
89 |
adx |
268 |
{ |
90 |
michael |
885 |
ircsprintf(t, "%s", response); |
91 |
adx |
268 |
t += rl; |
92 |
|
|
cur_len += rl; |
93 |
|
|
} |
94 |
michael |
885 |
else |
95 |
|
|
break; |
96 |
adx |
30 |
} |
97 |
adx |
268 |
} |
98 |
adx |
30 |
|
99 |
|
|
sendto_one(source_p, "%s", buf); |
100 |
|
|
} |
101 |
michael |
1230 |
|
102 |
|
|
static struct Message userhost_msgtab = { |
103 |
|
|
"USERHOST", 0, 0, 1, 1, MFLG_SLOW, 0, |
104 |
|
|
{m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore} |
105 |
|
|
}; |
106 |
|
|
|
107 |
|
|
static void |
108 |
|
|
module_init(void) |
109 |
|
|
{ |
110 |
|
|
mod_add_cmd(&userhost_msgtab); |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
static void |
114 |
|
|
module_exit(void) |
115 |
|
|
{ |
116 |
|
|
mod_del_cmd(&userhost_msgtab); |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
struct module module_entry = { |
120 |
|
|
.node = { NULL, NULL, NULL }, |
121 |
|
|
.name = NULL, |
122 |
|
|
.version = "$Revision$", |
123 |
|
|
.handle = NULL, |
124 |
|
|
.modinit = module_init, |
125 |
|
|
.modexit = module_exit, |
126 |
|
|
.flags = 0 |
127 |
|
|
}; |