ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.1.12/modules/core/m_squit.c
Revision: 1592
Committed: Sat Oct 27 21:02:32 2012 UTC (13 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid/trunk/modules/core/m_squit.c
File size: 4816 byte(s)
Log Message:
- Second time's the charm? Moving svnroot/ircd-hybrid-8 to
  svnroot/ircd-hybrid/trunk

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "client.h"
28     #include "hash.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32 michael 1309 #include "conf.h"
33     #include "log.h"
34 adx 30 #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 michael 1219 if (!MyConnect(target_p) && !HasOFlag(source_p, OPER_FLAG_REMOTE))
90 adx 30 {
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 michael 1247 ilog(LOG_TYPE_IRCD, "Received SQUIT %s from %s (%s)",
106 adx 30 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 michael 1572 const char *comment = NULL;
127 adx 30
128 michael 1572 if (parc < 2 || EmptyString(parv[parc - 1]))
129 adx 30 return;
130    
131 michael 1572 if ((target_p = hash_find_server(parv[1])) == NULL)
132 adx 30 return;
133    
134 michael 1572 if (!IsServer(target_p) && !IsMe(target_p))
135 adx 30 return;
136    
137 michael 1572 if (IsMe(target_p))
138     target_p = client_p;
139 adx 30
140 michael 1572 comment = (parc > 2 && parv[parc - 1]) ? parv[parc - 1] : client_p->name;
141 adx 30
142     if (MyConnect(target_p))
143     {
144     sendto_wallops_flags(UMODE_WALLOP, &me, "Remote SQUIT %s from %s (%s)",
145     target_p->name, source_p->name, comment);
146 michael 1474 sendto_server(NULL, CAP_TS6, NOCAPS,
147 adx 30 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
148     me.id, target_p->name, source_p->name, comment);
149 michael 1474 sendto_server(NULL, NOCAPS, CAP_TS6,
150 adx 30 ":%s WALLOPS :Remote SQUIT %s from %s (%s)",
151     me.name, target_p->name, source_p->name, comment);
152 michael 1247 ilog(LOG_TYPE_IRCD, "SQUIT From %s : %s (%s)", source_p->name,
153 adx 30 target_p->name, comment);
154     }
155    
156     exit_client(target_p, source_p, comment);
157     }
158 michael 1230
159     static struct Message squit_msgtab = {
160     "SQUIT", 0, 0, 1, MAXPARA, MFLG_SLOW, 0,
161     {m_unregistered, m_not_oper, ms_squit, m_ignore, mo_squit, m_ignore}
162     };
163    
164     static void
165     module_init(void)
166     {
167     mod_add_cmd(&squit_msgtab);
168     }
169    
170     static void
171     module_exit(void)
172     {
173     mod_del_cmd(&squit_msgtab);
174     }
175    
176     struct module module_entry = {
177     .node = { NULL, NULL, NULL },
178     .name = NULL,
179     .version = "$Revision$",
180     .handle = NULL,
181     .modinit = module_init,
182     .modexit = module_exit,
183     .flags = MODULE_FLAG_CORE
184     };

Properties

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