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

Comparing:
ircd-hybrid-7.3/modules/m_kline.c (file contents), Revision 1029 by michael, Sun Nov 8 13:10:50 2009 UTC vs.
ircd-hybrid/trunk/modules/m_kline.c (file contents), Revision 1644 by michael, Tue Nov 6 22:20:16 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 "s_gline.h"
43   #include "parse.h"
44   #include "modules.h"
45 < #include "irc_getnameinfo.h"
45 > #include "conf_db.h"
46  
47  
51 – static void me_kline(struct Client *, struct Client *, int, char **);
52 – static void mo_kline(struct Client *, struct Client *, int, char **);
53 – static void ms_kline(struct Client *, struct Client *, int, char **);
54 – static void mo_dline(struct Client *, struct Client *, int, char **);
55 – static void me_unkline(struct Client *, struct Client *, int, char **);
56 – static void mo_unkline(struct Client *, struct Client *, int, char **);
57 – static void ms_unkline(struct Client *, struct Client *, int, char **);
58 – static void mo_undline(struct Client *, struct Client *, int, char **);
59 –
60 – static int remove_tkline_match(const char *, const char *);
61 – static int remove_tdline_match(const char *);
62 –
63 – struct Message kline_msgtab = {
64 –  "KLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
65 –   {m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore}
66 – };
67 –
68 – struct Message dline_msgtab = {
69 –  "DLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
70 –   {m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_dline, m_ignore}
71 – };
72 –
73 – struct Message unkline_msgtab = {
74 –  "UNKLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
75 –   {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore}
76 – };
77 –
78 – struct Message undline_msgtab = {
79 –  "UNDLINE", 0, 0, 2, 0, MFLG_SLOW, 0,
80 –   {m_unregistered, m_not_oper, rfc1459_command_send_error, m_ignore, mo_undline, m_ignore}
81 – };
82 –
83 – #ifndef STATIC_MODULES
84 – void
85 – _modinit(void)
86 – {
87 –  mod_add_cmd(&kline_msgtab);
88 –  mod_add_cmd(&unkline_msgtab);
89 –  mod_add_cmd(&dline_msgtab);
90 –  mod_add_cmd(&undline_msgtab);
91 –  add_capability("KLN", CAP_KLN, 1);
92 –  add_capability("UNKLN", CAP_UNKLN, 1);
93 – }
94 –
95 – void
96 – _moddeinit(void)
97 – {
98 –  mod_del_cmd(&kline_msgtab);
99 –  mod_del_cmd(&unkline_msgtab);
100 –  mod_del_cmd(&dline_msgtab);
101 –  mod_del_cmd(&undline_msgtab);
102 –  delete_capability("UNKLN");
103 –  delete_capability("KLN");
104 – }
105 –
106 – const char *_version = "$Revision$";
107 – #endif
108 –
109 – /* Local function prototypes */
48   static int already_placed_kline(struct Client *, const char *, const char *, int);
49 < static void apply_kline(struct Client *, struct ConfItem *, const char *, time_t);
112 < static void apply_tkline(struct Client *, struct ConfItem *, int);
49 > static void m_kline_add_kline(struct Client *, struct MaskItem *, time_t);
50  
51   static char buffer[IRCD_BUFSIZE];
52 + static int remove_kline_match(const char *, const char *);
53 +
54  
55   /* mo_kline()
56   *
# Line 124 | Line 63 | static char buffer[IRCD_BUFSIZE];
63   */
64   static void
65   mo_kline(struct Client *client_p, struct Client *source_p,
66 <         int parc, char **parv)
66 >         int parc, char *parv[])
67   {
68    char *reason = NULL;
130 –  char *oper_reason;
69    char *user = NULL;
70    char *host = NULL;
71    const char *current_date;
72    char *target_server = NULL;
73 <  struct ConfItem *conf;
136 <  struct AccessItem *aconf;
73 >  struct MaskItem *conf;
74    time_t tkline_time = 0;
75    time_t cur_time;
76  
77 <  if (!IsOperK(source_p))
77 >  if (!HasOFlag(source_p, OPER_FLAG_K))
78    {
79      sendto_one(source_p, form_str(ERR_NOPRIVS),
80                 me.name, source_p->name, "kline");
# Line 152 | Line 89 | mo_kline(struct Client *client_p, struct
89    {
90      if (HasID(source_p))
91      {
92 <      sendto_server(NULL, NULL, CAP_KLN|CAP_TS6, NOCAPS,
92 >      sendto_server(NULL, CAP_KLN|CAP_TS6, NOCAPS,
93                      ":%s KLINE %s %lu %s %s :%s",
94                      source_p->id, target_server, (unsigned long)tkline_time,
95                      user, host, reason);
96 <      sendto_server(NULL, NULL, CAP_KLN, CAP_TS6,
96 >      sendto_server(NULL, CAP_KLN, CAP_TS6,
97                      ":%s KLINE %s %lu %s %s :%s",
98                      source_p->name, target_server, (unsigned long)tkline_time,
99                      user, host, reason);
100      }
101      else
102 <      sendto_server(NULL, NULL, CAP_KLN, NOCAPS,
102 >      sendto_server(NULL, CAP_KLN, NOCAPS,
103                      ":%s KLINE %s %lu %s %s :%s",
104                      source_p->name, target_server, (unsigned long)tkline_time,
105                      user, host, reason);
# Line 173 | Line 110 | mo_kline(struct Client *client_p, struct
110    }
111    else
112      cluster_a_line(source_p, "KLINE", CAP_KLN, SHARED_KLINE,
113 <                   "%d %s %s :%s", tkline_time, user, host, reason);
113 >                   "%d %s %s :%s", tkline_time, user, host, reason);
114  
115 <  if (already_placed_kline(source_p, user, host, YES))
115 >  if (already_placed_kline(source_p, user, host, 1))
116      return;
117  
181 –  /* Look for an oper reason */
182 –  if ((oper_reason = strchr(reason, '|')) != NULL)
183 –    *oper_reason++ = '\0';
184 –
118    cur_time = CurrentTime;
119    current_date = smalldate(cur_time);
120 <  conf = make_conf_item(KLINE_TYPE);
188 <  aconf = map_to_conf(conf);
120 >  conf = conf_make(CONF_KLINE);
121  
122 <  DupString(aconf->host, host);
123 <  DupString(aconf->user, user);
122 >  DupString(conf->host, host);
123 >  DupString(conf->user, user);
124  
125    if (tkline_time != 0)
126 <  {
127 <    ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)",
196 <               (int)(tkline_time/60), reason, current_date);
197 <    DupString(aconf->reason, buffer);
198 <
199 <    if (oper_reason != NULL)
200 <      DupString(aconf->oper_reason, oper_reason);
201 <    apply_tkline(source_p, conf, tkline_time);
202 <  }
126 >    snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)",
127 >             (int)(tkline_time/60), reason, current_date);
128    else
129 <  {
205 <    ircsprintf(buffer, "%s (%s)", reason, current_date);
206 <    DupString(aconf->reason, buffer);
129 >    snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
130  
131 <    if (oper_reason != NULL)
132 <      DupString(aconf->oper_reason, oper_reason);
210 <    apply_kline(source_p, conf, current_date, cur_time);
211 <  }
131 >  DupString(conf->reason, buffer);
132 >  m_kline_add_kline(source_p, conf, tkline_time);
133   }
134  
135   /* me_kline - handle remote kline. no propagation */
# Line 216 | Line 137 | static void
137   me_kline(struct Client *client_p, struct Client *source_p,
138           int parc, char *parv[])
139   {
140 <  struct ConfItem *conf=NULL;
141 <  struct AccessItem *aconf=NULL;
221 <  int tkline_time;
140 >  struct MaskItem *conf = NULL;
141 >  int tkline_time = 0;
142    const char* current_date;
143    time_t cur_time;
144 <  char *kuser, *khost, *kreason, *oper_reason;
144 >  char *kuser, *khost, *kreason;
145  
146    if (parc != 6 || EmptyString(parv[5]))
147      return;
# Line 234 | Line 154 | me_kline(struct Client *client_p, struct
154    khost = parv[4];
155    kreason = parv[5];
156  
237 –  if ((oper_reason = strchr(kreason, '|')) != NULL)
238 –    *oper_reason++ = '\0';
239 –
157    cur_time = CurrentTime;
158    current_date = smalldate(cur_time);
159  
160 <  if (find_matching_name_conf(ULINE_TYPE, source_p->servptr->name,
160 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
161                                source_p->username, source_p->host,
162                                SHARED_KLINE))
163    {
164      if (!IsClient(source_p) ||
165 <        already_placed_kline(source_p, kuser, khost, YES))
165 >        already_placed_kline(source_p, kuser, khost, 1))
166        return;
167  
168 <    conf = make_conf_item(KLINE_TYPE);
169 <    aconf = map_to_conf(conf);
170 <    DupString(aconf->host, khost);
254 <    DupString(aconf->user, kuser);
168 >    conf = conf_make(CONF_KLINE);
169 >    DupString(conf->host, khost);
170 >    DupString(conf->user, kuser);
171  
172      if (tkline_time != 0)
173 <    {
174 <      ircsprintf(buffer, "Temporary K-line %d min. - %s (%s)",
259 <                 (int)(tkline_time/60), kreason, current_date);
260 <      DupString(aconf->reason, buffer);
261 <
262 <      if (oper_reason != NULL)
263 <        DupString(aconf->oper_reason, oper_reason);
264 <      apply_tkline(source_p, conf, tkline_time);
265 <    }
173 >      snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)",
174 >               (int)(tkline_time/60), kreason, current_date);
175      else
176 <    {
268 <      ircsprintf(buffer, "%s (%s)", kreason, current_date);
269 <      DupString(aconf->reason, buffer);
176 >      snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date);
177  
178 <      if (oper_reason != NULL)
179 <        DupString(aconf->oper_reason, oper_reason);
273 <      apply_kline(source_p, conf, current_date, cur_time);
274 <    }
178 >    DupString(conf->reason, buffer);
179 >    m_kline_add_kline(source_p, conf, tkline_time);
180    }
181   }
182  
183   static void
184   ms_kline(struct Client *client_p, struct Client *source_p,
185 <         int parc, char *parv[])
185 >         int parc, char *parv[])
186   {
187    if (parc != 6 || EmptyString(parv[5]))
188      return;
# Line 291 | Line 196 | ms_kline(struct Client *client_p, struct
196    me_kline(client_p, source_p, parc, parv);
197   }
198  
294 – /* apply_kline()
295 – *
296 – * inputs       -
297 – * output       - NONE
298 – * side effects - kline as given, is added to the hashtable
299 – *                and conf file
300 – */
301 – static void
302 – apply_kline(struct Client *source_p, struct ConfItem *conf,
303 –            const char *current_date, time_t cur_time)
304 – {
305 –  struct AccessItem *aconf = map_to_conf(conf);
306 –
307 –  add_conf_by_address(CONF_KILL, aconf);
308 –  write_conf_line(source_p, conf, current_date, cur_time);
309 –  /* Now, activate kline against current online clients */
310 –  rehashed_klines = 1;
311 – }
312 –
199   /* apply_tkline()
200   *
201   * inputs       -
# Line 317 | Line 203 | apply_kline(struct Client *source_p, str
203   * side effects - tkline as given is placed
204   */
205   static void
206 < apply_tkline(struct Client *source_p, struct ConfItem *conf,
207 <             int tkline_time)
322 < {
323 <  struct AccessItem *aconf;
324 <
325 <  aconf = (struct AccessItem *)map_to_conf(conf);
326 <  aconf->hold = CurrentTime + tkline_time;
327 <  add_temp_line(conf);
328 <  sendto_realops_flags(UMODE_ALL, L_ALL,
329 <                       "%s added temporary %d min. K-Line for [%s@%s] [%s]",
330 <                       get_oper_name(source_p), tkline_time/60,
331 <                       aconf->user, aconf->host,
332 <                       aconf->reason);
333 <  sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
334 <             MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
335 <             source_p->name, tkline_time/60, aconf->user, aconf->host);
336 <  ilog(L_TRACE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
337 <       source_p->name, tkline_time/60,
338 <       aconf->user, aconf->host, aconf->reason);
339 <  log_oper_action(LOG_TEMP_KLINE_TYPE, source_p, "[%s@%s] [%s]\n",
340 <                  aconf->user, aconf->host, aconf->reason);
341 <  rehashed_klines = 1;
342 < }
343 <
344 < /* apply_tdline()
345 < *
346 < * inputs       -
347 < * output       - NONE
348 < * side effects - tkline as given is placed
349 < */
350 < static void
351 < apply_tdline(struct Client *source_p, struct ConfItem *conf,
352 <             const char *current_date, int tkline_time)
206 > m_kline_add_kline(struct Client *source_p, struct MaskItem *conf,
207 >                  time_t tkline_time)
208   {
209 <  struct AccessItem *aconf;
355 <
356 <  aconf = map_to_conf(conf);
357 <  aconf->hold = CurrentTime + tkline_time;
358 <
359 <  add_temp_line(conf);
360 <  sendto_realops_flags(UMODE_ALL, L_ALL,
361 <                       "%s added temporary %d min. D-Line for [%s] [%s]",
362 <                       get_oper_name(source_p), tkline_time/60,
363 <                       aconf->host, aconf->reason);
364 <
365 <  sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
366 <             MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
367 <             source_p->name, tkline_time/60, aconf->host);
368 <  ilog(L_TRACE, "%s added temporary %d min. D-Line for [%s] [%s]",
369 <       source_p->name, tkline_time/60, aconf->host, aconf->reason);
370 <  log_oper_action(LOG_TEMP_DLINE_TYPE, source_p, "[%s@%s] [%s]\n",
371 <                  aconf->user, aconf->host, aconf->reason);
372 <  rehashed_klines = 1;
373 < }
374 <
375 < /* mo_dline()
376 < *
377 < * inputs       - pointer to server
378 < *              - pointer to client
379 < *              - parameter count
380 < *              - parameter list
381 < * output       -
382 < * side effects - D line is added
383 < *
384 < */
385 < static void
386 < mo_dline(struct Client *client_p, struct Client *source_p,
387 <         int parc, char *parv[])
388 < {
389 <  char def_reason[] = "No reason";
390 <  char *dlhost, *oper_reason, *reason;
391 <  const char *creason;
392 <  const struct Client *target_p = NULL;
393 <  struct irc_ssaddr daddr;
394 <  struct ConfItem *conf=NULL;
395 <  struct AccessItem *aconf=NULL;
396 <  time_t tkline_time=0;
397 <  int bits, t;
398 <  const char *current_date = NULL;
399 <  time_t cur_time;
400 <  char hostip[HOSTIPLEN];
401 <
402 <  if (!IsOperK(source_p))
403 <  {
404 <    sendto_one(source_p, form_str(ERR_NOPRIVS),
405 <               me.name, source_p->name, "kline");
406 <    return;
407 <  }
408 <
409 <  if (parse_aline("DLINE", source_p,  parc, parv, AWILD, &dlhost,
410 <                  NULL, &tkline_time, NULL, &reason) < 0)
411 <    return;
412 <
413 <  if ((t = parse_netmask(dlhost, NULL, &bits)) == HM_HOST)
209 >  if (tkline_time)
210    {
211 <    if ((target_p = find_chasing(client_p, source_p, dlhost, NULL)) == NULL)
212 <      return;
213 <
214 <    if (!MyConnect(target_p))
215 <    {
216 <      sendto_one(source_p,
217 <                 ":%s NOTICE %s :Can't DLINE nick on another server",
218 <                 me.name, source_p->name);
219 <      return;
220 <    }
221 <
222 <    if (IsExemptKline(target_p))
427 <    {
428 <      sendto_one(source_p,
429 <                 ":%s NOTICE %s :%s is E-lined", me.name,
430 <                 source_p->name, target_p->name);
431 <      return;
432 <    }
433 <
434 <    irc_getnameinfo((struct sockaddr *)&target_p->localClient->ip,
435 <                    target_p->localClient->ip.ss_len, hostip,
436 <                    sizeof(hostip), NULL, 0, NI_NUMERICHOST);
437 <
438 <    dlhost = hostip;
439 <    t = parse_netmask(dlhost, NULL, &bits);
440 <    assert(t == HM_IPV4 || t == HM_IPV6);
211 >    conf->hold = CurrentTime + tkline_time;
212 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
213 >                         "%s added temporary %d min. K-Line for [%s@%s] [%s]",
214 >                         get_oper_name(source_p), tkline_time/60,
215 >                         conf->user, conf->host,
216 >                         conf->reason);
217 >    sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
218 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
219 >               source_p->name, tkline_time/60, conf->user, conf->host);
220 >    ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
221 >         source_p->name, tkline_time/60,
222 >         conf->user, conf->host, conf->reason);
223    }
442 –
443 –  if (bits < 8)
444 –  {
445 –    sendto_one(source_p,
446 –               ":%s NOTICE %s :For safety, bitmasks less than 8 require conf access.",
447 –               me.name, source_p->name);
448 –    return;
449 –  }
450 –
451 – #ifdef IPV6
452 –  if (t == HM_IPV6)
453 –    t = AF_INET6;
224    else
455 – #endif
456 –    t = AF_INET;
457 –
458 –  parse_netmask(dlhost, &daddr, NULL);
459 –
460 –  if ((aconf = find_dline_conf(&daddr, t)) != NULL)
225    {
226 <    creason = aconf->reason ? aconf->reason : def_reason;
227 <    if (IsConfExemptKline(aconf))
228 <      sendto_one(source_p,
229 <                 ":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
230 <                 me.name, source_p->name, dlhost, aconf->host, creason);
231 <    else
232 <      sendto_one(source_p,
233 <                 ":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
234 <                 me.name, source_p->name, dlhost, aconf->host, creason);
471 <    return;
226 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
227 >                         "%s added K-Line for [%s@%s] [%s]",
228 >                         get_oper_name(source_p),
229 >                         conf->user, conf->host, conf->reason);
230 >    sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
231 >               MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
232 >                 source_p->name, conf->user, conf->host);
233 >    ilog(LOG_TYPE_KLINE, "%s added K-Line for [%s@%s] [%s]",
234 >         source_p->name, conf->user, conf->host, conf->reason);
235    }
236  
237 <  cur_time = CurrentTime;
238 <  current_date = smalldate(cur_time);
476 <
477 <  /* Look for an oper reason */
478 <  if ((oper_reason = strchr(reason, '|')) != NULL)
479 <    *oper_reason++ = '\0';
480 <
481 <  if (!valid_comment(source_p, reason, YES))
482 <    return;
483 <
484 <  conf = make_conf_item(DLINE_TYPE);
485 <  aconf = map_to_conf(conf);
486 <  DupString(aconf->host, dlhost);
487 <
488 <  if (tkline_time != 0)
489 <  {
490 <    ircsprintf(buffer, "Temporary D-line %d min. - %s (%s)",
491 <               (int)(tkline_time/60), reason, current_date);
492 <    DupString(aconf->reason, buffer);
493 <    if (oper_reason != NULL)
494 <      DupString(aconf->oper_reason, oper_reason);
495 <    apply_tdline(source_p, conf, current_date, tkline_time);
496 <  }
497 <  else
498 <  {
499 <    ircsprintf(buffer, "%s (%s)", reason, current_date);
500 <    DupString(aconf->reason, buffer);
501 <    if (oper_reason != NULL)
502 <      DupString(aconf->oper_reason, oper_reason);
503 <    add_conf_by_address(CONF_DLINE, aconf);
504 <    write_conf_line(source_p, conf, current_date, cur_time);
505 <  }
237 >  conf->setat = CurrentTime;
238 >  SetConfDatabase(conf);
239  
240 +  add_conf_by_address(CONF_KLINE, conf);
241    rehashed_klines = 1;
242   }
243  
# Line 522 | Line 256 | already_placed_kline(struct Client *sour
256   {
257    const char *reason;
258    struct irc_ssaddr iphost, *piphost;
259 <  struct AccessItem *aconf;
260 <  int t;
259 >  struct MaskItem *conf = NULL;
260 >  int t = 0;
261 >  int aftype = 0;
262  
263 <  if ((t = parse_netmask(lhost, &iphost, &t)) != HM_HOST)
263 >  if ((t = parse_netmask(lhost, &iphost, NULL)) != HM_HOST)
264    {
265   #ifdef IPV6
266      if (t == HM_IPV6)
267 <      t = AF_INET6;
267 >      aftype = AF_INET6;
268      else
269   #endif
270 <      t = AF_INET;
270 >      aftype = AF_INET;
271      piphost = &iphost;
272    }
273    else
539 –  {
540 –    t = 0;
274      piphost = NULL;
542 –  }
275  
276 <  if ((aconf = find_conf_by_address(lhost, piphost, CONF_KILL, t, luser, NULL)))
276 >  if ((conf = find_conf_by_address(lhost, piphost, CONF_KLINE, aftype, luser, NULL, 0)))
277    {
278      if (warn)
279      {
280 <      reason = aconf->reason ? aconf->reason : "No reason";
280 >      reason = conf->reason ? conf->reason : "No reason";
281        sendto_one(source_p,
282                   ":%s NOTICE %s :[%s@%s] already K-Lined by [%s@%s] - %s",
283 <                 me.name, source_p->name, luser, lhost, aconf->user,
284 <                 aconf->host, reason);
283 >                 me.name, source_p->name, luser, lhost, conf->user,
284 >                 conf->host, reason);
285      }
286 <    return(1);
286 >
287 >    return 1;
288    }
289  
290 <  return(0);
290 >  return 0;
291   }
292  
293   /*
# Line 574 | Line 307 | mo_unkline(struct Client *client_p,struc
307    char *target_server = NULL;
308    char *user, *host;
309  
310 <  if (!IsOperUnkline(source_p))
310 >  if (!HasOFlag(source_p, OPER_FLAG_UNKLINE))
311    {
312      sendto_one(source_p, form_str(ERR_NOPRIVS),
313                 me.name, source_p->name, "unkline");
314      return;
315    }
316  
317 <  if (parc < 2 || EmptyString(parv[1]))
317 >  if (EmptyString(parv[1]))
318    {
319      sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
320                 me.name, source_p->name, "UNKLINE");
# Line 604 | Line 337 | mo_unkline(struct Client *client_p,struc
337    }
338    else
339      cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE,
340 <                   "%s %s", user, host);
340 >                   "%s %s", user, host);
341  
342 <  if (remove_tkline_match(host, user))
342 >  if (remove_kline_match(host, user))
343    {
344      sendto_one(source_p,
345 <               ":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines",
345 >               ":%s NOTICE %s :K-Line for [%s@%s] is removed",
346                 me.name, source_p->name, user, host);
347 <    sendto_realops_flags(UMODE_ALL, L_ALL,
348 <                         "%s has removed the temporary K-Line for: [%s@%s]",
347 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
348 >                         "%s has removed the K-Line for: [%s@%s]",
349                           get_oper_name(source_p), user, host);
350 <    ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
350 >    ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
351           source_p->name, user, host);
619 –    return;
620 –  }
621 –
622 –  if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0)
623 –  {
624 –    sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
625 –               me.name, source_p->name, user,host);
626 –    sendto_realops_flags(UMODE_ALL, L_ALL,
627 –                         "%s has removed the K-Line for: [%s@%s]",
628 –                         get_oper_name(source_p), user, host);
629 –    ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
630 –         source_p->name, user, host);
352    }
353    else
354      sendto_one(source_p, ":%s NOTICE %s :No K-Line for [%s@%s] found",
# Line 659 | Line 380 | me_unkline(struct Client *client_p, stru
380    if (!IsClient(source_p) || !match(parv[1], me.name))
381      return;
382  
383 <  if (find_matching_name_conf(ULINE_TYPE,
383 >  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE,
384                                     source_p->servptr->name,
385                                     source_p->username, source_p->host,
386                                     SHARED_UNKLINE))
387    {
388 <    if (remove_tkline_match(khost, kuser))
388 >    if (remove_kline_match(khost, kuser))
389      {
390        sendto_one(source_p,
391 <                 ":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines",
671 <                 me.name, source_p->name, kuser, khost);
672 <      sendto_realops_flags(UMODE_ALL, L_ALL,  
673 <                           "%s has removed the temporary K-Line for: [%s@%s]",
674 <                           get_oper_name(source_p), kuser, khost);
675 <      ilog(L_NOTICE, "%s removed temporary K-Line for [%s@%s]",
676 <           source_p->name, kuser, khost);
677 <      return;
678 <    }
679 <
680 <    if (remove_conf_line(KLINE_TYPE, source_p, kuser, khost) > 0)
681 <    {
682 <      sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
391 >                 ":%s NOTICE %s :K-Line for [%s@%s] is removed",
392                   me.name, source_p->name, kuser, khost);
393 <      sendto_realops_flags(UMODE_ALL, L_ALL,
393 >      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
394                             "%s has removed the K-Line for: [%s@%s]",
395 <                         get_oper_name(source_p), kuser, khost);
396 <
688 <      ilog(L_NOTICE, "%s removed K-Line for [%s@%s]",
395 >                           get_oper_name(source_p), kuser, khost);
396 >      ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
397             source_p->name, kuser, khost);
398      }
399      else
# Line 715 | Line 423 | ms_unkline(struct Client *client_p, stru
423   * Side effects: Any matching tklines are removed.
424   */
425   static int
426 < remove_tkline_match(const char *host, const char *user)
426 > remove_kline_match(const char *host, const char *user)
427   {
428 <  struct AccessItem *tk_c;
429 <  dlink_node *tk_n;
430 <  struct irc_ssaddr addr, caddr;
431 <  int nm_t, cnm_t, bits, cbits;
432 <  nm_t = parse_netmask(host, &addr, &bits);
433 <
434 <  DLINK_FOREACH(tk_n, temporary_klines.head)
727 <  {
728 <    tk_c = map_to_conf(tk_n->data);
729 <    cnm_t = parse_netmask(tk_c->host, &caddr, &cbits);
730 <    if (cnm_t != nm_t || irccmp(user, tk_c->user))
731 <      continue;
732 <    if ((nm_t==HM_HOST && !irccmp(tk_c->host, host)) ||
733 <        (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
428 >  struct irc_ssaddr iphost, *piphost;
429 >  struct MaskItem *conf;
430 >  int t = 0;
431 >  int aftype = 0;
432 >
433 >  if ((t = parse_netmask(host, &iphost, NULL)) != HM_HOST)
434 >  {
435   #ifdef IPV6
436 <        || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
436 >    if (t == HM_IPV6)
437 >      aftype = AF_INET6;
438 >    else
439   #endif
440 <        )
441 <      {
739 <        dlinkDelete(tk_n, &temporary_klines);
740 <        delete_one_address_conf(tk_c->host, tk_c);
741 <        return(YES);
742 <      }
440 >      aftype = AF_INET;
441 >    piphost = &iphost;
442    }
443 +  else
444 +    piphost = NULL;
445  
446 <  return(NO);
746 < }
747 <
748 < /* static int remove_tdline_match(const char *host, const char *user)
749 < * Input: An ip to undline.
750 < * Output: returns YES on success, NO if no tdline removed.
751 < * Side effects: Any matching tdlines are removed.
752 < */
753 < static int
754 < remove_tdline_match(const char *cidr)
755 < {
756 <  struct AccessItem *td_conf;
757 <  dlink_node *td_node;
758 <  struct irc_ssaddr addr, caddr;
759 <  int nm_t, cnm_t, bits, cbits;
760 <  nm_t = parse_netmask(cidr, &addr, &bits);
761 <
762 <  DLINK_FOREACH(td_node, temporary_dlines.head)
446 >  if ((conf = find_conf_by_address(host, piphost, CONF_KLINE, aftype, user, NULL, 0)))
447    {
448 <    td_conf = map_to_conf(td_node->data);
765 <    cnm_t   = parse_netmask(td_conf->host, &caddr, &cbits);
766 <
767 <    if (cnm_t != nm_t)
768 <      continue;
769 <
770 <    if((nm_t==HM_HOST && !irccmp(td_conf->host, cidr)) ||
771 <       (nm_t==HM_IPV4 && bits==cbits && match_ipv4(&addr, &caddr, bits))
772 < #ifdef IPV6
773 <       || (nm_t==HM_IPV6 && bits==cbits && match_ipv6(&addr, &caddr, bits))
774 < #endif
775 <      )
448 >    if (IsConfDatabase(conf))
449      {
450 <      dlinkDelete(td_node, &temporary_dlines);
451 <      delete_one_address_conf(td_conf->host, td_conf);
779 <      return(YES);
450 >      delete_one_address_conf(host, conf);
451 >      return 1;
452      }
453    }
454  
455 <  return(NO);
455 >  return 0;
456   }
457  
458 < /*
459 < ** m_undline
460 < ** added May 28th 2000 by Toby Verrall <toot@melnet.co.uk>
461 < ** based totally on m_unkline
790 < ** added to hybrid-7 7/11/2000 --is
791 < **
792 < **      parv[0] = sender nick
793 < **      parv[1] = dline to remove
794 < */
795 < static void
796 < mo_undline(struct Client *client_p, struct Client *source_p,
797 <           int parc, char *parv[])
798 < {
799 <  const char  *cidr;
800 <
801 <  if (!IsOperUnkline(source_p))
802 <  {
803 <    sendto_one(source_p, form_str(ERR_NOPRIVS),
804 <               me.name, source_p->name, "undline");
805 <    return;
806 <  }
458 > static struct Message kline_msgtab = {
459 >  "KLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
460 >   {m_unregistered, m_not_oper, ms_kline, me_kline, mo_kline, m_ignore}
461 > };
462  
463 <  cidr = parv[1];
463 > static struct Message unkline_msgtab = {
464 >  "UNKLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
465 >   {m_unregistered, m_not_oper, ms_unkline, me_unkline, mo_unkline, m_ignore}
466 > };
467  
468 <  if (remove_tdline_match(cidr))
469 <  {
470 <    sendto_one(source_p,
471 <              ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
472 <              me.name, source_p->name, cidr);
473 <    sendto_realops_flags(UMODE_ALL, L_ALL,
474 <                         "%s has removed the temporary D-Line for: [%s]",
475 <                         get_oper_name(source_p), cidr);
818 <    ilog(L_NOTICE, "%s removed temporary D-Line for [%s]", source_p->name, cidr);
819 <    return;
820 <  }
468 > static void
469 > module_init(void)
470 > {
471 >  mod_add_cmd(&kline_msgtab);
472 >  mod_add_cmd(&unkline_msgtab);
473 >  add_capability("KLN", CAP_KLN, 1);
474 >  add_capability("UNKLN", CAP_UNKLN, 1);
475 > }
476  
477 <  if (remove_conf_line(DLINE_TYPE, source_p, cidr, NULL) > 0)
478 <  {
479 <    sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
480 <               me.name, source_p->name, cidr);
481 <    sendto_realops_flags(UMODE_ALL, L_ALL,
482 <                         "%s has removed the D-Line for: [%s]",
483 <                         get_oper_name(source_p), cidr);
829 <    ilog(L_NOTICE, "%s removed D-Line for [%s]",
830 <         get_oper_name(source_p), cidr);
831 <  }
832 <  else
833 <    sendto_one(source_p, ":%s NOTICE %s :No D-Line for [%s] found",
834 <               me.name, source_p->name, cidr);
477 > static void
478 > module_exit(void)
479 > {
480 >  mod_del_cmd(&kline_msgtab);
481 >  mod_del_cmd(&unkline_msgtab);
482 >  delete_capability("UNKLN");
483 >  delete_capability("KLN");
484   }
485 +
486 + struct module module_entry = {
487 +  .node    = { NULL, NULL, NULL },
488 +  .name    = NULL,
489 +  .version = "$Revision$",
490 +  .handle  = NULL,
491 +  .modinit = module_init,
492 +  .modexit = module_exit,
493 +  .flags   = 0
494 + };

Diff Legend

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