ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_killhost.c
Revision: 1155
Committed: Tue Aug 9 20:27:45 2011 UTC (14 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 5373 byte(s)
Log Message:
- recreate "trunk"

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_killhost.c: Kills a users with agree host.
4 *
5 * Copyright (C) 2002 by Ilya Shtift.
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
26 #include "stdinc.h"
27 #include "handlers.h"
28 #include "client.h"
29 #include "common.h"
30 #include "hash.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "s_log.h"
34 #include "s_serv.h"
35 #include "s_conf.h"
36 #include "send.h"
37 #include "whowas.h"
38 #include "irc_string.h"
39 #include "sprintf_irc.h"
40 #include "msg.h"
41 #include "parse.h"
42 #include "channel_mode.h" /* needed only for split_nuh() */
43 #include "modules.h"
44
45 static void mo_killhost(struct Client *, struct Client *, int, char *[]);
46 static void kh_relay_kill(struct Client *, struct Client *, struct Client *,
47 const char *, const char *);
48
49 struct Message killhost_msgtab = {
50 "KILLHOST", 0, 0, 2, 0, MFLG_SLOW, 0,
51 { m_unregistered, m_ignore, m_ignore, m_ignore, mo_killhost, m_ignore }
52 };
53
54 void
55 _modinit(void)
56 {
57 mod_add_cmd(&killhost_msgtab);
58 }
59
60 void
61 _moddeinit(void)
62 {
63 mod_del_cmd(&killhost_msgtab);
64 }
65
66 const char *_version = "$Revision$";
67
68 /* mo_killhost()
69 * Created May 5, 2003
70 * common (Ilya Shtift) ishtift@tagil.svrw.ru
71 *
72 * parv[0] = sender prefix
73 * parv[1] = host
74 * parv[2] = reason
75 */
76 static void
77 mo_killhost(struct Client *client_p, struct Client *source_p,
78 int parc, char *parv[])
79 {
80 dlink_node *ptr = NULL, *ptr_next = NULL;
81 struct Client *target_p = NULL;
82 const char *inpath = client_p->name;
83 char *reason = NULL;
84 char bufhost[IRCD_BUFSIZE];
85 char nick[NICKLEN + 1];
86 char user[USERLEN + 1];
87 char host[HOSTLEN + 1];
88 char def_reason[] = "No reason";
89 unsigned int count = 0;
90 struct split_nuh_item nuh;
91
92 if (!(IsOperK(source_p) || IsOperGlobalKill(source_p)))
93 {
94 sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
95 me.name, source_p->name);
96 return;
97 }
98
99 nuh.nuhmask = parv[1];
100 nuh.nickptr = nick;
101 nuh.userptr = user;
102 nuh.hostptr = host;
103
104 nuh.nicksize = sizeof(nick);
105 nuh.usersize = sizeof(user);
106 nuh.hostsize = sizeof(host);
107
108 split_nuh(&nuh);
109
110 if (!valid_wild_card(source_p, YES, 3, nick, user, host))
111 return;
112
113 if (!EmptyString(parv[2]))
114 {
115 reason = parv[2];
116 if (strlen(reason) > (size_t)KILLLEN)
117 reason[KILLLEN] = '\0';
118 }
119 else
120 reason = def_reason;
121
122 DLINK_FOREACH_SAFE(ptr, ptr_next, global_client_list.head)
123 {
124 target_p = ptr->data;
125
126 if (!IsClient(target_p) || (source_p == target_p))
127 continue;
128
129 if (!MyConnect(target_p) && !IsOperGlobalKill(source_p))
130 continue;
131
132 if (match(nick, target_p->name) &&
133 match(user, target_p->username) &&
134 match(host, target_p->host))
135 {
136 if (MyConnect(target_p))
137 sendto_one(target_p, ":%s!%s@%s KILL %s :%s",
138 source_p->name, source_p->username, source_p->host,
139 target_p->name, reason);
140
141 sendto_realops_flags(UMODE_ALL, L_ALL,
142 "Received KILL message for %s. From %s Path: %s (%s)",
143 target_p->name, source_p->name, me.name, reason);
144
145 ilog(L_INFO,"KILL From %s For %s Path %s (%s)",
146 source_p->name, target_p->name, me.name, reason);
147
148 if (!MyConnect(target_p))
149 {
150 kh_relay_kill(client_p, source_p, target_p, inpath, reason);
151 SetKilled(target_p);
152 }
153
154 if (!count++)
155 ircsprintf(bufhost, "Killed (%s (%s))", source_p->name, reason);
156
157 exit_client(target_p, source_p, bufhost);
158 }
159 }
160
161 if (count > 0)
162 sendto_wallops_flags(UMODE_OPERWALL, source_p, "OPERWALL - KILLHOST %s %s",
163 host, reason);
164
165 sendto_one(source_p,":%s NOTICE %s :%u clients killed",
166 me.name, source_p->name, count);
167 }
168
169 static void
170 kh_relay_kill(struct Client *one, struct Client *source_p, struct Client *target_p,
171 const char *inpath, const char *reason)
172 {
173 dlink_node *ptr;
174 struct Client *client_p;
175 char *user;
176
177 DLINK_FOREACH(ptr, serv_list.head)
178 {
179 client_p = ptr->data;
180
181 if (client_p == one)
182 continue;
183
184 /* check the server supports TS6 */
185 if (IsCapable(client_p, CAP_TS6))
186 user = ID(target_p);
187 else
188 user = target_p->name;
189
190 if (MyClient(source_p))
191 {
192 sendto_one(client_p, ":%s KILL %s :%s!%s!%s!%s (%s)",
193 source_p->name, user,
194 me.name, source_p->host, source_p->username,
195 source_p->name, reason);
196 }
197 else
198 {
199 sendto_one(client_p, ":%s KILL %s :%s %s",
200 source_p->name, user,
201 inpath, reason);
202 }
203 }
204 }

Properties

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