ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 3156
Committed: Fri Mar 14 19:57:38 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4976 byte(s)
Log Message:
- Removed client_p pointers from everywhere

File Contents

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

Properties

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