]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/AccessLogEntry.cc
2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
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.
10 #include "AccessLogEntry.h"
11 #include "HttpReply.h"
12 #include "HttpRequest.h"
13 #include "SquidConfig.h"
14 #include "ssl/support.h"
17 AccessLogEntry::getLogClientIp(char *buf
, size_t bufsz
) const
21 #if FOLLOW_X_FORWARDED_FOR
22 if (Config
.onoff
.log_uses_indirect_client
&& request
)
23 log_ip
= request
->indirect_client_addr
;
27 log_ip
= tcpClient
->remote
;
31 // internally generated requests (and some ICAP) lack client IP
32 if (log_ip
.isNoAddr()) {
33 strncpy(buf
, "-", bufsz
);
37 // Apply so-called 'privacy masking' to IPv4 clients
38 // - localhost IP is always shown in full
39 // - IPv4 clients masked with client_netmask
40 // - IPv6 clients use 'privacy addressing' instead.
42 if (!log_ip
.isLocalhost() && log_ip
.isIPv4())
43 log_ip
.applyMask(Config
.Addrs
.client_netmask
);
45 log_ip
.toStr(buf
, bufsz
);
49 AccessLogEntry::getLogMethod() const
53 method
.append(icp_opcode_str
[icp
.opcode
]);
55 method
.append(htcp
.opcode
);
57 method
= http
.method
.image();
62 AccessLogEntry::syncNotes(HttpRequest
*req
)
64 // XXX: auth code only has access to HttpRequest being authenticated
65 // so we must handle the case where HttpRequest is set without ALE being set.
70 assert(notes
== req
->notes());
74 AccessLogEntry::getClientIdent() const
77 return tcpClient
->rfc931
;
79 if (cache
.rfc931
&& *cache
.rfc931
)
86 AccessLogEntry::getExtUser() const
88 if (request
&& request
->extacl_user
.size())
89 return request
->extacl_user
.termedBuf();
91 if (cache
.extuser
&& *cache
.extuser
)
97 AccessLogEntry::~AccessLogEntry()
99 safe_free(headers
.request
);
102 safe_free(adapt
.last_meta
);
105 safe_free(headers
.reply
);
107 safe_free(headers
.adapted_request
);
108 HTTPMSGUNLOCK(adapted_request
);
110 safe_free(lastAclName
);
112 HTTPMSGUNLOCK(reply
);
113 HTTPMSGUNLOCK(request
);
115 HTTPMSGUNLOCK(icap
.reply
);
116 HTTPMSGUNLOCK(icap
.request
);