ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/contrib/m_killhost.c
Revision: 812
Committed: Thu Sep 7 09:41:54 2006 UTC (17 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 5314 byte(s)
Log Message:
- Imported contrib/

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

Properties

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