]>
Commit | Line | Data |
---|---|---|
450e0c10 | 1 | /* |
450e0c10 | 2 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
3 | * ---------------------------------------------------------- | |
4 | * | |
5 | * Squid is the result of efforts by numerous individuals from | |
6 | * the Internet community; see the CONTRIBUTORS file for full | |
7 | * details. Many organizations have provided support for Squid's | |
8 | * development; see the SPONSORS file for full details. Squid is | |
9 | * Copyrighted (C) 2001 by the Regents of the University of | |
10 | * California; see the COPYRIGHT file for full details. Squid | |
11 | * incorporates software developed and/or copyrighted by other | |
12 | * sources; see the CREDITS file for full details. | |
13 | * | |
14 | * This program is free software; you can redistribute it and/or modify | |
15 | * it under the terms of the GNU General Public License as published by | |
16 | * the Free Software Foundation; either version 2 of the License, or | |
17 | * (at your option) any later version. | |
26ac0430 | 18 | * |
450e0c10 | 19 | * This program is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | * GNU General Public License for more details. | |
26ac0430 | 23 | * |
450e0c10 | 24 | * You should have received a copy of the GNU General Public License |
25 | * along with this program; if not, write to the Free Software | |
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
27 | * | |
28 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
29 | */ | |
450e0c10 | 30 | #ifndef SQUID_HTTPACCESSLOGENTRY_H |
31 | #define SQUID_HTTPACCESSLOGENTRY_H | |
32 | ||
65d448bc | 33 | #include "anyp/PortCfg.h" |
8bf217bd | 34 | #include "base/RefCount.h" |
a14f38d0 | 35 | #include "comm/Connection.h" |
d7f4a0b7 | 36 | #include "HttpHeader.h" |
450e0c10 | 37 | #include "HttpVersion.h" |
75cb38cb | 38 | #include "HttpRequestMethod.h" |
b24880fe | 39 | #include "HierarchyLogEntry.h" |
c8f1812b | 40 | #include "icp_opcode.h" |
96d89ea0 | 41 | #include "ip/Address.h" |
e1f7507e | 42 | #include "HttpRequestMethod.h" |
3ff65596 AR |
43 | #if ICAP_CLIENT |
44 | #include "adaptation/icap/Elements.h" | |
45 | #endif | |
d7f4a0b7 | 46 | #include "Notes.h" |
f4698e0b CT |
47 | #if USE_SSL |
48 | #include "ssl/gadgets.h" | |
49 | #endif | |
450e0c10 | 50 | |
62ee09ca | 51 | /* forward decls */ |
e1f7507e AJ |
52 | class HttpReply; |
53 | class HttpRequest; | |
613924ee | 54 | class CustomLog; |
62ee09ca | 55 | |
41ebd397 | 56 | class AccessLogEntry: public RefCountable |
450e0c10 | 57 | { |
58 | ||
59 | public: | |
41ebd397 CT |
60 | typedef RefCount<AccessLogEntry> Pointer; |
61 | ||
a14f38d0 | 62 | AccessLogEntry() : url(NULL), tcpClient(), reply(NULL), request(NULL), |
105d1937 | 63 | adapted_request(NULL) {} |
41ebd397 | 64 | ~AccessLogEntry(); |
450e0c10 | 65 | |
d4204018 AJ |
66 | /// Fetch the client IP log string into the given buffer. |
67 | /// Knows about several alternate locations of the IP | |
68 | /// including indirect forwarded-for IP if configured to log that | |
69 | void getLogClientIp(char *buf, size_t bufsz) const; | |
70 | ||
450e0c10 | 71 | const char *url; |
72 | ||
a14f38d0 AJ |
73 | /// TCP/IP level details about the client connection |
74 | Comm::ConnectionPointer tcpClient; | |
75 | // TCP/IP level details about the server or peer connection | |
76 | // are stored in hier.tcpServer | |
77 | ||
4e26d606 AJ |
78 | /** \brief This subclass holds log info for HTTP protocol |
79 | * \todo Inner class declarations should be moved outside | |
80 | * \todo details of HTTP held in the parent class need moving into here. | |
81 | */ | |
450e0c10 | 82 | class HttpDetails |
83 | { | |
84 | ||
85 | public: | |
c2a7cefd | 86 | HttpDetails() : method(Http::METHOD_NONE), code(0), content_type(NULL), |
307b696e | 87 | timedout(false), aborted(false) {} |
450e0c10 | 88 | |
60745f24 | 89 | HttpRequestMethod method; |
450e0c10 | 90 | int code; |
91 | const char *content_type; | |
92 | HttpVersion version; | |
f692498b AJ |
93 | bool timedout; ///< terminated due to a lifetime or I/O timeout |
94 | bool aborted; ///< other abnormal termination (e.g., I/O error) | |
95 | ||
96 | /// compute suffix for the status access.log field | |
97 | const char *statusSfx() const { | |
98 | return timedout ? "_TIMEDOUT" : (aborted ? "_ABORTED" : ""); | |
99 | } | |
2fadd50d | 100 | } http; |
450e0c10 | 101 | |
4e26d606 AJ |
102 | /** \brief This subclass holds log info for ICP protocol |
103 | * \todo Inner class declarations should be moved outside | |
104 | */ | |
105 | class IcpDetails | |
450e0c10 | 106 | { |
107 | ||
108 | public: | |
4e26d606 | 109 | IcpDetails() : opcode(ICP_INVALID) {} |
450e0c10 | 110 | |
111 | icp_opcode opcode; | |
2fadd50d | 112 | } icp; |
450e0c10 | 113 | |
4e26d606 AJ |
114 | /** \brief This subclass holds log info for HTCP protocol |
115 | * \todo Inner class declarations should be moved outside | |
116 | */ | |
04f7fd38 AJ |
117 | class HtcpDetails |
118 | { | |
a8b1cdf6 AJ |
119 | public: |
120 | HtcpDetails() : opcode(NULL) {}; | |
121 | ||
122 | const char *opcode; | |
123 | } htcp; | |
124 | ||
08097970 AR |
125 | #if USE_SSL |
126 | /// logging information specific to the SSL protocol | |
87f237a9 A |
127 | class SslDetails |
128 | { | |
08097970 | 129 | public: |
71cae389 | 130 | SslDetails(); |
08097970 AR |
131 | |
132 | const char *user; ///< emailAddress from the SSL client certificate | |
133 | int bumpMode; ///< whether and how the request was SslBumped | |
134 | } ssl; | |
135 | #endif | |
136 | ||
4e26d606 AJ |
137 | /** \brief This subclass holds log info for Squid internal stats |
138 | * \todo Inner class declarations should be moved outside | |
139 | * \todo some details relevant to particular protocols need shuffling to other sub-classes | |
140 | * \todo this object field need renaming to 'squid' or something. | |
141 | */ | |
450e0c10 | 142 | class CacheDetails |
143 | { | |
144 | ||
145 | public: | |
cc192b50 | 146 | CacheDetails() : caddr(), |
1a86db31 AJ |
147 | requestSize(0), |
148 | replySize(0), | |
3ff65596 AR |
149 | requestHeadersSize(0), |
150 | replyHeadersSize(0), | |
450e0c10 | 151 | highOffset(0), |
152 | objectSize(0), | |
153 | code (LOG_TAG_NONE), | |
154 | msec(0), | |
155 | rfc931 (NULL), | |
156 | authuser (NULL), | |
41ebd397 | 157 | extuser(NULL), |
450e0c10 | 158 | #if USE_SSL |
41ebd397 | 159 | ssluser(NULL), |
450e0c10 | 160 | #endif |
999aa5d2 A |
161 | port(NULL) { |
162 | ; | |
450e0c10 | 163 | } |
164 | ||
b7ac5457 | 165 | Ip::Address caddr; |
1a86db31 AJ |
166 | int64_t requestSize; |
167 | int64_t replySize; | |
3ff65596 AR |
168 | int requestHeadersSize; ///< received, including request line |
169 | int replyHeadersSize; ///< sent, including status line | |
47f6e231 | 170 | int64_t highOffset; |
171 | int64_t objectSize; | |
450e0c10 | 172 | log_type code; |
173 | int msec; | |
174 | const char *rfc931; | |
175 | const char *authuser; | |
661ef4eb | 176 | const char *extuser; |
450e0c10 | 177 | #if USE_SSL |
178 | ||
179 | const char *ssluser; | |
f4698e0b | 180 | Ssl::X509_Pointer sslClientCert; ///< cert received from the client |
450e0c10 | 181 | #endif |
65d448bc | 182 | AnyP::PortCfg *port; |
450e0c10 | 183 | |
2fadd50d | 184 | } cache; |
450e0c10 | 185 | |
4e26d606 AJ |
186 | /** \brief This subclass holds log info for various headers in raw format |
187 | * \todo shuffle this to the relevant protocol section. | |
188 | */ | |
450e0c10 | 189 | class Headers |
190 | { | |
191 | ||
192 | public: | |
3ff65596 | 193 | Headers() : request(NULL), |
105d1937 | 194 | adapted_request(NULL), |
e1381638 | 195 | reply(NULL) {} |
450e0c10 | 196 | |
6fca33e0 CT |
197 | char *request; //< virgin HTTP request headers |
198 | ||
105d1937 | 199 | char *adapted_request; //< HTTP request headers after adaptation and redirection |
6fca33e0 | 200 | |
99690f32 AR |
201 | char *reply; |
202 | } headers; | |
3ff65596 | 203 | |
5038f9d8 | 204 | #if USE_ADAPTATION |
99690f32 AR |
205 | /** \brief This subclass holds general adaptation log info. |
206 | * \todo Inner class declarations should be moved outside. | |
207 | */ | |
208 | class AdaptationDetails | |
209 | { | |
210 | ||
211 | public: | |
212 | AdaptationDetails(): last_meta(NULL) {} | |
5038f9d8 | 213 | |
99690f32 AR |
214 | /// image of the last ICAP response header or eCAP meta received |
215 | char *last_meta; | |
216 | } adapt; | |
3ff65596 | 217 | #endif |
450e0c10 | 218 | |
e1f7507e AJ |
219 | // Why is this a sub-class and not a set of real "private:" fields? |
220 | // It looks like its duplicating HTTPRequestMethod anyway! | |
4e26d606 | 221 | // TODO: shuffle this to the relevant protocol section OR replace with request->method |
450e0c10 | 222 | class Private |
223 | { | |
224 | ||
225 | public: | |
226 | Private() : method_str(NULL) {} | |
227 | ||
228 | const char *method_str; | |
2fadd50d | 229 | } _private; |
450e0c10 | 230 | HierarchyLogEntry hier; |
231 | HttpReply *reply; | |
105d1937 | 232 | HttpRequest *request; //< virgin HTTP request |
6fca33e0 | 233 | HttpRequest *adapted_request; //< HTTP request after adaptation and redirection |
d06e17ea AJ |
234 | |
235 | /// key:value pairs set by note and adaptation_meta directives | |
236 | /// plus key=value pairs returned from URL rewrite/redirect helper | |
d7f4a0b7 | 237 | NotePairs notes; |
6fca33e0 | 238 | |
3ff65596 AR |
239 | #if ICAP_CLIENT |
240 | /** \brief This subclass holds log info for ICAP part of request | |
241 | * \todo Inner class declarations should be moved outside | |
242 | */ | |
e1381638 AJ |
243 | class IcapLogEntry |
244 | { | |
3ff65596 | 245 | public: |
f5d0906a | 246 | IcapLogEntry() : reqMethod(Adaptation::methodNone), bytesSent(0), bytesRead(0), |
99c1b994 A |
247 | bodyBytesRead(-1), request(NULL), reply(NULL), |
248 | outcome(Adaptation::Icap::xoUnknown), trTime(0), | |
f5d0906a | 249 | ioTime(0), resStatus(HTTP_STATUS_NONE), processingTime(0) {} |
3ff65596 | 250 | |
b7ac5457 | 251 | Ip::Address hostAddr; ///< ICAP server IP address |
3ff65596 AR |
252 | String serviceName; ///< ICAP service name |
253 | String reqUri; ///< ICAP Request-URI | |
254 | Adaptation::Icap::ICAP::Method reqMethod; ///< ICAP request method | |
255 | int64_t bytesSent; ///< number of bytes sent to ICAP server so far | |
256 | int64_t bytesRead; ///< number of bytes read from ICAP server so far | |
bae917ac | 257 | /** |
dcaab393 | 258 | * number of ICAP body bytes read from ICAP server or -1 for no encapsulated |
bae917ac CT |
259 | * message data in ICAP reply (eg 204 responses) |
260 | */ | |
261 | int64_t bodyBytesRead; | |
3ff65596 AR |
262 | HttpRequest* request; ///< ICAP request |
263 | HttpReply* reply; ///< ICAP reply | |
264 | ||
265 | Adaptation::Icap::XactOutcome outcome; ///< final transaction status | |
266 | /** \brief Transaction response time. | |
267 | * The timer starts when the ICAP transaction | |
268 | * is created and stops when the result of the transaction is logged | |
269 | */ | |
270 | int trTime; | |
271 | /** \brief Transaction I/O time. | |
272 | * The timer starts when the first ICAP request | |
e1381638 | 273 | * byte is scheduled for sending and stops when the lastbyte of the |
3ff65596 AR |
274 | * ICAP response is received. |
275 | */ | |
276 | int ioTime; | |
277 | http_status resStatus; ///< ICAP response status code | |
278 | int processingTime; ///< total ICAP processing time in milliseconds | |
279 | } | |
280 | icap; | |
281 | #endif | |
450e0c10 | 282 | }; |
283 | ||
e1f7507e AJ |
284 | class ACLChecklist; |
285 | class StoreEntry; | |
e1f7507e | 286 | |
450e0c10 | 287 | /* Should be in 'AccessLog.h' as the driver */ |
8a648e8d FC |
288 | void accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist* checklist = NULL); |
289 | void accessLogLog(AccessLogEntry::Pointer &, ACLChecklist * checklist); | |
290 | void accessLogRotate(void); | |
291 | void accessLogClose(void); | |
292 | void accessLogInit(void); | |
293 | const char *accessLogTime(time_t); | |
450e0c10 | 294 | |
295 | #endif /* SQUID_HTTPACCESSLOGENTRY_H */ |