]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
hno squid-2.2.STABLE5.log_ip_on_direct.patch with additions
authorhno <>
Wed, 3 May 2000 01:35:23 +0000 (01:35 +0000)
committerhno <>
Wed, 3 May 2000 01:35:23 +0000 (01:35 +0000)
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

ChangeLog
src/cf.data.pre
src/forward.cc
src/ssl.cc
src/structs.h
src/tunnel.cc

index 70b3bcb9692459ecd79433ff7b2371e875d4dde1..c08f8dd9bab17be23deae5f4e84ab7db8ca7f0b8 100644 (file)
--- 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 ():
 
index fc28049fc1586a49ed76096438a7439e1c16587e..b79cf6ce866312d1890102ef4601ffeb0af167fb 100644 (file)
@@ -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
index 4dde99b4eca0c33cfe42b9c9f704ea272a1f1128..01a40c3eee3e7caed3f2a1b1c4926e9020ee16e4 100644 (file)
@@ -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;
index 67c39e9324af09527f12a9e706676b4cc19aae87..101bd62269fe969e320cf124173fcad8e857e7f4 100644 (file)
@@ -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,
index 3f30fef2505e132901f8972a8e4ae354bfa5c9c0..60ac6552fb7d2544174b937d74e7c60c2cb601f9 100644 (file)
@@ -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 {
index ce83f7ab7b8c7939278006b1740c64454357ecab..111352f23f49894b18e3dae7c501903e89d757e3 100644 (file)
@@ -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,