2 * ircd-ratbox: A slightly useful ircd.
3 * m_userhost.c: Shows a user's host.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31 #include "irc_string.h"
32 #include "sprintf_irc.h"
38 static char buf
[BUFSIZE
];
40 static int m_userhost(struct Client
*, struct Client
*, int, const char **);
42 struct Message userhost_msgtab
= {
43 "USERHOST", 0, 0, 0, MFLG_SLOW
,
44 {mg_unreg
, {m_userhost
, 2}, mg_ignore
, mg_ignore
, mg_ignore
, {m_userhost
, 2}}
47 mapi_clist_av1 userhost_clist
[] = { &userhost_msgtab
, NULL
};
48 DECLARE_MODULE_AV1(userhost
, NULL
, NULL
, userhost_clist
, NULL
, NULL
, "$Revision: 147 $");
51 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
52 * the need for complicated requests like WHOIS. It returns user/host
53 * information only (no spurious AWAY labels or channels).
56 m_userhost(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
58 struct Client
*target_p
;
59 char response
[NICKLEN
* 2 + USERLEN
+ HOSTLEN
+ 30];
61 int i
; /* loop counter */
65 cur_len
= ircsprintf(buf
, form_str(RPL_USERHOST
), me
.name
, parv
[0], "");
68 for (i
= 1; i
<= 5; i
++)
73 if((target_p
= find_person(parv
[i
])) != NULL
)
76 * Show real IP for USERHOST on yourself.
77 * This is needed for things like mIRC, which do a server-based
78 * lookup (USERHOST) to figure out what the clients' local IP
79 * is. Useful for things like NAT, and dynamic dial-up users.
81 if(MyClient(target_p
) && (target_p
== source_p
))
83 rl
= ircsprintf(response
, "%s%s=%c%s@%s ",
85 IsOper(target_p
) ? "*" : "",
86 (target_p
->user
->away
) ? '-' : '+',
92 rl
= ircsprintf(response
, "%s%s=%c%s@%s ",
94 SeesOper(source_p
, target_p
) ? "*" : "",
95 (target_p
->user
->away
) ? '-' : '+',
96 target_p
->username
, target_p
->host
);
99 if((rl
+ cur_len
) < (BUFSIZE
- 10))
101 ircsprintf(t
, "%s", response
);
110 sendto_one(source_p
, "%s", buf
);