Skip to content

Commit

Permalink
plumb down HandshakeLogging all the way to logging callbacks, save Ha…
Browse files Browse the repository at this point in the history
…ndshakeLogging into TransportInfo

Summary: ^^

Reviewed By: mingtaoy

Differential Revision: D66326959

fbshipit-source-id: 864488627c741731e59b4679f8aee24dd72b1eaa
  • Loading branch information
Yang Wang authored and facebook-github-bot committed Dec 5, 2024
1 parent 6b0882f commit 0cc11fb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 3 additions & 1 deletion wangle/acceptor/FizzAcceptorHandshakeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void FizzAcceptorHandshakeHelper::handshakeSuc(
tinfo_.acceptTime = acceptTime_;
tinfo_.sslSetupTime = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - acceptTime_);
tinfo_.handshakeLogging = std::move(fallback_.handshakeLogging);
wangle::SSLAcceptorHandshakeHelper::fillSSLTransportInfoFields(sock, tinfo_);

if (loggingCallback_) {
Expand All @@ -274,7 +275,8 @@ void FizzAcceptorHandshakeHelper::handshakeErr(
folly::AsyncSSLSocket* sock,
const folly::AsyncSocketException& ex) noexcept {
if (loggingCallback_) {
loggingCallback_->logFallbackHandshakeError(*sock, ex);
loggingCallback_->logFallbackHandshakeError(
*sock, ex, fallback_.handshakeLogging.get());
}

auto elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(
Expand Down
10 changes: 6 additions & 4 deletions wangle/acceptor/FizzAcceptorHandshakeHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class FizzLoggingCallback {
*
* @param server A valid, non-owning reference to the Fizz server side
* connection object that handled the connection.
* @param ew The exception object containing details on the cause of
* @param ex The exception object containing details on the cause of
* the handshake failure.
*/
virtual void logFizzHandshakeError(
const fizz::server::AsyncFizzServer& /*server*/,
const folly::exception_wrapper& /*ew*/) noexcept {}
const folly::exception_wrapper& /*ex*/) noexcept {}

/**
* logFallbackHandshakeError is invoked when the fallback OpenSSL
Expand All @@ -134,12 +134,14 @@ class FizzLoggingCallback {
*
* @param server A valid, non-owning reference to AsyncSSLSocket
* connection object that handled the connection.
* @param ew The exception object containing details on the cause of
* @param ex The exception object containing details on the cause of
* the handshake failure.
* @param logging If set, contains parsed ClientHello fields.
*/
virtual void logFallbackHandshakeError(
const folly::AsyncSSLSocket& /*server*/,
const folly::AsyncSocketException& /*ex*/) noexcept {}
const folly::AsyncSocketException& /*ex*/,
const fizz::server::HandshakeLogging* /*logging*/) noexcept {}
};

class FizzAcceptorHandshakeHelper;
Expand Down
13 changes: 13 additions & 0 deletions wangle/acceptor/TransportInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
#include <folly/SocketAddress.h>
#include <folly/portability/Sockets.h>

namespace fizz {
namespace server {
struct HandshakeLogging;
} // namespace server
} // namespace fizz

namespace folly {

class AsyncSocket;
Expand Down Expand Up @@ -317,6 +323,13 @@ struct TransportInfo {
*/
std::shared_ptr<std::string> tcpFingerprint{nullptr};

/*
* Additional handshake logging information parsed from the ClientHello by
* Fizz. This data is only used for logging and is not guaranteed to be
* present.
*/
std::shared_ptr<fizz::server::HandshakeLogging> handshakeLogging;

/*
* Whether or not TCP fast open succeded on this connection. Failure can occur
* due to several reasons, including cookies not matching or TFO not being
Expand Down
4 changes: 3 additions & 1 deletion wangle/acceptor/test/AcceptorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ class MockFizzLoggingCallback : public FizzLoggingCallback {
MOCK_METHOD(
void,
logFallbackHandshakeError,
(const folly::AsyncSSLSocket&, const folly::AsyncSocketException&),
(const folly::AsyncSSLSocket&,
const folly::AsyncSocketException&,
const fizz::server::HandshakeLogging*),
(noexcept));
};

Expand Down

0 comments on commit 0cc11fb

Please sign in to comment.