ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 1144
Committed: Tue Jul 26 19:33:54 2011 UTC (15 years, 2 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_links.c
File size: 5231 byte(s)
Log Message:
Added back STATS/TRACE/MOTD/ADMIN request notices. Removed
   spy_*_notice modules accordingly.


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 "handlers.h"
27 #include "client.h"
28 #include "irc_string.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "s_serv.h"
32 #include "send.h"
33 #include "s_conf.h"
34 #include "msg.h"
35 #include "motd.h"
36 #include "parse.h"
37 #include "modules.h"
38
39 static void do_links(struct Client *, int, char *[]);
40 static void m_links(struct Client *, struct Client *, int, char *[]);
41 static void mo_links(struct Client *, struct Client *, int, char *[]);
42 static void ms_links(struct Client *, struct Client *, int, char *[]);
43
44 struct Message links_msgtab = {
45 "LINKS", 0, 0, 0, 0, MFLG_SLOW, 0,
46 {m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore}
47 };
48
49 const char *_version = "$Revision$";
50
51
52 static void
53 do_links(struct Client *source_p, int parc, char *parv[])
54 {
55 sendto_realops_flags(UMODE_SPY, L_ALL,
56 "LINKS requested by %s (%s@%s) [%s]",
57 source_p->name,
58 source_p->username, source_p->host,
59 source_p->servptr->name);
60
61 if (IsOper(source_p) || !ConfigServerHide.flatten_links)
62 {
63 const char *mask = (parc > 2 ? parv[2] : parv[1]);
64 const char *me_name, *nick, *p;
65 struct Client *target_p;
66 dlink_node *ptr;
67
68 me_name = ID_or_name(&me, source_p->from);
69 nick = ID_or_name(source_p, source_p->from);
70
71 DLINK_FOREACH(ptr, global_serv_list.head)
72 {
73 target_p = ptr->data;
74
75 if (!EmptyString(mask) && !match(mask, target_p->name))
76 continue;
77
78 if (target_p->info[0])
79 {
80 if ((p = strchr(target_p->info, ']')))
81 p += 2; /* skip the nasty [IP] part */
82 else
83 p = target_p->info;
84 }
85 else
86 p = "(Unknown Location)";
87
88 /* We just send the reply, as if they are here there's either no SHIDE,
89 * or they're an oper..
90 */
91 sendto_one(source_p, form_str(RPL_LINKS),
92 me_name, nick,
93 target_p->name, target_p->servptr->name,
94 target_p->hopcount, p);
95 }
96
97 sendto_one(source_p, form_str(RPL_ENDOFLINKS),
98 me_name, nick,
99 EmptyString(mask) ? "*" : mask);
100 }
101 else {
102 /*
103 * Print our own info so at least it looks like a normal links
104 * then print out the file (which may or may not be empty)
105 */
106 sendto_one(source_p, form_str(RPL_LINKS),
107 ID_or_name(&me, source_p->from),
108 ID_or_name(source_p, source_p->from),
109 me.name, me.name, 0, me.info);
110 send_message_file(source_p, &ConfigFileEntry.linksfile);
111 sendto_one(source_p, form_str(RPL_ENDOFLINKS),
112 ID_or_name(&me, source_p->from),
113 ID_or_name(source_p, source_p->from), "*");
114 }
115 }
116
117 /*
118 * m_links - LINKS message handler
119 * parv[0] = sender prefix
120 * parv[1] = servername mask
121 * or
122 * parv[0] = sender prefix
123 * parv[1] = server to query
124 * parv[2] = servername mask
125 */
126 static void
127 m_links(struct Client *client_p, struct Client *source_p,
128 int parc, char *parv[])
129 {
130 static time_t last_used = 0;
131
132 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
133 {
134 sendto_one(source_p, form_str(RPL_LOAD2HI),
135 me.name, source_p->name);
136 return;
137 }
138
139 last_used = CurrentTime;
140
141 if (!ConfigServerHide.flatten_links)
142 {
143 mo_links(client_p, source_p, parc, parv);
144 return;
145 }
146
147 do_links(source_p, parc, parv);
148 }
149
150 static void
151 mo_links(struct Client *client_p, struct Client *source_p,
152 int parc, char *parv[])
153 {
154 if (parc > 2)
155 if (!ConfigFileEntry.disable_remote || IsOper(source_p))
156 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
157 parc, parv) != HUNTED_ISME)
158 return;
159
160 do_links(source_p, parc, parv);
161 }
162
163 /*
164 * ms_links - LINKS message handler
165 * parv[0] = sender prefix
166 * parv[1] = servername mask
167 * or
168 * parv[0] = sender prefix
169 * parv[1] = server to query
170 * parv[2] = servername mask
171 */
172 static void
173 ms_links(struct Client *client_p, struct Client *source_p,
174 int parc, char *parv[])
175 {
176 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
177 parc, parv) != HUNTED_ISME)
178 return;
179
180 if (IsClient(source_p))
181 m_links(client_p, source_p, parc, parv);
182 }

Properties

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