Skip to content

Commit

Permalink
fix: ipv6 rfc2732
Browse files Browse the repository at this point in the history
To use a literal IPv6 address in a URL, the literal address must be enclosed in "[" and "]" characters.

```
ssh example@[2010:836B:4179::836B:4179]
```

Refer to https://www.ietf.org/rfc/rfc2732.

Ref: #333

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
  • Loading branch information
tenthirtyam committed Apr 12, 2024
1 parent 2eb1527 commit 4ff64e4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions builder/vsphere/common/step_wait_for_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"log"
"net"
"strings"
"time"

"github.com/hashicorp/packer-plugin-sdk/multistep"
Expand Down Expand Up @@ -169,6 +170,12 @@ loop:
} else {
log.Printf("VM IP is still the same: %s", prevIp)
if time.Now().After(stopTime) {
if strings.Contains(ip, ":") {
// To use a literal IPv6 address in a URL the literal address should be enclosed in
// "[" and "]" characters. Refer to https://www.ietf.org/rfc/rfc2732.
// Example: ssh example@[2010:836B:4179::836B:4179]
ip = "["+ip+"]"
}
log.Printf("VM IP seems stable enough: %s", ip)
return ip, nil
}
Expand Down

0 comments on commit 4ff64e4

Please # to comment.