/proc/self/cwd/source/extensions/filters/network/sni_cluster/sni_cluster.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include "source/extensions/filters/network/sni_cluster/sni_cluster.h" |
2 | | |
3 | | #include "envoy/network/connection.h" |
4 | | |
5 | | #include "source/common/common/assert.h" |
6 | | #include "source/common/tcp_proxy/tcp_proxy.h" |
7 | | |
8 | | namespace Envoy { |
9 | | namespace Extensions { |
10 | | namespace NetworkFilters { |
11 | | namespace SniCluster { |
12 | | |
13 | 0 | Network::FilterStatus SniClusterFilter::onNewConnection() { |
14 | 0 | absl::string_view sni = read_callbacks_->connection().requestedServerName(); |
15 | 0 | ENVOY_CONN_LOG(trace, "sni_cluster: new connection with server name {}", |
16 | 0 | read_callbacks_->connection(), sni); |
17 | |
|
18 | 0 | if (!sni.empty()) { |
19 | | // Set the tcp_proxy cluster to the same value as SNI. The data is mutable to allow |
20 | | // other filters to change it. |
21 | 0 | read_callbacks_->connection().streamInfo().filterState()->setData( |
22 | 0 | TcpProxy::PerConnectionCluster::key(), |
23 | 0 | std::make_unique<TcpProxy::PerConnectionCluster>(sni), |
24 | 0 | StreamInfo::FilterState::StateType::Mutable, StreamInfo::FilterState::LifeSpan::Connection); |
25 | 0 | } |
26 | |
|
27 | 0 | return Network::FilterStatus::Continue; |
28 | 0 | } |
29 | | |
30 | | } // namespace SniCluster |
31 | | } // namespace NetworkFilters |
32 | | } // namespace Extensions |
33 | | } // namespace Envoy |