Skip to content

Commit

Permalink
emit->propagate
Browse files Browse the repository at this point in the history
Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov committed Sep 21, 2022
1 parent 0cfe94c commit 2cb76ea
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ message TcpProxy {
repeated config.core.v3.HeaderValueOption headers_to_add = 3
[(validate.rules).repeated = {max_items: 1000}];

// Emit response headers to the downstream info filter state for consumption
// Save the response headers to the downstream info filter state for consumption
// by the network filters. The filter state key is ``envoy.tcp_proxy.tunnel_response_headers``.
bool emit_response_headers = 4;
bool propagate_response_headers = 4;
}

message OnDemand {
Expand Down
2 changes: 1 addition & 1 deletion changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ new_features:
- area: tcp_proxy
change: |
added support for emitting the response headers in :ref:`TunnelingConfig
<envoy_v3_api_field_extensions.filters.network.tcp_proxy.v3.TcpProxy.TunnelingConfig.emit_response_headers>` to
<envoy_v3_api_field_extensions.filters.network.tcp_proxy.v3.TcpProxy.TunnelingConfig.propagate_response_headers>` to
the downstream info filter state.
- area: access_log
change: |
Expand Down
6 changes: 3 additions & 3 deletions source/common/tcp_proxy/tcp_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ TunnelingConfigHelperImpl::TunnelingConfigHelperImpl(
Server::Configuration::FactoryContext& context)
: use_post_(config_message.use_post()),
header_parser_(Envoy::Router::HeaderParser::configure(config_message.headers_to_add())),
emit_response_headers_(config_message.emit_response_headers()) {
propagate_response_headers_(config_message.propagate_response_headers()) {
envoy::config::core::v3::SubstitutionFormatString substitution_format_config;
substitution_format_config.mutable_text_format_source()->set_inline_string(
config_message.hostname());
Expand All @@ -579,10 +579,10 @@ std::string TunnelingConfigHelperImpl::host(const StreamInfo::StreamInfo& stream
absl::string_view());
}

void TunnelingConfigHelperImpl::emitResponseHeaders(
void TunnelingConfigHelperImpl::propagateResponseHeaders(
Http::ResponseHeaderMapPtr&& headers,
const StreamInfo::FilterStateSharedPtr& filter_state) const {
if (!emit_response_headers_) {
if (!propagate_response_headers_) {
return;
}
filter_state->setData(
Expand Down
5 changes: 3 additions & 2 deletions source/common/tcp_proxy/tcp_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ class TunnelingConfigHelperImpl : public TunnelingConfigHelper,
std::string host(const StreamInfo::StreamInfo& stream_info) const override;
bool usePost() const override { return use_post_; }
Envoy::Http::HeaderEvaluator& headerEvaluator() const override { return *header_parser_; }
void emitResponseHeaders(Http::ResponseHeaderMapPtr&& headers,
void
propagateResponseHeaders(Http::ResponseHeaderMapPtr&& headers,
const StreamInfo::FilterStateSharedPtr& filter_state) const override;

private:
const bool use_post_;
std::unique_ptr<Envoy::Router::HeaderParser> header_parser_;
Formatter::FormatterPtr hostname_fmt_;
const bool emit_response_headers_;
const bool propagate_response_headers_;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion test/integration/tcp_tunneling_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ TEST_P(TcpTunnelingIntegrationTest, CopyResponseHeaders) {
proxy_config.set_stat_prefix("tcp_stats");
proxy_config.set_cluster("cluster_0");
proxy_config.mutable_tunneling_config()->set_hostname("foo.lyft.com:80");
proxy_config.mutable_tunneling_config()->set_emit_response_headers(true);
proxy_config.mutable_tunneling_config()->set_propagate_response_headers(true);

envoy::extensions::access_loggers::file::v3::FileAccessLog access_log_config;
access_log_config.mutable_log_format()->mutable_text_format_source()->set_inline_string(
Expand Down

0 comments on commit 2cb76ea

Please sign in to comment.