test: ensure ipv6 compatability (#5110)
This commit is contained in:
1 parent
eb33649ded
commit
29efd5e6c6
5 files changed
+314
-10
No files matched your search
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -57,6 +58,12 @@ const (
|
||||
WorkerAuthReqFile = "auth_request_token"
|
||||
)
|
||||
|
||||
var (
|
||||
// This regular expression is used to find all instances of square brackets within a string.
|
||||
// This regular expression is used to remove the square brackets from an IPv6 address.
|
||||
squareBrackets = regexp.MustCompile("\\[|\\]")
|
||||
)
|
||||
|
||||
func init() {
|
||||
metric.InitializeBuildInfo(prometheus.DefaultRegisterer)
|
||||
}
|
||||
@@ -845,7 +852,12 @@ func (b *Server) SetupWorkerPublicAddress(conf *config.Config, flagValue string)
|
||||
return fmt.Errorf("Error splitting public adddress host/port: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// remove the square brackets from the ipv6 address because the method
|
||||
// net.JoinHostPort() will add a second pair of square brackets.
|
||||
host = squareBrackets.ReplaceAllString(host, "")
|
||||
conf.Worker.PublicAddr = net.JoinHostPort(host, port)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user