1 --- lighttpd-1.4.40/src/mod_evasive.c 2016-07-16 10:06:16.000000000 +0000
2 +++ lighttpd-1.4.40/src/mod_evasive.c 2016-07-26 12:11:56.730554000 +0000
5 unsigned short max_conns;
7 + unsigned short http_status_code;
8 + unsigned int retry_after;
15 + buffer *evasive_rftmp;
17 plugin_config **config_storage;
22 p = calloc(1, sizeof(*p));
24 + p->evasive_rftmp = buffer_init();
26 + buffer_prepare_copy(p->evasive_rftmp, 255);
33 if (!p) return HANDLER_GO_ON;
35 + buffer_free(p->evasive_rftmp);
37 if (p->config_storage) {
39 for (i = 0; i < srv->config_context->used; i++) {
41 { "evasive.max-conns-per-ip", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 0 */
42 { "evasive.silent", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 1 */
43 { "evasive.location", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 2 */
44 + { "evasive.http-status-code", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 3 */
45 + { "evasive.retry-after", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 4 */
46 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
52 s = calloc(1, sizeof(plugin_config));
55 - s->location = buffer_init();
58 + s->location = buffer_init();
59 + s->http_status_code = 503;
62 cv[0].destination = &(s->max_conns);
63 cv[1].destination = &(s->silent);
64 cv[2].destination = s->location;
65 + cv[2].destination = &(s->http_status_code);
66 + cv[3].destination = &(s->retry_after);
68 p->config_storage[i] = s;
74 + PATCH(http_status_code);
77 /* skip the first, the global context */
78 for (i = 1; i < srv->config_context->used; i++) {
81 } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.location"))) {
83 + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.http-status-code"))) {
84 + PATCH(http_status_code);
85 + } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.retry-after"))) {
91 con->http_status = 302;
92 con->file_finished = 1;
94 - con->http_status = 403;
95 + con->http_status = p->conf.http_status_code;
96 + buffer_copy_long(p->evasive_rftmp, p->conf.retry_after);
97 + response_header_overwrite(srv, con, CONST_STR_LEN("Retry-After"), CONST_BUF_LEN(p->evasive_rftmp));
100 return HANDLER_FINISHED;