Skip to content

Commit

Permalink
restore host port validation (behaves correctly now)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Nov 15, 2024
1 parent 9a4665e commit 6f9c748
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions provisioner/communication.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,18 @@ func (provisioner *Provisioner) determineUserAddr(connectionType string) (string
ipaddress, ok = provisioner.generatedData["Host"].(string)

if !ok || len(ipaddress) == 0 {
log.Print("host address could not be determined")
return "", "", errors.New("unknown host")
log.Print("host address could not be determined from available Packer data")
return "", "", errors.New("unknown host address")
}
}
// valid ip address so now determine port
port, ok := provisioner.generatedData[genDataMap[connectionType]["port"]].(int64)
if !ok || port == int64(0) {
// fallback to general port
port, _ = provisioner.generatedData["Port"].(int64)
port, ok = provisioner.generatedData["Port"].(int64)

//if !ok || port == int64(0) {
if port == int64(0) {
log.Print("host port could not be determined")
if !ok || port == int64(0) {
log.Print("host port could not be determined from available Packer data")
return "", "", errors.New("unknown host port")
}
}
Expand Down

0 comments on commit 6f9c748

Please sign in to comment.