This adds more RPL_TESTLINE numerics with code '!'.
Different from the other results, the I/K line or
RESV will be shown as well.
void init_reject(void);
int check_reject(rb_fde_t *F, struct sockaddr *addr);
void add_reject(struct Client *, const char *mask1, const char *mask2);
+int is_reject_ip(struct sockaddr *addr);
void flush_reject(void);
int remove_reject_ip(const char *ip);
int remove_reject_mask(const char *mask1, const char *mask2);
unsigned long delay_exit_length(void);
int throttle_add(struct sockaddr *addr);
+int is_throttle_ip(struct sockaddr *addr);
unsigned long throttle_size(void);
#include "numeric.h"
#include "s_conf.h"
#include "s_newconf.h"
+#include "reject.h"
static int mo_testline(struct Client *, struct Client *, int, const char **);
static int mo_testgecos(struct Client *, struct Client *, int, const char **);
char *p;
int host_mask;
int type;
+ int duration;
mask = LOCAL_COPY(parv[1]);
return 0;
}
+ /* Otherwise, aconf is an exempt{} */
+ if(aconf == NULL &&
+ (duration = is_reject_ip((struct sockaddr *)&ip)))
+ sendto_one(source_p, form_str(RPL_TESTLINE),
+ me.name, source_p->name,
+ '!',
+ duration / 60,
+ host, "Reject cache");
+ if(aconf == NULL &&
+ (duration = is_throttle_ip((struct sockaddr *)&ip)))
+ sendto_one(source_p, form_str(RPL_TESTLINE),
+ me.name, source_p->name,
+ '!',
+ duration / 60,
+ host, "Throttled");
}
if (username != NULL)
return 0;
}
+int
+is_reject_ip(struct sockaddr *addr)
+{
+ rb_patricia_node_t *pnode;
+ reject_t *rdata;
+ int duration;
+
+ /* Reject is disabled */
+ if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_duration == 0)
+ return 0;
+
+ pnode = rb_match_ip(reject_tree, addr);
+ if(pnode != NULL)
+ {
+ rdata = pnode->data;
+
+ if(rdata->count > (unsigned long)ConfigFileEntry.reject_after_count)
+ {
+ duration = rdata->time + ConfigFileEntry.reject_duration - rb_current_time();
+ return duration > 0 ? duration : 1;
+ }
+ }
+ return 0;
+}
+
void
flush_reject(void)
{
return 0;
}
+int
+is_throttle_ip(struct sockaddr *addr)
+{
+ throttle_t *t;
+ rb_patricia_node_t *pnode;
+ int duration;
+
+ if((pnode = rb_match_ip(throttle_tree, addr)) != NULL)
+ {
+ t = pnode->data;
+ if(t->count > ConfigFileEntry.throttle_count)
+ {
+ duration = t->last + ConfigFileEntry.throttle_duration - rb_current_time();
+ return duration > 0 ? duration : 1;
+ }
+ }
+ return 0;
+}
+
static void
throttle_expires(void *unused)
{