From f42e17d18d53848ddb78ce7c29e0c06709719a26 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 2 Jun 2026 22:47:57 +1200 Subject: [PATCH 1/2] Replace built-in logformat referrer --- src/cf.data.pre | 2 +- src/log/Config.cc | 6 ------ src/log/FormatSquidReferer.cc | 39 ----------------------------------- src/log/Formats.h | 4 ---- src/log/Makefile.am | 1 - src/log/access_log.cc | 4 ---- src/tests/stub_liblog.cc | 1 - 7 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 src/log/FormatSquidReferer.cc diff --git a/src/cf.data.pre b/src/cf.data.pre index 51c90a376e8..a1ffb11d448 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -4671,7 +4671,7 @@ COMMENT_END NAME: logformat TYPE: logformat LOC: Log::TheConfig -DEFAULT: none +DEFAULT: referrer %ts.%03tu %>a %{Referer}http::>h %http::ru DEFAULT_DOC: The format definitions squid, common, combined, referrer, useragent are built in. DOC_START Usage: diff --git a/src/log/Config.cc b/src/log/Config.cc index 37261373263..676a232c8da 100644 --- a/src/log/Config.cc +++ b/src/log/Config.cc @@ -39,9 +39,6 @@ Log::LogConfig::BuiltInFormatName(const Format::log_type logformatType) case Format::CLF_USERAGENT: return "useragent"; - - case Log::Format::CLF_REFERER: - return "referrer"; } // forgotten (by developers) type, invalid type, or unreachable code @@ -75,9 +72,6 @@ Log::LogConfig::FindBuiltInFormat(const char *logformatName) if (strcmp(logformatName, "useragent") == 0) return Format::CLF_USERAGENT; - if (strcmp(logformatName, "referrer") == 0) - return Format::CLF_REFERER; - // CLF_NONE, CLF_UNKNOWN, CLF_CUSTOM types cannot be specified explicitly. // TODO: Ban "none" and "unknown" custom logformat names to avoid confusion. return Format::CLF_UNKNOWN; diff --git a/src/log/FormatSquidReferer.cc b/src/log/FormatSquidReferer.cc deleted file mode 100644 index 20290fb68e4..00000000000 --- a/src/log/FormatSquidReferer.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 1996-2026 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -/* DEBUG: section 46 Access Log - Squid referer format */ - -#include "squid.h" -#include "AccessLogEntry.h" -#include "HttpRequest.h" -#include "log/File.h" -#include "log/Formats.h" - -void -Log::Format::SquidReferer(const AccessLogEntry::Pointer &al, Logfile *logfile) -{ - const char *referer = nullptr; - if (al->request) - referer = al->request->header.getStr(Http::HdrType::REFERER); - - if (!referer || *referer == '\0') - referer = "-"; - - char clientip[MAX_IPSTRLEN]; - al->getLogClientIp(clientip, MAX_IPSTRLEN); - - const SBuf url = !al->url.isEmpty() ? al->url : ::Format::Dash; - - logfilePrintf(logfile, "%9ld.%03d %s %s " SQUIDSBUFPH "\n", - (long int) current_time.tv_sec, - (int) current_time.tv_usec / 1000, - clientip, - referer, - SQUIDSBUFPRINT(url)); -} - diff --git a/src/log/Formats.h b/src/log/Formats.h index 43e010d628c..702a228a626 100644 --- a/src/log/Formats.h +++ b/src/log/Formats.h @@ -31,7 +31,6 @@ typedef enum { #if ICAP_CLIENT CLF_ICAP_SQUID, #endif - CLF_REFERER, CLF_SQUID, CLF_USERAGENT, CLF_NONE @@ -46,9 +45,6 @@ void SquidIcap(const AccessLogEntryPointer &al, Logfile * logfile); /// Display log details in useragent format. void SquidUserAgent(const AccessLogEntryPointer &al, Logfile * logfile); -/// Display log details in Squid old refererlog format. -void SquidReferer(const AccessLogEntryPointer &al, Logfile * logfile); - /// Log with a local custom format void SquidCustom(const AccessLogEntryPointer &al, CustomLog * log); diff --git a/src/log/Makefile.am b/src/log/Makefile.am index 51aa345e32b..6daf03f34e3 100644 --- a/src/log/Makefile.am +++ b/src/log/Makefile.am @@ -26,7 +26,6 @@ liblog_la_SOURCES = \ FormatSquidCustom.cc \ FormatSquidIcap.cc \ FormatSquidNative.cc \ - FormatSquidReferer.cc \ FormatSquidUseragent.cc \ Formats.h \ FormattedLog.cc \ diff --git a/src/log/access_log.cc b/src/log/access_log.cc index 1f0f12c4723..2253d905a66 100644 --- a/src/log/access_log.cc +++ b/src/log/access_log.cc @@ -100,10 +100,6 @@ accessLogLogTo(CustomLog *log, const AccessLogEntryPointer &al, ACLChecklist *ch Log::Format::HttpdCommon(al, log->logfile); break; - case Log::Format::CLF_REFERER: - Log::Format::SquidReferer(al, log->logfile); - break; - case Log::Format::CLF_USERAGENT: Log::Format::SquidUserAgent(al, log->logfile); break; diff --git a/src/tests/stub_liblog.cc b/src/tests/stub_liblog.cc index cd971198b20..022c68d8274 100644 --- a/src/tests/stub_liblog.cc +++ b/src/tests/stub_liblog.cc @@ -69,7 +69,6 @@ namespace Format void SquidNative(const AccessLogEntryPointer &, Logfile *) STUB void SquidIcap(const AccessLogEntryPointer &, Logfile *) STUB void SquidUserAgent(const AccessLogEntryPointer &, Logfile *) STUB -void SquidReferer(const AccessLogEntryPointer &, Logfile *) STUB void SquidCustom(const AccessLogEntryPointer &, CustomLog *) STUB void HttpdCommon(const AccessLogEntryPointer &, Logfile *) STUB void HttpdCombined(const AccessLogEntryPointer &, Logfile *) STUB From c1ff0eb49dfc8fba1d64eb85139f6eebee08423c Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 2 Jun 2026 22:55:45 +1200 Subject: [PATCH 2/2] remove debugs documentation --- doc/debug-sections.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/debug-sections.txt b/doc/debug-sections.txt index d4b16d8f3a1..324a5e1223a 100644 --- a/doc/debug-sections.txt +++ b/doc/debug-sections.txt @@ -89,7 +89,6 @@ section 46 Access Log - Apache common format section 46 Access Log - Squid Custom format section 46 Access Log - Squid ICAP Logging section 46 Access Log - Squid format -section 46 Access Log - Squid referer format section 46 Access Log - Squid useragent format section 47 Store Directory Routines section 47 Store Search