From c548fda65efdbfeb0ed214527cf8b469edb07442 Mon Sep 17 00:00:00 2001 From: Lilly Tempest <46890129+rainbowdashlabs@users.noreply.github.com> Date: Thu, 25 May 2023 04:28:38 +0200 Subject: [PATCH] Support TCP Shield host enrinchment (#195) --- server/routes.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/routes.go b/server/routes.go index ded52f3..e634de4 100644 --- a/server/routes.go +++ b/server/routes.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "net/http" + "regexp" "strings" "sync" @@ -11,6 +12,8 @@ import ( "github.com/sirupsen/logrus" ) +var tcpShieldPattern = regexp.MustCompile("///.*") + func init() { apiRoutes.Path("/routes").Methods("GET"). Headers("Accept", "application/json"). @@ -177,6 +180,9 @@ func (r *routesImpl) FindBackendForServerAddress(ctx context.Context, serverAddr // trim the root zone indicator, see https://en.wikipedia.org/wiki/Fully_qualified_domain_name strings.TrimSuffix(addressParts[0], ".")) + // Strip suffix of TCP Shield + address = tcpShieldPattern.ReplaceAllString(address, "") + if r.mappings != nil { if mapping, exists := r.mappings[address]; exists { return mapping.backend, address, mapping.waker