Support TCP Shield host enrinchment (#195)

This commit is contained in:
Lilly Tempest 2023-05-25 04:28:38 +02:00 committed by GitHub
parent 059ee78c5c
commit c548fda65e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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