/[svn]/ircd-hybrid/branches/8.2.x/modules/m_dline.c
ViewVC logotype

Diff of /ircd-hybrid/branches/8.2.x/modules/m_dline.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5829 by michael, Sun Apr 26 12:41:42 2015 UTC revision 5830 by michael, Sun Apr 26 16:25:56 2015 UTC
# Line 95  check_dline(struct AddressRec *arec) Line 95  check_dline(struct AddressRec *arec)
95  }  }
96    
97    
98  /* apply_tdline()  /* dline_add()
99   *   *
100   * inputs       -   * inputs       -
101   * output       - NONE   * output       - NONE
102   * side effects - tkline as given is placed   * side effects - dline as given is placed
103   */   */
104  static void  static void
105  apply_dline(struct Client *source_p, struct MaskItem *conf,  dline_add(struct Client *source_p, const char *addr,
106              time_t tkline_time)            const char *reason, time_t tdline_time)
107  {  {
108    if (tkline_time)    char buf[IRCD_BUFSIZE];
109      struct MaskItem *conf;
110    
111      if (tdline_time)
112        snprintf(buf, sizeof(buf), "Temporary D-line %d min. - %.*s (%s)",
113                 (int)(tdline_time/60), REASONLEN, reason, smalldate(0));
114      else
115        snprintf(buf, sizeof(buf), "%.*s (%s)", REASONLEN, reason, smalldate(0));
116    
117      conf = conf_make(CONF_DLINE);
118      conf->host = xstrdup(addr);
119      conf->reason = xstrdup(buf);
120      conf->setat = CurrentTime;
121      SetConfDatabase(conf);
122    
123      if (tdline_time)
124    {    {
125      conf->until = CurrentTime + tkline_time;      conf->until = CurrentTime + tdline_time;
126    
127      if (IsClient(source_p))      if (IsClient(source_p))
128        sendto_one_notice(source_p, &me, ":Added temporary %d min. D-Line [%s]",        sendto_one_notice(source_p, &me, ":Added temporary %d min. D-Line [%s]",
129                          tkline_time/60, conf->host);                          tdline_time/60, conf->host);
130    
131      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
132                           "%s added temporary %d min. D-Line for [%s] [%s]",                           "%s added temporary %d min. D-Line for [%s] [%s]",
133                           get_oper_name(source_p), tkline_time/60,                           get_oper_name(source_p), tdline_time/60,
134                           conf->host, conf->reason);                           conf->host, conf->reason);
135      ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",      ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
136           get_oper_name(source_p), tkline_time/60, conf->host, conf->reason);           get_oper_name(source_p), tdline_time/60, conf->host, conf->reason);
137    }    }
138    else    else
139    {    {
# Line 132  apply_dline(struct Client *source_p, str Line 147  apply_dline(struct Client *source_p, str
147           get_oper_name(source_p), conf->host, conf->reason);           get_oper_name(source_p), conf->host, conf->reason);
148    }    }
149    
   SetConfDatabase(conf);  
   conf->setat = CurrentTime;  
150    check_dline(add_conf_by_address(CONF_DLINE, conf));    check_dline(add_conf_by_address(CONF_DLINE, conf));
151  }  }
152    
# Line 155  mo_dline(struct Client *source_p, int pa Line 168  mo_dline(struct Client *source_p, int pa
168    const struct Client *target_p = NULL;    const struct Client *target_p = NULL;
169    struct irc_ssaddr daddr;    struct irc_ssaddr daddr;
170    struct MaskItem *conf = NULL;    struct MaskItem *conf = NULL;
171    time_t tkline_time=0;    time_t tdline_time = 0;
172    int bits = 0, aftype = 0, t = 0;    int bits = 0, aftype = 0, t = 0;
173    char hostip[HOSTIPLEN + 1];    char hostip[HOSTIPLEN + 1];
   char buffer[IRCD_BUFSIZE];  
174    
175    if (!HasOFlag(source_p, OPER_FLAG_DLINE))    if (!HasOFlag(source_p, OPER_FLAG_DLINE))
176    {    {
# Line 167  mo_dline(struct Client *source_p, int pa Line 179  mo_dline(struct Client *source_p, int pa
179    }    }
180    
181    if (!parse_aline("DLINE", source_p, parc, parv, AWILD, &dlhost,    if (!parse_aline("DLINE", source_p, parc, parv, AWILD, &dlhost,
182                     NULL, &tkline_time, &target_server, &reason))                     NULL, &tdline_time, &target_server, &reason))
183      return 0;      return 0;
184    
185    if (target_server)    if (target_server)
186    {    {
187      sendto_match_servs(source_p, target_server, CAP_DLN, "DLINE %s %lu %s :%s",      sendto_match_servs(source_p, target_server, CAP_DLN, "DLINE %s %lu %s :%s",
188                         target_server, (unsigned long)tkline_time,                         target_server, (unsigned long)tdline_time,
189                         dlhost, reason);                         dlhost, reason);
190    
191      /* Allow ON to apply local kline as well if it matches */      /* Allow ON to apply local kline as well if it matches */
# Line 182  mo_dline(struct Client *source_p, int pa Line 194  mo_dline(struct Client *source_p, int pa
194    }    }
195    else    else
196      cluster_a_line(source_p, "DLINE", CAP_DLN, SHARED_DLINE,      cluster_a_line(source_p, "DLINE", CAP_DLN, SHARED_DLINE,
197                     "%d %s :%s", tkline_time, dlhost, reason);                     "%d %s :%s", tdline_time, dlhost, reason);
198    
199    if ((t = parse_netmask(dlhost, NULL, NULL)) == HM_HOST)    if ((t = parse_netmask(dlhost, NULL, NULL)) == HM_HOST)
200    {    {
# Line 240  mo_dline(struct Client *source_p, int pa Line 252  mo_dline(struct Client *source_p, int pa
252      return 0;      return 0;
253    }    }
254    
255    conf = conf_make(CONF_DLINE);    dline_add(source_p, dlhost, reason, tdline_time);
   conf->host = xstrdup(dlhost);  
   
   if (tkline_time)  
     snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %.*s (%s)",  
              (int)(tkline_time/60), REASONLEN, reason, smalldate(0));  
   else  
     snprintf(buffer, sizeof(buffer), "%.*s (%s)", REASONLEN, reason, smalldate(0));  
   
   conf->reason = xstrdup(buffer);  
   apply_dline(source_p, conf, tkline_time);  
256    return 0;    return 0;
257  }  }
258    
259  static int  static int
260  ms_dline(struct Client *source_p, int parc, char *parv[])  ms_dline(struct Client *source_p, int parc, char *parv[])
261  {  {
262    char *dlhost, *reason;    const char *dlhost, *reason;
263    struct irc_ssaddr daddr;    struct irc_ssaddr daddr;
264    struct MaskItem *conf = NULL;    struct MaskItem *conf = NULL;
265    time_t tkline_time=0;    time_t tdline_time=0;
266    int bits = 0, aftype = 0;    int bits = 0, aftype = 0;
   char buffer[IRCD_BUFSIZE];  
267    
268    if (parc != 5 || EmptyString(parv[4]))    if (parc != 5 || EmptyString(parv[4]))
269      return 0;      return 0;
270    
271    /* parv[0]  parv[1]        parv[2]      parv[3]  parv[4] */    /* parv[0]  parv[1]        parv[2]      parv[3]  parv[4] */
272    /* command  target_server  tkline_time  host     reason  */    /* command  target_server  tdline_time  host     reason  */
273    sendto_match_servs(source_p, parv[1], CAP_DLN, "DLINE %s %s %s :%s",    sendto_match_servs(source_p, parv[1], CAP_DLN, "DLINE %s %s %s :%s",
274                       parv[1], parv[2], parv[3], parv[4]);                       parv[1], parv[2], parv[3], parv[4]);
275    
276    if (match(parv[1], me.name))    if (match(parv[1], me.name))
277      return 0;      return 0;
278    
279    tkline_time = valid_tkline(parv[2], TK_SECONDS);    tdline_time = valid_tkline(parv[2], TK_SECONDS);
280    dlhost = parv[3];    dlhost = parv[3];
281    reason = parv[4];    reason = parv[4];
282    
# Line 320  ms_dline(struct Client *source_p, int pa Line 321  ms_dline(struct Client *source_p, int pa
321        return 0;        return 0;
322      }      }
323    
324      conf = conf_make(CONF_DLINE);      dline_add(source_p, dlhost, reason, tdline_time);
     conf->host = xstrdup(dlhost);  
   
     if (tkline_time)  
       snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %.*s (%s)",  
                (int)(tkline_time/60), REASONLEN, reason, smalldate(0));  
     else  
       snprintf(buffer, sizeof(buffer), "%.*s (%s)", REASONLEN, reason, smalldate(0));  
   
     conf->reason = xstrdup(buffer);  
     apply_dline(source_p, conf, tkline_time);  
325    }    }
326    
327    return 0;    return 0;

Legend:
Removed from v.5829  
changed lines
  Added in v.5830

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28