Skip to content

Commit d6eeba5

Browse files
author
Felipe Zimmerle
committed
Retrieves the client ip addr from the correct place in v2.2
1 parent 4c86c94 commit d6eeba5

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/mod_security3.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ static int hook_connection_early(conn_rec *conn)
252252
static int hook_request_early(request_rec *r) {
253253
msc_t *msr = NULL;
254254
int rc = DECLINED;
255+
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER < 3
256+
const char *client_ip = r->connection->remote_ip;
257+
int client_port = r->connection->remote_addr->port;
258+
#else
259+
const char *client_ip = r->connection->client_ip;
260+
int client_port = r->connection->client_addr->port;
261+
#endif
255262

256263
/* This function needs to run only once per transaction
257264
* (i.e. subrequests and redirects are excluded).
@@ -274,8 +281,8 @@ static int hook_request_early(request_rec *r) {
274281

275282
#ifndef LATE_CONNECTION_PROCESS
276283
#error "Currently in v3 connection can only be processed late."
277-
msc_process_connection(msr->t, r->connection->client_ip,
278-
r->connection->client_addr->port,
284+
msc_process_connection(msr->t, client_ip,
285+
client_port,
279286
r->server->server_hostname,
280287
(int) r->server->port);
281288

@@ -305,6 +312,13 @@ static int hook_request_late(request_rec *r)
305312
{
306313
msc_t *msr = NULL;
307314
int it;
315+
#if AP_SERVER_MAJORVERSION_NUMBER > 1 && AP_SERVER_MINORVERSION_NUMBER < 3
316+
const char *client_ip = r->connection->remote_ip;
317+
int client_port = r->connection->remote_addr->port;
318+
#else
319+
const char *client_ip = r->connection->client_ip;
320+
int client_port = r->connection->client_addr->port;
321+
#endif
308322

309323
/* This function needs to run only once per transaction
310324
* (i.e. subrequests and redirects are excluded).
@@ -331,8 +345,8 @@ static int hook_request_late(request_rec *r)
331345
}
332346

333347
#ifdef LATE_CONNECTION_PROCESS
334-
msc_process_connection(msr->t, r->connection->client_ip,
335-
r->connection->client_addr->port,
348+
msc_process_connection(msr->t, client_ip,
349+
client_port,
336350
r->server->server_hostname,
337351
(int) r->server->port);
338352

0 commit comments

Comments
 (0)