Support TCP Shield host enrinchment (#195)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var tcpShieldPattern = regexp.MustCompile("///.*")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
apiRoutes.Path("/routes").Methods("GET").
|
apiRoutes.Path("/routes").Methods("GET").
|
||||||
Headers("Accept", "application/json").
|
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
|
// trim the root zone indicator, see https://en.wikipedia.org/wiki/Fully_qualified_domain_name
|
||||||
strings.TrimSuffix(addressParts[0], "."))
|
strings.TrimSuffix(addressParts[0], "."))
|
||||||
|
|
||||||
|
// Strip suffix of TCP Shield
|
||||||
|
address = tcpShieldPattern.ReplaceAllString(address, "")
|
||||||
|
|
||||||
if r.mappings != nil {
|
if r.mappings != nil {
|
||||||
if mapping, exists := r.mappings[address]; exists {
|
if mapping, exists := r.mappings[address]; exists {
|
||||||
return mapping.backend, address, mapping.waker
|
return mapping.backend, address, mapping.waker
|
||||||
|
|||||||
Reference in New Issue
Block a user