ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 9019
Committed: Mon May 27 22:05:04 2019 UTC (7 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 4774 byte(s)
Log Message:
- m_links.c: /links can no longer be used remotely

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 8752 * Copyright (c) 1997-2019 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 "parse.h"
36     #include "modules.h"
37    
38    
39 michael 3344 /*! \brief Shows a list of linked servers and notifies irc-operators
40     * about the LINKS request
41     *
42     * \param source_p Pointer to client to report to
43     */
44 michael 1144 static void
45     do_links(struct Client *source_p, int parc, char *parv[])
46 adx 30 {
47 michael 8431 dlink_node *node;
48 michael 2156
49 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
50 michael 1144 "LINKS requested by %s (%s@%s) [%s]",
51     source_p->name,
52     source_p->username, source_p->host,
53     source_p->servptr->name);
54 adx 30
55 michael 9019 if (HasUMode(source_p, UMODE_OPER) || ConfigServerHide.flatten_links == 0)
56 adx 30 {
57 michael 1045 const char *mask = (parc > 2 ? parv[2] : parv[1]);
58 adx 30
59 michael 4815 DLINK_FOREACH(node, global_server_list.head)
60 adx 30 {
61 michael 6355 const struct Client *target_p = node->data;
62 adx 30
63 michael 8431 /* Skip hidden servers */
64 michael 1490 if (IsHidden(target_p))
65     if (!HasUMode(source_p, UMODE_OPER))
66 michael 1489 continue;
67    
68 michael 1851 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
69     if (!HasUMode(source_p, UMODE_OPER))
70     continue;
71    
72 michael 1652 if (!EmptyString(mask) && match(mask, target_p->name))
73 adx 30 continue;
74 michael 575
75 michael 1544 /*
76     * We just send the reply, as if they are here there's either no SHIDE,
77 michael 8431 * or they're an oper.
78 adx 30 */
79 michael 3109 sendto_one_numeric(source_p, &me, RPL_LINKS,
80     target_p->name, target_p->servptr->name,
81     target_p->hopcount, target_p->info);
82 adx 30 }
83 michael 3109
84     sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS,
85     EmptyString(mask) ? "*" : mask);
86 adx 30 }
87 michael 1148 else
88     {
89 adx 30 /*
90 michael 8431 * Print our own info so at least it looks like a normal links, then
91     * print out the file (which may or may not be empty).
92 adx 30 */
93 michael 3573 sendto_one_numeric(source_p, &me, RPL_LINKS, me.name, me.name, 0, me.info);
94 michael 2156
95 michael 4815 DLINK_FOREACH(node, flatten_links.head)
96 michael 5583 sendto_one_numeric(source_p, &me, RPL_LINKS | SND_EXPLICIT, "%s", node->data);
97 michael 3109 sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS, "*");
98 adx 30 }
99     }
100    
101 michael 2820 static int
102 michael 3156 mo_links(struct Client *source_p, int parc, char *parv[])
103 michael 1230 {
104     do_links(source_p, parc, parv);
105 michael 2820 return 0;
106 michael 1230 }
107    
108 michael 3299 /*! \brief LINKS command handler
109     *
110     * \param source_p Pointer to allocated Client struct from which the message
111     * originally comes from. This can be a local or remote client.
112     * \param parc Integer holding the number of supplied arguments.
113     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
114     * pointers.
115     * \note Valid arguments for this command are:
116     * - parv[0] = command
117     * - parv[1] = servername mask
118 adx 30 * or
119 michael 3299 * - parv[0] = command
120     * - parv[1] = server to query
121     * - parv[2] = servername mask
122 adx 30 */
123 michael 2820 static int
124 michael 3156 m_links(struct Client *source_p, int parc, char *parv[])
125 adx 30 {
126 michael 7330 static uintmax_t last_used = 0;
127 adx 269
128 michael 8903 if ((last_used + ConfigGeneral.pace_wait) > event_base->time.sec_monotonic)
129 adx 269 {
130 michael 4759 sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "LINKS");
131 michael 2820 return 0;
132 adx 269 }
133    
134 michael 8903 last_used = event_base->time.sec_monotonic;
135 michael 1121
136 michael 1144 do_links(source_p, parc, parv);
137 michael 2820 return 0;
138 adx 30 }
139    
140 michael 2820 static struct Message links_msgtab =
141     {
142 michael 5881 .cmd = "LINKS",
143     .args_max = MAXPARA,
144     .handlers[UNREGISTERED_HANDLER] = m_unregistered,
145     .handlers[CLIENT_HANDLER] = m_links,
146 michael 9019 .handlers[SERVER_HANDLER] = m_ignore,
147 michael 5881 .handlers[ENCAP_HANDLER] = m_ignore,
148     .handlers[OPER_HANDLER] = mo_links
149 michael 1230 };
150    
151     static void
152     module_init(void)
153     {
154     mod_add_cmd(&links_msgtab);
155     }
156    
157     static void
158     module_exit(void)
159     {
160     mod_del_cmd(&links_msgtab);
161     }
162    
163 michael 2820 struct module module_entry =
164     {
165 michael 1230 .version = "$Revision$",
166     .modinit = module_init,
167     .modexit = module_exit,
168     };

Properties

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