]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
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. | |
7 | */ | |
8 | ||
f7f3304a | 9 | #include "squid.h" |
d4204018 | 10 | #include "AccessLogEntry.h" |
582c2af2 | 11 | #include "HttpReply.h" |
d4204018 | 12 | #include "HttpRequest.h" |
4d5904f7 | 13 | #include "SquidConfig.h" |
08097970 | 14 | |
cb4f4424 | 15 | #if USE_OPENSSL |
f3d7d090 AJ |
16 | #include "ssl/support.h" |
17 | ||
71cae389 | 18 | AccessLogEntry::SslDetails::SslDetails(): user(NULL), bumpMode(::Ssl::bumpEnd) |
08097970 AR |
19 | { |
20 | } | |
cb4f4424 | 21 | #endif /* USE_OPENSSL */ |
08097970 | 22 | |
d4204018 AJ |
23 | void |
24 | AccessLogEntry::getLogClientIp(char *buf, size_t bufsz) const | |
25 | { | |
998ef291 AJ |
26 | Ip::Address log_ip; |
27 | ||
d4204018 AJ |
28 | #if FOLLOW_X_FORWARDED_FOR |
29 | if (Config.onoff.log_uses_indirect_client && request) | |
998ef291 | 30 | log_ip = request->indirect_client_addr; |
d4204018 AJ |
31 | else |
32 | #endif | |
33 | if (tcpClient != NULL) | |
998ef291 AJ |
34 | log_ip = tcpClient->remote; |
35 | else if (cache.caddr.isNoAddr()) { // e.g., ICAP OPTIONS lack client | |
0a84e4fb | 36 | strncpy(buf, "-", bufsz); |
998ef291 AJ |
37 | return; |
38 | } else | |
39 | log_ip = cache.caddr; | |
40 | ||
41 | // Apply so-called 'privacy masking' to IPv4 clients | |
42 | // - localhost IP is always shown in full | |
43 | // - IPv4 clients masked with client_netmask | |
44 | // - IPv6 clients use 'privacy addressing' instead. | |
45 | ||
46 | if (!log_ip.isLocalhost() && log_ip.isIPv4()) | |
47 | log_ip.applyMask(Config.Addrs.client_netmask); | |
48 | ||
49 | log_ip.toStr(buf, bufsz); | |
d4204018 | 50 | } |
41ebd397 CT |
51 | |
52 | AccessLogEntry::~AccessLogEntry() | |
53 | { | |
54 | safe_free(headers.request); | |
55 | ||
f5d0906a | 56 | #if USE_ADAPTATION |
41ebd397 CT |
57 | safe_free(adapt.last_meta); |
58 | #endif | |
59 | ||
60 | safe_free(headers.reply); | |
41ebd397 CT |
61 | |
62 | safe_free(headers.adapted_request); | |
63 | HTTPMSGUNLOCK(adapted_request); | |
64 | ||
65 | HTTPMSGUNLOCK(reply); | |
66 | HTTPMSGUNLOCK(request); | |
67 | #if ICAP_CLIENT | |
68 | HTTPMSGUNLOCK(icap.reply); | |
69 | HTTPMSGUNLOCK(icap.request); | |
70 | #endif | |
41ebd397 | 71 | } |
f53969cc | 72 |