mirror of
https://github.com/containers/podman.git
synced 2025-06-04 21:55:24 +08:00
Update vendor of containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
21
vendor/github.com/containers/common/pkg/ssh/utils.go
generated
vendored
21
vendor/github.com/containers/common/pkg/ssh/utils.go
generated
vendored
@ -15,6 +15,8 @@ import (
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
const sshdPort = 22
|
||||
|
||||
func Validate(user *url.Userinfo, path string, port int, identity string) (*config.Destination, *url.URL, error) {
|
||||
// url.Parse NEEDS ssh://, if this ever fails or returns some nonsense, that is why.
|
||||
uri, err := url.Parse(path)
|
||||
@ -28,11 +30,10 @@ func Validate(user *url.Userinfo, path string, port int, identity string) (*conf
|
||||
}
|
||||
|
||||
if uri.Port() == "" {
|
||||
if port != 0 {
|
||||
uri.Host = net.JoinHostPort(uri.Host, strconv.Itoa(port))
|
||||
} else {
|
||||
uri.Host = net.JoinHostPort(uri.Host, "22")
|
||||
if port == 0 {
|
||||
port = sshdPort
|
||||
}
|
||||
uri.Host = net.JoinHostPort(uri.Host, strconv.Itoa(port))
|
||||
}
|
||||
|
||||
if user != nil {
|
||||
@ -165,11 +166,15 @@ func ParseScpArgs(options ConnectionScpOptions) (string, string, string, bool, e
|
||||
}
|
||||
|
||||
func DialNet(sshClient *ssh.Client, mode string, url *url.URL) (net.Conn, error) {
|
||||
port, err := strconv.Atoi(url.Port())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
port := sshdPort
|
||||
if url.Port() != "" {
|
||||
p, err := strconv.Atoi(url.Port())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
port = p
|
||||
}
|
||||
if _, _, err = Validate(url.User, url.Hostname(), port, ""); err != nil {
|
||||
if _, _, err := Validate(url.User, url.Hostname(), port, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sshClient.Dial(mode, url.Path)
|
||||
|
Reference in New Issue
Block a user