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 33 by knight, Sun Oct 2 20:50:00 2005 UTC vs.
ircd-hybrid-8/modules/m_kline.c (file contents), Revision 1276 by michael, Mon Jan 30 23:55:11 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"
# Line 40 | Line 38
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 – }
45  
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 – }
46  
110 – const char *_version = "$Revision$";
111 – #endif
112 –
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, 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, 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, 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  
# Line 337 | Line 272 | apply_tkline(struct Client *source_p, st
272    sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
273               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
274               source_p->name, tkline_time/60, aconf->user, aconf->host);
275 <  ilog(L_TRACE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
275 >  ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
276         source_p->name, tkline_time/60,
277         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;
278  
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);
368 –
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);
279    rehashed_klines = 1;
280   }
281  
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 –
282   /* already_placed_kline()
283   * inputs       - user to complain to, username & host to check for
284   * outputs      - returns 1 on existing K-line, 0 if doesn't exist
# Line 576 | Line 329 | already_placed_kline(struct Client *sour
329    return(0);
330   }
331  
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));
588 –
589 –  if ((p = strchr(cidr_form_host,'.')) == NULL)
590 –    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';
609 –
610 –   return(cidr_form_host);
611 – }
612 – #endif
613 –
332   /*
333   ** mo_unkline
334   ** Added Aug 31, 1997
# Line 628 | Line 346 | mo_unkline(struct Client *client_p,struc
346    char *target_server = NULL;
347    char *user, *host;
348  
349 <  if (!IsOperUnkline(source_p))
349 >  if (!HasOFlag(source_p, OPER_FLAG_UNKLINE))
350    {
351      sendto_one(source_p, form_str(ERR_NOPRIVS),
352                 me.name, source_p->name, "unkline");
# Line 658 | Line 376 | mo_unkline(struct Client *client_p,struc
376    }
377    else
378      cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE,
379 <                   "%s %s", user, host);
379 >                   "%s %s", user, host);
380  
381    if (remove_tkline_match(host, user))
382    {
# Line 668 | Line 386 | mo_unkline(struct Client *client_p,struc
386      sendto_realops_flags(UMODE_ALL, L_ALL,
387                           "%s has removed the temporary K-Line for: [%s@%s]",
388                           get_oper_name(source_p), user, host);
389 <    ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
389 >    ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]",
390           source_p->name, user, host);
391      return;
392    }
# Line 676 | Line 394 | mo_unkline(struct Client *client_p,struc
394    if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0)
395    {
396      sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
397 <               me.name, source_p->name, user,host);
397 >               me.name, source_p->name, user,host);
398      sendto_realops_flags(UMODE_ALL, L_ALL,
399 <                         "%s has removed the K-Line for: [%s@%s]",
400 <                         get_oper_name(source_p), user, host);
401 <    ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
402 <         source_p->name, user, host);
399 >                         "%s has removed the K-Line for: [%s@%s]",
400 >                         get_oper_name(source_p), user, host);
401 >    ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
402 >         source_p->name, user, host);
403    }
404    else
405      sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found",
# Line 713 | Line 431 | me_unkline(struct Client *client_p, stru
431    if (!IsClient(source_p) || !match(parv[1], me.name))
432      return;
433  
434 <  if (find_matching_name_conf(ULINE_TYPE,
434 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE,
435                                     source_p->servptr->name,
436                                     source_p->username, source_p->host,
437                                     SHARED_UNKLINE))
# Line 726 | Line 444 | me_unkline(struct Client *client_p, stru
444        sendto_realops_flags(UMODE_ALL, L_ALL,  
445                             "%s has removed the temporary K-Line for: [%s@%s]",
446                             get_oper_name(source_p), kuser, khost);
447 <      ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
447 >      ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]",
448             source_p->name, kuser, khost);
449        return;
450      }
# Line 739 | Line 457 | me_unkline(struct Client *client_p, stru
457                             "%s has removed the K-Line for: [%s@%s]",
458                           get_oper_name(source_p), kuser, khost);
459  
460 <      ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
460 >      ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
461             source_p->name, kuser, khost);
462      }
463      else
# Line 784 | Line 502 | remove_tkline_match(const char *host, co
502      if (cnm_t != nm_t || irccmp(user, tk_c->user))
503        continue;
504      if ((nm_t==HM_HOST && !irccmp(tk_c->host, host)) ||
505 <        (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
505 >        (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
506   #ifdef IPV6
507 <        || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
507 >       || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
508   #endif
509 <        )
509 >       )
510        {
511 <        dlinkDelete(tk_n, &temporary_klines);
512 <        delete_one_address_conf(tk_c->host, tk_c);
513 <        return(YES);
511 >        dlinkDelete(tk_n, &temporary_klines);
512 >        delete_one_address_conf(tk_c->host, tk_c);
513 >        return 1;
514        }
515    }
516  
517 <  return(NO);
517 >  return 0;
518   }
519  
520 < /* static int remove_tdline_match(const char *host, const char *user)
521 < * Input: An ip to undline.
522 < * Output: returns YES on success, NO if no tdline removed.
523 < * 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)
817 <  {
818 <    td_conf = map_to_conf(td_node->data);
819 <    cnm_t   = parse_netmask(td_conf->host, &caddr, &cbits);
820 <
821 <    if (cnm_t != nm_t)
822 <      continue;
520 > static struct Message kline_msgtab = {
521 >  "KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
522 >   {m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore}
523 > };
524  
525 <    if((nm_t==HM_HOST && !irccmp(td_conf->host, cidr)) ||
526 <       (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
527 < #ifdef IPV6
528 <       || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
828 < #endif
829 <      )
830 <    {
831 <      dlinkDelete(td_node, &temporary_dlines);
832 <      delete_one_address_conf(td_conf->host, td_conf);
833 <      return(YES);
834 <    }
835 <  }
525 > static struct Message unkline_msgtab = {
526 >  "UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
527 >   {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore}
528 > };
529  
530 <  return(NO);
530 > static void
531 > module_init(void)
532 > {
533 >  mod_add_cmd(&kline_msgtab);
534 >  mod_add_cmd(&unkline_msgtab);
535 >  add_capability("KLN", CAP_KLN, 1);
536 >  add_capability("UNKLN", CAP_UNKLN, 1);
537   }
538  
840 – /*
841 – ** m_undline
842 – ** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk>
843 – ** 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 – */
539   static void
540 < mo_undline(struct Client *client_p, struct Client *source_p,
851 <           int parc, char *parv[])
540 > module_exit(void)
541   {
542 <  const char  *cidr;
543 <
544 <  if (!IsOperUnkline(source_p))
545 <  {
857 <    sendto_one(source_p, form_str(ERR_NOPRIVS),
858 <               me.name, source_p->name, "undline");
859 <    return;
860 <  }
861 <
862 <  cidr = parv[1];
863 <
864 <  if (remove_tdline_match(cidr))
865 <  {
866 <    sendto_one(source_p,
867 <              ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
868 <              me.name, source_p->name, cidr);
869 <    sendto_realops_flags(UMODE_ALL, L_ALL,
870 <                         "%s has removed the temporary D-Line for: [%s]",
871 <                         get_oper_name(source_p), cidr);
872 <    ilog(L_NOTICE, "%s removed temporary D-Line for [%s]", source_p->name, cidr);
873 <    return;
874 <  }
875 <
876 <  if (remove_conf_line(DLINE_TYPE, source_p, cidr, NULL) > 0)
877 <  {
878 <    sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
879 <               me.name, source_p->name, cidr);
880 <    sendto_realops_flags(UMODE_ALL, L_ALL,
881 <                         "%s has removed the D-Line for: [%s]",
882 <                         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);
542 >  mod_del_cmd(&kline_msgtab);
543 >  mod_del_cmd(&unkline_msgtab);
544 >  delete_capability("UNKLN");
545 >  delete_capability("KLN");
546   }
547 +
548 + struct module module_entry = {
549 +  .node    = { NULL, NULL, NULL },
550 +  .name    = NULL,
551 +  .version = "$Revision$",
552 +  .handle  = NULL,
553 +  .modinit = module_init,
554 +  .modexit = module_exit,
555 +  .flags   = 0
556 + };

Diff Legend

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