c45b11b1962cd78e36659b1f0f2a9d8d2cbab165
[packages/apache1-mod_rpaf.git] / mod_rpaf_degtine.patch
1 --- mod_rpaf-0.5/mod_rpaf.c     2004-03-17 17:47:30.000000000 +0200
2 +++ mod_rpaf-0.5.ipv6/mod_rpaf.c        2006-01-05 18:18:09.000000000 +0200
3 @@ -148,7 +148,18 @@
4                      ++fwdvalue;
5              }
6              r->connection->remote_ip = ap_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
7 -            r->connection->remote_addr.sin_addr.s_addr = inet_addr(r->connection->remote_ip);
8 +                       switch (r->connection->remote_addr.ss_family) {
9 +                       case AF_INET:
10 +                               inet_pton(AF_INET, r->connection->remote_ip, &((struct sockaddr_in*)&r->connection->remote_addr)->sin_addr.s_addr);
11 +                               break;
12 +                       case AF_INET6:
13 +                               inet_pton(AF_INET6, r->connection->remote_ip, ((struct sockaddr_in6*)&r->connection->remote_addr)->sin6_addr.s6_addr);
14 +                               break;
15 +                       default:
16 +                               ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r, "Apache doesn't support this address family");
17 +                               break;
18 +                       }
19 +
20              if (cfg->sethostname) {
21                  const char *hostvalue;
22                  if (hostvalue = ap_table_get(r->headers_in, "X-Forwarded-Host")) {
23 --- mod_rpaf-0.6/mod_rpaf-2.0.c~        2008-01-14 12:27:30.000000000 +0200
24 +++ mod_rpaf-0.6/mod_rpaf-2.0.c 2008-01-14 12:28:18.413347347 +0200
25 @@ -130,6 +130,16 @@
26      return 0;
27  }
28  
29 +static char* last_not_in_array(apr_array_header_t *forwarded_for,
30 +                              apr_array_header_t *proxy_ips) {
31 +    int i;
32 +    for (i = (forwarded_for->nelts)-1; i > 0; i--) {
33 +       if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips))
34 +           break;
35 +    }
36 +    return ((char **)forwarded_for->elts)[i];
37 +}
38 +
39  static int change_remote_ip(request_rec *r) {
40      const char *fwdvalue;
41      char *val;
42 @@ -193,7 +193,7 @@
43              rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip);
44              rcr->r = r;
45              apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null);
46 -            r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
47 +            r->connection->remote_ip = apr_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips));
48              r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip);
49              if (cfg->sethostname) {
50                  const char *hostvalue;
51 --- mod_rpaf-0.6/mod_rpaf.c~    2008-01-14 12:28:40.000000000 +0200
52 +++ mod_rpaf-0.6/mod_rpaf.c     2008-01-14 12:30:47.021926815 +0200
53 @@ -130,6 +130,16 @@
54      return 0;
55  }
56  
57 +static char* last_not_in_array(array_header *forwarded_for,
58 +                              array_header *proxy_ips) {
59 +    int i;
60 +    for (i = (forwarded_for->nelts)-1; i > 0; i--) {
61 +       if (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips))
62 +           break;
63 +    }
64 +    return ((char **)forwarded_for->elts)[i];
65 +}
66 +
67  static int change_remote_ip(request_rec *r) {
68      const char *fwdvalue;
69      char *val;
70 @@ -192,18 +192,7 @@
71              rcr->old_ip = ap_pstrdup(r->connection->pool, r->connection->remote_ip);
72              rcr->r = r;
73              ap_register_cleanup(r->pool, (void *)rcr, rpaf_cleanup, ap_null_cleanup);
74 -            r->connection->remote_ip = ap_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
75 -                       switch (r->connection->remote_addr.ss_family) {
76 -                       case AF_INET:
77 -                               inet_pton(AF_INET, r->connection->remote_ip, &((struct sockaddr_in*)&r->connection->remote_addr)->sin_addr.s_addr);
78 -                               break;
79 -                       case AF_INET6:
80 -                               inet_pton(AF_INET6, r->connection->remote_ip, ((struct sockaddr_in6*)&r->connection->remote_addr)->sin6_addr.s6_addr);
81 -                               break;
82 -                       default:
83 -                               ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r, "Apache doesn't support this address family");
84 -                               break;
85 -                       }
86 +            r->connection->remote_ip = ap_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips));
87  
88              if (cfg->sethostname) {
89                  const char *hostvalue;
90 --- mod_rpaf-0.6/mod_rpaf.c~    2008-01-14 12:31:19.000000000 +0200
91 +++ mod_rpaf-0.6/mod_rpaf.c     2008-01-14 12:35:56.507787818 +0200
92 @@ -148,7 +148,15 @@
93  static void rpaf_cleanup(void *data) {
94      rpaf_cleanup_rec *rcr = (rpaf_cleanup_rec *)data;
95      rcr->r->connection->remote_ip   = ap_pstrdup(rcr->r->connection->pool, rcr->old_ip);
96 +#ifdef INET6
97 +       switch (rcr->r->connection->remote_addr.ss_family) {
98 +       case AF_INET:
99 +               inet_pton(AF_INET, rcr->r->connection->remote_ip, &((struct sockaddr_in*)&rcr->r->connection->remote_addr)->sin_addr.s_addr);
100 +               break;
101 +       }
102 +#else
103      rcr->r->connection->remote_addr.sin_addr.s_addr = inet_addr(rcr->r->connection->remote_ip);
104 +#endif
105  }
106  
107  static char* last_not_in_array(array_header *forwarded_for,
108 --- mod_rpaf-0.6/mod_rpaf.c~    2008-01-14 12:39:58.000000000 +0200
109 +++ mod_rpaf-0.6/mod_rpaf.c     2008-01-14 12:42:16.393702934 +0200
110 @@ -201,6 +201,15 @@
111              rcr->r = r;
112              ap_register_cleanup(r->pool, (void *)rcr, rpaf_cleanup, ap_null_cleanup);
113              r->connection->remote_ip = ap_pstrdup(r->connection->pool, last_not_in_array(arr, cfg->proxy_ips));
114 +#ifdef INET6
115 +                       switch (r->connection->remote_addr.ss_family) {
116 +                       case AF_INET:
117 +                               inet_pton(AF_INET, r->connection->remote_ip, &((struct sockaddr_in*)&r->connection->remote_addr)->sin_addr.s_addr);
118 +                               break;
119 +                       }
120 +#else
121 +                       r->connection->remote_addr.sin_addr.s_addr = inet_addr(r->connection->remote_ip);
122 +#endif
123  
124              if (cfg->sethostname) {
125                  const char *hostvalue;
This page took 0.034431 seconds and 2 git commands to generate.