nghttpx: Pass a pointer to SSL instead of TLSSessionInfo to LogSpec

This commit is contained in:
Tatsuhiro Tsujikawa 2017-10-29 19:47:39 +09:00
parent 3cd6817e21
commit c573c80bd3
3 changed files with 13 additions and 14 deletions

View File

@ -1194,7 +1194,6 @@ void ClientHandler::start_immediate_shutdown() {
} }
void ClientHandler::write_accesslog(Downstream *downstream) { void ClientHandler::write_accesslog(Downstream *downstream) {
nghttp2::tls::TLSSessionInfo tls_info;
auto &req = downstream->request(); auto &req = downstream->request();
auto config = get_config(); auto config = get_config();
@ -1208,8 +1207,7 @@ void ClientHandler::write_accesslog(Downstream *downstream) {
upstream_accesslog( upstream_accesslog(
config->logging.access.format, config->logging.access.format,
LogSpec{ LogSpec{
downstream, ipaddr_, alpn_, sni_, downstream, ipaddr_, alpn_, sni_, conn_.tls.ssl,
nghttp2::tls::get_tls_session_info(&tls_info, conn_.tls.ssl),
std::chrono::high_resolution_clock::now(), // request_end_time std::chrono::high_resolution_clock::now(), // request_end_time
port_, faddr_->port, config->pid, port_, faddr_->port, config->pid,
}); });

View File

@ -407,6 +407,8 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
? StringRef::from_lit("*") ? StringRef::from_lit("*")
: StringRef::from_lit("-") : StringRef::from_lit("-")
: req.path; : req.path;
nghttp2::tls::TLSSessionInfo tls_info;
nghttp2::tls::get_tls_session_info(&tls_info, lgsp.ssl);
auto p = std::begin(buf); auto p = std::begin(buf);
auto last = std::end(buf) - 2; auto last = std::end(buf) - 2;
@ -489,34 +491,33 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
std::tie(p, last) = copy_escape(lgsp.alpn, p, last); std::tie(p, last) = copy_escape(lgsp.alpn, p, last);
break; break;
case SHRPX_LOGF_TLS_CIPHER: case SHRPX_LOGF_TLS_CIPHER:
if (!lgsp.tls_info) { if (!lgsp.ssl) {
std::tie(p, last) = copy('-', p, last); std::tie(p, last) = copy('-', p, last);
break; break;
} }
std::tie(p, last) = copy(lgsp.tls_info->cipher, p, last); std::tie(p, last) = copy(tls_info.cipher, p, last);
break; break;
case SHRPX_LOGF_TLS_PROTOCOL: case SHRPX_LOGF_TLS_PROTOCOL:
if (!lgsp.tls_info) { if (!lgsp.ssl) {
std::tie(p, last) = copy('-', p, last); std::tie(p, last) = copy('-', p, last);
break; break;
} }
std::tie(p, last) = copy(lgsp.tls_info->protocol, p, last); std::tie(p, last) = copy(tls_info.protocol, p, last);
break; break;
case SHRPX_LOGF_TLS_SESSION_ID: 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); std::tie(p, last) = copy('-', p, last);
break; break;
} }
std::tie(p, last) = copy_hex_low( std::tie(p, last) = copy_hex_low(tls_info.session_id,
lgsp.tls_info->session_id, lgsp.tls_info->session_id_length, p, last); tls_info.session_id_length, p, last);
break; break;
case SHRPX_LOGF_TLS_SESSION_REUSED: case SHRPX_LOGF_TLS_SESSION_REUSED:
if (!lgsp.tls_info) { if (!lgsp.ssl) {
std::tie(p, last) = copy('-', p, last); std::tie(p, last) = copy('-', p, last);
break; break;
} }
std::tie(p, last) = std::tie(p, last) = copy(tls_info.session_reused ? 'r' : '.', p, last);
copy(lgsp.tls_info->session_reused ? 'r' : '.', p, last);
break; break;
case SHRPX_LOGF_TLS_SNI: case SHRPX_LOGF_TLS_SNI:
if (lgsp.sni.empty()) { if (lgsp.sni.empty()) {

View File

@ -154,7 +154,7 @@ struct LogSpec {
StringRef remote_addr; StringRef remote_addr;
StringRef alpn; StringRef alpn;
StringRef sni; StringRef sni;
const nghttp2::tls::TLSSessionInfo *tls_info; SSL *ssl;
std::chrono::high_resolution_clock::time_point request_end_time; std::chrono::high_resolution_clock::time_point request_end_time;
StringRef remote_port; StringRef remote_port;
uint16_t server_port; uint16_t server_port;