Package: libapache2-mod-rpaf
Version: 0.5-2
Severity: normal
Tags: patch

hi,

I wanted to use libapache2-mod-rpaf on an IPv6-enabled Webserver,
and created the attached patch in the process. I've been running
this since one week an a busy server.

This should most probably be forwarded upstream.
Maybe this can be optimized further, because change_remote_ip()
is called for each request, which is unnecessary for all
expect the first request for persistent connections.

cu
Maurice Massar

-- System Information:
Debian Release: 4.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (400, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-1-k7
Locale: LANG=C, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
--- libapache-mod-rpaf-0.5.orig/mod_rpaf-2.0.c
+++ libapache-mod-rpaf-0.5/mod_rpaf-2.0.c
@@ -133,6 +133,8 @@
 static int change_remote_ip(request_rec *r) {
     const char *fwdvalue;
     char *val;
+    apr_port_t tmpport;
+    apr_pool_t *tmppool;
     rpaf_server_cfg *cfg = (rpaf_server_cfg *)ap_get_module_config(r->server->module_config,
                                                                    &rpaf_module);
 
@@ -148,7 +150,11 @@
                     ++fwdvalue;
             }
             r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
-            r->connection->remote_addr->sa.sin.sin_addr.s_addr = inet_addr(r->connection->remote_ip);
+	    tmppool = r->connection->remote_addr->pool;
+	    tmpport = r->connection->remote_addr->port;
+	    memset(r->connection->remote_addr, '\0', sizeof(apr_sockaddr_t));
+	    r->connection->remote_addr = NULL;
+	    apr_sockaddr_info_get(&(r->connection->remote_addr), r->connection->remote_ip, APR_UNSPEC, tmpport, 0, tmppool);
             if (cfg->sethostname) {
                 const char *hostvalue;
                 if (hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host")) {

Reply via email to