Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do Not Merge]Test close after proxy header #19883

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,16 @@ ProxyProtoFilterChainMatchIntegrationTest::ProxyProtoFilterChainMatchIntegration
});
}

void ProxyProtoFilterChainMatchIntegrationTest::send(const std::string& data) {
void ProxyProtoFilterChainMatchIntegrationTest::send(const std::string& data, bool end_stream) {
initialize();

// Set verify to false because it is expected that Envoy will immediately disconnect after
// receiving the PROXY header, and it is a race whether the `write()` will fail due to
// disconnect, or finish the write before receiving the disconnect.
constexpr bool verify = false;

enableHalfClose(true);
IntegrationTcpClientPtr tcp_client = makeTcpConnection(lookupPort("tcp_proxy"));
ASSERT_TRUE(tcp_client->write(data, false, verify));
ASSERT_TRUE(tcp_client->write(data, end_stream, verify));
tcp_client->waitForDisconnect();
}

Expand All @@ -338,6 +338,12 @@ TEST_P(ProxyProtoFilterChainMatchIntegrationTest, MatchDirectSourceAndSource) {
testing::HasSubstr("directsource_localhost_and_source_1.2.3.0/24 -"));
}

TEST_P(ProxyProtoFilterChainMatchIntegrationTest, CloseAfterProxyProtocol) {
send("PROXY TCP4 1.2.3.4 254.254.254.254 12345 1234", true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the end_stream flag to end the connection before sending the full proxy header. @ggreenway

EXPECT_THAT(waitForAccessLog(listener_access_log_name_),
testing::HasSubstr("directsource_localhost_and_source_1.2.3.0/24 -"));
}

// Test that a mismatched direct source prevents matching a filter chain with a matching source.
TEST_P(ProxyProtoFilterChainMatchIntegrationTest, MismatchDirectSourceButMatchSource) {
send("PROXY TCP4 5.5.5.5 254.254.254.254 12345 1234\r\nhello");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProxyProtoFilterChainMatchIntegrationTest : public ProxyProtoTcpIntegratio
public:
ProxyProtoFilterChainMatchIntegrationTest();

void send(const std::string& data);
void send(const std::string& data, bool end_stream = false);
};

} // namespace Envoy