ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_links.c
Revision: 1144
Committed: Tue Jul 26 19:33:54 2011 UTC (14 years, 1 month ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_links.c
File size: 5231 byte(s)
Log Message:
Added back STATS/TRACE/MOTD/ADMIN request notices. Removed
   spy_*_notice modules accordingly.


File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "client.h"
28     #include "irc_string.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "s_conf.h"
34     #include "msg.h"
35     #include "motd.h"
36     #include "parse.h"
37     #include "modules.h"
38    
39 michael 1144 static void do_links(struct Client *, int, char *[]);
40 michael 1121 static void m_links(struct Client *, struct Client *, int, char *[]);
41     static void mo_links(struct Client *, struct Client *, int, char *[]);
42     static void ms_links(struct Client *, struct Client *, int, char *[]);
43 adx 30
44     struct Message links_msgtab = {
45     "LINKS", 0, 0, 0, 0, MFLG_SLOW, 0,
46     {m_unregistered, m_links, ms_links, m_ignore, mo_links, m_ignore}
47     };
48    
49 knight 31 const char *_version = "$Revision$";
50 adx 30
51    
52 michael 1144 static void
53     do_links(struct Client *source_p, int parc, char *parv[])
54 adx 30 {
55 michael 1144 sendto_realops_flags(UMODE_SPY, L_ALL,
56     "LINKS requested by %s (%s@%s) [%s]",
57     source_p->name,
58     source_p->username, source_p->host,
59     source_p->servptr->name);
60 adx 30
61     if (IsOper(source_p) || !ConfigServerHide.flatten_links)
62     {
63 michael 1045 const char *mask = (parc > 2 ? parv[2] : parv[1]);
64 adx 30 const char *me_name, *nick, *p;
65     struct Client *target_p;
66     dlink_node *ptr;
67    
68     me_name = ID_or_name(&me, source_p->from);
69     nick = ID_or_name(source_p, source_p->from);
70    
71     DLINK_FOREACH(ptr, global_serv_list.head)
72     {
73     target_p = ptr->data;
74    
75 michael 575 if (!EmptyString(mask) && !match(mask, target_p->name))
76 adx 30 continue;
77 michael 575
78 adx 30 if (target_p->info[0])
79     {
80     if ((p = strchr(target_p->info, ']')))
81     p += 2; /* skip the nasty [IP] part */
82     else
83     p = target_p->info;
84     }
85     else
86     p = "(Unknown Location)";
87    
88     /* We just send the reply, as if they are here there's either no SHIDE,
89     * or they're an oper..
90     */
91     sendto_one(source_p, form_str(RPL_LINKS),
92     me_name, nick,
93     target_p->name, target_p->servptr->name,
94     target_p->hopcount, p);
95     }
96    
97     sendto_one(source_p, form_str(RPL_ENDOFLINKS),
98     me_name, nick,
99     EmptyString(mask) ? "*" : mask);
100     }
101     else {
102     /*
103     * Print our own info so at least it looks like a normal links
104     * then print out the file (which may or may not be empty)
105     */
106     sendto_one(source_p, form_str(RPL_LINKS),
107     ID_or_name(&me, source_p->from),
108     ID_or_name(source_p, source_p->from),
109     me.name, me.name, 0, me.info);
110     send_message_file(source_p, &ConfigFileEntry.linksfile);
111     sendto_one(source_p, form_str(RPL_ENDOFLINKS),
112 adx 103 ID_or_name(&me, source_p->from),
113     ID_or_name(source_p, source_p->from), "*");
114 adx 30 }
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 adx 269 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 michael 1121 last_used = CurrentTime;
140    
141 adx 30 if (!ConfigServerHide.flatten_links)
142     {
143     mo_links(client_p, source_p, parc, parv);
144     return;
145     }
146    
147 michael 1144 do_links(source_p, parc, parv);
148 adx 30 }
149    
150     static void
151     mo_links(struct Client *client_p, struct Client *source_p,
152     int parc, char *parv[])
153     {
154     if (parc > 2)
155     if (!ConfigFileEntry.disable_remote || IsOper(source_p))
156 michael 1144 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
157     parc, parv) != HUNTED_ISME)
158 adx 30 return;
159    
160 michael 1144 do_links(source_p, parc, parv);
161 adx 30 }
162    
163     /*
164     * ms_links - LINKS message handler
165     * parv[0] = sender prefix
166     * parv[1] = servername mask
167     * or
168     * parv[0] = sender prefix
169     * parv[1] = server to query
170     * parv[2] = servername mask
171     */
172     static void
173     ms_links(struct Client *client_p, struct Client *source_p,
174     int parc, char *parv[])
175     {
176 michael 1144 if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1,
177     parc, parv) != HUNTED_ISME)
178 adx 30 return;
179    
180     if (IsClient(source_p))
181     m_links(client_p, source_p, parc, parv);
182     }

Properties

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