ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_links.c
Revision: 1309
Committed: Sun Mar 25 11:24:18 2012 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5259 byte(s)
Log Message:
- renaming files:

  ircd_parser.y -> conf_parser.y
  ircd_lexer.l  -> conf_lexer.l
  s_conf.c      -> conf.c
  s_conf.h      -> conf.h
  s_log.c       -> log.c
  s_log.h       -> log.h

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_links.c: Shows what servers are currently connected.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "client.h"
27 #include "irc_string.h"
28 #include "ircd.h"
29 #include "numeric.h"
30 #include "s_serv.h"
31 #include "send.h"
32 #include "conf.h"
33 #include "motd.h"
34 #include "parse.h"
35 #include "modules.h"
36
37
38 static void
39 do_links(struct Client *source_p, int parc, char *parv[])
40 {
41 sendto_realops_flags(UMODE_SPY, L_ALL,
42 "LINKS requested by %s (%s@%s) [%s]",
43 source_p->name,
44 source_p->username, source_p->host,
45 source_p->servptr->name);
46
47 if (HasUMode(source_p, UMODE_OPER) || !ConfigServerHide.flatten_links)
48 {
49 const char *mask = (parc > 2 ? parv[2] : parv[1]);
50 const char *me_name, *nick, *p;
51 struct Client *target_p;
52 dlink_node *ptr;
53
54 me_name = ID_or_name(&me, source_p->from);
55 nick = ID_or_name(source_p, source_p->from);
56
57 DLINK_FOREACH(ptr, global_serv_list.head)
58 {
59 target_p = ptr->data;
60
61 if (!EmptyString(mask) && !match(mask, target_p->name))
62 continue;
63
64 if (target_p->info[0])
65 {
66 if ((p = strchr(target_p->info, ']')))
67 p += 2; /* skip the nasty [IP] part */
68 else
69 p = target_p->info;
70 }
71 else
72 p = "(Unknown Location)";
73
74 /* We just send the reply, as if they are here there's either no SHIDE,
75 * or they're an oper..
76 */
77 sendto_one(source_p, form_str(RPL_LINKS),
78 me_name, nick,
79 target_p->name, target_p->servptr->name,
80 target_p->hopcount, p);
81 }
82
83 sendto_one(source_p, form_str(RPL_ENDOFLINKS),
84 me_name, nick,
85 EmptyString(mask) ? "*" : mask);
86 }
87 else
88 {
89 /*
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 sendto_one(source_p, form_str(RPL_LINKS),
94 ID_or_name(&me, source_p->from),
95 ID_or_name(source_p, source_p->from),
96 me.name, me.name, 0, me.info);
97 send_message_file(source_p, &ConfigFileEntry.linksfile);
98 sendto_one(source_p, form_str(RPL_ENDOFLINKS),
99 ID_or_name(&me, source_p->from),
100 ID_or_name(source_p, source_p->from), "*");
101 }
102 }
103
104 static void
105 mo_links(struct Client *client_p, struct Client *source_p,
106 int parc, char *parv[])
107 {
108 if (parc > 2)
109 if (!ConfigFileEntry.disable_remote || HasUMode(source_p, UMODE_OPER))
110 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
111 parc, parv) != HUNTED_ISME)
112 return;
113
114 do_links(source_p, parc, parv);
115 }
116
117 /*
118 * m_links - LINKS message handler
119 * parv[0] = sender prefix
120 * parv[1] = servername mask
121 * or
122 * parv[0] = sender prefix
123 * parv[1] = server to query
124 * parv[2] = servername mask
125 */
126 static void
127 m_links(struct Client *client_p, struct Client *source_p,
128 int parc, char *parv[])
129 {
130 static time_t last_used = 0;
131
132 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
133 {
134 sendto_one(source_p, form_str(RPL_LOAD2HI),
135 me.name, source_p->name);
136 return;
137 }
138
139 last_used = CurrentTime;
140
141 if (!ConfigServerHide.flatten_links)
142 {
143 mo_links(client_p, source_p, parc, parv);
144 return;
145 }
146
147 do_links(source_p, parc, parv);
148 }
149
150 /*
151 * ms_links - LINKS message handler
152 * parv[0] = sender prefix
153 * parv[1] = servername mask
154 * or
155 * parv[0] = sender prefix
156 * parv[1] = server to query
157 * parv[2] = servername mask
158 */
159 static void
160 ms_links(struct Client *client_p, struct Client *source_p,
161 int parc, char *parv[])
162 {
163 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
164 parc, parv) != HUNTED_ISME)
165 return;
166
167 if (IsClient(source_p))
168 m_links(client_p, source_p, parc, parv);
169 }
170
171 static struct Message links_msgtab = {
172 "LINKS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
173 {m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore}
174 };
175
176 static void
177 module_init(void)
178 {
179 mod_add_cmd(&links_msgtab);
180 }
181
182 static void
183 module_exit(void)
184 {
185 mod_del_cmd(&links_msgtab);
186 }
187
188 struct module module_entry = {
189 .node = { NULL, NULL, NULL },
190 .name = NULL,
191 .version = "$Revision$",
192 .handle = NULL,
193 .modinit = module_init,
194 .modexit = module_exit,
195 .flags = 0
196 };

Properties

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