]>
Commit | Line | Data |
---|---|---|
450e0c10 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
450e0c10 | 3 | * |
bbc27441 AJ |
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. | |
450e0c10 | 7 | */ |
bbc27441 | 8 | |
450e0c10 | 9 | #ifndef SQUID_HTTPACCESSLOGENTRY_H |
10 | #define SQUID_HTTPACCESSLOGENTRY_H | |
11 | ||
65d448bc | 12 | #include "anyp/PortCfg.h" |
8bf217bd | 13 | #include "base/RefCount.h" |
a14f38d0 | 14 | #include "comm/Connection.h" |
602d9612 | 15 | #include "HierarchyLogEntry.h" |
526ed14e | 16 | #include "http/ProtocolVersion.h" |
f35c0145 | 17 | #include "http/RequestMethod.h" |
e74be5fd | 18 | #include "HttpHeader.h" |
c8f1812b | 19 | #include "icp_opcode.h" |
96d89ea0 | 20 | #include "ip/Address.h" |
02c8dde5 | 21 | #include "LogTags.h" |
cc0ca3b9 | 22 | #include "MessageSizes.h" |
02c8dde5 | 23 | #include "Notes.h" |
f57ae909 | 24 | #include "sbuf/SBuf.h" |
3ff65596 AR |
25 | #if ICAP_CLIENT |
26 | #include "adaptation/icap/Elements.h" | |
27 | #endif | |
cb4f4424 | 28 | #if USE_OPENSSL |
f4698e0b | 29 | #include "ssl/gadgets.h" |
78a4bf03 | 30 | #include "ssl/support.h" |
f4698e0b | 31 | #endif |
450e0c10 | 32 | |
62ee09ca | 33 | /* forward decls */ |
e1f7507e AJ |
34 | class HttpReply; |
35 | class HttpRequest; | |
613924ee | 36 | class CustomLog; |
62ee09ca | 37 | |
41ebd397 | 38 | class AccessLogEntry: public RefCountable |
450e0c10 | 39 | { |
40 | ||
41 | public: | |
41ebd397 CT |
42 | typedef RefCount<AccessLogEntry> Pointer; |
43 | ||
78a4bf03 | 44 | AccessLogEntry() {} |
41ebd397 | 45 | ~AccessLogEntry(); |
450e0c10 | 46 | |
d4204018 AJ |
47 | /// Fetch the client IP log string into the given buffer. |
48 | /// Knows about several alternate locations of the IP | |
49 | /// including indirect forwarded-for IP if configured to log that | |
50 | void getLogClientIp(char *buf, size_t bufsz) const; | |
51 | ||
e3bf07f5 AJ |
52 | /// Fetch the client IDENT string, or nil if none is available. |
53 | const char *getClientIdent() const; | |
54 | ||
55 | /// Fetch the external ACL provided 'user=' string, or nil if none is available. | |
56 | const char *getExtUser() const; | |
57 | ||
58b148e1 AJ |
58 | /// Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method) |
59 | SBuf getLogMethod() const; | |
60 | ||
75d47340 CT |
61 | void syncNotes(HttpRequest *request); |
62 | ||
f57ae909 | 63 | SBuf url; |
450e0c10 | 64 | |
a14f38d0 AJ |
65 | /// TCP/IP level details about the client connection |
66 | Comm::ConnectionPointer tcpClient; | |
67 | // TCP/IP level details about the server or peer connection | |
68 | // are stored in hier.tcpServer | |
69 | ||
4e26d606 AJ |
70 | /** \brief This subclass holds log info for HTTP protocol |
71 | * \todo Inner class declarations should be moved outside | |
72 | * \todo details of HTTP held in the parent class need moving into here. | |
73 | */ | |
450e0c10 | 74 | class HttpDetails |
75 | { | |
76 | ||
77 | public: | |
60745f24 | 78 | HttpRequestMethod method; |
78a4bf03 AJ |
79 | int code = 0; |
80 | const char *content_type = nullptr; | |
2592bc70 | 81 | AnyP::ProtocolVersion version; |
d6df21d2 AJ |
82 | |
83 | /// counters for the original request received from client | |
84 | // TODO calculate header and payload better (by parser) | |
85 | // XXX payload encoding overheads not calculated at all yet. | |
cc0ca3b9 | 86 | MessageSizes clientRequestSz; |
d6df21d2 AJ |
87 | |
88 | /// counters for the response sent to client | |
89 | // TODO calculate header and payload better (by parser) | |
90 | // XXX payload encoding overheads not calculated at all yet. | |
cc0ca3b9 | 91 | MessageSizes clientReplySz; |
d6df21d2 | 92 | |
2fadd50d | 93 | } http; |
450e0c10 | 94 | |
4e26d606 AJ |
95 | /** \brief This subclass holds log info for ICP protocol |
96 | * \todo Inner class declarations should be moved outside | |
97 | */ | |
98 | class IcpDetails | |
450e0c10 | 99 | { |
450e0c10 | 100 | public: |
78a4bf03 | 101 | icp_opcode opcode = ICP_INVALID; |
2fadd50d | 102 | } icp; |
450e0c10 | 103 | |
4e26d606 AJ |
104 | /** \brief This subclass holds log info for HTCP protocol |
105 | * \todo Inner class declarations should be moved outside | |
106 | */ | |
04f7fd38 AJ |
107 | class HtcpDetails |
108 | { | |
a8b1cdf6 | 109 | public: |
78a4bf03 | 110 | const char *opcode = nullptr; |
a8b1cdf6 AJ |
111 | } htcp; |
112 | ||
cb4f4424 | 113 | #if USE_OPENSSL |
08097970 | 114 | /// logging information specific to the SSL protocol |
87f237a9 A |
115 | class SslDetails |
116 | { | |
08097970 | 117 | public: |
78a4bf03 AJ |
118 | const char *user = nullptr; ///< emailAddress from the SSL client certificate |
119 | int bumpMode = ::Ssl::bumpEnd; ///< whether and how the request was SslBumped | |
08097970 AR |
120 | } ssl; |
121 | #endif | |
122 | ||
4e26d606 AJ |
123 | /** \brief This subclass holds log info for Squid internal stats |
124 | * \todo Inner class declarations should be moved outside | |
125 | * \todo some details relevant to particular protocols need shuffling to other sub-classes | |
126 | * \todo this object field need renaming to 'squid' or something. | |
127 | */ | |
450e0c10 | 128 | class CacheDetails |
129 | { | |
450e0c10 | 130 | public: |
78a4bf03 | 131 | CacheDetails() { |
d4806c91 | 132 | caddr.setNoAddr(); |
4579a6d0 | 133 | memset(&start_time, 0, sizeof(start_time)); |
01bd87d8 | 134 | memset(&trTime, 0, sizeof(start_time)); |
450e0c10 | 135 | } |
136 | ||
b7ac5457 | 137 | Ip::Address caddr; |
78a4bf03 AJ |
138 | int64_t highOffset = 0; |
139 | int64_t objectSize = 0; | |
140 | LogTags code = LOG_TAG_NONE; | |
af0ded40 | 141 | struct timeval start_time; ///< The time the master transaction started |
01bd87d8 | 142 | struct timeval trTime; ///< The response time |
78a4bf03 AJ |
143 | const char *rfc931 = nullptr; |
144 | const char *extuser = nullptr; | |
cb4f4424 | 145 | #if USE_OPENSSL |
78a4bf03 | 146 | const char *ssluser = nullptr; |
f97700a0 | 147 | Security::CertPointer sslClientCert; ///< cert received from the client |
450e0c10 | 148 | #endif |
fa720bfb | 149 | AnyP::PortCfgPointer port; |
2fadd50d | 150 | } cache; |
450e0c10 | 151 | |
4e26d606 AJ |
152 | /** \brief This subclass holds log info for various headers in raw format |
153 | * \todo shuffle this to the relevant protocol section. | |
154 | */ | |
450e0c10 | 155 | class Headers |
156 | { | |
450e0c10 | 157 | public: |
78a4bf03 AJ |
158 | char *request = nullptr; //< virgin HTTP request headers |
159 | char *adapted_request = nullptr; //< HTTP request headers after adaptation and redirection | |
160 | char *reply = nullptr; | |
99690f32 | 161 | } headers; |
3ff65596 | 162 | |
5038f9d8 | 163 | #if USE_ADAPTATION |
99690f32 AR |
164 | /** \brief This subclass holds general adaptation log info. |
165 | * \todo Inner class declarations should be moved outside. | |
166 | */ | |
167 | class AdaptationDetails | |
168 | { | |
99690f32 | 169 | public: |
99690f32 | 170 | /// image of the last ICAP response header or eCAP meta received |
78a4bf03 | 171 | char *last_meta = nullptr; |
99690f32 | 172 | } adapt; |
3ff65596 | 173 | #endif |
450e0c10 | 174 | |
78a4bf03 | 175 | const char *lastAclName = nullptr; ///< string for external_acl_type %ACL format code |
b0e14ce2 | 176 | SBuf lastAclData; ///< string for external_acl_type %DATA format code |
4ff6370b | 177 | |
450e0c10 | 178 | HierarchyLogEntry hier; |
78a4bf03 AJ |
179 | HttpReply *reply = nullptr; |
180 | HttpRequest *request = nullptr; //< virgin HTTP request | |
181 | HttpRequest *adapted_request = nullptr; //< HTTP request after adaptation and redirection | |
d06e17ea | 182 | |
f4f55a21 | 183 | /// key:value pairs set by squid.conf note directive and |
cf9f0261 | 184 | /// key=value pairs returned from URL rewrite/redirect helper |
f4f55a21 | 185 | NotePairs::Pointer notes; |
6fca33e0 | 186 | |
3ff65596 AR |
187 | #if ICAP_CLIENT |
188 | /** \brief This subclass holds log info for ICAP part of request | |
189 | * \todo Inner class declarations should be moved outside | |
190 | */ | |
e1381638 AJ |
191 | class IcapLogEntry |
192 | { | |
3ff65596 | 193 | public: |
78a4bf03 | 194 | IcapLogEntry() { |
01bd87d8 CT |
195 | memset(&trTime, 0, sizeof(trTime)); |
196 | memset(&ioTime, 0, sizeof(ioTime)); | |
197 | memset(&processingTime, 0, sizeof(processingTime)); | |
198 | } | |
3ff65596 | 199 | |
b7ac5457 | 200 | Ip::Address hostAddr; ///< ICAP server IP address |
3ff65596 AR |
201 | String serviceName; ///< ICAP service name |
202 | String reqUri; ///< ICAP Request-URI | |
78a4bf03 AJ |
203 | Adaptation::Icap::ICAP::Method reqMethod = Adaptation::methodNone; ///< ICAP request method |
204 | int64_t bytesSent = 0; ///< number of bytes sent to ICAP server so far | |
205 | int64_t bytesRead = 0; ///< number of bytes read from ICAP server so far | |
bae917ac | 206 | /** |
dcaab393 | 207 | * number of ICAP body bytes read from ICAP server or -1 for no encapsulated |
bae917ac CT |
208 | * message data in ICAP reply (eg 204 responses) |
209 | */ | |
78a4bf03 AJ |
210 | int64_t bodyBytesRead = -1; |
211 | HttpRequest* request = nullptr; ///< ICAP request | |
212 | HttpReply* reply = nullptr; ///< ICAP reply | |
3ff65596 | 213 | |
78a4bf03 | 214 | Adaptation::Icap::XactOutcome outcome = Adaptation::Icap::xoUnknown; ///< final transaction status |
3ff65596 AR |
215 | /** \brief Transaction response time. |
216 | * The timer starts when the ICAP transaction | |
217 | * is created and stops when the result of the transaction is logged | |
218 | */ | |
01bd87d8 | 219 | struct timeval trTime; |
3ff65596 AR |
220 | /** \brief Transaction I/O time. |
221 | * The timer starts when the first ICAP request | |
e1381638 | 222 | * byte is scheduled for sending and stops when the lastbyte of the |
3ff65596 AR |
223 | * ICAP response is received. |
224 | */ | |
01bd87d8 | 225 | struct timeval ioTime; |
78a4bf03 | 226 | Http::StatusCode resStatus = Http::scNone; ///< ICAP response status code |
01bd87d8 | 227 | struct timeval processingTime; ///< total ICAP processing time |
3ff65596 AR |
228 | } |
229 | icap; | |
230 | #endif | |
450e0c10 | 231 | }; |
232 | ||
e1f7507e AJ |
233 | class ACLChecklist; |
234 | class StoreEntry; | |
e1f7507e | 235 | |
450e0c10 | 236 | /* Should be in 'AccessLog.h' as the driver */ |
8a648e8d FC |
237 | void accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist* checklist = NULL); |
238 | void accessLogLog(AccessLogEntry::Pointer &, ACLChecklist * checklist); | |
239 | void accessLogRotate(void); | |
240 | void accessLogClose(void); | |
241 | void accessLogInit(void); | |
242 | const char *accessLogTime(time_t); | |
450e0c10 | 243 | |
244 | #endif /* SQUID_HTTPACCESSLOGENTRY_H */ | |
f53969cc | 245 |