/proc/self/cwd/source/extensions/upstreams/http/config.h
Line | Count | Source |
1 | | #pragma once |
2 | | |
3 | | #include <chrono> |
4 | | #include <cstdint> |
5 | | #include <functional> |
6 | | #include <list> |
7 | | #include <map> |
8 | | #include <string> |
9 | | |
10 | | #include "envoy/config/core/v3/extension.pb.h" |
11 | | #include "envoy/config/core/v3/protocol.pb.h" |
12 | | #include "envoy/extensions/upstreams/http/v3/http_protocol_options.pb.h" |
13 | | #include "envoy/extensions/upstreams/http/v3/http_protocol_options.pb.validate.h" |
14 | | #include "envoy/http/filter.h" |
15 | | #include "envoy/http/header_validator.h" |
16 | | #include "envoy/server/filter_config.h" |
17 | | #include "envoy/server/transport_socket_config.h" |
18 | | |
19 | | #include "source/common/common/logger.h" |
20 | | #include "source/common/protobuf/message_validator_impl.h" |
21 | | |
22 | | namespace Envoy { |
23 | | namespace Extensions { |
24 | | namespace Upstreams { |
25 | | namespace Http { |
26 | | |
27 | | class ProtocolOptionsConfigImpl : public Upstream::ProtocolOptionsConfig { |
28 | | public: |
29 | | ProtocolOptionsConfigImpl( |
30 | | const envoy::extensions::upstreams::http::v3::HttpProtocolOptions& options, |
31 | | Server::Configuration::ServerFactoryContext& server_context); |
32 | | // Constructor for legacy (deprecated) config. |
33 | | ProtocolOptionsConfigImpl( |
34 | | const envoy::config::core::v3::Http1ProtocolOptions& http1_settings, |
35 | | const envoy::config::core::v3::Http2ProtocolOptions& http2_options, |
36 | | const envoy::config::core::v3::HttpProtocolOptions& common_options, |
37 | | const absl::optional<envoy::config::core::v3::UpstreamHttpProtocolOptions> upstream_options, |
38 | | bool use_downstream_protocol, bool use_http2, |
39 | | ProtobufMessage::ValidationVisitor& validation_visitor); |
40 | | |
41 | | // Given the supplied cluster config, and protocol options configuration, |
42 | | // returns a unit64_t representing the enabled Upstream::ClusterInfo::Features. |
43 | | static uint64_t parseFeatures(const envoy::config::cluster::v3::Cluster& config, |
44 | | const ProtocolOptionsConfigImpl& options); |
45 | | |
46 | | const Envoy::Http::Http1Settings http1_settings_; |
47 | | const envoy::config::core::v3::Http2ProtocolOptions http2_options_; |
48 | | const envoy::config::core::v3::Http3ProtocolOptions http3_options_{}; |
49 | | const envoy::config::core::v3::HttpProtocolOptions common_http_protocol_options_; |
50 | | const absl::optional<envoy::config::core::v3::UpstreamHttpProtocolOptions> |
51 | | upstream_http_protocol_options_; |
52 | | |
53 | | using FiltersList = Protobuf::RepeatedPtrField< |
54 | | envoy::extensions::filters::network::http_connection_manager::v3::HttpFilter>; |
55 | | const FiltersList http_filters_; |
56 | | const absl::optional<const envoy::config::core::v3::AlternateProtocolsCacheOptions> |
57 | | alternate_protocol_cache_options_; |
58 | | const Envoy::Http::HeaderValidatorFactoryPtr header_validator_factory_; |
59 | | const bool use_downstream_protocol_{}; |
60 | | const bool use_http2_{}; |
61 | | const bool use_http3_{}; |
62 | | const bool use_alpn_{}; |
63 | | }; |
64 | | |
65 | | class ProtocolOptionsConfigFactory : public Server::Configuration::ProtocolOptionsFactory { |
66 | | public: |
67 | | Upstream::ProtocolOptionsConfigConstSharedPtr createProtocolOptionsConfig( |
68 | | const Protobuf::Message& config, |
69 | 2.24k | Server::Configuration::ProtocolOptionsFactoryContext& context) override { |
70 | 2.24k | const auto& typed_config = MessageUtil::downcastAndValidate< |
71 | 2.24k | const envoy::extensions::upstreams::http::v3::HttpProtocolOptions&>( |
72 | 2.24k | config, context.messageValidationVisitor()); |
73 | 2.24k | return std::make_shared<ProtocolOptionsConfigImpl>(typed_config, |
74 | 2.24k | context.serverFactoryContext()); |
75 | 2.24k | } |
76 | 220 | std::string category() const override { return "envoy.upstream_options"; } |
77 | 5.67k | std::string name() const override { |
78 | 5.67k | return "envoy.extensions.upstreams.http.v3.HttpProtocolOptions"; |
79 | 5.67k | } |
80 | 24 | ProtobufTypes::MessagePtr createEmptyConfigProto() override { |
81 | 24 | return std::make_unique<envoy::extensions::upstreams::http::v3::HttpProtocolOptions>(); |
82 | 24 | } |
83 | 2.24k | ProtobufTypes::MessagePtr createEmptyProtocolOptionsProto() override { |
84 | 2.24k | return std::make_unique<envoy::extensions::upstreams::http::v3::HttpProtocolOptions>(); |
85 | 2.24k | } |
86 | | }; |
87 | | |
88 | | DECLARE_FACTORY(ProtocolOptionsConfigFactory); |
89 | | |
90 | | } // namespace Http |
91 | | } // namespace Upstreams |
92 | | } // namespace Extensions |
93 | | } // namespace Envoy |