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:
greatroar 2020-02-19 15:33:52 +01:00
parent f2bf06a419
commit 6ac6bca7a1
5 changed files with 60 additions and 22 deletions

View file

@ -23,11 +23,11 @@ var configTests = []struct {
},
{
"sftp://host:10022//dir/subdir",
Config{Host: "host:10022", Path: "/dir/subdir"},
Config{Host: "host", Port: "10022", Path: "/dir/subdir"},
},
{
"sftp://user@host:10022//dir/subdir",
Config{User: "user", Host: "host:10022", Path: "/dir/subdir"},
Config{User: "user", Host: "host", Port: "10022", Path: "/dir/subdir"},
},
{
"sftp://user@host/dir/subdir/../other",
@ -38,6 +38,17 @@ var configTests = []struct {
Config{User: "user", Host: "host", Path: "dir/subdir"},
},
// IPv6 address.
{
"sftp://user@[::1]/dir",
Config{User: "user", Host: "::1", Path: "dir"},
},
// IPv6 address with port.
{
"sftp://user@[::1]:22/dir",
Config{User: "user", Host: "::1", Port: "22", Path: "dir"},
},
// second form, user specified sftp:user@host:/dir
{
"sftp:user@host:/dir/subdir",