Skip to content

Commit

Permalink
surround IPv6 addresses with square brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenkov committed Mar 29, 2024
1 parent 6ce60c4 commit f625c1f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions shin/shin.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ func resolvePath(path string, username string) string {

idx := strings.Index(path, ":")
host, _ := resolve(path[:idx])

//
// Surround IPv6 IPs in square brackets in order for SCP to treat
// them correctly.
//
if strings.Count(host, ":") > 2 {
host = fmt.Sprintf("[%s]", host)
}

return fmt.Sprintf("%s@%s:%s", username, host, path[idx+1:])
}

Expand Down

0 comments on commit f625c1f

Please sign in to comment.