]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Thu, 13 Jul 2000 12:13:42 +0000 (12:13 +0000)
committerwessels <>
Thu, 13 Jul 2000 12:13:42 +0000 (12:13 +0000)
 - Jens-S. Voeckler <voeckler@rvs.uni-hannover.de> submitted this
   patch for referer header logging.

src/Makefile.in
src/cf.data.pre
src/client_side.cc
src/main.cc
src/protos.h
src/referer.cc [new file with mode: 0644]
src/structs.h

index 5c890af3eae9ce0b700806ec69cc11b237104358..41403273a55d53462fb602cdc9e0597cd5510440 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.190 2000/06/27 08:35:09 hno Exp $
+#  $Id: Makefile.in,v 1.191 2000/07/13 06:13:42 wessels Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -150,6 +150,7 @@ OBJS                = \
                peer_select.o \
                pump.o \
                redirect.o \
+               referer.o \
                refresh.o \
                repl_modules.o \
                send-announce.o \
index 1f18fc739e5301be8b7720b5eefe364f4917c139..8064f7719fbf804e2b4390897e2e3dec50e2a4e5 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.191 2000/06/26 04:57:16 wessels Exp $
+# $Id: cf.data.pre,v 1.192 2000/07/13 06:13:42 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -833,6 +833,20 @@ DOC_START
 DOC_END
 
 
+NAME: referer_log
+TYPE: string
+LOC: Config.Log.referer
+DEFAULT: none
+DOC_START
+       If configured with the "--enable-referer_log" configure
+       option, Squid will write the Referer field from HTTP
+       requests to the filename specified here.  By default
+       referer_log is disabled.
+
+referer_log none
+DOC_END
+
+
 NAME: pid_filename
 TYPE: string
 DEFAULT: @DEFAULT_PID_FILE@
index 2eddd3ae1a02725145219eda88516a255ec2dd06..67ffaa2d9390af64608862af4c5356a2e6fa44e1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.491 2000/07/12 16:20:02 wessels Exp $
+ * $Id: client_side.cc,v 1.492 2000/07/13 06:13:42 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -810,7 +810,7 @@ clientInterpretRequestHeaders(clientHttpRequest * http)
     request_t *request = http->request;
     const HttpHeader *req_hdr = &request->header;
     int no_cache = 0;
-#if USE_USERAGENT_LOG
+#if defined(USE_USERAGENT_LOG) || defined(USE_REFERER_LOG)
     const char *str;
 #endif
     request->imslen = -1;
@@ -868,6 +868,11 @@ clientInterpretRequestHeaders(clientHttpRequest * http)
     if ((str = httpHeaderGetStr(req_hdr, HDR_USER_AGENT)))
        logUserAgent(fqdnFromAddr(http->conn->peer.sin_addr), str);
 #endif
+#if USE_REFERER_LOG
+    if ((str = httpHeaderGetStr(req_hdr, HDR_REFERER)))
+       logReferer(fqdnFromAddr(http->conn->peer.sin_addr), str,
+           http->log_uri);
+#endif
 #if FORW_VIA_DB
     if (httpHeaderHas(req_hdr, HDR_X_FORWARDED_FOR)) {
        String s = httpHeaderGetList(req_hdr, HDR_X_FORWARDED_FOR);
index e573f9a6d338742769db4f679debf34681d46ab7..bb31811ac800dcb54b2dd1ae552f00e6b62e36d2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.315 2000/06/27 22:06:03 hno Exp $
+ * $Id: main.cc,v 1.316 2000/07/13 06:13:42 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -390,6 +390,7 @@ mainRotate(void)
     storeLogRotate();          /* store.log */
     accessLogRotate();         /* access.log */
     useragentRotateLog();      /* useragent.log */
+    refererRotateLog();                /* referer.log */
     icmpOpen();
 #if USE_DNSSERVERS
     dnsInit();
@@ -486,6 +487,7 @@ mainInitialize(void)
     redirectInit();
     authenticateInit();
     useragentOpenLog();
+    refererOpenLog();
     httpHeaderInitModule();    /* must go before any header processing (e.g. the one in errorInitialize) */
     httpReplyInitModule();     /* must go before accepting replies */
     errorInitialize();
index 44d712ee044748f59cd73ce977c2b0d5d7b41ee9..36915ea71186cdfdaa4d7f8b46eef73ea9508f7a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.375 2000/06/27 08:41:30 hno Exp $
+ * $Id: protos.h,v 1.376 2000/07/13 06:13:42 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1038,6 +1038,9 @@ extern void urlExtMethodConfigure();
 extern void useragentOpenLog(void);
 extern void useragentRotateLog(void);
 extern void logUserAgent(const char *, const char *);
+extern void refererOpenLog(void);
+extern void refererRotateLog(void);
+extern void logReferer(const char *, const char *, const char *);
 extern peer_t parseNeighborType(const char *s);
 
 extern void errorInitialize(void);
diff --git a/src/referer.cc b/src/referer.cc
new file mode 100644 (file)
index 0000000..d401b61
--- /dev/null
@@ -0,0 +1,79 @@
+
+/*
+ * $Id: referer.cc,v 1.1 2000/07/13 06:13:43 wessels Exp $
+ *
+ * DEBUG: section 40    User-Agent and Referer logging
+ * AUTHOR: Joe Ramey <ramey@csc.ti.com> (useragent)
+ *         Jens-S. Vöckler <voeckler@rvs.uni-hannover.de> (mod 4 referer)
+ *
+ * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from the
+ *  Internet community.  Development is led by Duane Wessels of the
+ *  National Laboratory for Applied Network Research and funded by the
+ *  National Science Foundation.  Squid is Copyrighted (C) 1998 by
+ *  the Regents of the University of California.  Please see the
+ *  COPYRIGHT file for full details.  Squid incorporates software
+ *  developed and/or copyrighted by other sources.  Please see the
+ *  CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#include "squid.h"
+
+#if USE_REFERER_LOG
+static Logfile *refererlog = NULL;
+#endif
+
+void
+refererOpenLog(void)
+{
+#if USE_REFERER_LOG
+    assert(NULL == refererlog);
+    if (!Config.Log.referer || (0 == strcmp(Config.Log.referer, "none"))) {
+       debug(40, 1) ("Referer logging is disabled.\n");
+       return;
+    }
+    logfileOpen(Config.Log.referer, 0);
+#endif
+}
+
+void
+refererRotateLog(void)
+{
+#if USE_REFERER_LOG
+    if (NULL == refererlog)
+       return;
+    logfileRotate(refererlog);
+#endif
+}
+
+void
+logReferer(const char *client, const char *referer, const char *uri)
+{
+#if USE_REFERER_LOG
+    if (NULL == refererlog)
+       return;
+    logfilePrintf(refererlog, "%9d.%03d %s %s %s\n",
+       (int) current_time.tv_sec,
+       (int) current_time.tv_usec / 1000,
+       client,
+       referer,
+       uri ? uri : "-");
+#endif
+}
index 516a5bad9375ea981172b730359bdb4eef7f9a39..cccc644c8dc6ae3b9866d8eda91c6ac5c768349f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.346 2000/06/27 08:41:31 hno Exp $
+ * $Id: structs.h,v 1.347 2000/07/13 06:13:43 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -296,6 +296,9 @@ struct _SquidConfig {
        char *swap;
 #if USE_USERAGENT_LOG
        char *useragent;
+#endif
+#if USE_REFERER_LOG
+       char *referer;
 #endif
        int rotateNumber;
     } Log;