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

Comparing ircd-hybrid/trunk/modules/m_dline.c (file contents):
Revision 1618 by michael, Tue Oct 30 21:04:38 2012 UTC vs.
Revision 1622 by michael, Thu Nov 1 13:16:37 2012 UTC

# Line 39 | Line 39
39   #include "send.h"
40   #include "hash.h"
41   #include "s_serv.h"
42 #include "s_gline.h"
42   #include "parse.h"
43   #include "modules.h"
44 + #include "conf_db.h"
45  
46  
47   /* apply_tdline()
# Line 51 | Line 51
51   * side effects - tkline as given is placed
52   */
53   static void
54 < apply_tdline(struct Client *source_p, struct ConfItem *conf,
55 <             const char *current_date, int tkline_time)
54 > apply_dline(struct Client *source_p, struct AccessItem *aconf,
55 >            time_t tkline_time)
56   {
57 <  struct AccessItem *aconf;
58 <
59 <  aconf = map_to_conf(conf);
60 <  aconf->hold = CurrentTime + tkline_time;
61 <  SetConfTemporary(aconf);
62 <  add_conf_by_address(CONF_DLINE, aconf);
63 <
57 >  if (tkline_time)
58 >  {
59 >    aconf->hold = CurrentTime + tkline_time;
60 >    SetConfTemporary(aconf);
61 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
62 >                         "%s added temporary %d min. D-Line for [%s] [%s]",
63 >                         get_oper_name(source_p), tkline_time/60,
64 >                         aconf->host, aconf->reason);
65 >    sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
66 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
67 >               source_p->name, tkline_time/60, aconf->host);
68 >    ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
69 >         get_oper_name(source_p), tkline_time/60, aconf->host, aconf->reason);
70 >  }
71 >  else
72 >  {
73 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
74 >                         "%s added D-Line for [%s] [%s]",
75 >                         get_oper_name(source_p), aconf->host, aconf->reason);
76 >    sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s]",
77 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
78 >               source_p->name, aconf->host);
79 >    ilog(LOG_TYPE_DLINE, "%s added D-Line for [%s] [%s]",
80 >         get_oper_name(source_p), aconf->host, aconf->reason);
81  
82 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
66 <                       "%s added temporary %d min. D-Line for [%s] [%s]",
67 <                       get_oper_name(source_p), tkline_time/60,
68 <                       aconf->host, aconf->reason);
69 <
70 <  sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
71 <             MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
72 <             source_p->name, tkline_time/60, aconf->host);
73 <  ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
74 <       source_p->name, tkline_time/60, aconf->host, aconf->reason);
82 >  }
83  
84 +  aconf->setat = CurrentTime;
85 +  add_conf_by_address(CONF_DLINE, aconf);
86 +  save_dline_database();
87    rehashed_klines = 1;
88   }
89  
# Line 82 | Line 93 | apply_tdline(struct Client *source_p, st
93   * Side effects: Any matching tdlines are removed.
94   */
95   static int
96 < remove_tdline_match(const char *host)
96 > remove_dline_match(const char *host)
97   {
98    struct irc_ssaddr iphost, *piphost;
99    struct AccessItem *aconf;
# Line 106 | Line 117 | remove_tdline_match(const char *host)
117  
118    if ((aconf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
119    {
120 <    if (IsConfTemporary(aconf))
120 >    if (!IsConfMain(aconf))
121      {
122        delete_one_address_conf(host, aconf);
123 +      save_dline_database();
124        return 1;
125      }
126    }
# Line 131 | Line 143 | mo_dline(struct Client *client_p, struct
143           int parc, char *parv[])
144   {
145    char def_reason[] = "<No reason specified>";
146 <  char *dlhost = NULL, *oper_reason = NULL, *reason = NULL;
146 >  char *dlhost = NULL, *reason = NULL;
147    char *target_server = NULL;
148    const char *creason;
149    const struct Client *target_p = NULL;
# Line 246 | Line 258 | mo_dline(struct Client *client_p, struct
258    cur_time = CurrentTime;
259    current_date = smalldate(cur_time);
260  
249  /* Look for an oper reason */
250  if ((oper_reason = strchr(reason, '|')) != NULL)
251    *oper_reason++ = '\0';
252
261    if (!valid_comment(source_p, reason, 1))
262      return;
263  
# Line 262 | Line 270 | mo_dline(struct Client *client_p, struct
270      snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
271               (int)(tkline_time/60), reason, current_date);
272      DupString(aconf->reason, buffer);
273 <    if (oper_reason != NULL)
266 <      DupString(aconf->oper_reason, oper_reason);
267 <    apply_tdline(source_p, conf, current_date, tkline_time);
273 >    apply_dline(source_p, aconf, tkline_time);
274    }
275    else
276    {
277      snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
278      DupString(aconf->reason, buffer);
279 <    if (oper_reason != NULL)
274 <      DupString(aconf->oper_reason, oper_reason);
275 <    add_conf_by_address(CONF_DLINE, aconf);
276 <    write_conf_line(source_p, conf, current_date, cur_time);
279 >    apply_dline(source_p, aconf, 0);
280    }
281  
282    rehashed_klines = 1;
# Line 284 | Line 287 | ms_dline(struct Client *client_p, struct
287           int parc, char *parv[])
288   {
289    char def_reason[] = "<No reason specified>";
290 <  char *dlhost, *oper_reason, *reason;
290 >  char *dlhost, *reason;
291    const char *creason;
292    const struct Client *target_p = NULL;
293    struct irc_ssaddr daddr;
# Line 382 | Line 385 | ms_dline(struct Client *client_p, struct
385      cur_time = CurrentTime;
386      current_date = smalldate(cur_time);
387  
385    /* Look for an oper reason */
386    if ((oper_reason = strchr(reason, '|')) != NULL)
387      *oper_reason++ = '\0';
388
388      if (!valid_comment(source_p, reason, 1))
389        return;
390  
# Line 398 | Line 397 | ms_dline(struct Client *client_p, struct
397        snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
398                 (int)(tkline_time/60), reason, current_date);
399        DupString(aconf->reason, buffer);
400 <      if (oper_reason != NULL)
402 <        DupString(aconf->oper_reason, oper_reason);
403 <      apply_tdline(source_p, conf, current_date, tkline_time);
400 >      apply_dline(source_p, aconf, tkline_time);
401      }
402      else
403      {
404        snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
405        DupString(aconf->reason, buffer);
406 <      if (oper_reason != NULL)
410 <        DupString(aconf->oper_reason, oper_reason);
411 <      add_conf_by_address(CONF_DLINE, aconf);
412 <      write_conf_line(source_p, conf, current_date, cur_time);
406 >      apply_dline(source_p, aconf, 0);
407      }
408  
409      rehashed_klines = 1;
# Line 463 | Line 457 | mo_undline(struct Client *client_p, stru
457      cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE,
458                     "%s", addr);
459  
460 <  if (remove_tdline_match(addr))
460 >  if (remove_dline_match(addr))
461    {
462      sendto_one(source_p,
463 <               ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
463 >               ":%s NOTICE %s :D-Line for [%s] is removed",
464                 me.name, source_p->name, addr);
465      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
466 <                         "%s has removed the temporary D-Line for: [%s]",
466 >                         "%s has removed the D-Line for: [%s]",
467                           get_oper_name(source_p), addr);
474    ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
475         source_p->name, addr);
476    return;
477  }
478
479  if (remove_conf_line(DLINE_TYPE, source_p, addr, NULL) > 0)
480  {
481    sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
482               me.name, source_p->name, addr);
483    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
484                         "%s has removed the D-Line for: [%s]",
485                         get_oper_name(source_p), addr);
468      ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
469           get_oper_name(source_p), addr);
470    }
# Line 510 | Line 492 | me_undline(struct Client *client_p, stru
492                                     source_p->username, source_p->host,
493                                     SHARED_UNDLINE))
494    {
495 <    if (remove_tdline_match(addr))
495 >    if (remove_dline_match(addr))
496      {
497        sendto_one(source_p,
498 <                 ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
517 <                 me.name, source_p->name, addr);
518 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
519 <                           "%s has removed the temporary D-Line for: [%s]",
520 <                           get_oper_name(source_p), addr);
521 <      ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
522 <           source_p->name, addr);
523 <      return;
524 <    }
525 <
526 <    if (remove_conf_line(DLINE_TYPE, source_p, addr, NULL) > 0)
527 <    {
528 <      sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
498 >                 ":%s NOTICE %s :D-Line for [%s] is removed",
499                   me.name, source_p->name, addr);
500        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
501                             "%s has removed the D-Line for: [%s]",
502                             get_oper_name(source_p), addr);
503 <      ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
503 >      ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
504             get_oper_name(source_p), addr);
505      }
506      else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines