ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_links.c
Revision: 3299
Committed: Sat Apr 12 16:55:13 2014 UTC (12 years, 3 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/modules/m_links.c
File size: 5753 byte(s)
Log Message:
- doxygen

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     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * 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     #include "s_serv.h"
33     #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 1144 static void
41     do_links(struct Client *source_p, int parc, char *parv[])
42 adx 30 {
43 michael 2156 dlink_node *ptr = NULL;
44    
45 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
46 michael 1144 "LINKS requested by %s (%s@%s) [%s]",
47     source_p->name,
48     source_p->username, source_p->host,
49     source_p->servptr->name);
50 adx 30
51 michael 1219 if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links)
52 adx 30 {
53 michael 1045 const char *mask = (parc > 2 ? parv[2] : parv[1]);
54 adx 30
55     DLINK_FOREACH(ptr, global_serv_list.head)
56     {
57 michael 1544 struct Client *target_p = ptr->data;
58 adx 30
59 michael 1489 /* skip hidden servers */
60 michael 1490 if (IsHidden(target_p))
61     if (!HasUMode(source_p, UMODE_OPER))
62 michael 1489 continue;
63    
64 michael 1851 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
65     if (!HasUMode(source_p, UMODE_OPER))
66     continue;
67    
68 michael 1652 if (!EmptyString(mask) && match(mask, target_p->name))
69 adx 30 continue;
70 michael 575
71 michael 1544 /*
72     * We just send the reply, as if they are here there's either no SHIDE,
73 michael 2820 * or they're an oper..
74 adx 30 */
75 michael 3109 sendto_one_numeric(source_p, &me, RPL_LINKS,
76     target_p->name, target_p->servptr->name,
77     target_p->hopcount, target_p->info);
78 adx 30 }
79 michael 3109
80     sendto_one_numeric(source_p, &me, RPL_ENDOFLINKS,
81     EmptyString(mask) ? "*" : mask);
82 adx 30 }
83 michael 1148 else
84     {
85 adx 30 /*
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 michael 3109 sendto_one_numeric(source_p, &me, RPL_LINKS,
90 adx 30 me.name, me.name, 0, me.info);
91 michael 2156
92     DLINK_FOREACH(ptr, flatten_links.head)
93     sendto_one(source_p, ":%s %d %s %s",
94 michael 2888 ID_or_name(&me, source_p), RPL_LINKS,
95     ID_or_name(source_p, source_p),
96 michael 2156 ptr->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     if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
135     {
136 michael 3109 sendto_one_numeric(source_p, &me, RPL_LOAD2HI);
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 3156 if (hunt_server(source_p, ":%s LINKS %s :%s", 1,
168 michael 1144 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 1230 "LINKS", 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