38#define strOrNull(s) ((s)==NULL||(s)[0]=='\0'?NULL:(s))
68 const char *
cur, *eos;
69 Token *new_lt, *last_lt;
72 debugs(46, 2,
"got definition '" << def <<
"'");
84 eos = def + strlen(def);
85 format = new_lt = last_lt =
new Token;
90 last_lt->
next = new_lt;
103 const auto tokenSize = tkn.
parse(token, "e);
105 if (ale !=
nullptr) {
106 Format fmt(
"SimpleToken");
113 return static_cast<size_t>(tokenSize);
122 for (
const Format *fmt =
this; fmt; fmt = fmt->next) {
123 debugs(46, 3,
"Dumping format definition for " << fmt->name);
127 for (
Token *t = fmt->format; t; t = t->next) {
151 if (t->data.header.separator !=
',')
152 snprintf(argbuf,
sizeof(argbuf),
"%s:%c%s", t->data.header.header, t->data.header.separator, t->data.header.element);
154 snprintf(argbuf,
sizeof(argbuf),
"%s:%s", t->data.header.header, t->data.header.element);
230 arg = t->data.string;
269 if (t->widthMin >= 0)
272 if (t->widthMax >= 0)
297 const auto l = strcspn(str,
"\"\\\r\n\t");
379 static char tmp[1024];
382 for (
Token *fmt = format; fmt; fmt = fmt->
next) {
383 const char *out =
nullptr;
390 struct timeval outtv = {};
393 bool doUint64 =
false;
394 uint64_t outUint64 = 0;
403 tmp[0] =
static_cast<char>(fmt->data.byteValue);
409 out = fmt->data.string;
437 if (conn->remote.isIPv4())
440 conn->remoteEui64.encode(tmp,
sizeof(tmp));
486 out = addr->toStr(tmp,
sizeof(tmp));
559 if (
const auto rawLength = handshake.length()) {
565 auto encLength =
base64_encode_update(&ctx, buf, rawLength,
reinterpret_cast<const uint8_t*
>(handshake.rawContent()));
589 spec = fmt->data.string;
593 spec =
"%d/%b/%Y:%H:%M:%S %z";
597 spec =
"%d/%b/%Y:%H:%M:%S";
602 strftime(tmp,
sizeof(tmp), spec, t);
613 const auto &stopwatch = al->
busyTime;
614 if (stopwatch.ran()) {
616 using nanos = std::chrono::duration<
decltype(outoff), std::nano>;
617 const nanos n = stopwatch.
total();
630 struct timeval peerResponseTime;
632 outtv = peerResponseTime;
643 using namespace std::chrono_literals;
644 const auto duration = timer.
total();
645 outtv.tv_sec = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
646 const auto totalUsec = std::chrono::duration_cast<std::chrono::microseconds>(duration);
647 outtv.tv_usec = (totalUsec % std::chrono::microseconds(1s)).count();
665 sb =
StringToSBuf(msg->header.getByName(fmt->data.header.header));
681 sb =
StringToSBuf(msg->header.getByName(fmt->data.header.header));
858 sb = msg->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator);
882 sb = al->
proxyProtocolHeader->getElem(fmt->data.headerId, fmt->data.header.element, fmt->data.header.separator);
898 sb = msg->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator);
1014 if (!
error->details.empty()) {
1023 mb.
append(
"TIMEOUT_", 8);
1224 outoff = logSequenceNumber;
1297 if (!conn->tlsClientSni().isEmpty()) {
1298 sb = conn->tlsClientSni();
1308 const char *separator = fmt->data.string ? fmt->data.string :
":";
1309 for (
const Security::CertErrors *sslError = srvBump->sslErrors(); sslError; sslError = sslError->next) {
1313 if (sslError->element.depth >= 0)
1314 sb.
appendf(
"@depth=%d", sslError->element.depth);
1327 if (X509 *serverCert = srvBump->serverCert.get()) {
1389 tmp[0] = fmt->data.header.separator;
1391 if (fmt->data.header.header && *fmt->data.header.header) {
1392 const char *separator = tmp;
1396 if (
const auto note = ah->
metaHeaders->
find(fmt->data.header.header, separator))
1401 if (
const auto note = al->
notes->
find(fmt->data.header.header, separator)) {
1413 const char *separator = fmt->data.string ? tmp :
"\r\n";
1459 sb.
appendf(
"%0*" PRId64, fmt->zero && fmt->widthMin >= 0 ? fmt->widthMin : 0, outoff);
1463 sb.
appendf(
"%0*ld", fmt->zero && fmt->widthMin >= 0 ? fmt->widthMin : 0, outint);
1465 }
else if (doUint64) {
1466 sb.
appendf(
"%0*" PRIu64, fmt->zero && fmt->widthMin >= 0 ? fmt->widthMin : 0, outUint64);
1468 }
else if (doMsec) {
1469 if (fmt->widthMax < 0) {
1470 sb.
appendf(
"%0*ld", fmt->zero && fmt->widthMin >= 0 ? fmt->widthMin : 0,
tvToMsec(outtv));
1472 int precision = fmt->widthMax;
1473 sb.
appendf(
"%0*" PRId64 ".%0*" PRId64 "", fmt->zero && (fmt->widthMin - precision - 1 >= 0) ? fmt->widthMin - precision - 1 : 0,
static_cast<int64_t
>(outtv.tv_sec * 1000 + outtv.tv_usec / 1000), precision,
static_cast<int64_t
>((outtv.tv_usec % 1000 )* (1000 / fmt->divisor)));
1477 int precision = fmt->widthMax >=0 ? fmt->widthMax :3;
1478 sb.
appendf(
"%0*" PRId64 ".%0*d", fmt->zero && (fmt->widthMin - precision - 1 >= 0) ? fmt->widthMin - precision - 1 : 0,
static_cast<int64_t
>(outtv.tv_sec), precision, (
int)(outtv.tv_usec / fmt->divisor));
1485 static char quotedOut[2 *
sizeof(tmp)];
1486 static_assert(
sizeof(quotedOut) > 0,
"quotedOut has zero length");
1487 quotedOut[0] =
'\0';
1489 char *newout =
nullptr;
1492 switch (fmt->quote) {
1499 size_t out_len =
static_cast<size_t>(strlen(out)) * 2 + 1;
1500 if (out_len >=
sizeof(tmp)) {
1501 newout = (
char *)
xmalloc(out_len);
1543 const bool haveMaxWidth = fmt->widthMax >=0 && !doint && !dooff && !doMsec && !doSec && !doUint64;
1544 if (haveMaxWidth || fmt->widthMin) {
1545 const int minWidth = fmt->widthMin >= 0 ?
1547 const int maxWidth = haveMaxWidth ?
1548 fmt->widthMax : strlen(out);
1551 mb.
appendf(
"%-*.*s", minWidth, maxWidth, out);
1553 mb.
appendf(
"%*.*s", minWidth, maxWidth, out);
1555 mb.
append(out, strlen(out));
AnyP::Port FindListeningPortNumber(const HttpRequest *callerRequest, const AccessLogEntry *ale)
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
void error(char *format,...)
void base64_encode_init(struct base64_encode_ctx *ctx)
size_t base64_encode_update(struct base64_encode_ctx *ctx, char *dst, size_t length, const uint8_t *src)
size_t base64_encode_final(struct base64_encode_ctx *ctx, char *dst)
#define base64_encode_len(length)
char * last_meta
image of the last ICAP response header or eCAP meta received
Security::CertPointer sslClientCert
cert received from the client
struct timeval start_time
The time the master transaction started.
struct timeval trTime
The response time.
MessageSizes clientReplySz
counters for the response sent to client
const char * content_type
MessageSizes clientRequestSz
counters for the original request received from client
AnyP::ProtocolVersion version
SBuf reqUri
ICAP Request-URI.
struct timeval processingTime
total ICAP processing time
struct timeval trTime
Transaction response time. The timer starts when the ICAP transaction is created and stops when the r...
Adaptation::Icap::XactOutcome outcome
final transaction status
Ip::Address hostAddr
ICAP server IP address.
HttpReply * reply
ICAP reply.
SBuf serviceName
ICAP service name.
Http::StatusCode resStatus
ICAP response status code.
int64_t bytesRead
number of bytes read from ICAP server so far
Adaptation::Icap::ICAP::Method reqMethod
ICAP request method.
struct timeval ioTime
Transaction I/O time. The timer starts when the first ICAP request byte is scheduled for sending and ...
int64_t bytesSent
number of bytes sent to ICAP server so far
HttpRequest * request
ICAP request.
int bumpMode
whether and how the request was SslBumped
SBuf lastAclName
string for external_acl_type ACL format code
const Error * error() const
void getLogClientIp(char *buf, size_t bufsz) const
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
void packReplyHeaders(MemBuf &mb) const
dump all reply headers (for sending or risky logging)
class AccessLogEntry::CacheDetails cache
bool hasLogMethod() const
whether we know what the request method is
class AccessLogEntry::IcapLogEntry icap
class AccessLogEntry::Headers headers
Comm::ConnectionPointer tcpClient
TCP/IP level details about the client connection.
class AccessLogEntry::HttpDetails http
HttpRequest * adapted_request
const char * getExtUser() const
Fetch the external ACL provided 'user=' string, or nil if none is available.
SBuf lastAclData
string for external_acl_type DATA format code
const char * getLogClientFqdn(char *buf, size_t bufSize) const
class AccessLogEntry::AdaptationDetails adapt
ProxyProtocol::HeaderPointer proxyProtocolHeader
see ConnStateData::proxyProtocolHeader_
const SBuf * effectiveVirginUrl() const
class AccessLogEntry::SslDetails ssl
void sumLogString(const char *serviceId, SBuf &)
dump xaction times, merging retried and retry times together
NotePairs::Pointer metaHeaders
HttpHeader allMeta
All REQMOD and RESPMOD meta headers merged. Last field wins conflicts.
RefCount< Adaptation::History > Pointer
void allLogString(const char *serviceId, SBuf &)
dump individual xaction times to a string
unsigned int major
major version number
unsigned int minor
minor version number
AnyP::UriScheme const & getScheme() const
SBuf & absolutePath() const
RFC 3986 section 4.2 relative reference called 'absolute-path'.
void port(const Port p)
reset authority port subcomponent
void host(const char *src)
virtual const char * credentialsStr()=0
char const * username() const
Cbc * valid() const
was set and is valid
Cbc * get() const
a temporary valid raw Cbc pointer or NULL
Stopwatch busyTime
time spent in this context (see also: busy_time)
InstanceId< Connection, uint64_t > id
const Security::NegotiationHistory * hasTlsNegotiations() const
Ssl::ServerBump * serverBump()
bool encode(char *buf, const int len) const
bool encode(char *buf, const int len) const
char host[SQUIDHOSTNAMELEN]
Stopwatch totalPeeringTime
cumulative time spent (so far) communicating with all peers (see %<tt)
int64_t bodyBytesRead
number of body bytes received from the next hop or -1
Http::StatusCode peer_reply_status
last HTTP status code received
Comm::ConnectionPointer tcpServer
TCP/IP level details of the last peer/server connection.
bool peerResponseTime(struct timeval &responseTime)
const SBuf & image() const
CbcPointer< ConnStateData > clientConnectionManager
Adaptation::History::Pointer adaptHistory(bool createIfNone=false) const
Returns possibly nil history, creating it if requested.
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Auth::UserRequest::Pointer auth_user_request
AnyP::Uri url
the request URI
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
common parts of HttpRequest and HttpReply
AnyP::ProtocolVersion http_ver
Value value
instance identifier
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
unsigned short port() const
InstanceId< MasterXaction, uint64_t > id
transaction ID.
void append(const char *c, int sz) override
void init(mb_size_t szInit, mb_size_t szMax)
char * content()
start of the added data
mb_size_t contentSize() const
available data size
uint64_t messageTotal() const
total message size
std::optional< SBuf > find(const char *noteKey, const char *sep=",") const
void print(std::ostream &os, const char *nameValueSeparator, const char *entryTerminator) const
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
SBuf buf()
bytes written so far
char * rawAppendStart(size_type anticipatedSize)
SBuf & appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
SBuf & append(const SBuf &S)
void rawAppendFinish(const char *start, size_type actualSize)
SBuf & assign(const SBuf &S)
const char * negotiatedVersion() const
String representation of TLS negotiated version.
const char * cipherName() const
const char * helloVersion() const
String representation of the received TLS hello message version.
const char * supportedVersion() const
Comm::ConnectionPointer clientConnection
Clock::duration total() const
bool ran() const
whether we ever measured time (i.e. resume() has been called)
void append(char const *, int) override
Appends a c-string to existing packed data.
char const * termedBuf() const
#define debugs(SECTION, LEVEL, CONTENT)
const char * errorPageName(int pageId)
error ID to string
const char * bumpMode(int bm)
SBuf sslGetUserCertificatePEM(SSL *ssl)
const char * sslGetUserAttribute(SSL *ssl, const char *attribute_name)
const char * sslGetCAAttribute(SSL *ssl, const char *attribute_name)
GETX509ATTRIBUTE GetX509UserAttribute
GETX509ATTRIBUTE GetX509CAAttribute
const char * hier_code_str[]
bool IsConnOpen(const Comm::ConnectionPointer &conn)
SBuf IssuerName(Certificate &)
The Issuer field of the given certificate (if found) or an empty SBuf.
SBuf SubjectName(Certificate &)
The SubjectName field of the given certificate (if found) or an empty SBuf.
const char * GetErrorName(const Security::ErrorCode code, const bool prefixRawCode=false)
#define rfc1738_escape(x)
#define rfc1738_escape_unescaped(x)
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
long int tvToMsec(struct timeval &t)