From 5e509e7032ca6cbf4ebd944f299bcbc60e027cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=84=E6=BD=AD?= Date: Wed, 10 Jan 2024 20:16:36 +0800 Subject: [PATCH] fix: strip port from host when match scope rds (#770) --- .../patches/envoy/20240110-fix-srds.patch | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 envoy/1.20/patches/envoy/20240110-fix-srds.patch diff --git a/envoy/1.20/patches/envoy/20240110-fix-srds.patch b/envoy/1.20/patches/envoy/20240110-fix-srds.patch new file mode 100644 index 000000000..df727d701 --- /dev/null +++ b/envoy/1.20/patches/envoy/20240110-fix-srds.patch @@ -0,0 +1,49 @@ +diff -Naur envoy/source/common/router/BUILD envoy-new/source/common/router/BUILD +--- envoy/source/common/router/BUILD 2024-01-10 20:10:14.505600746 +0800 ++++ envoy-new/source/common/router/BUILD 2024-01-10 20:07:25.960379955 +0800 +@@ -212,6 +212,7 @@ + "//envoy/router:rds_interface", + "//envoy/router:scopes_interface", + "//envoy/thread_local:thread_local_interface", ++ "//source/common/http:header_utility_lib", + "@envoy_api//envoy/config/route/v3:pkg_cc_proto", + "@envoy_api//envoy/extensions/filters/network/http_connection_manager/v3:pkg_cc_proto", + ], +diff -Naur envoy/source/common/router/scoped_config_impl.cc envoy-new/source/common/router/scoped_config_impl.cc +--- envoy/source/common/router/scoped_config_impl.cc 2024-01-10 20:10:14.529600924 +0800 ++++ envoy-new/source/common/router/scoped_config_impl.cc 2024-01-10 20:09:50.161422411 +0800 +@@ -3,6 +3,8 @@ + #include "envoy/config/route/v3/scoped_route.pb.h" + #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h" + ++#include "source/common/http/header_utility.h" ++ + namespace Envoy { + namespace Router { + +@@ -74,18 +76,20 @@ + HostValueExtractorImpl::computeFragment(const Http::HeaderMap& headers, + const StreamInfo::StreamInfo&, + ReComputeCbPtr& recompute) const { +- auto fragment = computeFragment(headers); + auto host = static_cast(headers).getHostValue(); ++ auto port_start = Http::HeaderUtility::getPortStart(host); ++ if (port_start != absl::string_view::npos) { ++ host = host.substr(0, port_start); ++ } + *recompute = [this, host, recompute]() mutable -> std::unique_ptr { + return reComputeHelper(std::string(host), recompute, 0); + }; +- return fragment; ++ return std::make_unique(host); + } + + std::unique_ptr +-HostValueExtractorImpl::computeFragment(const Http::HeaderMap& headers) const { +- return std::make_unique( +- static_cast(headers).getHostValue()); ++HostValueExtractorImpl::computeFragment(const Http::HeaderMap&) const { ++ return nullptr; + } + + std::unique_ptr