| 1 |
adx |
30 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
| 3 |
|
|
* m_kline.c: Bans a user. |
| 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 "channel.h" |
| 28 |
|
|
#include "client.h" |
| 29 |
|
|
#include "irc_string.h" |
| 30 |
|
|
#include "sprintf_irc.h" |
| 31 |
|
|
#include "ircd.h" |
| 32 |
michael |
1632 |
#include "conf.h" |
| 33 |
adx |
30 |
#include "hostmask.h" |
| 34 |
|
|
#include "numeric.h" |
| 35 |
|
|
#include "fdlist.h" |
| 36 |
|
|
#include "s_bsd.h" |
| 37 |
michael |
1309 |
#include "log.h" |
| 38 |
adx |
30 |
#include "s_misc.h" |
| 39 |
|
|
#include "send.h" |
| 40 |
|
|
#include "hash.h" |
| 41 |
|
|
#include "s_serv.h" |
| 42 |
|
|
#include "s_gline.h" |
| 43 |
|
|
#include "parse.h" |
| 44 |
|
|
#include "modules.h" |
| 45 |
michael |
1622 |
#include "conf_db.h" |
| 46 |
michael |
1666 |
#include "memory.h" |
| 47 |
adx |
30 |
|
| 48 |
michael |
1058 |
static int already_placed_kline(struct Client *, const char *, const char *, int); |
| 49 |
michael |
1632 |
static void m_kline_add_kline(struct Client *, struct MaskItem *, time_t); |
| 50 |
michael |
1058 |
|
| 51 |
|
|
static char buffer[IRCD_BUFSIZE]; |
| 52 |
michael |
1622 |
static int remove_kline_match(const char *, const char *); |
| 53 |
adx |
30 |
|
| 54 |
|
|
|
| 55 |
|
|
/* mo_kline() |
| 56 |
|
|
* |
| 57 |
|
|
* inputs - pointer to server |
| 58 |
|
|
* - pointer to client |
| 59 |
|
|
* - parameter count |
| 60 |
|
|
* - parameter list |
| 61 |
|
|
* output - |
| 62 |
|
|
* side effects - k line is added |
| 63 |
|
|
*/ |
| 64 |
|
|
static void |
| 65 |
|
|
mo_kline(struct Client *client_p, struct Client *source_p, |
| 66 |
michael |
1298 |
int parc, char *parv[]) |
| 67 |
adx |
30 |
{ |
| 68 |
|
|
char *reason = NULL; |
| 69 |
|
|
char *user = NULL; |
| 70 |
|
|
char *host = NULL; |
| 71 |
|
|
const char *current_date; |
| 72 |
|
|
char *target_server = NULL; |
| 73 |
michael |
1632 |
struct MaskItem *conf; |
| 74 |
adx |
30 |
time_t tkline_time = 0; |
| 75 |
|
|
time_t cur_time; |
| 76 |
|
|
|
| 77 |
michael |
1219 |
if (!HasOFlag(source_p, OPER_FLAG_K)) |
| 78 |
adx |
30 |
{ |
| 79 |
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 80 |
|
|
me.name, source_p->name, "kline"); |
| 81 |
|
|
return; |
| 82 |
|
|
} |
| 83 |
|
|
|
| 84 |
|
|
if (parse_aline("KLINE", source_p, parc, parv, |
| 85 |
|
|
AWILD, &user, &host, &tkline_time, &target_server, &reason) < 0) |
| 86 |
|
|
return; |
| 87 |
|
|
|
| 88 |
|
|
if (target_server != NULL) |
| 89 |
|
|
{ |
| 90 |
|
|
if (HasID(source_p)) |
| 91 |
|
|
{ |
| 92 |
michael |
1474 |
sendto_server(NULL, CAP_KLN|CAP_TS6, NOCAPS, |
| 93 |
adx |
30 |
":%s KLINE %s %lu %s %s :%s", |
| 94 |
|
|
source_p->id, target_server, (unsigned long)tkline_time, |
| 95 |
|
|
user, host, reason); |
| 96 |
michael |
1474 |
sendto_server(NULL, CAP_KLN, CAP_TS6, |
| 97 |
adx |
30 |
":%s KLINE %s %lu %s %s :%s", |
| 98 |
|
|
source_p->name, target_server, (unsigned long)tkline_time, |
| 99 |
|
|
user, host, reason); |
| 100 |
|
|
} |
| 101 |
|
|
else |
| 102 |
michael |
1474 |
sendto_server(NULL, CAP_KLN, NOCAPS, |
| 103 |
adx |
30 |
":%s KLINE %s %lu %s %s :%s", |
| 104 |
|
|
source_p->name, target_server, (unsigned long)tkline_time, |
| 105 |
|
|
user, host, reason); |
| 106 |
|
|
|
| 107 |
|
|
/* Allow ON to apply local kline as well if it matches */ |
| 108 |
michael |
1652 |
if (match(target_server, me.name)) |
| 109 |
adx |
30 |
return; |
| 110 |
|
|
} |
| 111 |
|
|
else |
| 112 |
|
|
cluster_a_line(source_p, "KLINE", CAP_KLN, SHARED_KLINE, |
| 113 |
michael |
1058 |
"%d %s %s :%s", tkline_time, user, host, reason); |
| 114 |
adx |
30 |
|
| 115 |
michael |
1243 |
if (already_placed_kline(source_p, user, host, 1)) |
| 116 |
adx |
30 |
return; |
| 117 |
|
|
|
| 118 |
|
|
cur_time = CurrentTime; |
| 119 |
|
|
current_date = smalldate(cur_time); |
| 120 |
michael |
1632 |
conf = conf_make(CONF_KLINE); |
| 121 |
adx |
30 |
|
| 122 |
michael |
1646 |
conf->host = xstrdup(host); |
| 123 |
|
|
conf->user = xstrdup(user); |
| 124 |
adx |
30 |
|
| 125 |
|
|
if (tkline_time != 0) |
| 126 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", |
| 127 |
|
|
(int)(tkline_time/60), reason, current_date); |
| 128 |
adx |
30 |
else |
| 129 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date); |
| 130 |
adx |
30 |
|
| 131 |
michael |
1646 |
conf->reason = xstrdup(buffer); |
| 132 |
michael |
1632 |
m_kline_add_kline(source_p, conf, tkline_time); |
| 133 |
adx |
30 |
} |
| 134 |
|
|
|
| 135 |
|
|
/* me_kline - handle remote kline. no propagation */ |
| 136 |
|
|
static void |
| 137 |
|
|
me_kline(struct Client *client_p, struct Client *source_p, |
| 138 |
|
|
int parc, char *parv[]) |
| 139 |
|
|
{ |
| 140 |
michael |
1632 |
struct MaskItem *conf = NULL; |
| 141 |
michael |
1628 |
int tkline_time = 0; |
| 142 |
adx |
30 |
const char* current_date; |
| 143 |
|
|
time_t cur_time; |
| 144 |
michael |
1622 |
char *kuser, *khost, *kreason; |
| 145 |
adx |
30 |
|
| 146 |
michael |
352 |
if (parc != 6 || EmptyString(parv[5])) |
| 147 |
adx |
30 |
return; |
| 148 |
|
|
|
| 149 |
michael |
1652 |
if (match(parv[1], me.name)) |
| 150 |
adx |
30 |
return; |
| 151 |
|
|
|
| 152 |
|
|
tkline_time = valid_tkline(parv[2], TK_SECONDS); |
| 153 |
|
|
kuser = parv[3]; |
| 154 |
|
|
khost = parv[4]; |
| 155 |
|
|
kreason = parv[5]; |
| 156 |
|
|
|
| 157 |
|
|
cur_time = CurrentTime; |
| 158 |
|
|
current_date = smalldate(cur_time); |
| 159 |
|
|
|
| 160 |
michael |
1632 |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
| 161 |
adx |
30 |
source_p->username, source_p->host, |
| 162 |
|
|
SHARED_KLINE)) |
| 163 |
|
|
{ |
| 164 |
|
|
if (!IsClient(source_p) || |
| 165 |
michael |
1243 |
already_placed_kline(source_p, kuser, khost, 1)) |
| 166 |
adx |
30 |
return; |
| 167 |
|
|
|
| 168 |
michael |
1632 |
conf = conf_make(CONF_KLINE); |
| 169 |
michael |
1646 |
conf->host = xstrdup(khost); |
| 170 |
|
|
conf->user = xstrdup(kuser); |
| 171 |
adx |
30 |
|
| 172 |
|
|
if (tkline_time != 0) |
| 173 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)", |
| 174 |
|
|
(int)(tkline_time/60), kreason, current_date); |
| 175 |
adx |
30 |
else |
| 176 |
michael |
1233 |
snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date); |
| 177 |
adx |
30 |
|
| 178 |
michael |
1646 |
conf->reason = xstrdup(buffer); |
| 179 |
michael |
1632 |
m_kline_add_kline(source_p, conf, tkline_time); |
| 180 |
adx |
30 |
} |
| 181 |
|
|
} |
| 182 |
|
|
|
| 183 |
|
|
static void |
| 184 |
|
|
ms_kline(struct Client *client_p, struct Client *source_p, |
| 185 |
michael |
1058 |
int parc, char *parv[]) |
| 186 |
adx |
30 |
{ |
| 187 |
michael |
352 |
if (parc != 6 || EmptyString(parv[5])) |
| 188 |
adx |
30 |
return; |
| 189 |
|
|
|
| 190 |
|
|
/* parv[0] parv[1] parv[2] parv[3] parv[4] parv[5] */ |
| 191 |
|
|
/* oper target_server tkline_time user host reason */ |
| 192 |
|
|
sendto_match_servs(source_p, parv[1], CAP_KLN, |
| 193 |
|
|
"KLINE %s %s %s %s :%s", |
| 194 |
|
|
parv[1], parv[2], parv[3], parv[4], parv[5]); |
| 195 |
|
|
|
| 196 |
|
|
me_kline(client_p, source_p, parc, parv); |
| 197 |
|
|
} |
| 198 |
|
|
|
| 199 |
|
|
/* apply_tkline() |
| 200 |
|
|
* |
| 201 |
|
|
* inputs - |
| 202 |
|
|
* output - NONE |
| 203 |
|
|
* side effects - tkline as given is placed |
| 204 |
|
|
*/ |
| 205 |
|
|
static void |
| 206 |
michael |
1632 |
m_kline_add_kline(struct Client *source_p, struct MaskItem *conf, |
| 207 |
michael |
1622 |
time_t tkline_time) |
| 208 |
adx |
30 |
{ |
| 209 |
michael |
1622 |
if (tkline_time) |
| 210 |
|
|
{ |
| 211 |
michael |
1649 |
conf->until = CurrentTime + tkline_time; |
| 212 |
michael |
1622 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 213 |
|
|
"%s added temporary %d min. K-Line for [%s@%s] [%s]", |
| 214 |
|
|
get_oper_name(source_p), tkline_time/60, |
| 215 |
michael |
1632 |
conf->user, conf->host, |
| 216 |
|
|
conf->reason); |
| 217 |
michael |
1622 |
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]", |
| 218 |
michael |
1632 |
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
| 219 |
|
|
source_p->name, tkline_time/60, conf->user, conf->host); |
| 220 |
michael |
1622 |
ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]", |
| 221 |
|
|
source_p->name, tkline_time/60, |
| 222 |
michael |
1632 |
conf->user, conf->host, conf->reason); |
| 223 |
michael |
1622 |
} |
| 224 |
|
|
else |
| 225 |
|
|
{ |
| 226 |
|
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 227 |
|
|
"%s added K-Line for [%s@%s] [%s]", |
| 228 |
|
|
get_oper_name(source_p), |
| 229 |
michael |
1632 |
conf->user, conf->host, conf->reason); |
| 230 |
michael |
1622 |
sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]", |
| 231 |
|
|
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from), |
| 232 |
michael |
1632 |
source_p->name, conf->user, conf->host); |
| 233 |
michael |
1622 |
ilog(LOG_TYPE_KLINE, "%s added K-Line for [%s@%s] [%s]", |
| 234 |
michael |
1632 |
source_p->name, conf->user, conf->host, conf->reason); |
| 235 |
michael |
1622 |
} |
| 236 |
michael |
1247 |
|
| 237 |
michael |
1632 |
conf->setat = CurrentTime; |
| 238 |
|
|
SetConfDatabase(conf); |
| 239 |
michael |
1628 |
|
| 240 |
michael |
1632 |
add_conf_by_address(CONF_KLINE, conf); |
| 241 |
adx |
30 |
rehashed_klines = 1; |
| 242 |
|
|
} |
| 243 |
|
|
|
| 244 |
|
|
/* already_placed_kline() |
| 245 |
|
|
* inputs - user to complain to, username & host to check for |
| 246 |
|
|
* outputs - returns 1 on existing K-line, 0 if doesn't exist |
| 247 |
|
|
* side effects - notifies source_p if the K-line already exists |
| 248 |
|
|
*/ |
| 249 |
|
|
/* |
| 250 |
|
|
* Note: This currently works if the new K-line is a special case of an |
| 251 |
|
|
* existing K-line, but not the other way round. To do that we would |
| 252 |
|
|
* have to walk the hash and check every existing K-line. -A1kmm. |
| 253 |
|
|
*/ |
| 254 |
|
|
static int |
| 255 |
|
|
already_placed_kline(struct Client *source_p, const char *luser, const char *lhost, int warn) |
| 256 |
|
|
{ |
| 257 |
|
|
const char *reason; |
| 258 |
|
|
struct irc_ssaddr iphost, *piphost; |
| 259 |
michael |
1632 |
struct MaskItem *conf = NULL; |
| 260 |
michael |
1644 |
int t = 0; |
| 261 |
|
|
int aftype = 0; |
| 262 |
adx |
30 |
|
| 263 |
michael |
1644 |
if ((t = parse_netmask(lhost, &iphost, NULL)) != HM_HOST) |
| 264 |
adx |
30 |
{ |
| 265 |
|
|
#ifdef IPV6 |
| 266 |
|
|
if (t == HM_IPV6) |
| 267 |
michael |
1644 |
aftype = AF_INET6; |
| 268 |
adx |
30 |
else |
| 269 |
|
|
#endif |
| 270 |
michael |
1644 |
aftype = AF_INET; |
| 271 |
adx |
30 |
piphost = &iphost; |
| 272 |
|
|
} |
| 273 |
|
|
else |
| 274 |
|
|
piphost = NULL; |
| 275 |
|
|
|
| 276 |
michael |
1644 |
if ((conf = find_conf_by_address(lhost, piphost, CONF_KLINE, aftype, luser, NULL, 0))) |
| 277 |
adx |
30 |
{ |
| 278 |
|
|
if (warn) |
| 279 |
|
|
{ |
| 280 |
michael |
1632 |
reason = conf->reason ? conf->reason : "No reason"; |
| 281 |
adx |
30 |
sendto_one(source_p, |
| 282 |
|
|
":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s", |
| 283 |
michael |
1632 |
me.name, source_p->name, luser, lhost, conf->user, |
| 284 |
|
|
conf->host, reason); |
| 285 |
adx |
30 |
} |
| 286 |
michael |
1298 |
|
| 287 |
|
|
return 1; |
| 288 |
adx |
30 |
} |
| 289 |
|
|
|
| 290 |
michael |
1298 |
return 0; |
| 291 |
adx |
30 |
} |
| 292 |
|
|
|
| 293 |
|
|
/* |
| 294 |
|
|
** mo_unkline |
| 295 |
|
|
** Added Aug 31, 1997 |
| 296 |
|
|
** common (Keith Fralick) fralick@gate.net |
| 297 |
|
|
** |
| 298 |
|
|
** parv[0] = sender |
| 299 |
|
|
** parv[1] = address to remove |
| 300 |
|
|
* |
| 301 |
|
|
* |
| 302 |
|
|
*/ |
| 303 |
|
|
static void |
| 304 |
|
|
mo_unkline(struct Client *client_p,struct Client *source_p, |
| 305 |
|
|
int parc, char *parv[]) |
| 306 |
|
|
{ |
| 307 |
|
|
char *target_server = NULL; |
| 308 |
|
|
char *user, *host; |
| 309 |
|
|
|
| 310 |
michael |
1219 |
if (!HasOFlag(source_p, OPER_FLAG_UNKLINE)) |
| 311 |
adx |
30 |
{ |
| 312 |
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), |
| 313 |
|
|
me.name, source_p->name, "unkline"); |
| 314 |
|
|
return; |
| 315 |
|
|
} |
| 316 |
|
|
|
| 317 |
michael |
1622 |
if (EmptyString(parv[1])) |
| 318 |
adx |
30 |
{ |
| 319 |
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), |
| 320 |
|
|
me.name, source_p->name, "UNKLINE"); |
| 321 |
|
|
return; |
| 322 |
|
|
} |
| 323 |
|
|
|
| 324 |
|
|
if (parse_aline("UNKLINE", source_p, parc, parv, 0, &user, |
| 325 |
|
|
&host, NULL, &target_server, NULL) < 0) |
| 326 |
|
|
return; |
| 327 |
|
|
|
| 328 |
|
|
if (target_server != NULL) |
| 329 |
|
|
{ |
| 330 |
|
|
sendto_match_servs(source_p, target_server, CAP_UNKLN, |
| 331 |
|
|
"UNKLINE %s %s %s", |
| 332 |
|
|
target_server, user, host); |
| 333 |
|
|
|
| 334 |
|
|
/* Allow ON to apply local unkline as well if it matches */ |
| 335 |
michael |
1652 |
if (match(target_server, me.name)) |
| 336 |
adx |
30 |
return; |
| 337 |
|
|
} |
| 338 |
|
|
else |
| 339 |
|
|
cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE, |
| 340 |
michael |
1058 |
"%s %s", user, host); |
| 341 |
adx |
30 |
|
| 342 |
michael |
1622 |
if (remove_kline_match(host, user)) |
| 343 |
adx |
30 |
{ |
| 344 |
|
|
sendto_one(source_p, |
| 345 |
michael |
1622 |
":%s NOTICE %s :K-Line for [%s@%s] is removed", |
| 346 |
adx |
30 |
me.name, source_p->name, user, host); |
| 347 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 348 |
michael |
1058 |
"%s has removed the K-Line for: [%s@%s]", |
| 349 |
|
|
get_oper_name(source_p), user, host); |
| 350 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]", |
| 351 |
michael |
1058 |
source_p->name, user, host); |
| 352 |
adx |
30 |
} |
| 353 |
|
|
else |
| 354 |
|
|
sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found", |
| 355 |
|
|
me.name, source_p->name, user, host); |
| 356 |
|
|
} |
| 357 |
|
|
|
| 358 |
|
|
/* me_unkline() |
| 359 |
|
|
* |
| 360 |
|
|
* inputs - server |
| 361 |
|
|
* - client |
| 362 |
|
|
* - parc |
| 363 |
|
|
* - parv |
| 364 |
|
|
* outputs - none |
| 365 |
|
|
* side effects - if server is authorized, kline is removed |
| 366 |
|
|
* does not propagate message |
| 367 |
|
|
*/ |
| 368 |
|
|
static void |
| 369 |
|
|
me_unkline(struct Client *client_p, struct Client *source_p, |
| 370 |
|
|
int parc, char *parv[]) |
| 371 |
|
|
{ |
| 372 |
|
|
const char *kuser, *khost; |
| 373 |
|
|
|
| 374 |
|
|
if (parc != 4) |
| 375 |
|
|
return; |
| 376 |
|
|
|
| 377 |
|
|
kuser = parv[2]; |
| 378 |
|
|
khost = parv[3]; |
| 379 |
|
|
|
| 380 |
michael |
1652 |
if (!IsClient(source_p) || match(parv[1], me.name)) |
| 381 |
adx |
30 |
return; |
| 382 |
|
|
|
| 383 |
michael |
1632 |
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, |
| 384 |
adx |
30 |
source_p->servptr->name, |
| 385 |
|
|
source_p->username, source_p->host, |
| 386 |
|
|
SHARED_UNKLINE)) |
| 387 |
|
|
{ |
| 388 |
michael |
1622 |
if (remove_kline_match(khost, kuser)) |
| 389 |
adx |
30 |
{ |
| 390 |
|
|
sendto_one(source_p, |
| 391 |
michael |
1622 |
":%s NOTICE %s :K-Line for [%s@%s] is removed", |
| 392 |
adx |
30 |
me.name, source_p->name, kuser, khost); |
| 393 |
michael |
1618 |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
| 394 |
michael |
1622 |
"%s has removed the K-Line for: [%s@%s]", |
| 395 |
adx |
30 |
get_oper_name(source_p), kuser, khost); |
| 396 |
michael |
1247 |
ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]", |
| 397 |
adx |
30 |
source_p->name, kuser, khost); |
| 398 |
|
|
} |
| 399 |
|
|
else |
| 400 |
|
|
sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found", |
| 401 |
|
|
me.name, source_p->name, kuser, khost); |
| 402 |
|
|
} |
| 403 |
|
|
} |
| 404 |
|
|
|
| 405 |
|
|
/* ms_unkline - propagates and handles a remote unkline message */ |
| 406 |
|
|
static void |
| 407 |
|
|
ms_unkline(struct Client *client_p, struct Client *source_p, |
| 408 |
|
|
int parc, char *parv[]) |
| 409 |
|
|
{ |
| 410 |
|
|
if (parc != 4) |
| 411 |
|
|
return; |
| 412 |
|
|
|
| 413 |
|
|
sendto_match_servs(source_p, parv[1], CAP_UNKLN, |
| 414 |
|
|
"UNKLINE %s %s %s", |
| 415 |
|
|
parv[1], parv[2], parv[3]); |
| 416 |
|
|
|
| 417 |
|
|
me_unkline(client_p, source_p, parc, parv); |
| 418 |
|
|
} |
| 419 |
|
|
|
| 420 |
|
|
/* static int remove_tkline_match(const char *host, const char *user) |
| 421 |
|
|
* Input: A hostname, a username to unkline. |
| 422 |
|
|
* Output: returns YES on success, NO if no tkline removed. |
| 423 |
|
|
* Side effects: Any matching tklines are removed. |
| 424 |
|
|
*/ |
| 425 |
|
|
static int |
| 426 |
michael |
1622 |
remove_kline_match(const char *host, const char *user) |
| 427 |
adx |
30 |
{ |
| 428 |
michael |
1369 |
struct irc_ssaddr iphost, *piphost; |
| 429 |
michael |
1644 |
struct MaskItem *conf; |
| 430 |
|
|
int t = 0; |
| 431 |
|
|
int aftype = 0; |
| 432 |
michael |
1298 |
|
| 433 |
michael |
1369 |
if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST) |
| 434 |
adx |
30 |
{ |
| 435 |
|
|
#ifdef IPV6 |
| 436 |
michael |
1369 |
if (t == HM_IPV6) |
| 437 |
michael |
1644 |
aftype = AF_INET6; |
| 438 |
michael |
1369 |
else |
| 439 |
adx |
30 |
#endif |
| 440 |
michael |
1644 |
aftype = AF_INET; |
| 441 |
michael |
1369 |
piphost = &iphost; |
| 442 |
adx |
30 |
} |
| 443 |
michael |
1369 |
else |
| 444 |
|
|
piphost = NULL; |
| 445 |
adx |
30 |
|
| 446 |
michael |
1644 |
if ((conf = find_conf_by_address(host, piphost, CONF_KLINE, aftype, user, NULL, 0))) |
| 447 |
michael |
1369 |
{ |
| 448 |
michael |
1632 |
if (IsConfDatabase(conf)) |
| 449 |
michael |
1369 |
{ |
| 450 |
michael |
1632 |
delete_one_address_conf(host, conf); |
| 451 |
michael |
1369 |
return 1; |
| 452 |
|
|
} |
| 453 |
|
|
} |
| 454 |
|
|
|
| 455 |
michael |
1058 |
return 0; |
| 456 |
adx |
30 |
} |
| 457 |
michael |
1230 |
|
| 458 |
|
|
static struct Message kline_msgtab = { |
| 459 |
|
|
"KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 460 |
|
|
{m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore} |
| 461 |
|
|
}; |
| 462 |
|
|
|
| 463 |
|
|
static struct Message unkline_msgtab = { |
| 464 |
|
|
"UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
| 465 |
|
|
{m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore} |
| 466 |
|
|
}; |
| 467 |
|
|
|
| 468 |
|
|
static void |
| 469 |
|
|
module_init(void) |
| 470 |
|
|
{ |
| 471 |
|
|
mod_add_cmd(&kline_msgtab); |
| 472 |
|
|
mod_add_cmd(&unkline_msgtab); |
| 473 |
|
|
add_capability("KLN", CAP_KLN, 1); |
| 474 |
|
|
add_capability("UNKLN", CAP_UNKLN, 1); |
| 475 |
|
|
} |
| 476 |
|
|
|
| 477 |
|
|
static void |
| 478 |
|
|
module_exit(void) |
| 479 |
|
|
{ |
| 480 |
|
|
mod_del_cmd(&kline_msgtab); |
| 481 |
|
|
mod_del_cmd(&unkline_msgtab); |
| 482 |
|
|
delete_capability("UNKLN"); |
| 483 |
|
|
delete_capability("KLN"); |
| 484 |
|
|
} |
| 485 |
|
|
|
| 486 |
|
|
struct module module_entry = { |
| 487 |
|
|
.node = { NULL, NULL, NULL }, |
| 488 |
|
|
.name = NULL, |
| 489 |
|
|
.version = "$Revision$", |
| 490 |
|
|
.handle = NULL, |
| 491 |
|
|
.modinit = module_init, |
| 492 |
|
|
.modexit = module_exit, |
| 493 |
|
|
.flags = 0 |
| 494 |
|
|
}; |