91177088dbb30003bfdd065b995d9fce6a1231d2
[packages/apache1-mod_rpaf.git] / mod_rpaf_degtine.patch
1 --- mod_rpaf-0.6/mod_rpaf-2.0.c~        2008-01-14 12:22:30.000000000 +0200
2 +++ mod_rpaf-0.6/mod_rpaf-2.0.c 2008-01-14 12:24:24.311847900 +0200
3 @@ -130,6 +130,16 @@
4      return 0;
5  }
6  
7 +static char* last_not_in_array(apr_array_header_t *forwarded_for,
8 +                              apr_array_header_t *proxy_ips) {
9 +    int i;
10 +    for (i = (forwarded_for->nelts)-1; i > 0; i--) {
11 +       if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips))
12 +           break;
13 +    }
14 +    return ((char **)forwarded_for->elts)[i];
15 +}
16 +
17  static int change_remote_ip(request_rec *r) {
18      const char *fwdvalue;
19      char *val;
20 @@ -193,7 +193,7 @@
21              rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip);
22              rcr->r = r;
23              apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null);
24 -            r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
25 +            r->connection->remote_ip = apr_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips));
26              r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip);
27              if (cfg->sethostname) {
28                  const char *hostvalue;
29 --- mod_rpaf-0.6/mod_rpaf.c~    2008-01-14 12:25:04.000000000 +0200
30 +++ mod_rpaf-0.6/mod_rpaf.c     2008-01-14 12:25:28.975575680 +0200
31 @@ -130,6 +130,16 @@
32      return 0;
33  }
34  
35 +static char* last_not_in_array(array_header *forwarded_for,
36 +                              array_header *proxy_ips) {
37 +    int i;
38 +    for (i = (forwarded_for->nelts)-1; i > 0; i--) {
39 +       if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips))
40 +           break;
41 +    }
42 +    return ((char **)forwarded_for->elts)[i];
43 +}
44 +
45  static int change_remote_ip(request_rec *r) {
46      const char *fwdvalue;
47      char *val;
48 @@ -192,7 +192,7 @@
49              rcr->old_ip = ap_pstrdup(r->connection->pool, r->connection->remote_ip);
50              rcr->r = r;
51              ap_register_cleanup(r->pool, (void *)rcr, rpaf_cleanup, ap_null_cleanup);
52 -            r->connection->remote_ip = ap_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
53 +            r->connection->remote_ip = ap_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips));
54              r->connection->remote_addr.sin_addr.s_addr = inet_addr(r->connection->remote_ip);
55              if (cfg->sethostname) {
56                  const char *hostvalue;
This page took 0.062089 seconds and 2 git commands to generate.