ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/core/m_squit.c
Revision: 1309
Committed: Sun Mar 25 11:24:18 2012 UTC (12 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/core/m_squit.c
File size: 4894 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_squit.c: Makes a server quit.
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 "list.h"
27 #include "client.h"
28 #include "hash.h"
29 #include "irc_string.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "conf.h"
33 #include "log.h"
34 #include "s_serv.h"
35 #include "send.h"
36 #include "parse.h"
37 #include "modules.h"
38
39
40 /* mo_squit - SQUIT message handler
41 * parv[0] = sender prefix
42 * parv[1] = server name
43 * parv[2] = comment
44 */
45 static void
46 mo_squit(struct Client *client_p, struct Client *source_p,
47 int parc, char *parv[])
48 {
49 struct Client *target_p = NULL;
50 struct Client *p;
51 dlink_node *ptr;
52 char *comment;
53 const char *server;
54 char def_reason[] = "No reason";
55
56 if (parc < 2 || EmptyString(parv[1]))
57 {
58 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
59 me.name, source_p->name, "SQUIT");
60 return;
61 }
62
63 server = parv[1];
64
65 /* The following allows wild cards in SQUIT. Only
66 * useful when the command is issued by an oper.
67 */
68 DLINK_FOREACH(ptr, global_serv_list.head)
69 {
70 p = ptr->data;
71
72 if (IsServer(p) || IsMe(p))
73 {
74 if (match(server, p->name))
75 {
76 target_p = p;
77 break;
78 }
79 }
80 }
81
82 if ((target_p == NULL) || IsMe(target_p))
83 {
84 sendto_one(source_p, form_str(ERR_NOSUCHSERVER),
85 me.name, source_p->name, server);
86 return;
87 }
88
89 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_REMOTE))
90 {
91 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
92 me.name, source_p->name);
93 return;
94 }
95
96 comment = (parc > 2 && parv[2]) ? parv[2] : def_reason;
97
98 if (strlen(comment) > (size_t)REASONLEN)
99 comment[REASONLEN] = '\0';
100
101 if (MyConnect(target_p))
102 {
103 sendto_realops_flags(UMODE_ALL, L_ALL, "Received SQUIT %s from %s (%s)",
104 target_p->name, get_client_name(source_p, HIDE_IP), comment);
105 ilog(LOG_TYPE_IRCD, "Received SQUIT %s from %s (%s)",
106 target_p->name, get_client_name(source_p, HIDE_IP), comment);
107 }
108
109 exit_client(target_p, source_p, comment);
110 }
111
112 /** NOTE: I removed wildcard lookups here, because a wildcarded
113 ** SQUIT should/can never happen in ms_squit. -Michael
114 **/
115
116 /* ms_squit - SQUIT message handler
117 * parv[0] = sender prefix
118 * parv[1] = server name
119 * parv[2] = comment
120 */
121 static void
122 ms_squit(struct Client *client_p, struct Client *source_p,
123 int parc, char *parv[])
124 {
125 struct Client *target_p = NULL;
126 char *comment;
127 const char *server;
128 char def_reason[] = "No reason";
129
130 if (parc < 2 || EmptyString(parv[1]))
131 return;
132
133 server = parv[1];
134
135 if ((target_p = hash_find_server(server)) == NULL)
136 return;
137
138 if (!IsServer(target_p) || IsMe(target_p))
139 return;
140
141 comment = (parc > 2 && parv[2]) ? parv[2] : def_reason;
142
143 if (strlen(comment) > (size_t)REASONLEN)
144 comment[REASONLEN] = '\0';
145
146 if (MyConnect(target_p))
147 {
148 sendto_wallops_flags(UMODE_WALLOP, &me, "Remote SQUIT %s from %s (%s)",
149 target_p->name, source_p->name, comment);
150 sendto_server(NULL, NULL, CAP_TS6, NOCAPS,
151 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
152 me.id, target_p->name, source_p->name, comment);
153 sendto_server(NULL, NULL, NOCAPS, CAP_TS6,
154 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
155 me.name, target_p->name, source_p->name, comment);
156 ilog(LOG_TYPE_IRCD, "SQUIT From %s : %s (%s)", source_p->name,
157 target_p->name, comment);
158
159 }
160
161 exit_client(target_p, source_p, comment);
162 }
163
164 static struct Message squit_msgtab = {
165 "SQUIT", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
166 {m_unregistered, m_not_oper, ms_squit, m_ignore, mo_squit, m_ignore}
167 };
168
169 static void
170 module_init(void)
171 {
172 mod_add_cmd(&squit_msgtab);
173 }
174
175 static void
176 module_exit(void)
177 {
178 mod_del_cmd(&squit_msgtab);
179 }
180
181 struct module module_entry = {
182 .node = { NULL, NULL, NULL },
183 .name = NULL,
184 .version = "$Revision$",
185 .handle = NULL,
186 .modinit = module_init,
187 .modexit = module_exit,
188 .flags = MODULE_FLAG_CORE
189 };

Properties

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