From 461fb077b82b86f0584ef6b7150c269f93481aaf Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 13 Sep 2024 16:38:16 +0200 Subject: [PATCH] dnsdist: Fix clang-tidy warnings (cherry picked from commit afcd4ccefb73efbf025b2f910a6506e18b4cf116) --- pdns/tcpiohandler.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pdns/tcpiohandler.cc b/pdns/tcpiohandler.cc index f53336c9b92a..d13e3be149de 100644 --- a/pdns/tcpiohandler.cc +++ b/pdns/tcpiohandler.cc @@ -565,7 +565,7 @@ class OpenSSLTLSConnection: public TLSConnection d_ktls = true; } - bool isClient() const + [[nodiscard]] bool isClient() const { return d_isClient; } @@ -615,9 +615,9 @@ class OpenSSLTLSIOCtx: public TLSCtx, public std::enable_shared_from_this createServerSideContext(TLSFrontend& fe) + static std::shared_ptr createServerSideContext(TLSFrontend& frontend) { - return std::make_shared(fe, Private()); + return std::make_shared(frontend, Private()); } static std::shared_ptr createClientSideContext(const TLSContextParameters& params) @@ -626,13 +626,13 @@ class OpenSSLTLSIOCtx: public TLSCtx, public std::enable_shared_from_this(fe.d_addr, fe.d_tlsConfig)) + OpenSSLTLSIOCtx(TLSFrontend& frontend, [[maybe_unused]] Private priv): d_feContext(std::make_unique(frontend.d_addr, frontend.d_tlsConfig)) { OpenSSLTLSConnection::generateConnectionIndexIfNeeded(); - d_ticketsKeyRotationDelay = fe.d_tlsConfig.d_ticketsKeyRotationDelay; + d_ticketsKeyRotationDelay = frontend.d_tlsConfig.d_ticketsKeyRotationDelay; - if (fe.d_tlsConfig.d_enableTickets && fe.d_tlsConfig.d_numberOfTicketsKeys > 0) { + if (frontend.d_tlsConfig.d_enableTickets && frontend.d_tlsConfig.d_numberOfTicketsKeys > 0) { /* use our own ticket keys handler so we can rotate them */ #if OPENSSL_VERSION_MAJOR >= 3 SSL_CTX_set_tlsext_ticket_key_evp_cb(d_feContext->d_tlsCtx.get(), &OpenSSLTLSIOCtx::ticketKeyCb); @@ -649,18 +649,18 @@ class OpenSSLTLSIOCtx: public TLSCtx, public std::enable_shared_from_thisd_tlsCtx, &fe.d_tlsCounters); + libssl_set_error_counters_callback(d_feContext->d_tlsCtx, &frontend.d_tlsCounters); - if (!fe.d_tlsConfig.d_keyLogFile.empty()) { - d_feContext->d_keyLogFile = libssl_set_key_log_file(d_feContext->d_tlsCtx, fe.d_tlsConfig.d_keyLogFile); + if (!frontend.d_tlsConfig.d_keyLogFile.empty()) { + d_feContext->d_keyLogFile = libssl_set_key_log_file(d_feContext->d_tlsCtx, frontend.d_tlsConfig.d_keyLogFile); } try { - if (fe.d_tlsConfig.d_ticketKeyFile.empty()) { + if (frontend.d_tlsConfig.d_ticketKeyFile.empty()) { handleTicketsKeyRotation(time(nullptr)); } else { - OpenSSLTLSIOCtx::loadTicketsKeys(fe.d_tlsConfig.d_ticketKeyFile); + OpenSSLTLSIOCtx::loadTicketsKeys(frontend.d_tlsConfig.d_ticketKeyFile); } } catch (const std::exception& e) { @@ -669,7 +669,7 @@ class OpenSSLTLSIOCtx: public TLSCtx, public std::enable_shared_from_this