From c573c80bd31277e362b72c545595563489998060 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 29 Oct 2017 19:47:39 +0900 Subject: [PATCH] nghttpx: Pass a pointer to SSL instead of TLSSessionInfo to LogSpec --- src/shrpx_client_handler.cc | 4 +--- src/shrpx_log.cc | 21 +++++++++++---------- src/shrpx_log.h | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/shrpx_client_handler.cc b/src/shrpx_client_handler.cc index 582b57da..97040266 100644 --- a/src/shrpx_client_handler.cc +++ b/src/shrpx_client_handler.cc @@ -1194,7 +1194,6 @@ void ClientHandler::start_immediate_shutdown() { } void ClientHandler::write_accesslog(Downstream *downstream) { - nghttp2::tls::TLSSessionInfo tls_info; auto &req = downstream->request(); auto config = get_config(); @@ -1208,8 +1207,7 @@ void ClientHandler::write_accesslog(Downstream *downstream) { upstream_accesslog( config->logging.access.format, LogSpec{ - downstream, ipaddr_, alpn_, sni_, - nghttp2::tls::get_tls_session_info(&tls_info, conn_.tls.ssl), + downstream, ipaddr_, alpn_, sni_, conn_.tls.ssl, std::chrono::high_resolution_clock::now(), // request_end_time port_, faddr_->port, config->pid, }); diff --git a/src/shrpx_log.cc b/src/shrpx_log.cc index 19896549..6e1430ef 100644 --- a/src/shrpx_log.cc +++ b/src/shrpx_log.cc @@ -407,6 +407,8 @@ void upstream_accesslog(const std::vector &lfv, ? StringRef::from_lit("*") : StringRef::from_lit("-") : req.path; + nghttp2::tls::TLSSessionInfo tls_info; + nghttp2::tls::get_tls_session_info(&tls_info, lgsp.ssl); auto p = std::begin(buf); auto last = std::end(buf) - 2; @@ -489,34 +491,33 @@ void upstream_accesslog(const std::vector &lfv, std::tie(p, last) = copy_escape(lgsp.alpn, p, last); break; case SHRPX_LOGF_TLS_CIPHER: - if (!lgsp.tls_info) { + if (!lgsp.ssl) { std::tie(p, last) = copy('-', p, last); break; } - std::tie(p, last) = copy(lgsp.tls_info->cipher, p, last); + std::tie(p, last) = copy(tls_info.cipher, p, last); break; case SHRPX_LOGF_TLS_PROTOCOL: - if (!lgsp.tls_info) { + if (!lgsp.ssl) { std::tie(p, last) = copy('-', p, last); break; } - std::tie(p, last) = copy(lgsp.tls_info->protocol, p, last); + std::tie(p, last) = copy(tls_info.protocol, p, last); break; case SHRPX_LOGF_TLS_SESSION_ID: - if (!lgsp.tls_info || lgsp.tls_info->session_id_length == 0) { + if (!lgsp.ssl || tls_info.session_id_length == 0) { std::tie(p, last) = copy('-', p, last); break; } - std::tie(p, last) = copy_hex_low( - lgsp.tls_info->session_id, lgsp.tls_info->session_id_length, p, last); + std::tie(p, last) = copy_hex_low(tls_info.session_id, + tls_info.session_id_length, p, last); break; case SHRPX_LOGF_TLS_SESSION_REUSED: - if (!lgsp.tls_info) { + if (!lgsp.ssl) { std::tie(p, last) = copy('-', p, last); break; } - std::tie(p, last) = - copy(lgsp.tls_info->session_reused ? 'r' : '.', p, last); + std::tie(p, last) = copy(tls_info.session_reused ? 'r' : '.', p, last); break; case SHRPX_LOGF_TLS_SNI: if (lgsp.sni.empty()) { diff --git a/src/shrpx_log.h b/src/shrpx_log.h index 3a923778..780d81f0 100644 --- a/src/shrpx_log.h +++ b/src/shrpx_log.h @@ -154,7 +154,7 @@ struct LogSpec { StringRef remote_addr; StringRef alpn; StringRef sni; - const nghttp2::tls::TLSSessionInfo *tls_info; + SSL *ssl; std::chrono::high_resolution_clock::time_point request_end_time; StringRef remote_port; uint16_t server_port;