Line data Source code
1 : #pragma once 2 : 3 : #include <string> 4 : #include <vector> 5 : 6 : #include "envoy/config/cluster/v3/cluster.pb.h" 7 : #include "envoy/config/core/v3/base.pb.h" 8 : #include "envoy/config/typed_metadata.h" 9 : #include "envoy/server/transport_socket_config.h" 10 : #include "envoy/stats/scope.h" 11 : #include "envoy/upstream/host_description.h" 12 : #include "envoy/upstream/upstream.h" 13 : 14 : #include "source/common/common/logger.h" 15 : #include "source/common/config/metadata.h" 16 : #include "source/common/config/well_known_names.h" 17 : #include "source/common/protobuf/protobuf.h" 18 : 19 : namespace Envoy { 20 : namespace Upstream { 21 : 22 : class TransportSocketMatcherImpl : public Logger::Loggable<Logger::Id::upstream>, 23 : public TransportSocketMatcher { 24 : public: 25 : struct FactoryMatch { 26 : FactoryMatch(std::string match_name, Network::UpstreamTransportSocketFactoryPtr socket_factory, 27 : TransportSocketMatchStats match_stats) 28 159 : : name(std::move(match_name)), factory(std::move(socket_factory)), stats(match_stats) {} 29 : const std::string name; 30 : Network::UpstreamTransportSocketFactoryPtr factory; 31 : Config::Metadata::LabelSet label_set; 32 : mutable TransportSocketMatchStats stats; 33 : }; 34 : 35 : TransportSocketMatcherImpl( 36 : const Protobuf::RepeatedPtrField<envoy::config::cluster::v3::Cluster::TransportSocketMatch>& 37 : socket_matches, 38 : Server::Configuration::TransportSocketFactoryContext& factory_context, 39 : Network::UpstreamTransportSocketFactoryPtr& default_factory, Stats::Scope& stats_scope); 40 : 41 : MatchData resolve(const envoy::config::core::v3::Metadata* metadata) const override; 42 : 43 159 : bool allMatchesSupportAlpn() const override { 44 159 : if (!default_match_.factory->supportsAlpn()) { 45 159 : return false; 46 159 : } 47 0 : for (const auto& match : matches_) { 48 0 : if (!match.factory->supportsAlpn()) { 49 0 : return false; 50 0 : } 51 0 : } 52 0 : return true; 53 0 : } 54 : 55 : protected: 56 : TransportSocketMatchStats generateStats(const std::string& prefix); 57 : Stats::Scope& stats_scope_; 58 : FactoryMatch default_match_; 59 : std::vector<FactoryMatch> matches_; 60 : }; 61 : 62 : } // namespace Upstream 63 : } // namespace Envoy