Project

General

Profile

Feature #2199 ยป mod_evasive.patch

crypt, 2010-07-15 09:05

View differences:

lighttpd-1.4.23___/src/mod_evasive.c 2010-05-24 02:10:58.000000000 +0200
typedef struct {
unsigned short max_conns;
unsigned short silent;
buffer *location;
} plugin_config;
typedef struct {
......
for (i = 0; i < srv->config_context->used; i++) {
plugin_config *s = p->config_storage[i];
buffer_free(s->location);
free(s);
}
free(p->config_storage);
......
config_values_t cv[] = {
{ "evasive.max-conns-per-ip", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
{ "evasive.silent", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
{ "evasive.location", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
......
s = calloc(1, sizeof(plugin_config));
s->max_conns = 0;
s->silent = 0;
s->location = buffer_init();
cv[0].destination = &(s->max_conns);
cv[1].destination = &(s->silent);
cv[2].destination = s->location;
p->config_storage[i] = s;
......
PATCH(max_conns);
PATCH(silent);
PATCH(location);
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
......
PATCH(max_conns);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.silent"))) {
PATCH(silent);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.location"))) {
PATCH(location);
}
}
}
......
"turned away. Too many connections.");
}
con->http_status = 403;
if (2 < p->conf.location->used) {
response_header_insert(srv, con, CONST_STR_LEN("Location"), CONST_BUF_LEN(p->conf.location));
con->http_status = 302;
con->file_finished = 1;
} else {
con->http_status = 403;
}
con->mode = DIRECT;
return HANDLER_FINISHED;
}
    (1-1/1)