]> git.pld-linux.org Git - packages/lighttpd.git/blame - lighttpd-mod_evasive-status_code.patch
- update to r2392 (PRE-RELEASE: 1.4.21-r2392)
[packages/lighttpd.git] / lighttpd-mod_evasive-status_code.patch
CommitLineData
4fa4837c
ER
1--- lighttpd-1.4.19/src/mod_evasive.c~ 2008-09-19 17:46:59.000000000 +0300
2+++ lighttpd-1.4.19/src/mod_evasive.c 2008-09-19 17:50:24.307245276 +0300
53e13862
SP
3@@ -27,11 +27,15 @@
4
5 typedef struct {
6 unsigned short max_conns;
7+ unsigned short http_status_code;
8+ unsigned int retry_after;
9 } plugin_config;
10
11 typedef struct {
12 PLUGIN_DATA;
0315e022 13
53e13862 14+ buffer *evasive_rftmp;
0315e022 15+
53e13862 16 plugin_config **config_storage;
0315e022
ER
17
18 plugin_config conf;
53e13862 19@@ -42,6 +46,10 @@
0315e022 20
53e13862 21 p = calloc(1, sizeof(*p));
0315e022 22
53e13862
SP
23+ p->evasive_rftmp = buffer_init();
24+
25+ buffer_prepare_copy(p->evasive_rftmp, 255);
0315e022 26+
53e13862
SP
27 return p;
28 }
29
30@@ -52,6 +60,8 @@
31
32 if (!p) return HANDLER_GO_ON;
0315e022 33
53e13862 34+ buffer_free(p->evasive_rftmp);
0315e022 35+
53e13862
SP
36 if (p->config_storage) {
37 size_t i;
38 for (i = 0; i < srv->config_context->used; i++) {
39@@ -73,6 +83,8 @@
40
41 config_values_t cv[] = {
42 { "evasive.max-conns-per-ip", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },
43+ { "evasive.http-status-code", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },
44+ { "evasive.retry-after", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },
45 { NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
46 };
47
0315e022 48@@ -84,9 +94,13 @@
53e13862 49 plugin_config *s;
0315e022 50
53e13862
SP
51 s = calloc(1, sizeof(plugin_config));
52- s->max_conns = 0;
53+ s->max_conns = 0;
54+ s->http_status_code = 503;
55+ s->retry_after = 0;
0315e022 56
53e13862
SP
57 cv[0].destination = &(s->max_conns);
58+ cv[1].destination = &(s->http_status_code);
59+ cv[2].destination = &(s->retry_after);
0315e022 60
53e13862 61 p->config_storage[i] = s;
0315e022
ER
62
63@@ -105,6 +119,8 @@
53e13862
SP
64 plugin_config *s = p->config_storage[0];
65
66 PATCH(max_conns);
67+ PATCH(http_status_code);
68+ PATCH(retry_after);
0315e022 69
53e13862
SP
70 /* skip the first, the global context */
71 for (i = 1; i < srv->config_context->used; i++) {
72@@ -118,6 +136,10 @@
73
74 if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.max-conns-per-ip"))) {
75 PATCH(max_conns);
76+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.http-status-code"))) {
77+ PATCH(http_status_code);
78+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("evasive.retry-after"))) {
79+ PATCH(retry_after);
80 }
81 }
82 }
4fa4837c
ER
83@@ -198,8 +198,10 @@
84 inet_ntop_cache_get_ip(srv, &(con->dst_addr)),
85 "turned away. Too many connections.");
86
87- con->http_status = 403;
88 con->mode = DIRECT;
89+ con->http_status = p->conf.http_status_code;
90+ buffer_copy_long(p->evasive_rftmp, p->conf.retry_after);
91+ response_header_overwrite(srv, con, CONST_STR_LEN("Retry-After"), CONST_BUF_LEN(p->evasive_rftmp));
92 return HANDLER_FINISHED;
53e13862 93 }
4fa4837c 94 }
This page took 0.048417 seconds and 4 git commands to generate.