Support IPv6 in SFTP backend
The previous code was doing its own hostname:port splitting, which caused IPv6 addresses to be misinterpreted.
This commit is contained in:
parent
f2bf06a419
commit
6ac6bca7a1
5 changed files with 60 additions and 22 deletions
|
@ -8,7 +8,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/errors"
|
||||
|
@ -190,10 +189,11 @@ func buildSSHCommand(cfg Config) (cmd string, args []string, err error) {
|
|||
|
||||
cmd = "ssh"
|
||||
|
||||
hostport := strings.Split(cfg.Host, ":")
|
||||
args = []string{hostport[0]}
|
||||
if len(hostport) > 1 {
|
||||
args = append(args, "-p", hostport[1])
|
||||
host, port := cfg.Host, cfg.Port
|
||||
|
||||
args = []string{host}
|
||||
if port != "" {
|
||||
args = append(args, "-p", port)
|
||||
}
|
||||
if cfg.User != "" {
|
||||
args = append(args, "-l")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue