ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 4690
Committed: Fri Oct 3 14:01:08 2014 UTC (10 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 5797 byte(s)
Log Message:
- Style corrections

File Contents

# User Rev Content
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 michael 4565 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 adx 30 * USA
20     */
21    
22 michael 2820 /*! \file m_links.c
23     * \brief Includes required functions for processing the LINKS command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32 michael 3347 #include "server.h"
33 adx 30 #include "send.h"
34 michael 1309 #include "conf.h"
35 adx 30 #include "motd.h"
36     #include "parse.h"
37     #include "modules.h"
38    
39    
40 michael 3344 /*! \brief Shows a list of linked servers and notifies irc-operators
41     * about the LINKS request
42     *
43     * \param source_p Pointer to client to report to
44     */
45 michael 1144 static void
46     do_links(struct Client *source_p, int parc, char *parv[])
47 adx 30 {
48 michael 2156 dlink_node *ptr = NULL;
49    
50 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
51 michael 1144 "LINKS requested by %s (%s@%s) [%s]",
52     source_p->name,
53     source_p->username, source_p->host,
54     source_p->servptr->name);
55 adx 30
56 michael 1219 if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links)
57 adx 30 {
58 michael 1045 const char *mask = (parc > 2 ? parv[2] : parv[1]);
59 adx 30
60 michael 4209 DLINK_FOREACH(ptr, global_server_list.head)
61 adx 30 {
62 michael 1544 struct Client *target_p = ptr->data;
63 adx 30
64 michael 1489 /* skip hidden servers */
65 michael 1490 if (IsHidden(target_p))
66     if (!HasUMode(source_p, UMODE_OPER))
67 michael 1489 continue;
68    
69 michael 1851 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
70     if (!HasUMode(source_p, UMODE_OPER))
71     continue;
72    
73 michael 1652 if (!EmptyString(mask) && match(mask, target_p->name))
74 adx 30 continue;
75 michael 575
76 michael 1544 /*
77     * We just send the reply, as if they are here there's either no SHIDE,
78 michael 2820 * or they're an oper..
79 adx 30 */
80 michael 3109 sendto_one_numeric(source_p, &me, RPL_LINKS,
81     target_p->name, target_p->servptr->name,
82     target_p->hopcount, target_p->info);
83 adx 30 }
84 michael 3109
85     sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS,
86     EmptyString(mask) ? "*" : mask);
87 adx 30 }
88 michael 1148 else
89     {
90 adx 30 /*
91     * Print our own info so at least it looks like a normal links
92     * then print out the file (which may or may not be empty)
93     */
94 michael 3573 sendto_one_numeric(source_p, &me, RPL_LINKS, me.name, me.name, 0, me.info);
95 michael 2156
96     DLINK_FOREACH(ptr, flatten_links.head)
97 michael 3573 sendto_one_numeric(source_p, &me, RPL_LINKS|SND_EXPLICIT, "%s", ptr->data);
98 michael 3109 sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS, "*");
99 adx 30 }
100     }
101    
102 michael 2820 static int
103 michael 3156 mo_links(struct Client *source_p, int parc, char *parv[])
104 michael 1230 {
105     if (parc > 2)
106 michael 2196 if (!ConfigServerHide.disable_remote_commands || HasUMode(source_p, UMODE_OPER))
107 michael 3156 if (hunt_server(source_p, ":%s LINKS %s :%s", 1,
108 michael 1230 parc, parv) != HUNTED_ISME)
109 michael 2820 return 0;
110 michael 1230
111     do_links(source_p, parc, parv);
112 michael 2820 return 0;
113 michael 1230 }
114    
115 michael 3299 /*! \brief LINKS command handler
116     *
117     * \param source_p Pointer to allocated Client struct from which the message
118     * originally comes from. This can be a local or remote client.
119     * \param parc Integer holding the number of supplied arguments.
120     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
121     * pointers.
122     * \note Valid arguments for this command are:
123     * - parv[0] = command
124     * - parv[1] = servername mask
125 adx 30 * or
126 michael 3299 * - parv[0] = command
127     * - parv[1] = server to query
128     * - parv[2] = servername mask
129 adx 30 */
130 michael 2820 static int
131 michael 3156 m_links(struct Client *source_p, int parc, char *parv[])
132 adx 30 {
133 adx 269 static time_t last_used = 0;
134    
135 michael 4340 if ((last_used + ConfigGeneral.pace_wait) > CurrentTime)
136 adx 269 {
137 michael 3109 sendto_one_numeric(source_p, &me, RPL_LOAD2HI);
138 michael 2820 return 0;
139 adx 269 }
140    
141 michael 1121 last_used = CurrentTime;
142    
143 adx 30 if (!ConfigServerHide.flatten_links)
144 michael 3156 return mo_links(source_p, parc, parv);
145 adx 30
146 michael 1144 do_links(source_p, parc, parv);
147 michael 2820 return 0;
148 adx 30 }
149    
150 michael 3299 /*! \brief LINKS command handler
151     *
152     * \param source_p Pointer to allocated Client struct from which the message
153     * originally comes from. This can be a local or remote client.
154     * \param parc Integer holding the number of supplied arguments.
155     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
156     * pointers.
157     * \note Valid arguments for this command are:
158     * - parv[0] = command
159     * - parv[1] = servername mask
160 adx 30 * or
161 michael 3299 * - parv[0] = command
162     * - parv[1] = server to query
163     * - parv[2] = servername mask
164 adx 30 */
165 michael 2820 static int
166 michael 3156 ms_links(struct Client *source_p, int parc, char *parv[])
167 adx 30 {
168 michael 4690 if (hunt_server(source_p, ":%s LINKS %s :%s", 1, parc, parv) != HUNTED_ISME)
169 michael 2820 return 0;
170 adx 30
171 michael 3156 return m_links(source_p, parc, parv);
172 adx 30 }
173 michael 1230
174 michael 2820 static struct Message links_msgtab =
175     {
176 michael 4545 "LINKS", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
177 michael 2820 { m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore }
178 michael 1230 };
179    
180     static void
181     module_init(void)
182     {
183     mod_add_cmd(&links_msgtab);
184     }
185    
186     static void
187     module_exit(void)
188     {
189     mod_del_cmd(&links_msgtab);
190     }
191    
192 michael 2820 struct module module_entry =
193     {
194 michael 1230 .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