assert(notes == req->notes());
}
+const char *
+AccessLogEntry::getClientIdent() const
+{
+ if (tcpClient)
+ return tcpClient->rfc931;
+
+ if (cache.rfc931 && *cache.rfc931)
+ return cache.rfc931;
+
+ return nullptr;
+}
+
+const char *
+AccessLogEntry::getExtUser() const
+{
+ if (request && request->extacl_user.size())
+ return request->extacl_user.termedBuf();
+
+ if (cache.extuser && *cache.extuser)
+ return cache.extuser;
+
+ return nullptr;
+}
+
AccessLogEntry::~AccessLogEntry()
{
safe_free(headers.request);
/// including indirect forwarded-for IP if configured to log that
void getLogClientIp(char *buf, size_t bufsz) const;
+ /// Fetch the client IDENT string, or nil if none is available.
+ const char *getClientIdent() const;
+
+ /// Fetch the external ACL provided 'user=' string, or nil if none is available.
+ const char *getExtUser() const;
+
/// Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
SBuf getLogMethod() const;
if (request)
prepareLogWithRequestDetails(request, al);
- if (getConn() != NULL && getConn()->clientConnection != NULL && getConn()->clientConnection->rfc931[0])
- al->cache.rfc931 = getConn()->clientConnection->rfc931;
-
#if USE_OPENSSL && 0
/* This is broken. Fails if the connection has been closed. Needs
out = t;
}
if (!out)
- out = strOrNull(al->cache.extuser);
+ out = strOrNull(al->getExtUser());
#if USE_OPENSSL
if (!out)
out = strOrNull(al->cache.ssluser);
#endif
if (!out)
- out = strOrNull(al->cache.rfc931);
+ out = strOrNull(al->getClientIdent());
break;
case LFT_USER_LOGIN:
break;
case LFT_USER_IDENT:
- out = strOrNull(al->cache.rfc931);
+ out = strOrNull(al->getClientIdent());
break;
case LFT_USER_EXTERNAL:
- if (al->request && al->request->extacl_user.size()) {
- if (const char *t = al->request->extacl_user.termedBuf())
- out = t;
- }
-
- if (!out)
- out = strOrNull(al->cache.extuser);
+ out = strOrNull(al->getExtUser());
break;
/* case LFT_USER_REALM: */
void
Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile)
{
- const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->cache.rfc931);
+ const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->getClientIdent());
const char *user_auth = NULL;
const char *referer = NULL;
const char *agent = NULL;
if (al->request && al->request->auth_user_request != NULL)
user_auth = ::Format::QuoteUrlEncodeUsername(al->request->auth_user_request->username());
#endif
- const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->cache.rfc931);
+ const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->getClientIdent());
char clientip[MAX_IPSTRLEN];
al->getLogClientIp(clientip, MAX_IPSTRLEN);
#endif
if (!user)
- user = ::Format::QuoteUrlEncodeUsername(al->cache.extuser);
+ user = ::Format::QuoteUrlEncodeUsername(al->getExtUser());
#if USE_OPENSSL
if (!user)
#endif
if (!user)
- user = ::Format::QuoteUrlEncodeUsername(al->cache.rfc931);
+ user = ::Format::QuoteUrlEncodeUsername(al->getClientIdent());
if (user && !*user)
safe_free(user);
#endif
if (!user)
- user = ::Format::QuoteUrlEncodeUsername(al->cache.extuser);
+ user = ::Format::QuoteUrlEncodeUsername(al->getExtUser());
#if USE_OPENSSL
if (!user)
#endif
if (!user)
- user = ::Format::QuoteUrlEncodeUsername(al->cache.rfc931);
+ user = ::Format::QuoteUrlEncodeUsername(al->getClientIdent());
if (user && !*user)
safe_free(user);