1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2004-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_etrace.c |
23 |
* \brief Includes required functions for processing the ETRACE command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "list.h" |
29 |
#include "client.h" |
30 |
#include "hash.h" |
31 |
#include "irc_string.h" |
32 |
#include "ircd.h" |
33 |
#include "numeric.h" |
34 |
#include "send.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
#include "conf.h" |
38 |
|
39 |
|
40 |
/* report_this_status() |
41 |
* |
42 |
* inputs - pointer to client to report to |
43 |
* - pointer to client to report about |
44 |
* - flag full etrace or not |
45 |
* output - NONE |
46 |
* side effects - NONE |
47 |
*/ |
48 |
static void |
49 |
report_this_status(struct Client *source_p, const struct Client *target_p) |
50 |
{ |
51 |
if (target_p->status != STAT_CLIENT) |
52 |
return; |
53 |
|
54 |
if (ConfigFileEntry.hide_spoof_ips) |
55 |
sendto_one_numeric(source_p, &me, RPL_ETRACE, |
56 |
HasUMode(target_p, UMODE_OPER) ? "Oper" : "User", |
57 |
get_client_class(&target_p->localClient->confs), |
58 |
target_p->name, |
59 |
target_p->username, |
60 |
target_p->host, |
61 |
IsIPSpoof(target_p) ? "255.255.255.255" : target_p->sockhost, |
62 |
target_p->info); |
63 |
else |
64 |
sendto_one_numeric(source_p, &me, RPL_ETRACE, |
65 |
HasUMode(target_p, UMODE_OPER) ? "Oper" : "User", |
66 |
get_client_class(&target_p->localClient->confs), |
67 |
target_p->name, |
68 |
target_p->username, |
69 |
target_p->host, |
70 |
target_p->sockhost, |
71 |
target_p->info); |
72 |
} |
73 |
|
74 |
/* |
75 |
* do_etrace() |
76 |
*/ |
77 |
static void |
78 |
do_etrace(struct Client *source_p, const char *arg) |
79 |
{ |
80 |
const char *tname = NULL; |
81 |
unsigned int wilds = 0, do_all = 0; |
82 |
const dlink_node *ptr = NULL; |
83 |
|
84 |
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
85 |
"ETRACE requested by %s (%s@%s) [%s]", |
86 |
source_p->name, source_p->username, |
87 |
source_p->host, source_p->servptr->name); |
88 |
|
89 |
if (!EmptyString(arg)) |
90 |
{ |
91 |
tname = arg; |
92 |
wilds = has_wildcards(tname); |
93 |
} |
94 |
else |
95 |
{ |
96 |
do_all = 1; |
97 |
tname = "*"; |
98 |
} |
99 |
|
100 |
if (!wilds && !do_all) |
101 |
{ |
102 |
const struct Client *target_p = hash_find_client(tname); |
103 |
|
104 |
if (target_p && MyClient(target_p)) |
105 |
report_this_status(source_p, target_p); |
106 |
|
107 |
sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, tname); |
108 |
return; |
109 |
} |
110 |
|
111 |
DLINK_FOREACH(ptr, local_client_list.head) |
112 |
{ |
113 |
const struct Client *target_p = ptr->data; |
114 |
|
115 |
if (wilds) |
116 |
{ |
117 |
if (!match(tname, target_p->name)) |
118 |
report_this_status(source_p, target_p); |
119 |
} |
120 |
else |
121 |
report_this_status(source_p, target_p); |
122 |
} |
123 |
|
124 |
sendto_one_numeric(source_p, &me, RPL_ENDOFTRACE, tname); |
125 |
} |
126 |
|
127 |
/* mo_etrace() |
128 |
* parv[0] = command |
129 |
* parv[1] = servername |
130 |
*/ |
131 |
static int |
132 |
mo_etrace(struct Client *source_p, int parc, char *parv[]) |
133 |
{ |
134 |
do_etrace(source_p, parv[1]); |
135 |
return 0; |
136 |
} |
137 |
|
138 |
static struct Message etrace_msgtab = |
139 |
{ |
140 |
"ETRACE", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
141 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_etrace, m_ignore } |
142 |
}; |
143 |
|
144 |
static void |
145 |
module_init(void) |
146 |
{ |
147 |
mod_add_cmd(&etrace_msgtab); |
148 |
} |
149 |
|
150 |
static void |
151 |
module_exit(void) |
152 |
{ |
153 |
mod_del_cmd(&etrace_msgtab); |
154 |
} |
155 |
|
156 |
struct module module_entry = |
157 |
{ |
158 |
.node = { NULL, NULL, NULL }, |
159 |
.name = NULL, |
160 |
.version = "$Revision$", |
161 |
.handle = NULL, |
162 |
.modinit = module_init, |
163 |
.modexit = module_exit, |
164 |
.flags = 0 |
165 |
}; |