-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: add functionality to override requested server name in the upstr…
…eam cluster (#4973) Add functionality to override requested server name in the upstream cluster Risk Level: medium Testing: unit tests Docs Changes: yes Release Notes: yes Related to #4076 Signed-off-by: Vadim Eisenberg <[email protected]>
- Loading branch information
1 parent
08310eb
commit 48b161e
Showing
68 changed files
with
889 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <inttypes.h> | ||
|
||
#include <vector> | ||
|
||
namespace Envoy { | ||
template <typename T> void pushScalarToByteVector(T val, std::vector<uint8_t>& bytes) { | ||
uint8_t* byte_ptr = reinterpret_cast<uint8_t*>(&val); | ||
for (uint32_t byte_index = 0; byte_index < sizeof val; byte_index++) { | ||
bytes.push_back(*byte_ptr++); | ||
} | ||
} | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "common/network/transport_socket_options_impl.h" | ||
|
||
#include "common/common/scalar_to_byte_vector.h" | ||
#include "common/common/utility.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
void TransportSocketOptionsImpl::hashKey(std::vector<uint8_t>& key) const { | ||
if (!override_server_name_.has_value()) { | ||
return; | ||
} | ||
|
||
pushScalarToByteVector(StringUtil::CaseInsensitiveHash()(override_server_name_.value()), key); | ||
} | ||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "envoy/network/transport_socket.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
class TransportSocketOptionsImpl : public TransportSocketOptions { | ||
public: | ||
TransportSocketOptionsImpl(absl::string_view override_server_name = "") | ||
: override_server_name_(override_server_name.empty() | ||
? absl::nullopt | ||
: absl::optional<std::string>(override_server_name)) {} | ||
|
||
// Network::TransportSocketOptions | ||
const absl::optional<std::string>& serverNameOverride() const override { | ||
return override_server_name_; | ||
} | ||
void hashKey(std::vector<uint8_t>& key) const override; | ||
|
||
private: | ||
const absl::optional<std::string> override_server_name_; | ||
}; | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "common/network/upstream_server_name.h" | ||
|
||
#include "common/common/macros.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
const std::string& UpstreamServerName::key() { | ||
CONSTRUCT_ON_FIRST_USE(std::string, "envoy.network.upstream_server_name"); | ||
} | ||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "envoy/stream_info/filter_state.h" | ||
|
||
#include "absl/strings/string_view.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
/** | ||
* Server name to set in the upstream connection. The filters like tcp_proxy should use this | ||
* value to override the server name specified in the upstream cluster, for example to override | ||
* the SNI value in the upstream TLS context. | ||
*/ | ||
class UpstreamServerName : public StreamInfo::FilterState::Object { | ||
public: | ||
UpstreamServerName(absl::string_view server_name) : server_name_(server_name) {} | ||
const std::string& value() const { return server_name_; } | ||
static const std::string& key(); | ||
|
||
private: | ||
const std::string server_name_; | ||
}; | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.