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

Comparing:
ircd-hybrid-8/modules/m_xline.c (file contents), Revision 1219 by michael, Sun Sep 18 09:02:38 2011 UTC vs.
ircd-hybrid/trunk/modules/m_xline.c (file contents), Revision 1632 by michael, Sun Nov 4 15:37:10 2012 UTC

# Line 26 | Line 26
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 "conf.h"
33   #include "hostmask.h"
34   #include "numeric.h"
35   #include "fdlist.h"
36   #include "s_bsd.h"
37 < #include "s_conf.h"
38 < #include "s_log.h"
37 > #include "log.h"
38   #include "s_misc.h"
39   #include "send.h"
40   #include "hash.h"
42 #include "handlers.h"
41   #include "s_serv.h"
44 #include "msg.h"
42   #include "parse.h"
43   #include "modules.h"
44   #include "resv.h"
45 + #include "conf_db.h"
46  
49 static void mo_xline(struct Client *, struct Client *, int, char *[]);
50 static void ms_xline(struct Client *, struct Client *, int, char *[]);
51 static void me_xline(struct Client *, struct Client *, int, char *[]);
52
53 static void mo_unxline(struct Client *, struct Client *, int, char *[]);
54 static void ms_unxline(struct Client *, struct Client *, int, char *[]);
47  
48   static int valid_xline(struct Client *, char *, char *, int);
49   static void write_xline(struct Client *, char *, char *, time_t);
50   static void remove_xline(struct Client *, char *);
51 < static int remove_txline_match(const char *);
51 > static int remove_xline_match(const char *);
52  
53   static void relay_xline(struct Client *, char *[]);
54  
63 struct Message xline_msgtab = {
64  "XLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
65  { m_unregistered, m_not_oper, ms_xline, me_xline, mo_xline, m_ignore }
66 };
67
68 struct Message unxline_msgtab = {
69  "UNXLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
70  { m_unregistered, m_not_oper, ms_unxline, m_ignore, mo_unxline, m_ignore }
71 };
72
73 void
74 _modinit(void)
75 {
76  mod_add_cmd(&xline_msgtab);
77  mod_add_cmd(&unxline_msgtab);
78 }
79
80 void
81 _moddeinit(void)
82 {
83  mod_del_cmd(&xline_msgtab);
84  mod_del_cmd(&unxline_msgtab);
85 }
86
87 const char *_version = "$Revision$";
88
89
55   /* mo_xline()
56   *
57   * inputs       - pointer to server
# Line 103 | Line 68 | mo_xline(struct Client *client_p, struct
68   {
69    char *reason = NULL;
70    char *gecos = NULL;
71 <  struct ConfItem *conf = NULL;
107 <  struct MatchItem *match_item = NULL;
71 >  struct MaskItem *conf = NULL;
72    char *target_server = NULL;
73    time_t tkline_time = 0;
74  
# Line 152 | Line 116 | mo_xline(struct Client *client_p, struct
116    if (!valid_xline(source_p, gecos, reason, 0))
117      return;
118  
119 <  if ((conf = find_matching_name_conf(XLINE_TYPE, gecos,
119 >  if ((conf = find_matching_name_conf(CONF_XLINE, gecos,
120                                        NULL, NULL, 0)) != NULL)
121    {
158    match_item = map_to_conf(conf);
159
122      sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s",
123                 me.name, source_p->name, gecos,
124 <               conf->name, match_item->reason);
124 >               conf->name, conf->reason);
125      return;
126    }
127  
# Line 219 | Line 181 | me_xline(struct Client *client_p, struct
181   static void
182   relay_xline(struct Client *source_p, char *parv[])
183   {
184 <  struct ConfItem *conf;
223 <  struct MatchItem *match_item;
184 >  struct MaskItem *conf = NULL;
185    int t_sec;
186  
187    t_sec = atoi(parv[3]);
# Line 235 | Line 196 | relay_xline(struct Client *source_p, cha
196    if (!match(parv[1], me.name))
197      return;
198  
199 <  if (find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
199 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
200                                source_p->username, source_p->host,
201                                SHARED_XLINE))
202    {
203 <    if ((conf = find_matching_name_conf(XLINE_TYPE, parv[2],
203 >    if ((conf = find_matching_name_conf(CONF_XLINE, parv[2],
204                                          NULL, NULL, 0)) != NULL)
205      {
245      match_item = map_to_conf(conf);
206        sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s",
207                   ID_or_name(&me, source_p->from),
208                   ID_or_name(source_p, source_p->from),
209 <                 parv[2], conf->name, match_item->reason);
209 >                 parv[2], conf->name, conf->reason);
210        return;
211      }
212  
# Line 320 | Line 280 | ms_unxline(struct Client *client_p, stru
280    if (!match(parv[1], me.name))
281      return;
282  
283 <  if (find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
283 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
284                                source_p->username, source_p->host,
285                                SHARED_UNXLINE))
286      remove_xline(source_p, parv[2]);
# Line 343 | Line 303 | valid_xline(struct Client *source_p, cha
303      return 0;
304    }
305  
346  if (strchr(gecos, '"'))
347  {
348    sendto_one(source_p, ":%s NOTICE %s :Invalid character '\"'",
349               me.name, source_p->name);
350    return 0;
351  }
352
306    if (!valid_wild_card_simple(gecos))
307    {
308      if (warn)
# Line 372 | Line 325 | static void
325   write_xline(struct Client *source_p, char *gecos, char *reason,
326              time_t tkline_time)
327   {
328 <  struct ConfItem *conf;
376 <  struct MatchItem *match_item;
328 >  struct MaskItem *conf;
329    const char *current_date;
330    time_t cur_time;
331  
332 <  conf = make_conf_item(XLINE_TYPE);
381 <  match_item = map_to_conf(conf);
332 >  conf = conf_make(CONF_XLINE);
333  
334    collapse(gecos);
335    DupString(conf->name, gecos);
336 <  DupString(match_item->reason, reason);
386 <  DupString(match_item->oper_reason, "");       /* XXX */
336 >  DupString(conf->reason, reason);
337    cur_time = CurrentTime;
338    current_date = smalldate(cur_time);
339 +  conf->setat = CurrentTime;
340 +
341 +  SetConfDatabase(conf);
342  
343    if (tkline_time != 0)
344    {
345 <    sendto_realops_flags(UMODE_ALL, L_ALL,
345 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
346                           "%s added temporary %d min. X-Line for [%s] [%s]",
347                           get_oper_name(source_p), (int)tkline_time/60,
348 <                         conf->name, match_item->reason);
348 >                         conf->name, conf->reason);
349      sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. X-Line [%s]",
350                 MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
351                 source_p->name, (int)tkline_time/60, conf->name);
352 <    ilog(L_TRACE, "%s added temporary %d min. X-Line for [%s] [%s]",
352 >    ilog(LOG_TYPE_KLINE, "%s added temporary %d min. X-Line for [%s] [%s]",
353           source_p->name, (int)tkline_time/60,
354 <         conf->name, match_item->reason);
355 <    match_item->hold = CurrentTime + tkline_time;
403 <    add_temp_line(conf);
354 >         conf->name, conf->reason);
355 >    conf->hold = CurrentTime + tkline_time;
356    }
357    else
358 <    write_conf_line(source_p, conf, current_date, cur_time);
358 >  {
359 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
360 >                         "%s added X-Line for [%s] [%s]",
361 >                         get_oper_name(source_p), conf->name,
362 >                         conf->reason);
363 >    sendto_one(source_p,
364 >               ":%s NOTICE %s :Added X-Line [%s] [%d] [%s]",
365 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
366 >               source_p->name, conf->name,
367 >               conf->action, conf->reason);
368 >    ilog(LOG_TYPE_IRCD, "%s added X-Line for [%s] [%s]",
369 >         get_oper_name(source_p), conf->name, conf->reason);
370 >  }
371 >
372    rehashed_klines = 1;
373   }
374  
375   static void
376   remove_xline(struct Client *source_p, char *gecos)
377   {
378 <  /* XXX use common temporary un function later */
414 <  if (remove_txline_match(gecos))
378 >  if (remove_xline_match(gecos))
379    {
380      sendto_one(source_p,
381 <               ":%s NOTICE %s :Un-xlined [%s] from temporary X-Lines",
381 >               ":%s NOTICE %s :X-Line for [%s] is removed",
382                 me.name, source_p->name, gecos);
383 <    sendto_realops_flags(UMODE_ALL, L_ALL,
420 <                         "%s has removed the temporary X-Line for: [%s]",
421 <                         get_oper_name(source_p), gecos);
422 <    ilog(L_NOTICE, "%s removed temporary X-Line for [%s]",
423 <         source_p->name, gecos);
424 <    return;
425 <  }
426 <
427 <  if (remove_conf_line(XLINE_TYPE, source_p, gecos, NULL) > 0)
428 <  {
429 <    sendto_one(source_p, ":%s NOTICE %s :X-Line for [%s] is removed",
430 <               me.name, source_p->name, gecos);
431 <    sendto_realops_flags(UMODE_ALL, L_ALL,
383 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
384                           "%s has removed the X-Line for: [%s]",
385                           get_oper_name(source_p), gecos);
386 <    ilog(L_NOTICE, "%s removed X-Line for [%s]",
387 <         get_oper_name(source_p), gecos);
386 >    ilog(LOG_TYPE_KLINE, "%s removed X-Line for [%s]",
387 >         source_p->name, gecos);
388    }
389    else
390      sendto_one(source_p, ":%s NOTICE %s :No X-Line for %s",
# Line 446 | Line 398 | remove_xline(struct Client *source_p, ch
398   * Side effects: Any matching tklines are removed.
399   */
400   static int
401 < remove_txline_match(const char *gecos)
401 > remove_xline_match(const char *gecos)
402   {
403    dlink_node *ptr = NULL, *next_ptr = NULL;
452  struct ConfItem *conf = NULL;
404  
405 <  DLINK_FOREACH_SAFE(ptr, next_ptr, temporary_xlines.head)
405 >  DLINK_FOREACH_SAFE(ptr, next_ptr, xconf_items.head)
406    {
407 <    conf = ptr->data;
407 >    struct MaskItem *conf = ptr->data;
408  
409 <    if (irccmp(gecos, conf->name) == 0)
410 <    {
460 <      dlinkDelete(ptr, &temporary_xlines);
461 <      free_dlink_node(ptr);
462 <      delete_conf_item(conf);
409 >    if (!IsConfDatabase(conf))
410 >      continue;
411  
412 +    if (!irccmp(gecos, conf->name))
413 +    {
414 +      conf_free(conf);
415        return 1;
416      }
417    }
418  
419    return 0;
420   }
421 +
422 + static struct Message xline_msgtab = {
423 +  "XLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
424 +  { m_unregistered, m_not_oper, ms_xline, me_xline, mo_xline, m_ignore }
425 + };
426 +
427 + static struct Message unxline_msgtab = {
428 +  "UNXLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
429 +  { m_unregistered, m_not_oper, ms_unxline, m_ignore, mo_unxline, m_ignore }
430 + };
431 +
432 + static void
433 + module_init(void)
434 + {
435 +  mod_add_cmd(&xline_msgtab);
436 +  mod_add_cmd(&unxline_msgtab);
437 + }
438 +
439 + static void
440 + module_exit(void)
441 + {
442 +  mod_del_cmd(&xline_msgtab);
443 +  mod_del_cmd(&unxline_msgtab);
444 + }
445 +
446 + struct module module_entry = {
447 +  .node    = { NULL, NULL, NULL },
448 +  .name    = NULL,
449 +  .version = "$Revision$",
450 +  .handle  = NULL,
451 +  .modinit = module_init,
452 +  .modexit = module_exit,
453 +  .flags   = 0
454 + };

Diff Legend

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