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/trunk/modules/m_dline.c (file contents):
Revision 1622 by michael, Thu Nov 1 13:16:37 2012 UTC vs.
Revision 1793 by michael, Sun Mar 31 14:06:08 2013 UTC

# Line 27 | Line 27
27   #include "channel.h"
28   #include "client.h"
29   #include "irc_string.h"
30 < #include "sprintf_irc.h"
30 > #include "conf.h"
31   #include "ircd.h"
32   #include "hostmask.h"
33   #include "numeric.h"
34   #include "fdlist.h"
35   #include "s_bsd.h"
36 #include "conf.h"
36   #include "log.h"
37   #include "s_misc.h"
38   #include "send.h"
# Line 42 | Line 41
41   #include "parse.h"
42   #include "modules.h"
43   #include "conf_db.h"
44 + #include "memory.h"
45  
46  
47   /* apply_tdline()
# Line 51 | Line 51
51   * side effects - tkline as given is placed
52   */
53   static void
54 < apply_dline(struct Client *source_p, struct AccessItem *aconf,
54 > apply_dline(struct Client *source_p, struct MaskItem *conf,
55              time_t tkline_time)
56   {
57    if (tkline_time)
58    {
59 <    aconf->hold = CurrentTime + tkline_time;
60 <    SetConfTemporary(aconf);
59 >    conf->until = 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 <                         aconf->host, aconf->reason);
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, aconf->host);
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, aconf->host, aconf->reason);
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), aconf->host, aconf->reason);
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, aconf->host);
77 >               source_p->name, conf->host);
78      ilog(LOG_TYPE_DLINE, "%s added D-Line for [%s] [%s]",
79 <         get_oper_name(source_p), aconf->host, aconf->reason);
79 >         get_oper_name(source_p), conf->host, conf->reason);
80  
81    }
82  
83 <  aconf->setat = CurrentTime;
84 <  add_conf_by_address(CONF_DLINE, aconf);
85 <  save_dline_database();
83 >  SetConfDatabase(conf);
84 >  conf->setat = CurrentTime;
85 >  add_conf_by_address(CONF_DLINE, conf);
86    rehashed_klines = 1;
87   }
88  
# Line 96 | Line 95 | static int
95   remove_dline_match(const char *host)
96   {
97    struct irc_ssaddr iphost, *piphost;
98 <  struct AccessItem *aconf;
99 <  int t;
98 >  struct MaskItem *conf;
99 >  int t = 0;
100 >  int aftype = 0;
101  
102    if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
103    {
104   #ifdef IPV6
105      if (t == HM_IPV6)
106 <      t = AF_INET6;
106 >      aftype = AF_INET6;
107      else
108   #endif
109 <      t = AF_INET;
109 >      aftype = AF_INET;
110      piphost = &iphost;
111    }
112    else
113  {
114    t = 0;
113      piphost = NULL;
116  }
114  
115 <  if ((aconf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
115 >  if ((conf = find_conf_by_address(host, piphost, CONF_DLINE | 1, aftype, NULL, NULL, 0)))
116    {
117 <    if (!IsConfMain(aconf))
117 >    if (IsConfDatabase(conf))
118      {
119 <      delete_one_address_conf(host, aconf);
123 <      save_dline_database();
119 >      delete_one_address_conf(host, conf);
120        return 1;
121      }
122    }
# Line 148 | Line 144 | mo_dline(struct Client *client_p, struct
144    const char *creason;
145    const struct Client *target_p = NULL;
146    struct irc_ssaddr daddr;
147 <  struct ConfItem *conf=NULL;
152 <  struct AccessItem *aconf=NULL;
147 >  struct MaskItem *conf=NULL;
148    time_t tkline_time=0;
149 <  int bits, t;
149 >  int bits = 0, aftype = 0, t = 0;
150    const char *current_date = NULL;
151    time_t cur_time;
152    char hostip[HOSTIPLEN + 1];
# Line 188 | Line 183 | mo_dline(struct Client *client_p, struct
183                      dlhost, reason);
184  
185      /* Allow ON to apply local kline as well if it matches */
186 <    if (!match(target_server, me.name))
186 >    if (match(target_server, me.name))
187        return;
188    }
189    else
# Line 234 | Line 229 | mo_dline(struct Client *client_p, struct
229  
230   #ifdef IPV6
231    if (t == HM_IPV6)
232 <    t = AF_INET6;
232 >    aftype = AF_INET6;
233    else
234   #endif
235 <    t = AF_INET;
235 >    aftype = AF_INET;
236  
237    parse_netmask(dlhost, &daddr, NULL);
238  
239 <  if ((aconf = find_dline_conf(&daddr, t)) != NULL)
239 >  if ((conf = find_dline_conf(&daddr, aftype)) != NULL)
240    {
241 <    creason = aconf->reason ? aconf->reason : def_reason;
242 <    if (IsConfExemptKline(aconf))
241 >    creason = conf->reason ? conf->reason : def_reason;
242 >    if (IsConfExemptKline(conf))
243        sendto_one(source_p,
244                   ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
245 <                 me.name, source_p->name, dlhost, aconf->host, creason);
245 >                 me.name, source_p->name, dlhost, conf->host, creason);
246      else
247        sendto_one(source_p,
248                   ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
249 <                 me.name, source_p->name, dlhost, aconf->host, creason);
249 >                 me.name, source_p->name, dlhost, conf->host, creason);
250      return;
251    }
252  
# Line 261 | Line 256 | mo_dline(struct Client *client_p, struct
256    if (!valid_comment(source_p, reason, 1))
257      return;
258  
259 <  conf = make_conf_item(DLINE_TYPE);
260 <  aconf = map_to_conf(conf);
266 <  DupString(aconf->host, dlhost);
259 >  conf = conf_make(CONF_DLINE);
260 >  conf->host = xstrdup(dlhost);
261  
262    if (tkline_time != 0)
269  {
263      snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
264               (int)(tkline_time/60), reason, current_date);
272    DupString(aconf->reason, buffer);
273    apply_dline(source_p, aconf, tkline_time);
274  }
265    else
276  {
266      snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
278    DupString(aconf->reason, buffer);
279    apply_dline(source_p, aconf, 0);
280  }
267  
268 +  conf->reason = xstrdup(buffer);
269 +  apply_dline(source_p, conf, tkline_time);
270    rehashed_klines = 1;
271   }
272  
# Line 291 | Line 279 | ms_dline(struct Client *client_p, struct
279    const char *creason;
280    const struct Client *target_p = NULL;
281    struct irc_ssaddr daddr;
282 <  struct ConfItem *conf=NULL;
295 <  struct AccessItem *aconf=NULL;
282 >  struct MaskItem *conf=NULL;
283    time_t tkline_time=0;
284 <  int bits, t;
284 >  int bits = 0, aftype = 0, t = 0;
285    const char *current_date = NULL;
286    time_t cur_time;
287    char hostip[HOSTIPLEN + 1];
# Line 309 | Line 296 | ms_dline(struct Client *client_p, struct
296                       "DLINE %s %s %s :%s",
297                       parv[1], parv[2], parv[3], parv[4]);
298  
299 <  if (!match(parv[1], me.name))
299 >  if (match(parv[1], me.name))
300      return;
301  
302    tkline_time = valid_tkline(parv[2], TK_SECONDS);
303    dlhost = parv[3];
304    reason = parv[4];
305  
306 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
306 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
307                                source_p->username, source_p->host,
308                                SHARED_DLINE))
309    {
# Line 361 | Line 348 | ms_dline(struct Client *client_p, struct
348  
349   #ifdef IPV6
350      if (t == HM_IPV6)
351 <      t = AF_INET6;
351 >      aftype= AF_INET6;
352      else
353   #endif
354 <      t = AF_INET;
354 >      aftype = AF_INET;
355  
356      parse_netmask(dlhost, &daddr, NULL);
357  
358 <    if ((aconf = find_dline_conf(&daddr, t)) != NULL)
358 >    if ((conf = find_dline_conf(&daddr, aftype)) != NULL)
359      {
360 <      creason = aconf->reason ? aconf->reason : def_reason;
361 <      if (IsConfExemptKline(aconf))
360 >      creason = conf->reason ? conf->reason : def_reason;
361 >      if (IsConfExemptKline(conf))
362          sendto_one(source_p,
363                     ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
364 <                   me.name, source_p->name, dlhost, aconf->host, creason);
364 >                   me.name, source_p->name, dlhost, conf->host, creason);
365        else
366          sendto_one(source_p,
367                     ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
368 <                   me.name, source_p->name, dlhost, aconf->host, creason);
368 >                   me.name, source_p->name, dlhost, conf->host, creason);
369        return;
370      }
371  
# Line 388 | Line 375 | ms_dline(struct Client *client_p, struct
375      if (!valid_comment(source_p, reason, 1))
376        return;
377  
378 <    conf = make_conf_item(DLINE_TYPE);
379 <    aconf = map_to_conf(conf);
393 <    DupString(aconf->host, dlhost);
378 >    conf = conf_make(CONF_DLINE);
379 >    conf->host = xstrdup(dlhost);
380  
381      if (tkline_time != 0)
396    {
382        snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
383                 (int)(tkline_time/60), reason, current_date);
399      DupString(aconf->reason, buffer);
400      apply_dline(source_p, aconf, tkline_time);
401    }
384      else
403    {
385        snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
405      DupString(aconf->reason, buffer);
406      apply_dline(source_p, aconf, 0);
407    }
386  
387 +    conf->reason = xstrdup(buffer);
388 +    apply_dline(source_p, conf, tkline_time);
389      rehashed_klines = 1;
390    }
391   }
# Line 450 | Line 430 | mo_undline(struct Client *client_p, stru
430                         "UNDLINE %s %s", target_server, addr);
431  
432      /* Allow ON to apply local unkline as well if it matches */
433 <    if (!match(target_server, me.name))
433 >    if (match(target_server, me.name))
434        return;
435    }
436    else
# Line 484 | Line 464 | me_undline(struct Client *client_p, stru
464  
465    addr = parv[2];
466  
467 <  if (!IsClient(source_p) || !match(parv[1], me.name))
467 >  if (!IsClient(source_p) || match(parv[1], me.name))
468      return;
469  
470 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE,
470 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE,
471                                     source_p->servptr->name,
472                                     source_p->username, source_p->host,
473                                     SHARED_UNDLINE))
# Line 517 | Line 497 | ms_undline(struct Client *client_p, stru
497      return;
498  
499    sendto_match_servs(source_p, parv[1], CAP_UNDLN,
500 <                     "UNDLINE %s %s %s",
500 >                     "UNDLINE %s %s",
501                       parv[1], parv[2]);
502  
503    me_undline(client_p, source_p, parc, parv);

Diff Legend

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