nghttpx: Add $ssl_session_reused log variable

The syntax for this variable is the same as nginx: if SSL/TLS session
was reused, "r" is produced.  Otherwise ".".
This commit is contained in:
Tatsuhiro Tsujikawa 2015-06-28 22:15:04 +09:00
parent 197493afd4
commit 515c313073
6 changed files with 15 additions and 0 deletions

View File

@ -1348,6 +1348,8 @@ Logging:
* $ssl_cipher: cipher used for SSL/TLS connection. * $ssl_cipher: cipher used for SSL/TLS connection.
* $ssl_protocol: protocol for SSL/TLS connection. * $ssl_protocol: protocol for SSL/TLS connection.
* $ssl_session_id: session ID for SSL/TLS connection. * $ssl_session_id: session ID for SSL/TLS connection.
* $ssl_session_reused: "r" if SSL/TLS session was
reused. Otherwise, "."
Default: )" << DEFAULT_ACCESSLOG_FORMAT << R"( Default: )" << DEFAULT_ACCESSLOG_FORMAT << R"(
--errorlog-file=<PATH> --errorlog-file=<PATH>

View File

@ -389,6 +389,8 @@ std::vector<LogFragment> parse_log_format(const char *optarg) {
type = SHRPX_LOGF_SSL_PROTOCOL; type = SHRPX_LOGF_SSL_PROTOCOL;
} else if (util::strieq_l("$ssl_session_id", var_start, varlen)) { } else if (util::strieq_l("$ssl_session_id", var_start, varlen)) {
type = SHRPX_LOGF_SSL_SESSION_ID; type = SHRPX_LOGF_SSL_SESSION_ID;
} else if (util::strieq_l("$ssl_session_reused", var_start, varlen)) {
type = SHRPX_LOGF_SSL_SESSION_REUSED;
} else { } else {
LOG(WARN) << "Unrecognized log format variable: " LOG(WARN) << "Unrecognized log format variable: "
<< std::string(var_start, varlen); << std::string(var_start, varlen);

View File

@ -294,6 +294,14 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
copy_hex_low(lgsp.tls_info->session_id, copy_hex_low(lgsp.tls_info->session_id,
lgsp.tls_info->session_id_length, avail, p); lgsp.tls_info->session_id_length, avail, p);
break; break;
case SHRPX_LOGF_SSL_SESSION_REUSED:
if (!lgsp.tls_info) {
std::tie(p, avail) = copy("-", avail, p);
break;
}
std::tie(p, avail) =
copy(lgsp.tls_info->session_reused ? "r" : ".", avail, p);
break;
case SHRPX_LOGF_NONE: case SHRPX_LOGF_NONE:
break; break;
default: default:

View File

@ -119,6 +119,7 @@ enum LogFragmentType {
SHRPX_LOGF_SSL_CIPHER, SHRPX_LOGF_SSL_CIPHER,
SHRPX_LOGF_SSL_PROTOCOL, SHRPX_LOGF_SSL_PROTOCOL,
SHRPX_LOGF_SSL_SESSION_ID, SHRPX_LOGF_SSL_SESSION_ID,
SHRPX_LOGF_SSL_SESSION_REUSED,
}; };
struct LogFragment { struct LogFragment {

View File

@ -114,6 +114,7 @@ TLSSessionInfo *get_tls_session_info(TLSSessionInfo *tls_info, SSL *ssl) {
tls_info->protocol = get_tls_protocol(ssl); tls_info->protocol = get_tls_protocol(ssl);
tls_info->session_id = session->session_id; tls_info->session_id = session->session_id;
tls_info->session_id_length = session->session_id_length; tls_info->session_id_length = session->session_id_length;
tls_info->session_reused = SSL_session_reused(ssl);
return tls_info; return tls_info;
} }

View File

@ -53,6 +53,7 @@ struct TLSSessionInfo {
const char *cipher; const char *cipher;
const char *protocol; const char *protocol;
const uint8_t *session_id; const uint8_t *session_id;
bool session_reused;
size_t session_id_length; size_t session_id_length;
}; };