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 1628 by michael, Thu Nov 1 21:08:56 2012 UTC vs.
Revision 1703 by michael, Sun Dec 23 14:26:36 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"
# Line 42 | Line 42
42   #include "parse.h"
43   #include "modules.h"
44   #include "conf_db.h"
45 + #include "memory.h"
46  
47  
48   /* apply_tdline()
# Line 51 | Line 52
52   * side effects - tkline as given is placed
53   */
54   static void
55 < apply_dline(struct Client *source_p, struct AccessItem *aconf,
55 > apply_dline(struct Client *source_p, struct MaskItem *conf,
56              time_t tkline_time)
57   {
58    if (tkline_time)
59    {
60 <    aconf->hold = CurrentTime + tkline_time;
60 >    conf->until = CurrentTime + tkline_time;
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);
64 >                         conf->host, conf->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);
67 >               source_p->name, tkline_time/60, conf->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);
69 >         get_oper_name(source_p), tkline_time/60, conf->host, conf->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);
75 >                         get_oper_name(source_p), conf->host, conf->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);
78 >               source_p->name, conf->host);
79      ilog(LOG_TYPE_DLINE, "%s added D-Line for [%s] [%s]",
80 <         get_oper_name(source_p), aconf->host, aconf->reason);
80 >         get_oper_name(source_p), conf->host, conf->reason);
81  
82    }
83  
84 <  SetConfDatabase(aconf);
85 <  aconf->setat = CurrentTime;
86 <  add_conf_by_address(CONF_DLINE, aconf);
84 >  SetConfDatabase(conf);
85 >  conf->setat = CurrentTime;
86 >  add_conf_by_address(CONF_DLINE, conf);
87    rehashed_klines = 1;
88   }
89  
# Line 95 | Line 96 | static int
96   remove_dline_match(const char *host)
97   {
98    struct irc_ssaddr iphost, *piphost;
99 <  struct AccessItem *aconf;
100 <  int t;
99 >  struct MaskItem *conf;
100 >  int t = 0;
101 >  int aftype = 0;
102  
103    if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
104    {
105   #ifdef IPV6
106      if (t == HM_IPV6)
107 <      t = AF_INET6;
107 >      aftype = AF_INET6;
108      else
109   #endif
110 <      t = AF_INET;
110 >      aftype = AF_INET;
111      piphost = &iphost;
112    }
113    else
112  {
113    t = 0;
114      piphost = NULL;
115  }
115  
116 <  if ((aconf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
116 >  if ((conf = find_conf_by_address(host, piphost, CONF_DLINE | 1, aftype, NULL, NULL, 0)))
117    {
118 <    if (IsConfDatabase(aconf))
118 >    if (IsConfDatabase(conf))
119      {
120 <      delete_one_address_conf(host, aconf);
120 >      delete_one_address_conf(host, conf);
121        return 1;
122      }
123    }
# Line 146 | Line 145 | mo_dline(struct Client *client_p, struct
145    const char *creason;
146    const struct Client *target_p = NULL;
147    struct irc_ssaddr daddr;
148 <  struct AccessItem *aconf=NULL;
148 >  struct MaskItem *conf=NULL;
149    time_t tkline_time=0;
150 <  int bits, t;
150 >  int bits = 0, aftype = 0, t = 0;
151    const char *current_date = NULL;
152    time_t cur_time;
153    char hostip[HOSTIPLEN + 1];
# Line 185 | Line 184 | mo_dline(struct Client *client_p, struct
184                      dlhost, reason);
185  
186      /* Allow ON to apply local kline as well if it matches */
187 <    if (!match(target_server, me.name))
187 >    if (match(target_server, me.name))
188        return;
189    }
190    else
# Line 231 | Line 230 | mo_dline(struct Client *client_p, struct
230  
231   #ifdef IPV6
232    if (t == HM_IPV6)
233 <    t = AF_INET6;
233 >    aftype = AF_INET6;
234    else
235   #endif
236 <    t = AF_INET;
236 >    aftype = AF_INET;
237  
238    parse_netmask(dlhost, &daddr, NULL);
239  
240 <  if ((aconf = find_dline_conf(&daddr, t)) != NULL)
240 >  if ((conf = find_dline_conf(&daddr, aftype)) != NULL)
241    {
242 <    creason = aconf->reason ? aconf->reason : def_reason;
243 <    if (IsConfExemptKline(aconf))
242 >    creason = conf->reason ? conf->reason : def_reason;
243 >    if (IsConfExemptKline(conf))
244        sendto_one(source_p,
245                   ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
246 <                 me.name, source_p->name, dlhost, aconf->host, creason);
246 >                 me.name, source_p->name, dlhost, conf->host, creason);
247      else
248        sendto_one(source_p,
249                   ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
250 <                 me.name, source_p->name, dlhost, aconf->host, creason);
250 >                 me.name, source_p->name, dlhost, conf->host, creason);
251      return;
252    }
253  
# Line 258 | Line 257 | mo_dline(struct Client *client_p, struct
257    if (!valid_comment(source_p, reason, 1))
258      return;
259  
260 <  aconf = map_to_conf(make_conf_item(DLINE_TYPE));
261 <  DupString(aconf->host, dlhost);
260 >  conf = conf_make(CONF_DLINE);
261 >  conf->host = xstrdup(dlhost);
262  
263    if (tkline_time != 0)
264      snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
# Line 267 | Line 266 | mo_dline(struct Client *client_p, struct
266    else
267      snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
268  
269 <  DupString(aconf->reason, buffer);
270 <  apply_dline(source_p, aconf, tkline_time);
269 >  conf->reason = xstrdup(buffer);
270 >  apply_dline(source_p, conf, tkline_time);
271    rehashed_klines = 1;
272   }
273  
# Line 281 | Line 280 | ms_dline(struct Client *client_p, struct
280    const char *creason;
281    const struct Client *target_p = NULL;
282    struct irc_ssaddr daddr;
283 <  struct AccessItem *aconf=NULL;
283 >  struct MaskItem *conf=NULL;
284    time_t tkline_time=0;
285 <  int bits, t;
285 >  int bits = 0, aftype = 0, t = 0;
286    const char *current_date = NULL;
287    time_t cur_time;
288    char hostip[HOSTIPLEN + 1];
# Line 298 | Line 297 | ms_dline(struct Client *client_p, struct
297                       "DLINE %s %s %s :%s",
298                       parv[1], parv[2], parv[3], parv[4]);
299  
300 <  if (!match(parv[1], me.name))
300 >  if (match(parv[1], me.name))
301      return;
302  
303    tkline_time = valid_tkline(parv[2], TK_SECONDS);
304    dlhost = parv[3];
305    reason = parv[4];
306  
307 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
307 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
308                                source_p->username, source_p->host,
309                                SHARED_DLINE))
310    {
# Line 350 | Line 349 | ms_dline(struct Client *client_p, struct
349  
350   #ifdef IPV6
351      if (t == HM_IPV6)
352 <      t = AF_INET6;
352 >      aftype= AF_INET6;
353      else
354   #endif
355 <      t = AF_INET;
355 >      aftype = AF_INET;
356  
357      parse_netmask(dlhost, &daddr, NULL);
358  
359 <    if ((aconf = find_dline_conf(&daddr, t)) != NULL)
359 >    if ((conf = find_dline_conf(&daddr, aftype)) != NULL)
360      {
361 <      creason = aconf->reason ? aconf->reason : def_reason;
362 <      if (IsConfExemptKline(aconf))
361 >      creason = conf->reason ? conf->reason : def_reason;
362 >      if (IsConfExemptKline(conf))
363          sendto_one(source_p,
364                     ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
365 <                   me.name, source_p->name, dlhost, aconf->host, creason);
365 >                   me.name, source_p->name, dlhost, conf->host, creason);
366        else
367          sendto_one(source_p,
368                     ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
369 <                   me.name, source_p->name, dlhost, aconf->host, creason);
369 >                   me.name, source_p->name, dlhost, conf->host, creason);
370        return;
371      }
372  
# Line 377 | Line 376 | ms_dline(struct Client *client_p, struct
376      if (!valid_comment(source_p, reason, 1))
377        return;
378  
379 <    aconf = map_to_conf(make_conf_item(DLINE_TYPE));
380 <    DupString(aconf->host, dlhost);
379 >    conf = conf_make(CONF_DLINE);
380 >    conf->host = xstrdup(dlhost);
381  
382      if (tkline_time != 0)
383        snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
# Line 386 | Line 385 | ms_dline(struct Client *client_p, struct
385      else
386        snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
387  
388 <    DupString(aconf->reason, buffer);
389 <    apply_dline(source_p, aconf, tkline_time);
388 >    conf->reason = xstrdup(buffer);
389 >    apply_dline(source_p, conf, tkline_time);
390      rehashed_klines = 1;
391    }
392   }
# Line 432 | Line 431 | mo_undline(struct Client *client_p, stru
431                         "UNDLINE %s %s", target_server, addr);
432  
433      /* Allow ON to apply local unkline as well if it matches */
434 <    if (!match(target_server, me.name))
434 >    if (match(target_server, me.name))
435        return;
436    }
437    else
# Line 466 | Line 465 | me_undline(struct Client *client_p, stru
465  
466    addr = parv[2];
467  
468 <  if (!IsClient(source_p) || !match(parv[1], me.name))
468 >  if (!IsClient(source_p) || match(parv[1], me.name))
469      return;
470  
471 <  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(ULINE_TYPE,
471 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE,
472                                     source_p->servptr->name,
473                                     source_p->username, source_p->host,
474                                     SHARED_UNDLINE))

Diff Legend

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