AccessLogEntry.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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 
9 #include "squid.h"
10 #include "AccessLogEntry.h"
11 #include "HttpReply.h"
12 #include "HttpRequest.h"
13 #include "SquidConfig.h"
14 #include "ssl/support.h"
15 
16 void
17 AccessLogEntry::getLogClientIp(char *buf, size_t bufsz) const
18 {
19  Ip::Address log_ip;
20 
21 #if FOLLOW_X_FORWARDED_FOR
23  log_ip = request->indirect_client_addr;
24  else
25 #endif
26  if (tcpClient)
27  log_ip = tcpClient->remote;
28  else
29  log_ip = cache.caddr;
30 
31  // internally generated requests (and some ICAP) lack client IP
32  if (log_ip.isNoAddr()) {
33  strncpy(buf, "-", bufsz);
34  return;
35  }
36 
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.
41 
42  if (!log_ip.isLocalhost() && log_ip.isIPv4())
44 
45  log_ip.toStr(buf, bufsz);
46 }
47 
48 SBuf
50 {
51  SBuf method;
52  if (icp.opcode)
54  else if (htcp.opcode)
55  method.append(htcp.opcode);
56  else
57  method = http.method.image();
58  return method;
59 }
60 
61 void
63 {
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.
66  assert(req);
67  if (!notes)
68  notes = req->notes();
69  else
70  assert(notes == req->notes());
71 }
72 
73 const char *
75 {
76  if (tcpClient)
77  return tcpClient->rfc931;
78 
79  if (cache.rfc931 && *cache.rfc931)
80  return cache.rfc931;
81 
82  return nullptr;
83 }
84 
85 const char *
87 {
88  if (request && request->extacl_user.size())
89  return request->extacl_user.termedBuf();
90 
91  if (cache.extuser && *cache.extuser)
92  return cache.extuser;
93 
94  return nullptr;
95 }
96 
98 {
100 
101 #if USE_ADAPTATION
103 #endif
104 
106 
109 
111 
114 #if ICAP_CLIENT
117 #endif
118 }
119 
#define assert(EX)
Definition: assert.h:17
class AccessLogEntry::IcapLogEntry icap
NotePairs::Pointer notes
Definition: SBuf.h:87
void getLogClientIp(char *buf, size_t bufsz) const
int log_uses_indirect_client
Definition: SquidConfig.h:328
bool isNoAddr() const
Definition: Address.cc:277
SBuf & append(const SBuf &S)
Definition: SBuf.cc:207
#define safe_free(x)
Definition: xalloc.h:73
HttpRequest * request
ICAP request.
bool isLocalhost() const
Definition: Address.cc:242
int applyMask(const Address &mask)
Definition: Address.cc:87
char * last_meta
image of the last ICAP response header or eCAP meta received
Comm::ConnectionPointer tcpClient
TCP/IP level details about the client connection.
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
size_type size() const
Definition: SquidString.h:71
const char * lastAclName
string for external_acl_type ACL format code
NotePairs::Pointer notes()
Definition: HttpRequest.cc:681
HttpRequest * adapted_request
HttpReply * reply
class AccessLogEntry::HtcpDetails htcp
class AccessLogEntry::AdaptationDetails adapt
char const * termedBuf() const
Definition: SquidString.h:90
const char * getExtUser() const
Fetch the external ACL provided 'user=' string, or nil if none is available.
class AccessLogEntry::Headers headers
HttpRequest * request
Ip::Address client_netmask
Definition: SquidConfig.h:238
class AccessLogEntry::IcpDetails icp
class AccessLogEntry::HttpDetails http
bool isIPv4() const
Definition: Address.cc:151
void const char * buf
Definition: stub_helper.cc:16
class AccessLogEntry::CacheDetails cache
struct SquidConfig::@112 onoff
HttpReply * reply
ICAP reply.
struct SquidConfig::@107 Addrs
char rfc931[USER_IDENT_SZ]
Definition: Connection.h:155
const SBuf & image() const
Ip::Address remote
Definition: Connection.h:138
String extacl_user
Definition: HttpRequest.h:167
size_t HttpReply *STUB StoreEntry const KeyScope scope const HttpRequestMethod & method
Definition: stub_store.cc:126
void syncNotes(HttpRequest *request)
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:810
Ip::Address indirect_client_addr
Definition: HttpRequest.h:140
HttpRequestMethod method
class SquidConfig Config
Definition: SquidConfig.cc:12
void HTTPMSGUNLOCK(Http::Message *a)
Definition: Message.h:144
const char * getClientIdent() const
Fetch the client IDENT string, or nil if none is available.
const char * icp_opcode_str[]

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors