mirror of
https://github.com/itzg/mc-router.git
synced 2024-11-21 11:25:41 +01:00
Support TCP Shield host enrinchment (#195)
This commit is contained in:
parent
059ee78c5c
commit
c548fda65e
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user