| 1 |
adx |
30 |
/* |
| 2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
2820 |
* Copyright (c) 1997-2014 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 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 19 |
|
|
* 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 "s_serv.h" |
| 32 |
|
|
#include "send.h" |
| 33 |
|
|
#include "irc_string.h" |
| 34 |
|
|
#include "parse.h" |
| 35 |
|
|
#include "modules.h" |
| 36 |
|
|
|
| 37 |
|
|
|
| 38 |
|
|
/* |
| 39 |
|
|
* m_userhost added by Darren Reed 13/8/91 to aid clients and reduce |
| 40 |
|
|
* the need for complicated requests like WHOIS. It returns user/host |
| 41 |
|
|
* information only (no spurious AWAY labels or channels). |
| 42 |
|
|
*/ |
| 43 |
michael |
2820 |
static int |
| 44 |
michael |
3156 |
m_userhost(struct Client *source_p, int parc, char *parv[]) |
| 45 |
adx |
30 |
{ |
| 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 |
3109 |
cur_len = snprintf(buf, sizeof(buf), numeric_form(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 |
3246 |
if ((target_p = find_person(source_p, nick))) |
| 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 |
michael |
1793 |
rl = sprintf(response, "%s%s=%c%s@%s ", |
| 71 |
|
|
target_p->name, |
| 72 |
|
|
HasUMode(target_p, UMODE_OPER) ? "*" : "", |
| 73 |
|
|
(target_p->away[0]) ? '-' : '+', |
| 74 |
|
|
target_p->username, |
| 75 |
|
|
target_p->sockhost); |
| 76 |
michael |
885 |
} |
| 77 |
adx |
268 |
else |
| 78 |
michael |
885 |
{ |
| 79 |
michael |
1793 |
rl = sprintf(response, "%s%s=%c%s@%s ", |
| 80 |
|
|
target_p->name, (HasUMode(target_p, UMODE_OPER) && |
| 81 |
|
|
(!HasUMode(target_p, UMODE_HIDDEN) || |
| 82 |
|
|
HasUMode(source_p, UMODE_OPER))) ? "*" : "", |
| 83 |
|
|
(target_p->away[0]) ? '-' : '+', |
| 84 |
|
|
target_p->username, |
| 85 |
|
|
target_p->host); |
| 86 |
michael |
885 |
} |
| 87 |
adx |
30 |
|
| 88 |
michael |
885 |
if ((rl + cur_len) < (IRCD_BUFSIZE - 10)) |
| 89 |
adx |
268 |
{ |
| 90 |
michael |
1793 |
sprintf(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 |
michael |
2820 |
return 0; |
| 101 |
adx |
30 |
} |
| 102 |
michael |
1230 |
|
| 103 |
michael |
2820 |
static struct Message userhost_msgtab = |
| 104 |
|
|
{ |
| 105 |
michael |
1728 |
"USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0, |
| 106 |
michael |
2820 |
{ m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore } |
| 107 |
michael |
1230 |
}; |
| 108 |
|
|
|
| 109 |
|
|
static void |
| 110 |
|
|
module_init(void) |
| 111 |
|
|
{ |
| 112 |
|
|
mod_add_cmd(&userhost_msgtab); |
| 113 |
|
|
} |
| 114 |
|
|
|
| 115 |
|
|
static void |
| 116 |
|
|
module_exit(void) |
| 117 |
|
|
{ |
| 118 |
|
|
mod_del_cmd(&userhost_msgtab); |
| 119 |
|
|
} |
| 120 |
|
|
|
| 121 |
michael |
2820 |
struct module module_entry = |
| 122 |
|
|
{ |
| 123 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
| 124 |
|
|
.name = NULL, |
| 125 |
|
|
.version = "$Revision$", |
| 126 |
|
|
.handle = NULL, |
| 127 |
|
|
.modinit = module_init, |
| 128 |
|
|
.modexit = module_exit, |
| 129 |
|
|
.flags = 0 |
| 130 |
|
|
}; |