fix IPv6 connection problem

use net.JoinHostPort to fix ipv6 address at createSystemConnection
This commit is contained in:
D
2024-11-17 16:34:05 +08:00
committed by GitHub
parent 4e64d9efad
commit bcefb8e43c

View File

@@ -14,6 +14,7 @@ import (
"encoding/pem"
"fmt"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
@@ -371,7 +372,7 @@ 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)
client, err := ssh.Dial("tcp", net.JoinHostPort(record.GetString("host"), record.GetString("port")), h.sshClientConfig)
if err != nil {
return nil, err
}