]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add logformat code %>rd to log client URL domain name
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Jan 2014 02:56:31 +0000 (18:56 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 5 Jan 2014 02:56:31 +0000 (18:56 -0800)
Logging the Host header or the full URL have been the only ways to log
the domain name requested by the client. However full URL may contain
far too many unwanted bytes and Host header many contain a host:port
very different to the URL.

 This work is sponsored by Brendan Kearney

src/cf.data.pre
src/format/ByteCode.h
src/format/Format.cc
src/format/Token.cc

index 657d1ca210d15222cb099b22eae9fed743059801..b086986690e6467e6e4a30737f90d892b1e8f84e 100644 (file)
@@ -3761,6 +3761,7 @@ DOC_START
                [http::]ru      Request URL from client (historic, filtered for logging)
                [http::]>ru     Request URL from client
                [http::]<ru     Request URL sent to server or peer
+               [http::]>rd     Request URL domain from client
                [http::]rp      Request URL-Path excluding hostname
                [http::]>rp     Request URL-Path excluding hostname from client
                [http::]<rp     Request URL-Path excluding hostname sent to server or peer
index e19d7d4a1e4b1b704cdb80bd9279029d1ce17674..93082f0968ac35e2373a4f5aa742b9c8fb001e7a 100644 (file)
@@ -58,6 +58,7 @@ typedef enum {
     /* original Request-Line details recieved from client */
     LFT_CLIENT_REQ_METHOD,
     LFT_CLIENT_REQ_URI,
+    LFT_CLIENT_REQ_URLDOMAIN,
     LFT_CLIENT_REQ_URLPATH,
     /* LFT_CLIENT_REQ_QUERY, */
     LFT_CLIENT_REQ_VERSION,
index f15ff7596c85e73052c27fc9b8fcafd3cdc61e29..dee57681ae92f5491c37d646bb64d268c5665eeb 100644 (file)
@@ -929,6 +929,13 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS
             }
             break;
 
+        case LFT_CLIENT_REQ_URLDOMAIN:
+            if (al->request) {
+                out = al->request->GetHost();
+                quote = 1;
+            }
+            break;
+
         case LFT_REQUEST_URLPATH_OLD_31:
         case LFT_CLIENT_REQ_URLPATH:
             if (al->request) {
index a0341be0d83067de711519b58769fdd9938a5a70..72c90dbeae868b20023e47dff7a53e3398954704 100644 (file)
@@ -81,6 +81,7 @@ static TokenTableEntry TokenTable2C[] = {
 
     {">rm", LFT_CLIENT_REQ_METHOD},
     {">ru", LFT_CLIENT_REQ_URI},
+    {">rd", LFT_CLIENT_REQ_URLDOMAIN},
     {">rp", LFT_CLIENT_REQ_URLPATH},
     /*{">rq", LFT_CLIENT_REQ_QUERY},*/
     {">rv", LFT_CLIENT_REQ_VERSION},