From: hno <> Date: Wed, 3 May 2000 01:35:23 +0000 (+0000) Subject: hno squid-2.2.STABLE5.log_ip_on_direct.patch with additions X-Git-Tag: SQUID_3_0_PRE1~2024 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=890b0fa87774417fbd38853e9fa844b4670a5b09;p=thirdparty%2Fsquid.git hno squid-2.2.STABLE5.log_ip_on_direct.patch with additions Squid-2.2.STABLE5: Log destination IP on DIRECT This patch logs the destination IP as part of the hierarchy tag in access.log when going direct. This has been requested by a number of people from accounting reasons, and logging the hostname is mostly redundant as it is part of the URL as well. Additions: Can be rewerted to the old behaviour by turning log_ip_on_direct off --- diff --git a/ChangeLog b/ChangeLog index 70b3bcb969..c08f8dd9ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,8 @@ Changes to Squid-2.4.DEVEL3 (): - Delay pools tuned to allow large initial pool values - cachemgr filesystem space information changed to show useable space rather than raw space, and platform support somewhat extended. + - Logs destination IP in the hierarchy log tag when going direct. + (can be disabled by turning log_ip_on_direct off) Changes to Squid-2.4.DEVEL2 (): diff --git a/src/cf.data.pre b/src/cf.data.pre index fc28049fc1..b79cf6ce86 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.170 2000/05/02 18:51:51 hno Exp $ +# $Id: cf.data.pre,v 1.171 2000/05/02 19:35:23 hno Exp $ # # # SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -741,6 +741,18 @@ DOC_START emulate_httpd_log off DOC_END +NAME: log_ip_on_direct +COMMENT: on|off +TYPE: onoff +DEFAULT: on +LOC: Config.onoff.log_ip_on_direct +DOC_START + Log the destination IP address in the hierarchy log tag when going + direct. Earlier Squid versions logged the hostname here. If you + prefer the old way set this to off. + +log_ip_on_direct on +DOC_END NAME: mime_table TYPE: string diff --git a/src/forward.cc b/src/forward.cc index 4dde99b4ec..01a40c3eee 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.70 2000/05/02 18:32:41 hno Exp $ + * $Id: forward.cc,v 1.71 2000/05/02 19:35:23 hno Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -193,6 +193,12 @@ fwdConnectDone(int server_fd, int status, void *data) comm_close(server_fd); } else { debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, storeUrl(fwdState->entry)); + if (fs->peer) + hierarchyNote(&fwdState->request->hier, fs->code, fs->peer->host); + else if (Config.onoff.log_ip_on_direct) + hierarchyNote(&fwdState->request->hier, fs->code, fd_table[server_fd].ipaddr); + else + hierarchyNote(&fwdState->request->hier, fs->code, request->host); fd_note(server_fd, storeUrl(fwdState->entry)); fd_table[server_fd].uses++; if (fs->peer) @@ -249,7 +255,6 @@ fwdConnectStart(void *data) port = fwdState->request->port; ctimeout = Config.Timeout.connect; } - hierarchyNote(&fwdState->request->hier, fs->code, host); if ((fd = pconnPop(host, port)) >= 0) { debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd); fwdState->server_fd = fd; diff --git a/src/ssl.cc b/src/ssl.cc index 67c39e9324..101bd62269 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl.cc,v 1.102 2000/03/06 16:23:34 wessels Exp $ + * $Id: ssl.cc,v 1.103 2000/05/02 19:35:23 hno Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -377,6 +377,15 @@ sslConnectDone(int fdnotused, int status, void *data) SslStateData *sslState = data; request_t *request = sslState->request; ErrorState *err = NULL; + if (sslState->servers->peer) + hierarchyNote(&sslState->request->hier, sslState->servers->code, + sslState->servers->peer->host); + else if (Config.onoff.log_ip_on_direct) + hierarchyNote(&sslState->request->hier, sslState->servers->code, + fd_table[sslState->server.fd].ipaddr); + else + hierarchyNote(&sslState->request->hier, sslState->servers->code, + sslState->host); if (status == COMM_ERR_DNS) { debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host); err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND); @@ -546,9 +555,6 @@ sslPeerSelectComplete(FwdServer * fs, void *data) sslState->delay_id = 0; } #endif - hierarchyNote(&sslState->request->hier, - fs->peer ? fs->code : DIRECT, - sslState->host); commConnectStart(sslState->server.fd, sslState->host, sslState->port, diff --git a/src/structs.h b/src/structs.h index 3f30fef250..60ac6552fb 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.320 2000/05/02 18:51:51 hno Exp $ + * $Id: structs.h,v 1.321 2000/05/02 19:35:24 hno Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -416,6 +416,7 @@ struct _SquidConfig { #if USE_CACHE_DIGESTS int digest_generation; #endif + int log_ip_on_direct; } onoff; acl *aclList; struct { diff --git a/src/tunnel.cc b/src/tunnel.cc index ce83f7ab7b..111352f23f 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.102 2000/03/06 16:23:34 wessels Exp $ + * $Id: tunnel.cc,v 1.103 2000/05/02 19:35:23 hno Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -377,6 +377,15 @@ sslConnectDone(int fdnotused, int status, void *data) SslStateData *sslState = data; request_t *request = sslState->request; ErrorState *err = NULL; + if (sslState->servers->peer) + hierarchyNote(&sslState->request->hier, sslState->servers->code, + sslState->servers->peer->host); + else if (Config.onoff.log_ip_on_direct) + hierarchyNote(&sslState->request->hier, sslState->servers->code, + fd_table[sslState->server.fd].ipaddr); + else + hierarchyNote(&sslState->request->hier, sslState->servers->code, + sslState->host); if (status == COMM_ERR_DNS) { debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host); err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND); @@ -546,9 +555,6 @@ sslPeerSelectComplete(FwdServer * fs, void *data) sslState->delay_id = 0; } #endif - hierarchyNote(&sslState->request->hier, - fs->peer ? fs->code : DIRECT, - sslState->host); commConnectStart(sslState->server.fd, sslState->host, sslState->port,