ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 2196
Committed: Tue Jun 4 18:30:12 2013 UTC (13 years, 1 month ago) by michael
Content type: text/x-csrc
File size: 5517 byte(s)
Log Message:
- Moved disable_remote_command configuration directive from
  general{} block to serverhide{] block

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_links.c: Shows what servers are currently connected.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "client.h"
27 #include "irc_string.h"
28 #include "ircd.h"
29 #include "numeric.h"
30 #include "s_serv.h"
31 #include "send.h"
32 #include "conf.h"
33 #include "motd.h"
34 #include "parse.h"
35 #include "modules.h"
36
37
38 static void
39 do_links(struct Client *source_p, int parc, char *parv[])
40 {
41 dlink_node *ptr = NULL;
42
43 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
44 "LINKS requested by %s (%s@%s) [%s]",
45 source_p->name,
46 source_p->username, source_p->host,
47 source_p->servptr->name);
48
49 if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links)
50 {
51 const char *mask = (parc > 2 ? parv[2] : parv[1]);
52 const char *me_name, *nick;
53
54 me_name = ID_or_name(&me, source_p->from);
55 nick = ID_or_name(source_p, source_p->from);
56
57 DLINK_FOREACH(ptr, global_serv_list.head)
58 {
59 struct Client *target_p = ptr->data;
60
61 /* skip hidden servers */
62 if (IsHidden(target_p))
63 if (!HasUMode(source_p, UMODE_OPER))
64 continue;
65
66 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
67 if (!HasUMode(source_p, UMODE_OPER))
68 continue;
69
70 if (!EmptyString(mask) && match(mask, target_p->name))
71 continue;
72
73 /*
74 * We just send the reply, as if they are here there's either no SHIDE,
75 * or they're an oper..
76 */
77 sendto_one(source_p, form_str(RPL_LINKS),
78 me_name, nick,
79 target_p->name, target_p->servptr->name,
80 target_p->hopcount, target_p->info);
81 }
82
83 sendto_one(source_p, form_str(RPL_ENDOFLINKS),
84 me_name, nick,
85 EmptyString(mask) ? "*" : mask);
86 }
87 else
88 {
89 /*
90 * Print our own info so at least it looks like a normal links
91 * then print out the file (which may or may not be empty)
92 */
93 sendto_one(source_p, form_str(RPL_LINKS),
94 ID_or_name(&me, source_p->from),
95 ID_or_name(source_p, source_p->from),
96 me.name, me.name, 0, me.info);
97
98 DLINK_FOREACH(ptr, flatten_links.head)
99 sendto_one(source_p, ":%s %d %s %s",
100 ID_or_name(&me, source_p->from), RPL_LINKS,
101 ID_or_name(source_p, source_p->from),
102 ptr->data);
103 sendto_one(source_p, form_str(RPL_ENDOFLINKS),
104 ID_or_name(&me, source_p->from),
105 ID_or_name(source_p, source_p->from), "*");
106 }
107 }
108
109 static void
110 mo_links(struct Client *client_p, struct Client *source_p,
111 int parc, char *parv[])
112 {
113 if (parc > 2)
114 if (!ConfigServerHide.disable_remote_commands || HasUMode(source_p, UMODE_OPER))
115 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
116 parc, parv) != HUNTED_ISME)
117 return;
118
119 do_links(source_p, parc, parv);
120 }
121
122 /*
123 * m_links - LINKS message handler
124 * parv[0] = sender prefix
125 * parv[1] = servername mask
126 * or
127 * parv[0] = sender prefix
128 * parv[1] = server to query
129 * parv[2] = servername mask
130 */
131 static void
132 m_links(struct Client *client_p, struct Client *source_p,
133 int parc, char *parv[])
134 {
135 static time_t last_used = 0;
136
137 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
138 {
139 sendto_one(source_p, form_str(RPL_LOAD2HI),
140 me.name, source_p->name);
141 return;
142 }
143
144 last_used = CurrentTime;
145
146 if (!ConfigServerHide.flatten_links)
147 {
148 mo_links(client_p, source_p, parc, parv);
149 return;
150 }
151
152 do_links(source_p, parc, parv);
153 }
154
155 /*
156 * ms_links - LINKS message handler
157 * parv[0] = sender prefix
158 * parv[1] = servername mask
159 * or
160 * parv[0] = sender prefix
161 * parv[1] = server to query
162 * parv[2] = servername mask
163 */
164 static void
165 ms_links(struct Client *client_p, struct Client *source_p,
166 int parc, char *parv[])
167 {
168 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
169 parc, parv) != HUNTED_ISME)
170 return;
171
172 if (IsClient(source_p))
173 m_links(client_p, source_p, parc, parv);
174 }
175
176 static struct Message links_msgtab = {
177 "LINKS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
178 {m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore}
179 };
180
181 static void
182 module_init(void)
183 {
184 mod_add_cmd(&links_msgtab);
185 }
186
187 static void
188 module_exit(void)
189 {
190 mod_del_cmd(&links_msgtab);
191 }
192
193 struct module module_entry = {
194 .node = { NULL, NULL, NULL },
195 .name = NULL,
196 .version = "$Revision$",
197 .handle = NULL,
198 .modinit = module_init,
199 .modexit = module_exit,
200 .flags = 0
201 };

Properties

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