Skip to content

Commit bb71b82

Browse files
committed
Allow using address like raspberrypi.local
Add a shorter timeout for mDNS IP lookup Allow .local hosts to be offline or slow Signed-off-by: Anders F Björklund <[email protected]>
1 parent b9dd08c commit bb71b82

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pkg/limayaml/validate.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,22 @@ func validateParamIsUsed(y *limatype.LimaYAML) error {
551551
return nil
552552
}
553553

554+
func lookupIP(host string) error {
555+
if strings.HasSuffix(host, ".local") {
556+
// allow offline or slow mDNS
557+
return nil
558+
}
559+
ctx := context.Background()
560+
_, err := net.DefaultResolver.LookupIP(ctx, "ip", host)
561+
return err
562+
}
563+
554564
func validateHost(field, host string) error {
555-
if net.ParseIP(host) == nil {
556-
return fmt.Errorf("field `%s` must be IP", field)
565+
if net.ParseIP(host) != nil {
566+
return nil
567+
}
568+
if err := lookupIP(host); err != nil {
569+
return fmt.Errorf("field `%s` must be IP: %w", field, err)
557570
}
558571
return nil
559572
}

0 commit comments

Comments
 (0)