]>
Commit | Line | Data |
---|---|---|
11a22cd7 ER |
1 | diff -ur mod_rpaf-0.5/mod_rpaf-2.0.c libapache-mod-rpaf-0.5/mod_rpaf-2.0.c |
2 | --- mod_rpaf-0.5/mod_rpaf-2.0.c 2004-03-17 15:47:30.000000000 +0000 | |
3 | +++ libapache-mod-rpaf-0.5/mod_rpaf-2.0.c 2006-06-16 18:04:05.000000000 +0100 | |
4 | @@ -130,6 +130,16 @@ | |
5 | return 0; | |
6 | } | |
7 | ||
8 | +static char* last_not_in_array(apr_array_header_t *forwarded_for, | |
9 | + apr_array_header_t *proxy_ips) { | |
10 | + int i; | |
11 | + for (i = (forwarded_for->nelts)-1; i > 0; i--) { | |
12 | + if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips)) | |
13 | + break; | |
14 | + } | |
15 | + return ((char **)forwarded_for->elts)[i]; | |
16 | +} | |
17 | + | |
18 | static int change_remote_ip(request_rec *r) { | |
19 | const char *fwdvalue; | |
20 | char *val; | |
21 | @@ -147,7 +157,7 @@ | |
22 | if (*fwdvalue != '\0') | |
23 | ++fwdvalue; | |
24 | } | |
25 | - r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]); | |
26 | + r->connection->remote_ip = apr_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips)); | |
27 | r->connection->remote_addr->sa.sin.sin_addr.s_addr = inet_addr(r->connection->remote_ip); | |
28 | if (cfg->sethostname) { | |
29 | const char *hostvalue; | |
30 | diff -ur mod_rpaf-0.5/mod_rpaf.c libapache-mod-rpaf-0.5/mod_rpaf.c | |
31 | --- mod_rpaf-0.5/mod_rpaf.c 2004-03-17 15:47:30.000000000 +0000 | |
32 | +++ libapache-mod-rpaf-0.5/mod_rpaf.c 2006-06-16 18:04:38.000000000 +0100 | |
33 | @@ -130,6 +130,16 @@ | |
34 | return 0; | |
35 | } | |
36 | ||
37 | +static char* last_not_in_array(array_header *forwarded_for, | |
38 | + array_header *proxy_ips) { | |
39 | + int i; | |
40 | + for (i = (forwarded_for->nelts)-1; i > 0; i--) { | |
41 | + if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips)) | |
42 | + break; | |
43 | + } | |
44 | + return ((char **)forwarded_for->elts)[i]; | |
45 | +} | |
46 | + | |
47 | static int change_remote_ip(request_rec *r) { | |
48 | const char *fwdvalue; | |
49 | char *val; | |
50 | @@ -147,7 +157,7 @@ | |
51 | if (*fwdvalue != '\0') | |
52 | ++fwdvalue; | |
53 | } | |
54 | - r->connection->remote_ip = ap_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]); | |
55 | + r->connection->remote_ip = ap_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips)); | |
56 | r->connection->remote_addr.sin_addr.s_addr = inet_addr(r->connection->remote_ip); | |
57 | if (cfg->sethostname) { | |
58 | const char *hostvalue; | |
59 |