From bcefb8e43c61e978c67fceb2ff5fff17309151b7 Mon Sep 17 00:00:00 2001 From: D <17147265+wwng2333@users.noreply.github.com> Date: Sun, 17 Nov 2024 16:34:05 +0800 Subject: [PATCH] fix IPv6 connection problem use net.JoinHostPort to fix ipv6 address at createSystemConnection --- beszel/internal/hub/hub.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/beszel/internal/hub/hub.go b/beszel/internal/hub/hub.go index acdce1e..d8559d7 100644 --- a/beszel/internal/hub/hub.go +++ b/beszel/internal/hub/hub.go @@ -14,6 +14,7 @@ import ( "encoding/pem" "fmt" "log" + "net" "net/http" "net/http/httputil" "net/url" @@ -371,11 +372,11 @@ func (h *Hub) deleteSystemConnection(record *models.Record) { } func (h *Hub) createSystemConnection(record *models.Record) (*ssh.Client, error) { - client, err := ssh.Dial("tcp", fmt.Sprintf("%s:%s", record.GetString("host"), record.GetString("port")), h.sshClientConfig) - if err != nil { - return nil, err - } - return client, nil + client, err := ssh.Dial("tcp", net.JoinHostPort(record.GetString("host"), record.GetString("port")), h.sshClientConfig) + if err != nil { + return nil, err + } + return client, nil } func (h *Hub) createSSHClientConfig() error {