From 04baa013784721ad7d8f65034685fc7f30cb9732 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Wed, 4 Dec 2024 18:49:32 -0800 Subject: [PATCH] save HandshakeLogging into AttemptVersionFallback when we receive it Summary: let's save the received AttemptVersionFallback after it's passed to us from ServerProtocol's event handler. We will need to pass the handshakeLogging property of AttemptVersionFallback later on into our logging callbacks. Reviewed By: mingtaoy Differential Revision: D66325817 fbshipit-source-id: 27b1799e3f1fb7b23e874a63c4375c6ef8b13294 --- fizz/server/Actions.h | 6 ++++++ fizz/server/AsyncFizzServer-inl.h | 4 +++- fizz/server/ServerProtocol.cpp | 6 ++++++ fizz/server/test/AsyncFizzServerTest.cpp | 3 ++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fizz/server/Actions.h b/fizz/server/Actions.h index d3bf603fbce..64c8338a9c4 100644 --- a/fizz/server/Actions.h +++ b/fizz/server/Actions.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,11 @@ struct AttemptVersionFallback { * for processing the ClientHello. */ folly::Optional sni; + + /** + * Parsed fields from the ClientHello for logging purposes. + */ + std::unique_ptr handshakeLogging; }; /** diff --git a/fizz/server/AsyncFizzServer-inl.h b/fizz/server/AsyncFizzServer-inl.h index 62e889b0328..8724c011e96 100644 --- a/fizz/server/AsyncFizzServer-inl.h +++ b/fizz/server/AsyncFizzServer-inl.h @@ -374,7 +374,9 @@ void AsyncFizzServerT::ActionMoveVisitor::operator()( fallback.clientHello->prependChain(server_.transportReadBuf_.move()); } callback->fizzHandshakeAttemptFallback(AttemptVersionFallback{ - std::move(fallback.clientHello), std::move(fallback.sni)}); + std::move(fallback.clientHello), + std::move(fallback.sni), + std::move(fallback.handshakeLogging)}); } template diff --git a/fizz/server/ServerProtocol.cpp b/fizz/server/ServerProtocol.cpp index ec46412abaa..66e0600886b 100644 --- a/fizz/server/ServerProtocol.cpp +++ b/fizz/server/ServerProtocol.cpp @@ -1257,6 +1257,12 @@ EventHandler:: .hostname->to(); } + auto logging = state.handshakeLogging(); + if (logging) { + fallback.handshakeLogging = + std::make_unique(*logging); + } + return actions( MutateState(&Transition), std::move(fallback)); } else { diff --git a/fizz/server/test/AsyncFizzServerTest.cpp b/fizz/server/test/AsyncFizzServerTest.cpp index e5418bdeb8f..1dce15952d5 100644 --- a/fizz/server/test/AsyncFizzServerTest.cpp +++ b/fizz/server/test/AsyncFizzServerTest.cpp @@ -299,7 +299,8 @@ TEST_F(AsyncFizzServerTest, TestAttemptVersionFallback) { [](State& newState) { newState.state() = StateEnum::Error; }), AttemptVersionFallback{ IOBuf::copyBuffer("ClientHello"), - folly::Optional("www.hostname.com")}); + folly::Optional("www.hostname.com"), + std::make_unique()}); })); EXPECT_CALL(handshakeCallback_, _fizzHandshakeAttemptFallback(_)) .WillOnce(Invoke([&](AttemptVersionFallback& fallback) {