ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_kline.c
(Generate patch)

Comparing:
ircd-hybrid/modules/m_kline.c (file contents), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid/trunk/modules/m_kline.c (file contents), Revision 1592 by michael, Sat Oct 27 21:02:32 2012 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
26 > #include "list.h"
27   #include "channel.h"
28   #include "client.h"
29 – #include "common.h"
29   #include "irc_string.h"
30   #include "sprintf_irc.h"
31   #include "ircd.h"
32   #include "hostmask.h"
33   #include "numeric.h"
35 – #include "list.h"
34   #include "fdlist.h"
35   #include "s_bsd.h"
36 < #include "s_conf.h"
37 < #include "s_log.h"
36 > #include "conf.h"
37 > #include "log.h"
38   #include "s_misc.h"
39   #include "send.h"
40   #include "hash.h"
43 – #include "handlers.h"
41   #include "s_serv.h"
45 – #include "msg.h"
42   #include "s_gline.h"
43   #include "parse.h"
44   #include "modules.h"
49 – #include "tools.h"
50 –
51 – static void me_kline(struct Client *, struct Client *, int, char **);
52 – static void mo_kline(struct Client *, struct Client *, int, char **);
53 – static void ms_kline(struct Client *, struct Client *, int, char **);
54 – static void mo_dline(struct Client *, struct Client *, int, char **);
55 – static void me_unkline(struct Client *, struct Client *, int, char **);
56 – static void mo_unkline(struct Client *, struct Client *, int, char **);
57 – static void ms_unkline(struct Client *, struct Client *, int, char **);
58 – static void mo_undline(struct Client *, struct Client *, int, char **);
59 –
60 – #ifndef IPV6
61 – static char *make_cidr(char *dlhost, struct Client *);
62 – #endif
63 –
64 – static int remove_tkline_match(const char *, const char *);
65 – static int remove_tdline_match(const char *);
66 –
67 – struct Message kline_msgtab = {
68 –  "KLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
69 –   {m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore}
70 – };
71 –
72 – struct Message dline_msgtab = {
73 –  "DLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
74 –   {m_unregistered, m_not_oper, m_error, m_ignore, mo_dline, m_ignore}
75 – };
76 –
77 – struct Message unkline_msgtab = {
78 –  "UNKLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
79 –   {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore}
80 – };
81 –
82 – struct Message undline_msgtab = {
83 –  "UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
84 –   {m_unregistered, m_not_oper, m_error, m_ignore, mo_undline, m_ignore}
85 – };
86 –
87 – #ifndef STATIC_MODULES
88 – void
89 – _modinit(void)
90 – {
91 –  mod_add_cmd(&kline_msgtab);
92 –  mod_add_cmd(&unkline_msgtab);
93 –  mod_add_cmd(&dline_msgtab);
94 –  mod_add_cmd(&undline_msgtab);
95 –  add_capability("KLN", CAP_KLN, 1);
96 –  add_capability("UNKLN", CAP_UNKLN, 1);
97 – }
98 –
99 – void
100 – _moddeinit(void)
101 – {
102 –  mod_del_cmd(&kline_msgtab);
103 –  mod_del_cmd(&unkline_msgtab);
104 –  mod_del_cmd(&dline_msgtab);
105 –  mod_del_cmd(&undline_msgtab);
106 –  delete_capability("UNKLN");
107 –  delete_capability("KLN");
108 – }
45  
110 – const char *_version = "$Revision$";
111 – #endif
46  
113 – /* Local function prototypes */
47   static int already_placed_kline(struct Client *, const char *, const char *, int);
48   static void apply_kline(struct Client *, struct ConfItem *, const char *, time_t);
49   static void apply_tkline(struct Client *, struct ConfItem *, int);
50  
51   static char buffer[IRCD_BUFSIZE];
52 + static int remove_tkline_match(const char *, const char *);
53 +
54  
55   /* mo_kline()
56   *
# Line 128 | Line 63 | static char buffer[IRCD_BUFSIZE];
63   */
64   static void
65   mo_kline(struct Client *client_p, struct Client *source_p,
66 <         int parc, char **parv)
66 >         int parc, char *parv[])
67   {
68    char *reason = NULL;
69    char *oper_reason;
# Line 141 | Line 76 | mo_kline(struct Client *client_p, struct
76    time_t tkline_time = 0;
77    time_t cur_time;
78  
79 <  if (!IsOperK(source_p))
79 >  if (!HasOFlag(source_p, OPER_FLAG_K))
80    {
81      sendto_one(source_p, form_str(ERR_NOPRIVS),
82                 me.name, source_p->name, "kline");
# Line 156 | Line 91 | mo_kline(struct Client *client_p, struct
91    {
92      if (HasID(source_p))
93      {
94 <      sendto_server(NULL, source_p, NULL, CAP_KLN|CAP_TS6, NOCAPS, LL_ICLIENT,
94 >      sendto_server(NULL, CAP_KLN|CAP_TS6, NOCAPS,
95                      ":%s KLINE %s %lu %s %s :%s",
96                      source_p->id, target_server, (unsigned long)tkline_time,
97                      user, host, reason);
98 <      sendto_server(NULL, source_p, NULL, CAP_KLN, CAP_TS6, LL_ICLIENT,
98 >      sendto_server(NULL, CAP_KLN, CAP_TS6,
99                      ":%s KLINE %s %lu %s %s :%s",
100                      source_p->name, target_server, (unsigned long)tkline_time,
101                      user, host, reason);
102      }
103      else
104 <      sendto_server(NULL, source_p, NULL, CAP_KLN, NOCAPS, LL_ICLIENT,
104 >      sendto_server(NULL, CAP_KLN, NOCAPS,
105                      ":%s KLINE %s %lu %s %s :%s",
106                      source_p->name, target_server, (unsigned long)tkline_time,
107                      user, host, reason);
# Line 177 | Line 112 | mo_kline(struct Client *client_p, struct
112    }
113    else
114      cluster_a_line(source_p, "KLINE", CAP_KLN, SHARED_KLINE,
115 <                   "%d %s %s :%s", tkline_time, user, host, reason);
115 >                   "%d %s %s :%s", tkline_time, user, host, reason);
116  
117 <  if (already_placed_kline(source_p, user, host, YES))
117 >  if (already_placed_kline(source_p, user, host, 1))
118      return;
119  
120    /* Look for an oper reason */
# Line 196 | Line 131 | mo_kline(struct Client *client_p, struct
131  
132    if (tkline_time != 0)
133    {
134 <    ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)",
135 <               (int)(tkline_time/60), reason, current_date);
134 >    snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)",
135 >             (int)(tkline_time/60), reason, current_date);
136      DupString(aconf->reason, buffer);
137  
138      if (oper_reason != NULL)
# Line 206 | Line 141 | mo_kline(struct Client *client_p, struct
141    }
142    else
143    {
144 <    ircsprintf(buffer, "%s (%s)", reason, current_date);
144 >    snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
145      DupString(aconf->reason, buffer);
146  
147      if (oper_reason != NULL)
# Line 227 | Line 162 | me_kline(struct Client *client_p, struct
162    time_t cur_time;
163    char *kuser, *khost, *kreason, *oper_reason;
164  
165 <  if (parc != 6)
165 >  if (parc != 6 || EmptyString(parv[5]))
166      return;
167  
168    if (!match(parv[1], me.name))
# Line 244 | Line 179 | me_kline(struct Client *client_p, struct
179    cur_time = CurrentTime;
180    current_date = smalldate(cur_time);
181  
182 <  if (find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
182 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
183                                source_p->username, source_p->host,
184                                SHARED_KLINE))
185    {
186      if (!IsClient(source_p) ||
187 <        already_placed_kline(source_p, kuser, khost, YES))
187 >        already_placed_kline(source_p, kuser, khost, 1))
188        return;
189  
190      conf = make_conf_item(KLINE_TYPE);
# Line 259 | Line 194 | me_kline(struct Client *client_p, struct
194  
195      if (tkline_time != 0)
196      {
197 <      ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)",
198 <                 (int)(tkline_time/60), kreason, current_date);
197 >      snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)",
198 >               (int)(tkline_time/60), kreason, current_date);
199        DupString(aconf->reason, buffer);
200  
201        if (oper_reason != NULL)
# Line 269 | Line 204 | me_kline(struct Client *client_p, struct
204      }
205      else
206      {
207 <      ircsprintf(buffer, "%s (%s)", kreason, current_date);
207 >      snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date);
208        DupString(aconf->reason, buffer);
209  
210        if (oper_reason != NULL)
# Line 281 | Line 216 | me_kline(struct Client *client_p, struct
216  
217   static void
218   ms_kline(struct Client *client_p, struct Client *source_p,
219 <         int parc, char *parv[])
219 >         int parc, char *parv[])
220   {
221 <  if (parc != 6)
221 >  if (parc != 6 || EmptyString(parv[5]))
222      return;
223  
224    /* parv[0]  parv[1]        parv[2]      parv[3]  parv[4]  parv[5] */
# Line 304 | Line 239 | ms_kline(struct Client *client_p, struct
239   */
240   static void
241   apply_kline(struct Client *source_p, struct ConfItem *conf,
242 <            const char *current_date, time_t cur_time)
242 >            const char *current_date, time_t cur_time)
243   {
244    struct AccessItem *aconf = map_to_conf(conf);
245  
246 <  add_conf_by_address(CONF_KILL, aconf);
246 >  add_conf_by_address(CONF_KLINE, aconf);
247    write_conf_line(source_p, conf, current_date, cur_time);
248    /* Now, activate kline against current online clients */
249    rehashed_klines = 1;
# Line 328 | Line 263 | apply_tkline(struct Client *source_p, st
263  
264    aconf = (struct AccessItem *)map_to_conf(conf);
265    aconf->hold = CurrentTime + tkline_time;
266 <  add_temp_line(conf);
266 >  SetConfTemporary(aconf);
267 >  add_conf_by_address(CONF_KLINE, aconf);
268 >
269    sendto_realops_flags(UMODE_ALL, L_ALL,
270                         "%s added temporary %d min. K-Line for [%s@%s] [%s]",
271                         get_oper_name(source_p), tkline_time/60,
# Line 337 | Line 274 | apply_tkline(struct Client *source_p, st
274    sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
275               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
276               source_p->name, tkline_time/60, aconf->user, aconf->host);
277 <  ilog(L_TRACE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
277 >  ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
278         source_p->name, tkline_time/60,
279         aconf->user, aconf->host, aconf->reason);
343 –  log_oper_action(LOG_TEMP_KLINE_TYPE, source_p, "[%s@%s] [%s]\n",
344 –                  aconf->user, aconf->host, aconf->reason);
345 –  rehashed_klines = 1;
346 – }
347 –
348 – /* apply_tdline()
349 – *
350 – * inputs       -
351 – * output       - NONE
352 – * side effects - tkline as given is placed
353 – */
354 – static void
355 – apply_tdline(struct Client *source_p, struct ConfItem *conf,
356 –             const char *current_date, int tkline_time)
357 – {
358 –  struct AccessItem *aconf;
359 –
360 –  aconf = map_to_conf(conf);
361 –  aconf->hold = CurrentTime + tkline_time;
362 –
363 –  add_temp_line(conf);
364 –  sendto_realops_flags(UMODE_ALL, L_ALL,
365 –                       "%s added temporary %d min. D-Line for [%s] [%s]",
366 –                       get_oper_name(source_p), tkline_time/60,
367 –                       aconf->host, aconf->reason);
280  
369 –  sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
370 –             MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
371 –             source_p->name, tkline_time/60, aconf->host);
372 –  ilog(L_TRACE, "%s added temporary %d min. D-Line for [%s] [%s]",
373 –       source_p->name, tkline_time/60, aconf->host, aconf->reason);
374 –  log_oper_action(LOG_TEMP_DLINE_TYPE, source_p, "[%s@%s] [%s]\n",
375 –                  aconf->user, aconf->host, aconf->reason);
281    rehashed_klines = 1;
282   }
283  
379 – /* mo_dline()
380 – *
381 – * inputs       - pointer to server
382 – *              - pointer to client
383 – *              - parameter count
384 – *              - parameter list
385 – * output       -
386 – * side effects - D line is added
387 – *
388 – */
389 – static void
390 – mo_dline(struct Client *client_p, struct Client *source_p,
391 –         int parc, char *parv[])
392 – {
393 –  char def_reason[] = "No reason";
394 –  char *dlhost, *oper_reason, *reason;
395 –  const char *creason;
396 – #ifndef IPV6
397 –  struct Client *target_p;
398 – #endif
399 –  struct irc_ssaddr daddr;
400 –  struct ConfItem *conf=NULL;
401 –  struct AccessItem *aconf=NULL;
402 –  time_t tkline_time=0;
403 –  int bits, t;
404 –  const char* current_date;
405 –  time_t cur_time;
406 –
407 –  if (!IsOperK(source_p))
408 –  {
409 –    sendto_one(source_p, form_str(ERR_NOPRIVS),
410 –               me.name, source_p->name, "kline");
411 –    return;
412 –  }
413 –
414 –  if (parse_aline("DLINE", source_p,  parc, parv,
415 –                  AWILD, &dlhost, NULL, &tkline_time, NULL, &reason) < 0)
416 –    return;
417 –
418 –  if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
419 –  {
420 – #ifdef IPV6
421 –   sendto_one(source_p, ":%s NOTICE %s :Sorry, please supply an address.",
422 –              me.name, parv[0]);
423 –   return;
424 – #else
425 –   if ((target_p = find_chasing(client_p, source_p, dlhost, NULL)) == NULL)
426 –     return;
427 –
428 –   t = HM_IPV4;
429 –   if (IsServer(target_p))
430 –   {
431 –     sendto_one(source_p,
432 –                ":%s NOTICE %s :Can't DLINE a server silly",
433 –                me.name, source_p->name);
434 –     return;
435 –   }
436 –              
437 –   if (!MyConnect(target_p))
438 –   {
439 –     sendto_one(source_p,
440 –                ":%s NOTICE %s :Can't DLINE nick on another server",
441 –                me.name, source_p->name);
442 –     return;
443 –   }
444 –
445 –   if (IsExemptKline(target_p))
446 –   {
447 –     sendto_one(source_p,
448 –                ":%s NOTICE %s :%s is E-lined",me.name,
449 –                source_p->name, target_p->name);
450 –     return;
451 –   }
452 –
453 –   if ((dlhost = make_cidr(dlhost, target_p)) == NULL)
454 –     return;
455 –
456 –   bits = 0xFFFFFF00UL;
457 – #endif
458 –    }
459 –
460 –  if (bits < 8)
461 –  {
462 –    sendto_one(source_p,
463 –        ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
464 –               me.name, source_p->name);
465 –    return;
466 –  }
467 –
468 –
469 – #ifdef IPV6
470 –  if (t == HM_IPV6)
471 –    t = AF_INET6;
472 –  else
473 – #endif
474 –    t = AF_INET;
475 –
476 –  parse_netmask(dlhost, &daddr, NULL);
477 –
478 –  if ((aconf = find_dline_conf(&daddr, t)) != NULL)
479 –  {
480 –    creason = aconf->reason ? aconf->reason : def_reason;
481 –    if (IsConfExemptKline(aconf))
482 –      sendto_one(source_p,
483 –                 ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
484 –                 me.name, source_p->name, dlhost, aconf->host, creason);
485 –    else
486 –      sendto_one(source_p,
487 –                 ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
488 –                 me.name, source_p->name, dlhost, aconf->host, creason);
489 –    return;
490 –  }
491 –
492 –  cur_time = CurrentTime;
493 –  current_date = smalldate(cur_time);
494 –
495 –  /* Look for an oper reason */
496 –  if ((oper_reason = strchr(reason, '|')) != NULL)
497 –    *oper_reason++ = '\0';
498 –
499 –  if (!valid_comment(source_p, reason, YES))
500 –    return;
501 –
502 –  conf = make_conf_item(DLINE_TYPE);
503 –  aconf = map_to_conf(conf);
504 –  DupString(aconf->host, dlhost);
505 –
506 –  if (tkline_time != 0)
507 –  {
508 –    ircsprintf(buffer, "Temporary D-line %d min. - %s (%s)",
509 –               (int)(tkline_time/60), reason, current_date);
510 –    DupString(aconf->reason, buffer);
511 –    if (oper_reason != NULL)
512 –      DupString(aconf->oper_reason, oper_reason);
513 –    apply_tdline(source_p, conf, current_date, tkline_time);
514 –  }
515 –  else
516 –  {
517 –    ircsprintf(buffer, "%s (%s)", reason, current_date);
518 –    DupString(aconf->reason, buffer);
519 –    if (oper_reason != NULL)
520 –      DupString(aconf->oper_reason, oper_reason);
521 –    add_conf_by_address(CONF_DLINE, aconf);
522 –    write_conf_line(source_p, conf, current_date, cur_time);
523 –  }
524 –
525 –  rehashed_klines = 1;
526 – } /* mo_dline() */
527 –
528 –
284   /* already_placed_kline()
285   * inputs       - user to complain to, username & host to check for
286   * outputs      - returns 1 on existing K-line, 0 if doesn't exist
# Line 560 | Line 315 | already_placed_kline(struct Client *sour
315      piphost = NULL;
316    }
317  
318 <  if ((aconf = find_conf_by_address(lhost, piphost, CONF_KILL, t, luser, NULL)))
318 >  if ((aconf = find_conf_by_address(lhost, piphost, CONF_KLINE, t, luser, NULL, 0)))
319    {
320      if (warn)
321      {
# Line 570 | Line 325 | already_placed_kline(struct Client *sour
325                   me.name, source_p->name, luser, lhost, aconf->user,
326                   aconf->host, reason);
327      }
573 –    return(1);
574 –  }
575 –
576 –  return(0);
577 – }
578 –
579 – #ifndef IPV6
580 – static char *
581 – make_cidr(char *dlhost, struct Client *target_p)
582 – {
583 –  static char cidr_form_host[HOSTLEN + 2];
584 –  char *p;
585 –
586 –  strlcpy(cidr_form_host, inetntoa((const char *)&target_p->localClient->ip),
587 –          sizeof(cidr_form_host));
328  
329 <  if ((p = strchr(cidr_form_host,'.')) == NULL)
330 <    return(NULL);
591 <
592 <  /* 192. <- p */
593 <   p++;
594 <   if ((p = strchr(p,'.')) == NULL)
595 <     return(NULL);
596 <
597 <   /* 192.168. <- p */
598 <   p++;
599 <   if ((p = strchr(p,'.')) == NULL)
600 <     return(NULL);
601 <
602 <   /* 192.168.0. <- p */
603 <   p++;
604 <   *p++ = '0';
605 <   *p++ = '/';
606 <   *p++ = '2';
607 <   *p++ = '4';
608 <   *p++ = '\0';
329 >    return 1;
330 >  }
331  
332 <   return(cidr_form_host);
332 >  return 0;
333   }
612 – #endif
334  
335   /*
336   ** mo_unkline
# Line 628 | Line 349 | mo_unkline(struct Client *client_p,struc
349    char *target_server = NULL;
350    char *user, *host;
351  
352 <  if (!IsOperUnkline(source_p))
352 >  if (!HasOFlag(source_p, OPER_FLAG_UNKLINE))
353    {
354      sendto_one(source_p, form_str(ERR_NOPRIVS),
355                 me.name, source_p->name, "unkline");
# Line 658 | Line 379 | mo_unkline(struct Client *client_p,struc
379    }
380    else
381      cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE,
382 <                   "%s %s", user, host);
382 >                   "%s %s", user, host);
383  
384    if (remove_tkline_match(host, user))
385    {
# Line 668 | Line 389 | mo_unkline(struct Client *client_p,struc
389      sendto_realops_flags(UMODE_ALL, L_ALL,
390                           "%s has removed the temporary K-Line for: [%s@%s]",
391                           get_oper_name(source_p), user, host);
392 <    ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
392 >    ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]",
393           source_p->name, user, host);
394      return;
395    }
# Line 676 | Line 397 | mo_unkline(struct Client *client_p,struc
397    if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0)
398    {
399      sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
400 <               me.name, source_p->name, user,host);
400 >               me.name, source_p->name, user,host);
401      sendto_realops_flags(UMODE_ALL, L_ALL,
402 <                         "%s has removed the K-Line for: [%s@%s]",
403 <                         get_oper_name(source_p), user, host);
404 <    ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
405 <         source_p->name, user, host);
402 >                         "%s has removed the K-Line for: [%s@%s]",
403 >                         get_oper_name(source_p), user, host);
404 >    ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
405 >         source_p->name, user, host);
406    }
407    else
408      sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found",
# Line 713 | Line 434 | me_unkline(struct Client *client_p, stru
434    if (!IsClient(source_p) || !match(parv[1], me.name))
435      return;
436  
437 <  if (find_matching_name_conf(ULINE_TYPE,
437 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE,
438                                     source_p->servptr->name,
439                                     source_p->username, source_p->host,
440                                     SHARED_UNKLINE))
# Line 726 | Line 447 | me_unkline(struct Client *client_p, stru
447        sendto_realops_flags(UMODE_ALL, L_ALL,  
448                             "%s has removed the temporary K-Line for: [%s@%s]",
449                             get_oper_name(source_p), kuser, khost);
450 <      ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
450 >      ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]",
451             source_p->name, kuser, khost);
452        return;
453      }
# Line 739 | Line 460 | me_unkline(struct Client *client_p, stru
460                             "%s has removed the K-Line for: [%s@%s]",
461                           get_oper_name(source_p), kuser, khost);
462  
463 <      ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
463 >      ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
464             source_p->name, kuser, khost);
465      }
466      else
# Line 771 | Line 492 | ms_unkline(struct Client *client_p, stru
492   static int
493   remove_tkline_match(const char *host, const char *user)
494   {
495 <  struct AccessItem *tk_c;
496 <  dlink_node *tk_n;
497 <  struct irc_ssaddr addr, caddr;
498 <  int nm_t, cnm_t, bits, cbits;
499 <  nm_t = parse_netmask(host, &addr, &bits);
500 <
780 <  DLINK_FOREACH(tk_n, temporary_klines.head)
781 <  {
782 <    tk_c = map_to_conf(tk_n->data);
783 <    cnm_t = parse_netmask(tk_c->host, &caddr, &cbits);
784 <    if (cnm_t != nm_t || irccmp(user, tk_c->user))
785 <      continue;
786 <    if ((nm_t==HM_HOST && !irccmp(tk_c->host, host)) ||
787 <        (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
495 >  struct irc_ssaddr iphost, *piphost;
496 >  struct AccessItem *aconf;
497 >  int t;
498 >
499 >  if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
500 >  {
501   #ifdef IPV6
502 <        || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
502 >    if (t == HM_IPV6)
503 >      t = AF_INET6;
504 >    else
505   #endif
506 <        )
507 <      {
793 <        dlinkDelete(tk_n, &temporary_klines);
794 <        delete_one_address_conf(tk_c->host, tk_c);
795 <        return(YES);
796 <      }
506 >      t = AF_INET;
507 >    piphost = &iphost;
508    }
509 <
799 <  return(NO);
800 < }
801 <
802 < /* static int remove_tdline_match(const char *host, const char *user)
803 < * Input: An ip to undline.
804 < * Output: returns YES on success, NO if no tdline removed.
805 < * Side effects: Any matching tdlines are removed.
806 < */
807 < static int
808 < remove_tdline_match(const char *cidr)
809 < {
810 <  struct AccessItem *td_conf;
811 <  dlink_node *td_node;
812 <  struct irc_ssaddr addr, caddr;
813 <  int nm_t, cnm_t, bits, cbits;
814 <  nm_t = parse_netmask(cidr, &addr, &bits);
815 <
816 <  DLINK_FOREACH(td_node, temporary_dlines.head)
509 >  else
510    {
511 <    td_conf = map_to_conf(td_node->data);
512 <    cnm_t   = parse_netmask(td_conf->host, &caddr, &cbits);
513 <
821 <    if (cnm_t != nm_t)
822 <      continue;
511 >    t = 0;
512 >    piphost = NULL;
513 >  }
514  
515 <    if((nm_t==HM_HOST && !irccmp(td_conf->host, cidr)) ||
516 <       (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
517 < #ifdef IPV6
827 <       || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
828 < #endif
829 <      )
515 >  if ((aconf = find_conf_by_address(host, piphost, CONF_KLINE, t, user, NULL, 0)))
516 >  {
517 >    if (IsConfTemporary(aconf))
518      {
519 <      dlinkDelete(td_node, &temporary_dlines);
520 <      delete_one_address_conf(td_conf->host, td_conf);
833 <      return(YES);
519 >      delete_one_address_conf(host, aconf);
520 >      return 1;
521      }
522    }
523  
524 <  return(NO);
524 >  return 0;
525   }
526  
527 < /*
528 < ** m_undline
529 < ** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk>
530 < ** based totally on m_unkline
844 < ** added to hybrid-7 7/11/2000 --is
845 < **
846 < **      parv[0] = sender nick
847 < **      parv[1] = dline to remove
848 < */
849 < static void
850 < mo_undline(struct Client *client_p, struct Client *source_p,
851 <           int parc, char *parv[])
852 < {
853 <  const char  *cidr;
854 <
855 <  if (!IsOperUnkline(source_p))
856 <  {
857 <    sendto_one(source_p, form_str(ERR_NOPRIVS),
858 <               me.name, source_p->name, "undline");
859 <    return;
860 <  }
527 > static struct Message kline_msgtab = {
528 >  "KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
529 >   {m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore}
530 > };
531  
532 <  cidr = parv[1];
532 > static struct Message unkline_msgtab = {
533 >  "UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
534 >   {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore}
535 > };
536  
537 <  if (remove_tdline_match(cidr))
538 <  {
539 <    sendto_one(source_p,
540 <              ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
541 <              me.name, source_p->name, cidr);
542 <    sendto_realops_flags(UMODE_ALL, L_ALL,
543 <                         "%s has removed the temporary D-Line for: [%s]",
544 <                         get_oper_name(source_p), cidr);
872 <    ilog(L_NOTICE, "%s removed temporary D-Line for [%s]", source_p->name, cidr);
873 <    return;
874 <  }
537 > static void
538 > module_init(void)
539 > {
540 >  mod_add_cmd(&kline_msgtab);
541 >  mod_add_cmd(&unkline_msgtab);
542 >  add_capability("KLN", CAP_KLN, 1);
543 >  add_capability("UNKLN", CAP_UNKLN, 1);
544 > }
545  
546 <  if (remove_conf_line(DLINE_TYPE, source_p, cidr, NULL) > 0)
547 <  {
548 <    sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
549 <               me.name, source_p->name, cidr);
550 <    sendto_realops_flags(UMODE_ALL, L_ALL,
551 <                         "%s has removed the D-Line for: [%s]",
552 <                         get_oper_name(source_p), cidr);
883 <    ilog(L_NOTICE, "%s removed D-Line for [%s]",
884 <         get_oper_name(source_p), cidr);
885 <  }
886 <  else
887 <    sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found",
888 <               me.name, source_p->name, cidr);
546 > static void
547 > module_exit(void)
548 > {
549 >  mod_del_cmd(&kline_msgtab);
550 >  mod_del_cmd(&unkline_msgtab);
551 >  delete_capability("UNKLN");
552 >  delete_capability("KLN");
553   }
554 +
555 + struct module module_entry = {
556 +  .node    = { NULL, NULL, NULL },
557 +  .name    = NULL,
558 +  .version = "$Revision$",
559 +  .handle  = NULL,
560 +  .modinit = module_init,
561 +  .modexit = module_exit,
562 +  .flags   = 0
563 + };

Comparing:
ircd-hybrid/modules/m_kline.c (property svn:keywords), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid/trunk/modules/m_kline.c (property svn:keywords), Revision 1592 by michael, Sat Oct 27 21:02:32 2012 UTC

# Line 1 | Line 1
1 < Revision
1 > Id Revision

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)