--------------------- PatchSet 293 Date: 2002/12/09 18:06:26 Author: apbarrett Branch: follow_xff Tag: (none) Log: Implement the log_uses_indirect_client functionality. We were already parsing the configuration option, but until now we did nothing with it. If configured to do so, clientFollowXForwardedForDone() now sets conn->log_addr to the indirect_client_addr, masked with the client_netmask. Members: src/client_side.cc:1.12.2.1->1.12.2.2 src/client_side_request.cc:1.4.6.2->1.4.6.3 Index: squid3/src/client_side.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side.cc,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -u -r1.12.2.1 -r1.12.2.2 --- squid3/src/client_side.cc 9 Dec 2002 14:51:51 -0000 1.12.2.1 +++ squid3/src/client_side.cc 9 Dec 2002 18:06:26 -0000 1.12.2.2 @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.12.2.1 2002/12/09 14:51:51 apbarrett Exp $ + * $Id: client_side.cc,v 1.12.2.2 2002/12/09 18:06:26 apbarrett Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1778,6 +1778,10 @@ ConnStateData *result = cbdataAlloc(ConnStateData); result->peer = *peer; result->log_addr = peer->sin_addr; +#if FOLLOW_X_FORWARDED_FOR + /* log_addr might be changed later if the log_uses_indirect_client + * option is set. */ +#endif /* FOLLOW_X_FORWARDED_FOR */ result->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr; result->me = *me; result->fd = fd; Index: squid3/src/client_side_request.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.cc,v retrieving revision 1.4.6.2 retrieving revision 1.4.6.3 diff -u -r1.4.6.2 -r1.4.6.3 --- squid3/src/client_side_request.cc 9 Dec 2002 17:44:31 -0000 1.4.6.2 +++ squid3/src/client_side_request.cc 9 Dec 2002 18:06:30 -0000 1.4.6.3 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.4.6.2 2002/12/09 17:44:31 apbarrett Exp $ + * $Id: client_side_request.cc,v 1.4.6.3 2002/12/09 18:06:30 apbarrett Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -353,6 +353,19 @@ cleanup: /* clean up, and pass control to clientAccessCheck */ debug(85, 6) ("clientFollowXForwardedForDone: cleanup\n"); + if (Config.onoff.log_uses_indirect_client) { + /* + * Ensure that the access log shows the indirect client + * instead of the direct client. Be sure to mask with the + * client_netmask, just as connStateCreate() would do. + */ + ConnStateData *conn = http->conn; + conn->log_addr = request->indirect_client_addr; + conn->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr; + debug(33, 3) ("clientFollowXForwardedForDone: " + "setting log_addr=%s\n", + inet_ntoa(conn->log_addr)); + } stringClean(&context->xff_state); if (context->acl_checklist) aclChecklistFree(context->acl_checklist);