Trim root zone indicator from server address (#97)
This commit is contained in:
+4
-1
@@ -177,7 +177,10 @@ func (c *connectorImpl) findAndConnectBackend(ctx context.Context, frontendConn
|
||||
}
|
||||
|
||||
if backendHostPort == "" {
|
||||
logrus.WithField("serverAddress", serverAddress).Warn("Unable to find registered backend")
|
||||
logrus.
|
||||
WithField("serverAddress", serverAddress).
|
||||
WithField("resolvedHost", resolvedHost).
|
||||
Warn("Unable to find registered backend")
|
||||
c.metrics.Errors.With("type", "missing_backend").Add(1)
|
||||
return
|
||||
}
|
||||
|
||||
+3
-1
@@ -170,7 +170,9 @@ func (r *routesImpl) FindBackendForServerAddress(ctx context.Context, serverAddr
|
||||
|
||||
addressParts := strings.Split(serverAddress, "\x00")
|
||||
|
||||
address := strings.ToLower(addressParts[0])
|
||||
address := strings.ToLower(
|
||||
// trim the root zone indicator, see https://en.wikipedia.org/wiki/Fully_qualified_domain_name
|
||||
strings.TrimSuffix(addressParts[0], "."))
|
||||
|
||||
if r.mappings != nil {
|
||||
if mapping, exists := r.mappings[address]; exists {
|
||||
|
||||
@@ -41,6 +41,26 @@ func Test_routesImpl_FindBackendForServerAddress(t *testing.T) {
|
||||
},
|
||||
want: "backend:25566",
|
||||
},
|
||||
{
|
||||
name: "root zone indicator",
|
||||
mapping: mapping{
|
||||
serverAddress: "my.domain", backend: "backend:25566",
|
||||
},
|
||||
args: args{
|
||||
serverAddress: "my.domain.",
|
||||
},
|
||||
want: "backend:25566",
|
||||
},
|
||||
{
|
||||
name: "root zone indicator and forge",
|
||||
mapping: mapping{
|
||||
serverAddress: "forge.my.domain", backend: "backend:25566",
|
||||
},
|
||||
args: args{
|
||||
serverAddress: "forge.my.domain.\x00FML2\x00",
|
||||
},
|
||||
want: "backend:25566",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user