-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_limitipconn_local_IP_patch.diff
More file actions
69 lines (62 loc) · 2.18 KB
/
mod_limitipconn_local_IP_patch.diff
File metadata and controls
69 lines (62 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--- mod_limitipconn.c.org Wed Apr 30 14:57:33 2003
+++ mod_limitipconn.c Wed Apr 30 15:10:31 2003
@@ -44,6 +44,8 @@
checking */
array_header *excl_limit; /* array of MIME types to limit check; all
other types are exempt */
+ array_header *local_ip; /* array of local ip exempt from limit
+ checking */
} limitipconn_dir_config;
static void *limitipconn_create_dir_config(pool *p, char *path)
@@ -55,6 +57,7 @@
cfg->limit = 0;
cfg->no_limit = ap_make_array(p, 0, sizeof(char *));
cfg->excl_limit = ap_make_array(p, 0, sizeof(char *));
+ cfg->local_ip = ap_make_array(p, 0, sizeof(char *));
return (void *) cfg;
}
@@ -68,6 +71,7 @@
/* convert Apache arrays to normal C arrays */
char **nolim = (char **) cfg->no_limit->elts;
char **exlim = (char **) cfg->excl_limit->elts;
+ char **localip = (char **) cfg->local_ip->elts;
const char *address;
@@ -109,6 +113,15 @@
return OK;
}
+ /* Cycle through the local ip list; if the ip is local,
+ * return OK */
+ for (i = 0; i < cfg->local_ip->nelts; i++) {
+ if ((ap_strcasecmp_match(address, localip[i]) == 0)
+ || (strncmp(localip[i], address, strlen(localip[i])) == 0)) {
+ return OK;
+ }
+ }
+
/* Cycle through the exempt list; if our content_type is exempt,
* return OK */
for (i = 0; i < cfg->no_limit->nelts; i++) {
@@ -219,6 +232,16 @@
return NULL;
}
+/* Parse the LocalIP directive */
+static const char *local_ip_config_cmd(cmd_parms *parms, void *mconfig,
+ const char *arg)
+{
+ limitipconn_dir_config *cfg = (limitipconn_dir_config *) mconfig;
+
+ *(char **) ap_push_array(cfg->local_ip) = ap_pstrdup(parms->pool, arg);
+ return NULL;
+}
+
/* Array describing structure of configuration directives */
static command_rec limitipconn_cmds[] = {
{"MaxConnPerIP", limit_config_cmd, NULL, OR_LIMIT, TAKE1,
@@ -227,6 +250,8 @@
"MIME types for which limit checking is disabled"},
{"OnlyIPLimit", excl_limit_config_cmd, NULL, OR_LIMIT, ITERATE,
"restrict limit checking to these MIME types only"},
+ {"LocalIP", local_ip_config_cmd, NULL, OR_LIMIT, ITERATE,
+ "no checking on local IP"},
{NULL},
};