]> git.ipfire.org Git - thirdparty/squid.git/blame - src/AccessLogEntry.cc
Prep for 3.3.12 and 3.4.4
[thirdparty/squid.git] / src / AccessLogEntry.cc
CommitLineData
f7f3304a 1#include "squid.h"
d4204018 2#include "AccessLogEntry.h"
582c2af2 3#include "HttpReply.h"
d4204018 4#include "HttpRequest.h"
4d5904f7 5#include "SquidConfig.h"
08097970 6
dc544ce5 7#if USE_SSL
f3d7d090
AJ
8#include "ssl/support.h"
9
71cae389 10AccessLogEntry::SslDetails::SslDetails(): user(NULL), bumpMode(::Ssl::bumpEnd)
08097970
AR
11{
12}
dc544ce5 13#endif /* USE_SSL */
08097970 14
d4204018
AJ
15void
16AccessLogEntry::getLogClientIp(char *buf, size_t bufsz) const
17{
998ef291
AJ
18 Ip::Address log_ip;
19
d4204018
AJ
20#if FOLLOW_X_FORWARDED_FOR
21 if (Config.onoff.log_uses_indirect_client && request)
998ef291 22 log_ip = request->indirect_client_addr;
d4204018
AJ
23 else
24#endif
25 if (tcpClient != NULL)
998ef291
AJ
26 log_ip = tcpClient->remote;
27 else if (cache.caddr.isNoAddr()) { // e.g., ICAP OPTIONS lack client
0a84e4fb 28 strncpy(buf, "-", bufsz);
998ef291
AJ
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);
d4204018 42}
41ebd397
CT
43
44AccessLogEntry::~AccessLogEntry()
45{
46 safe_free(headers.request);
47
f5d0906a 48#if USE_ADAPTATION
41ebd397
CT
49 safe_free(adapt.last_meta);
50#endif
51
52 safe_free(headers.reply);
41ebd397
CT
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}