-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Adding direct connect support. #21942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e6d74a6
ae206f0
5298b63
db9ff26
57b8b6a
ceec0fd
f0f6a0b
d4f0844
2ec1b9a
82afcd2
cff9d17
9b078cd
903c300
c0bb05a
1d491f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. | ||
|
|
||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| api_proto_package( | ||
| deps = [ | ||
| "//envoy/config/core/v3:pkg", | ||
| "@com_github_cncf_udpa//udpa/annotations:pkg", | ||
| ], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package envoy.extensions.transport_sockets.http_11_proxy.v3; | ||
|
|
||
| import "envoy/config/core/v3/base.proto"; | ||
|
|
||
| import "udpa/annotations/status.proto"; | ||
| import "validate/validate.proto"; | ||
|
|
||
| option java_package = "io.envoyproxy.envoy.extensions.transport_sockets.http_11_proxy.v3"; | ||
| option java_outer_classname = "UpstreamHttp11ConnectProto"; | ||
| option java_multiple_files = true; | ||
| option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/http_11_proxy/v3;http_11_proxyv3"; | ||
| option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
|
||
| // [#protodoc-title: Upstream HTTP/1.1 Proxy] | ||
| // [#extension: envoy.transport_sockets.http_11_proxy] | ||
|
|
||
| // Configuration for HTTP/1.1 proxy transport sockets. | ||
| // If this is configured and an intermediate filter adds proxy metadata to the | ||
| // stream info then | ||
| // - Upstream connections will be directed to the specified proxy address rather | ||
| // than the host's address | ||
|
RyanTheOptimist marked this conversation as resolved.
Outdated
|
||
| // - Upstream TLS connections will have a raw HTTP/1.1 CONNECT header prefaced | ||
| // to the payload, and 200 response stripped | ||
| // - Plaintext HTTP/1.1 connections will be sent with a fully qualified URL. | ||
| // This transport socket is not compatible with HTTP/3, plaintext HTTP/2, or raw TCP. | ||
| message Http11ProxyUpstreamTransport { | ||
| // The underlying transport socket being wrapped. | ||
| config.core.v3.TransportSocket transport_socket = 1 [(validate.rules).message = {required: true}]; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -230,6 +230,22 @@ class TransportSocketOptions { | |
| */ | ||
| virtual absl::optional<Network::ProxyProtocolData> proxyProtocolOptions() const PURE; | ||
|
|
||
| // Information for use by the http_11_proxy transport socket. | ||
| struct ProxyInfo { | ||
|
RyanTheOptimist marked this conversation as resolved.
Outdated
|
||
| ProxyInfo(std::string hostname, Network::Address::InstanceConstSharedPtr address) | ||
| : hostname(hostname), proxy_address(address) {} | ||
| // The hostname of the original request, to be used in CONNECT request if | ||
| // the underlying transport is TLS. | ||
| std::string hostname; | ||
| // The address of the proxy, where connections should be routed to. | ||
| Network::Address::InstanceConstSharedPtr proxy_address; | ||
| }; | ||
|
|
||
| /** | ||
| * @return any proxy information if sending to an intermediate proxy over HTTP/1.1. | ||
| */ | ||
| virtual const std::unique_ptr<const ProxyInfo>& proxyInfo() const PURE; | ||
|
RyanTheOptimist marked this conversation as resolved.
Outdated
RyanTheOptimist marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not keep this private to the extension? E.g. per #21700, would be another private hashable object.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it can be because Envoy needs to use it for hashing and connection creation.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These objects are also hashed in transport options and passed along during connection creation to the upstream connection stream info. Maybe I'm missing something?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see how I could handle hashing but I don't see how I could handle the createConnection in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I suppose we could split the two since |
||
|
|
||
| /** | ||
| * @return filter state from the downstream request or connection. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #include "source/common/network/filter_state_proxy_info.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| const std::string& FilterStateProxyInfo::key() { | ||
| CONSTRUCT_ON_FIRST_USE(std::string, "envoy.network.transport_socket.http_11_proxy.info"); | ||
| } | ||
|
|
||
| } // namespace Network | ||
| } // namespace Envoy |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/network/address.h" | ||
| #include "envoy/stream_info/filter_state.h" | ||
|
|
||
| #include "absl/strings/string_view.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Network { | ||
|
|
||
| /** | ||
| * Information which filters can add if they detect the stream should go | ||
| * upstream through an HTTP/1.1 proxy. | ||
| */ | ||
| class FilterStateProxyInfo : public StreamInfo::FilterState::Object { | ||
|
RyanTheOptimist marked this conversation as resolved.
Outdated
|
||
| public: | ||
| static const std::string& key(); | ||
|
RyanTheOptimist marked this conversation as resolved.
|
||
|
|
||
| FilterStateProxyInfo(absl::string_view hostname, Network::Address::InstanceConstSharedPtr address) | ||
| : hostname_(hostname), address_(address) {} | ||
| Network::Address::InstanceConstSharedPtr address() const { return address_; } | ||
|
RyanTheOptimist marked this conversation as resolved.
|
||
|
|
||
| private: | ||
| // The hostname of this individual request. | ||
| const std::string hostname_; | ||
|
RyanTheOptimist marked this conversation as resolved.
|
||
| // The address of the proxy. | ||
| const Network::Address::InstanceConstSharedPtr address_; | ||
| }; | ||
|
|
||
| } // namespace Network | ||
| } // namespace Envoy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| #include "source/common/common/scalar_to_byte_vector.h" | ||
| #include "source/common/common/utility.h" | ||
| #include "source/common/network/application_protocol.h" | ||
| #include "source/common/network/filter_state_proxy_info.h" | ||
| #include "source/common/network/proxy_protocol_filter_state.h" | ||
| #include "source/common/network/upstream_server_name.h" | ||
| #include "source/common/network/upstream_subject_alt_names.h" | ||
|
|
@@ -52,6 +53,7 @@ TransportSocketOptionsConstSharedPtr TransportSocketOptionsUtility::fromFilterSt | |
| std::vector<std::string> subject_alt_names; | ||
| std::vector<std::string> alpn_fallback; | ||
| absl::optional<Network::ProxyProtocolData> proxy_protocol_options; | ||
| std::unique_ptr<const TransportSocketOptions::ProxyInfo> proxy_info; | ||
|
|
||
| if (auto typed_data = | ||
| filter_state->getDataReadOnly<UpstreamServerName>(UpstreamServerName::key()); | ||
|
|
@@ -77,9 +79,15 @@ TransportSocketOptionsConstSharedPtr TransportSocketOptionsUtility::fromFilterSt | |
| proxy_protocol_options.emplace(typed_data->value()); | ||
| } | ||
|
|
||
| if (auto typed_data = | ||
| filter_state->getDataReadOnly<FilterStateProxyInfo>(FilterStateProxyInfo::key()); | ||
| typed_data != nullptr) { | ||
| proxy_info = std::make_unique<TransportSocketOptions::ProxyInfo>("host", typed_data->address()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, since this is passing in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion to use well-known endpoint metadata ("tunnel.address" or something). We've been doing that for the internal listener effectively.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using the hostname() sorry for missing this as I fixed things up. |
||
| } | ||
|
|
||
| return std::make_shared<Network::TransportSocketOptionsImpl>( | ||
| server_name, std::move(subject_alt_names), std::move(application_protocols), | ||
| std::move(alpn_fallback), proxy_protocol_options, filter_state); | ||
| std::move(alpn_fallback), proxy_protocol_options, filter_state, std::move(proxy_info)); | ||
| } | ||
|
|
||
| } // namespace Network | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what "proxy metadata" means in this context?