Skip to content

Commit

Permalink
use requestStreamInfo() directly
Browse files Browse the repository at this point in the history
Signed-off-by: ohadvano <[email protected]>
  • Loading branch information
ohadvano committed Sep 10, 2023
1 parent d12d47b commit 34fd252
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 4 additions & 0 deletions source/common/tcp_proxy/tcp_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ class Filter : public Network::ReadFilter,
return &read_callbacks_->connection();
}

const StreamInfo::StreamInfo* requestStreamInfo() const override {
return &read_callbacks_->connection().streamInfo();
}

Network::TransportSocketOptionsConstSharedPtr upstreamTransportSocketOptions() const override {
return transport_socket_options_;
}
Expand Down
12 changes: 4 additions & 8 deletions source/extensions/clusters/dynamic_forward_proxy/cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,9 @@ Cluster::LoadBalancer::chooseHost(Upstream::LoadBalancerContext* context) {
}

const Router::StringAccessor* dynamic_host_filter_state = nullptr;
if (context->downstreamConnection()) {
if (context->requestStreamInfo()) {
dynamic_host_filter_state =
context->downstreamConnection()
->streamInfo()
.filterState()
context->requestStreamInfo()->filterState()
.getDataReadOnly<Router::StringAccessor>("envoy.upstream.dynamic_host");
}

Expand All @@ -338,11 +336,9 @@ Cluster::LoadBalancer::chooseHost(Upstream::LoadBalancerContext* context) {
.resolve(nullptr)
.factory_.implementsSecureTransport();
uint32_t port = is_secure ? 443 : 80;
if (context->downstreamConnection()) {
if (context->requestStreamInfo()) {
const StreamInfo::UInt32Accessor* dynamic_port_filter_state =
context->downstreamConnection()
->streamInfo()
.filterState()
context->requestStreamInfo()->filterState()
.getDataReadOnly<StreamInfo::UInt32Accessor>("envoy.upstream.dynamic_port");
if (dynamic_port_filter_state != nullptr && dynamic_port_filter_state->value() > 0 &&
dynamic_port_filter_state->value() <= 65535) {
Expand Down

0 comments on commit 34fd252

Please sign in to comment.