]> git.ipfire.org Git - thirdparty/squid.git/blob - src/AccessLogEntry.cc
Prep for 3.3.12 and 3.4.4
[thirdparty/squid.git] / src / AccessLogEntry.cc
1 #include "squid.h"
2 #include "AccessLogEntry.h"
3 #include "HttpReply.h"
4 #include "HttpRequest.h"
5 #include "SquidConfig.h"
6
7 #if USE_SSL
8 #include "ssl/support.h"
9
10 AccessLogEntry::SslDetails::SslDetails(): user(NULL), bumpMode(::Ssl::bumpEnd)
11 {
12 }
13 #endif /* USE_SSL */
14
15 void
16 AccessLogEntry::getLogClientIp(char *buf, size_t bufsz) const
17 {
18 Ip::Address log_ip;
19
20 #if FOLLOW_X_FORWARDED_FOR
21 if (Config.onoff.log_uses_indirect_client && request)
22 log_ip = request->indirect_client_addr;
23 else
24 #endif
25 if (tcpClient != NULL)
26 log_ip = tcpClient->remote;
27 else if (cache.caddr.isNoAddr()) { // e.g., ICAP OPTIONS lack client
28 strncpy(buf, "-", bufsz);
29 return;
30 } else
31 log_ip = cache.caddr;
32
33 // Apply so-called 'privacy masking' to IPv4 clients
34 // - localhost IP is always shown in full
35 // - IPv4 clients masked with client_netmask
36 // - IPv6 clients use 'privacy addressing' instead.
37
38 if (!log_ip.isLocalhost() && log_ip.isIPv4())
39 log_ip.applyMask(Config.Addrs.client_netmask);
40
41 log_ip.toStr(buf, bufsz);
42 }
43
44 AccessLogEntry::~AccessLogEntry()
45 {
46 safe_free(headers.request);
47
48 #if USE_ADAPTATION
49 safe_free(adapt.last_meta);
50 #endif
51
52 safe_free(headers.reply);
53
54 safe_free(headers.adapted_request);
55 HTTPMSGUNLOCK(adapted_request);
56
57 HTTPMSGUNLOCK(reply);
58 HTTPMSGUNLOCK(request);
59 #if ICAP_CLIENT
60 HTTPMSGUNLOCK(icap.reply);
61 HTTPMSGUNLOCK(icap.request);
62 #endif
63 cbdataReferenceDone(cache.port);
64 }