Skip to content

Commit

Permalink
save HandshakeLogging into AttemptVersionFallback when we receive it
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Yang Wang authored and facebook-github-bot committed Dec 5, 2024
1 parent 3af2d30 commit 04baa01
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions fizz/server/Actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <boost/variant.hpp>

#include <fizz/protocol/Actions.h>
#include <fizz/server/HandshakeLogging.h>
#include <fizz/util/Variant.h>
#include <folly/Optional.h>
#include <folly/futures/Future.h>
Expand Down Expand Up @@ -38,6 +39,11 @@ struct AttemptVersionFallback {
* for processing the ClientHello.
*/
folly::Optional<std::string> sni;

/**
* Parsed fields from the ClientHello for logging purposes.
*/
std::unique_ptr<HandshakeLogging> handshakeLogging;
};

/**
Expand Down
4 changes: 3 additions & 1 deletion fizz/server/AsyncFizzServer-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ void AsyncFizzServerT<SM>::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 <typename SM>
Expand Down
6 changes: 6 additions & 0 deletions fizz/server/ServerProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,12 @@ EventHandler<ServerTypes, StateEnum::ExpectingClientHello, Event::ClientHello>::
.hostname->to<std::string>();
}

auto logging = state.handshakeLogging();
if (logging) {
fallback.handshakeLogging =
std::make_unique<HandshakeLogging>(*logging);
}

return actions(
MutateState(&Transition<StateEnum::Error>), std::move(fallback));
} else {
Expand Down
3 changes: 2 additions & 1 deletion fizz/server/test/AsyncFizzServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ TEST_F(AsyncFizzServerTest, TestAttemptVersionFallback) {
[](State& newState) { newState.state() = StateEnum::Error; }),
AttemptVersionFallback{
IOBuf::copyBuffer("ClientHello"),
folly::Optional<std::string>("www.hostname.com")});
folly::Optional<std::string>("www.hostname.com"),
std::make_unique<HandshakeLogging>()});
}));
EXPECT_CALL(handshakeCallback_, _fizzHandshakeAttemptFallback(_))
.WillOnce(Invoke([&](AttemptVersionFallback& fallback) {
Expand Down

0 comments on commit 04baa01

Please sign in to comment.