提交 378e88b4 编写于 作者: A Aaron Prindle

Changed docker-machine and sshutil to support hostnames with colons in them,...

Changed docker-machine and sshutil to support hostnames with colons in them, for example ipv6 addresses
上级 5cf2a811
......@@ -19,7 +19,9 @@ package sshutil
import (
"fmt"
"io"
"net"
"path/filepath"
"strconv"
"sync"
"github.com/docker/machine/libmachine/drivers"
......@@ -52,7 +54,7 @@ func NewSSHClient(d drivers.Driver) (*ssh.Client, error) {
return nil, errors.Wrapf(err, "Error creating new native config from ssh using: %s, %s", h.Username, auth)
}
client, err := ssh.Dial("tcp", fmt.Sprintf("%s:%d", h.IP, h.Port), &config)
client, err := ssh.Dial("tcp", net.JoinHostPort(h.IP, strconv.Itoa(h.Port)), &config)
if err != nil {
return nil, errors.Wrap(err, "Error dialing tcp via ssh client")
}
......
......@@ -4,9 +4,11 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"github.com/docker/docker/pkg/term"
......@@ -154,7 +156,7 @@ func NewNativeConfig(user string, auth *Auth) (ssh.ClientConfig, error) {
}
func (client *NativeClient) dialSuccess() bool {
if _, err := ssh.Dial("tcp", fmt.Sprintf("%s:%d", client.Hostname, client.Port), &client.Config); err != nil {
if _, err := ssh.Dial("tcp", net.JoinHostPort(client.Hostname, strconv.Itoa(client.Port)), &client.Config); err != nil {
log.Debugf("Error dialing TCP: %s", err)
return false
}
......@@ -166,7 +168,7 @@ func (client *NativeClient) session(command string) (*ssh.Session, error) {
return nil, fmt.Errorf("Error attempting SSH client dial: %s", err)
}
conn, err := ssh.Dial("tcp", fmt.Sprintf("%s:%d", client.Hostname, client.Port), &client.Config)
conn, err := ssh.Dial("tcp", net.JoinHostPort(client.Hostname, strconv.Itoa(client.Port)), &client.Config)
if err != nil {
return nil, fmt.Errorf("Mysterious error dialing TCP for SSH (we already succeeded at least once) : %s", err)
}
......@@ -250,7 +252,7 @@ func (client *NativeClient) Shell(args ...string) error {
var (
termWidth, termHeight int
)
conn, err := ssh.Dial("tcp", fmt.Sprintf("%s:%d", client.Hostname, client.Port), &client.Config)
conn, err := ssh.Dial("tcp", net.JoinHostPort(client.Hostname, strconv.Itoa(client.Port)), &client.Config)
if err != nil {
return err
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册