ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 5347
Committed: Sun Jan 11 12:42:20 2015 UTC (11 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 5793 byte(s)
Log Message:
- Update copyright years

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 5347 * Copyright (c) 1997-2015 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 4815 dlink_node *node = NULL;
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 1219 if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links)
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 4815 struct Client *target_p = node->data;
62 adx 30
63 michael 1489 /* 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 2820 * 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     * 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 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     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     if (parc > 2)
105 michael 2196 if (!ConfigServerHide.disable_remote_commands || HasUMode(source_p, UMODE_OPER))
106 michael 3156 if (hunt_server(source_p, ":%s LINKS %s :%s", 1,
107 michael 1230 parc, parv) != HUNTED_ISME)
108 michael 2820 return 0;
109 michael 1230
110     do_links(source_p, parc, parv);
111 michael 2820 return 0;
112 michael 1230 }
113    
114 michael 3299 /*! \brief LINKS command handler
115     *
116     * \param source_p Pointer to allocated Client struct from which the message
117     * originally comes from. This can be a local or remote client.
118     * \param parc Integer holding the number of supplied arguments.
119     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
120     * pointers.
121     * \note Valid arguments for this command are:
122     * - parv[0] = command
123     * - parv[1] = servername mask
124 adx 30 * or
125 michael 3299 * - parv[0] = command
126     * - parv[1] = server to query
127     * - parv[2] = servername mask
128 adx 30 */
129 michael 2820 static int
130 michael 3156 m_links(struct Client *source_p, int parc, char *parv[])
131 adx 30 {
132 adx 269 static time_t last_used = 0;
133    
134 michael 4340 if ((last_used + ConfigGeneral.pace_wait) > CurrentTime)
135 adx 269 {
136 michael 4759 sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "LINKS");
137 michael 2820 return 0;
138 adx 269 }
139    
140 michael 1121 last_used = CurrentTime;
141    
142 adx 30 if (!ConfigServerHide.flatten_links)
143 michael 3156 return mo_links(source_p, parc, parv);
144 adx 30
145 michael 1144 do_links(source_p, parc, parv);
146 michael 2820 return 0;
147 adx 30 }
148    
149 michael 3299 /*! \brief LINKS command handler
150     *
151     * \param source_p Pointer to allocated Client struct from which the message
152     * originally comes from. This can be a local or remote client.
153     * \param parc Integer holding the number of supplied arguments.
154     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
155     * pointers.
156     * \note Valid arguments for this command are:
157     * - parv[0] = command
158     * - parv[1] = servername mask
159 adx 30 * or
160 michael 3299 * - parv[0] = command
161     * - parv[1] = server to query
162     * - parv[2] = servername mask
163 adx 30 */
164 michael 2820 static int
165 michael 3156 ms_links(struct Client *source_p, int parc, char *parv[])
166 adx 30 {
167 michael 4690 if (hunt_server(source_p, ":%s LINKS %s :%s", 1, parc, parv) != HUNTED_ISME)
168 michael 2820 return 0;
169 adx 30
170 michael 3156 return m_links(source_p, parc, parv);
171 adx 30 }
172 michael 1230
173 michael 2820 static struct Message links_msgtab =
174     {
175 michael 4545 "LINKS", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
176 michael 2820 { m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore }
177 michael 1230 };
178    
179     static void
180     module_init(void)
181     {
182     mod_add_cmd(&links_msgtab);
183     }
184    
185     static void
186     module_exit(void)
187     {
188     mod_del_cmd(&links_msgtab);
189     }
190    
191 michael 2820 struct module module_entry =
192     {
193 michael 1230 .node = { NULL, NULL, NULL },
194     .name = NULL,
195     .version = "$Revision$",
196     .handle = NULL,
197     .modinit = module_init,
198     .modexit = module_exit,
199     .flags = 0
200     };

Properties

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