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

Comparing:
ircd-hybrid-8/modules/m_dline.c (file contents), Revision 1474 by michael, Sun Jul 22 14:44:07 2012 UTC vs.
ircd-hybrid/trunk/modules/m_dline.c (file contents), Revision 1632 by michael, Sun Nov 4 15:37:10 2012 UTC

# Line 28 | Line 28
28   #include "client.h"
29   #include "irc_string.h"
30   #include "sprintf_irc.h"
31 + #include "conf.h"
32   #include "ircd.h"
33   #include "hostmask.h"
34   #include "numeric.h"
35   #include "fdlist.h"
36   #include "s_bsd.h"
36 – #include "conf.h"
37   #include "log.h"
38   #include "s_misc.h"
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 MaskItem *conf,
55 >            time_t tkline_time)
56   {
57 <  struct AccessItem *aconf;
57 >  if (tkline_time)
58 >  {
59 >    conf->hold = CurrentTime + tkline_time;
60 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
61 >                         "%s added temporary %d min. D-Line for [%s] [%s]",
62 >                         get_oper_name(source_p), tkline_time/60,
63 >                         conf->host, conf->reason);
64 >    sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
65 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
66 >               source_p->name, tkline_time/60, conf->host);
67 >    ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
68 >         get_oper_name(source_p), tkline_time/60, conf->host, conf->reason);
69 >  }
70 >  else
71 >  {
72 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
73 >                         "%s added D-Line for [%s] [%s]",
74 >                         get_oper_name(source_p), conf->host, conf->reason);
75 >    sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s]",
76 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
77 >               source_p->name, conf->host);
78 >    ilog(LOG_TYPE_DLINE, "%s added D-Line for [%s] [%s]",
79 >         get_oper_name(source_p), conf->host, conf->reason);
80  
81 <  aconf = map_to_conf(conf);
60 <  aconf->hold = CurrentTime + tkline_time;
61 <  SetConfTemporary(aconf);
62 <  add_conf_by_address(CONF_DLINE, aconf);
63 <
64 <
65 <  sendto_realops_flags(UMODE_ALL, L_ALL,
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);
81 >  }
82  
83 +  SetConfDatabase(conf);
84 +  conf->setat = CurrentTime;
85 +  add_conf_by_address(CONF_DLINE, conf);
86    rehashed_klines = 1;
87   }
88  
# Line 82 | Line 92 | apply_tdline(struct Client *source_p, st
92   * Side effects: Any matching tdlines are removed.
93   */
94   static int
95 < remove_tdline_match(const char *host)
95 > remove_dline_match(const char *host)
96   {
97    struct irc_ssaddr iphost, *piphost;
98 <  struct AccessItem *aconf;
98 >  struct MaskItem *conf;
99    int t;
100  
101    if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
# Line 104 | Line 114 | remove_tdline_match(const char *host)
114      piphost = NULL;
115    }
116  
117 <  if ((aconf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
117 >  if ((conf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
118    {
119 <    if (IsConfTemporary(aconf))
119 >    if (IsConfDatabase(conf))
120      {
121 <      delete_one_address_conf(host, aconf);
121 >      delete_one_address_conf(host, conf);
122        return 1;
123      }
124    }
# Line 131 | Line 141 | mo_dline(struct Client *client_p, struct
141           int parc, char *parv[])
142   {
143    char def_reason[] = "<No reason specified>";
144 <  char *dlhost = NULL, *oper_reason = NULL, *reason = NULL;
144 >  char *dlhost = NULL, *reason = NULL;
145    char *target_server = NULL;
146    const char *creason;
147    const struct Client *target_p = NULL;
148    struct irc_ssaddr daddr;
149 <  struct ConfItem *conf=NULL;
140 <  struct AccessItem *aconf=NULL;
149 >  struct MaskItem *conf=NULL;
150    time_t tkline_time=0;
151    int bits, t;
152    const char *current_date = NULL;
# Line 148 | Line 157 | mo_dline(struct Client *client_p, struct
157    if (!HasOFlag(source_p, OPER_FLAG_DLINE))
158    {
159      sendto_one(source_p, form_str(ERR_NOPRIVS),
160 <               me.name, source_p->name, "kline");
160 >               me.name, source_p->name, "dline");
161      return;
162    }
163  
# Line 229 | Line 238 | mo_dline(struct Client *client_p, struct
238  
239    parse_netmask(dlhost, &daddr, NULL);
240  
241 <  if ((aconf = find_dline_conf(&daddr, t)) != NULL)
241 >  if ((conf = find_dline_conf(&daddr, t)) != NULL)
242    {
243 <    creason = aconf->reason ? aconf->reason : def_reason;
244 <    if (IsConfExemptKline(aconf))
243 >    creason = conf->reason ? conf->reason : def_reason;
244 >    if (IsConfExemptKline(conf))
245        sendto_one(source_p,
246                   ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
247 <                 me.name, source_p->name, dlhost, aconf->host, creason);
247 >                 me.name, source_p->name, dlhost, conf->host, creason);
248      else
249        sendto_one(source_p,
250                   ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
251 <                 me.name, source_p->name, dlhost, aconf->host, creason);
251 >                 me.name, source_p->name, dlhost, conf->host, creason);
252      return;
253    }
254  
255    cur_time = CurrentTime;
256    current_date = smalldate(cur_time);
257  
249 –  /* Look for an oper reason */
250 –  if ((oper_reason = strchr(reason, '|')) != NULL)
251 –    *oper_reason++ = '\0';
252 –
258    if (!valid_comment(source_p, reason, 1))
259      return;
260  
261 <  conf = make_conf_item(DLINE_TYPE);
262 <  aconf = map_to_conf(conf);
258 <  DupString(aconf->host, dlhost);
261 >  conf = conf_make(CONF_DLINE);
262 >  DupString(conf->host, dlhost);
263  
264    if (tkline_time != 0)
261 –  {
265      snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
266               (int)(tkline_time/60), reason, current_date);
264 –    DupString(aconf->reason, buffer);
265 –    if (oper_reason != NULL)
266 –      DupString(aconf->oper_reason, oper_reason);
267 –    apply_tdline(source_p, conf, current_date, tkline_time);
268 –  }
267    else
270 –  {
268      snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
272 –    DupString(aconf->reason, buffer);
273 –    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);
277 –  }
269  
270 +  DupString(conf->reason, buffer);
271 +  apply_dline(source_p, conf, tkline_time);
272    rehashed_klines = 1;
273   }
274  
# Line 284 | Line 277 | ms_dline(struct Client *client_p, struct
277           int parc, char *parv[])
278   {
279    char def_reason[] = "<No reason specified>";
280 <  char *dlhost, *oper_reason, *reason;
280 >  char *dlhost, *reason;
281    const char *creason;
282    const struct Client *target_p = NULL;
283    struct irc_ssaddr daddr;
284 <  struct ConfItem *conf=NULL;
292 <  struct AccessItem *aconf=NULL;
284 >  struct MaskItem *conf=NULL;
285    time_t tkline_time=0;
286    int bits, t;
287    const char *current_date = NULL;
# Line 313 | Line 305 | ms_dline(struct Client *client_p, struct
305    dlhost = parv[3];
306    reason = parv[4];
307  
308 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
308 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
309                                source_p->username, source_p->host,
310                                SHARED_DLINE))
311    {
# Line 365 | Line 357 | ms_dline(struct Client *client_p, struct
357  
358      parse_netmask(dlhost, &daddr, NULL);
359  
360 <    if ((aconf = find_dline_conf(&daddr, t)) != NULL)
360 >    if ((conf = find_dline_conf(&daddr, t)) != NULL)
361      {
362 <      creason = aconf->reason ? aconf->reason : def_reason;
363 <      if (IsConfExemptKline(aconf))
362 >      creason = conf->reason ? conf->reason : def_reason;
363 >      if (IsConfExemptKline(conf))
364          sendto_one(source_p,
365                     ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
366 <                   me.name, source_p->name, dlhost, aconf->host, creason);
366 >                   me.name, source_p->name, dlhost, conf->host, creason);
367        else
368          sendto_one(source_p,
369                     ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
370 <                   me.name, source_p->name, dlhost, aconf->host, creason);
370 >                   me.name, source_p->name, dlhost, conf->host, creason);
371        return;
372      }
373  
374      cur_time = CurrentTime;
375      current_date = smalldate(cur_time);
376  
385 –    /* Look for an oper reason */
386 –    if ((oper_reason = strchr(reason, '|')) != NULL)
387 –      *oper_reason++ = '\0';
388 –
377      if (!valid_comment(source_p, reason, 1))
378        return;
379  
380 <    conf = make_conf_item(DLINE_TYPE);
381 <    aconf = map_to_conf(conf);
394 <    DupString(aconf->host, dlhost);
380 >    conf = conf_make(CONF_DLINE);
381 >    DupString(conf->host, dlhost);
382  
383      if (tkline_time != 0)
397 –    {
384        snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
385                 (int)(tkline_time/60), reason, current_date);
400 –      DupString(aconf->reason, buffer);
401 –      if (oper_reason != NULL)
402 –        DupString(aconf->oper_reason, oper_reason);
403 –      apply_tdline(source_p, conf, current_date, tkline_time);
404 –    }
386      else
406 –    {
387        snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
408 –      DupString(aconf->reason, buffer);
409 –      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);
413 –    }
388  
389 +    DupString(conf->reason, buffer);
390 +    apply_dline(source_p, conf, tkline_time);
391      rehashed_klines = 1;
392    }
393   }
# Line 463 | Line 439 | mo_undline(struct Client *client_p, stru
439      cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE,
440                     "%s", addr);
441  
442 <  if (remove_tdline_match(addr))
442 >  if (remove_dline_match(addr))
443    {
444      sendto_one(source_p,
445 <               ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
445 >               ":%s NOTICE %s :D-Line for [%s] is removed",
446                 me.name, source_p->name, addr);
447 <    sendto_realops_flags(UMODE_ALL, L_ALL,
448 <                         "%s has removed the temporary D-Line for: [%s]",
447 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
448 >                         "%s has removed the D-Line for: [%s]",
449                           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,
484 –                         "%s has removed the D-Line for: [%s]",
485 –                         get_oper_name(source_p), addr);
450      ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
451           get_oper_name(source_p), addr);
452    }
# Line 505 | Line 469 | me_undline(struct Client *client_p, stru
469    if (!IsClient(source_p) || !match(parv[1], me.name))
470      return;
471  
472 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE,
472 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE,
473                                     source_p->servptr->name,
474                                     source_p->username, source_p->host,
475                                     SHARED_UNDLINE))
476    {
477 <    if (remove_tdline_match(addr))
477 >    if (remove_dline_match(addr))
478      {
479        sendto_one(source_p,
480 <                 ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
480 >                 ":%s NOTICE %s :D-Line for [%s] is removed",
481                   me.name, source_p->name, addr);
482 <      sendto_realops_flags(UMODE_ALL, L_ALL,
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",
529 <                 me.name, source_p->name, addr);
530 <      sendto_realops_flags(UMODE_ALL, L_ALL,
482 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
483                             "%s has removed the D-Line for: [%s]",
484                             get_oper_name(source_p), addr);
485 <      ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
485 >      ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
486             get_oper_name(source_p), addr);
487      }
488      else

Diff Legend

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