]>
Commit | Line | Data |
---|---|---|
fd2c5549 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
fd2c5549 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
fd2c5549 | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 46 Access Log - Squid ICAP Logging */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
20efa1c2 AJ |
12 | |
13 | #if ICAP_CLIENT | |
14 | ||
15 | #include "AccessLogEntry.h" | |
38e16f92 | 16 | #include "format/Quoting.h" |
95e6d864 | 17 | #include "fqdncache.h" |
20efa1c2 | 18 | #include "HttpRequest.h" |
82b7abe3 | 19 | #include "log/File.h" |
20efa1c2 | 20 | #include "log/Formats.h" |
4d5904f7 | 21 | #include "SquidConfig.h" |
0268f798 | 22 | #include "SquidTime.h" |
23 | ||
fd2c5549 | 24 | void |
41ebd397 | 25 | Log::Format::SquidIcap(const AccessLogEntry::Pointer &al, Logfile * logfile) |
fd2c5549 | 26 | { |
20efa1c2 AJ |
27 | const char *client = NULL; |
28 | const char *user = NULL; | |
29 | char tmp[MAX_IPSTRLEN], clientbuf[MAX_IPSTRLEN]; | |
30 | ||
4dd643d5 | 31 | if (al->cache.caddr.isAnyAddr()) { // ICAP OPTIONS xactions lack client |
20efa1c2 AJ |
32 | client = "-"; |
33 | } else { | |
34 | if (Config.onoff.log_fqdn) | |
35 | client = fqdncache_gethostbyaddr(al->cache.caddr, FQDN_LOOKUP_IF_MISS); | |
36 | if (!client) | |
4dd643d5 | 37 | client = al->cache.caddr.toStr(clientbuf, MAX_IPSTRLEN); |
fd2c5549 | 38 | } |
62e76326 | 39 | |
c0e8c76f AJ |
40 | #if USE_AUTH |
41 | if (al->request != NULL && al->request->auth_user_request != NULL) | |
42 | user = ::Format::QuoteUrlEncodeUsername(al->request->auth_user_request->username()); | |
43 | #endif | |
62e76326 | 44 | |
20efa1c2 | 45 | if (!user) |
e3bf07f5 | 46 | user = ::Format::QuoteUrlEncodeUsername(al->getExtUser()); |
62e76326 | 47 | |
cb4f4424 | 48 | #if USE_OPENSSL |
20efa1c2 | 49 | if (!user) |
38e16f92 | 50 | user = ::Format::QuoteUrlEncodeUsername(al->cache.ssluser); |
fd2c5549 | 51 | #endif |
fd2c5549 | 52 | |
20efa1c2 | 53 | if (!user) |
e3bf07f5 | 54 | user = ::Format::QuoteUrlEncodeUsername(al->getClientIdent()); |
62e76326 | 55 | |
20efa1c2 AJ |
56 | if (user && !*user) |
57 | safe_free(user); | |
62e76326 | 58 | |
01bd87d8 | 59 | logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " %s %s %s -/%s -\n", |
20efa1c2 | 60 | (long int) current_time.tv_sec, |
62e76326 | 61 | (int) current_time.tv_usec / 1000, |
01bd87d8 | 62 | tvToMsec(al->icap.trTime), |
62e76326 | 63 | client, |
f5f9e44c | 64 | al->icap.outcome, |
20efa1c2 AJ |
65 | al->icap.resStatus, |
66 | al->icap.bytesRead, | |
67 | Adaptation::Icap::ICAP::methodStr(al->icap.reqMethod), | |
68 | al->icap.reqUri.termedBuf(), | |
69 | user ? user : "-", | |
4dd643d5 | 70 | al->icap.hostAddr.toStr(tmp, MAX_IPSTRLEN)); |
20efa1c2 | 71 | safe_free(user); |
fd2c5549 | 72 | } |
c9b99797 | 73 | #endif |
f53969cc | 74 |