From 40e1de52e5a901d0ddf471821c5cdaf17f42a315 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sat, 18 Oct 2014 11:30:15 +0100 Subject: [PATCH 1/3] Rename `conn_rec->remote_ip` to `conn_rec->client_ip` Apache v2.4 has changed the conn_rec record structure (see, http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html) --- apache/mod_blockinator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache/mod_blockinator.c b/apache/mod_blockinator.c index 1aba422..bd61e69 100644 --- a/apache/mod_blockinator.c +++ b/apache/mod_blockinator.c @@ -61,7 +61,7 @@ static int mod_blockinator_method_handler(request_rec *r) int sqlite3_rc; /* Capture the relevant information from the inbound request */ - remote_ip = r->connection->remote_ip; + remote_ip = r->connection->client_ip; forwarded_ip = apr_table_get(r->headers_in, "X-Forwarded-For"); useragent = apr_table_get(r->headers_in, "User-Agent"); From d5bc945bc357d40b7f3709dd698b09c7fc817727 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sat, 18 Oct 2014 12:22:22 +0100 Subject: [PATCH 2/3] Ensure that the Apache logging is also v2.4 compatible --- apache/mod_blockinator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apache/mod_blockinator.c b/apache/mod_blockinator.c index bd61e69..01d98f2 100644 --- a/apache/mod_blockinator.c +++ b/apache/mod_blockinator.c @@ -1,5 +1,5 @@ /* - * mod_blockinator for Apache v2.2 + * mod_blockinator for Apache v2.4 * * Author: Scott Wallace * Date: March 2012 @@ -21,6 +21,10 @@ module AP_MODULE_DECLARE_DATA blockinator_module; +#ifdef APLOG_USE_MODULE +APLOG_USE_MODULE(blockinator); +#endif + /* * Global variables for use everywhere */ From d71a0abedefde36170d193d7290d02129d6b8d1a Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sat, 18 Oct 2014 18:43:53 +0100 Subject: [PATCH 3/3] Detect if the Apache `conn_rec` structure uses `client_ip` and uses it accordingly. Fallback is the original `conn_rec->remote_ip`. --- apache/configure.in | 2 ++ apache/mod_blockinator.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apache/configure.in b/apache/configure.in index beb9274..f1e0a46 100644 --- a/apache/configure.in +++ b/apache/configure.in @@ -43,6 +43,8 @@ APACHE_DIR # The AC_SUBST macro causes the variable to be saved in config.status AC_SUBST(apache_dir) +AC_CHECK_MEMBER(conn_rec.client_ip, AC_DEFINE(USE_CONN_REC_CLIENT_IP,1,[Do we have conn_rec.client_ip]),,[#include "httpd.h"]) + # Write config.status and the Makefile AC_OUTPUT(Makefile) diff --git a/apache/mod_blockinator.c b/apache/mod_blockinator.c index 01d98f2..9ebdd06 100644 --- a/apache/mod_blockinator.c +++ b/apache/mod_blockinator.c @@ -65,7 +65,11 @@ static int mod_blockinator_method_handler(request_rec *r) int sqlite3_rc; /* Capture the relevant information from the inbound request */ - remote_ip = r->connection->client_ip; +#ifdef USE_CONN_REC_CLIENT_IP + remote_ip = r->connection->client_ip, +#else + remote_ip = r->connection->remote_ip, +#endif forwarded_ip = apr_table_get(r->headers_in, "X-Forwarded-For"); useragent = apr_table_get(r->headers_in, "User-Agent");