fix: adding safe validation for ipv6 host (#51522)

Signed-off-by: Luiz Rosa <luiz.rosa@suse.com>
This commit is contained in:
Luiz Rosa, ローザ
2025-08-19 13:52:58 -03:00
committed by GitHub
parent 94399de3d6
commit f566820974

View File

@@ -31,6 +31,7 @@ import (
"github.com/rancher/rancher/pkg/controllers/managementuser/cavalidator"
"github.com/rancher/rancher/pkg/features"
"github.com/rancher/rancher/pkg/logserver"
"github.com/rancher/rancher/pkg/utils"
"github.com/rancher/remotedialer"
"github.com/rancher/wrangler/v3/pkg/signals"
"github.com/sirupsen/logrus"
@@ -280,7 +281,11 @@ func run(ctx context.Context) error {
}()
for {
wsURL := fmt.Sprintf("wss://%s/v3/connect", serverURL.Host)
safeHost := serverURL.Host
if utils.IsPlainIPV6(safeHost) {
safeHost = fmt.Sprintf("[%s]", safeHost)
}
wsURL := fmt.Sprintf("wss://%s/v3/connect", safeHost)
if !isConnect() {
wsURL += "/register"
}