Skip to content

Commit a22f88a

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 b4f1b7f commit a22f88a

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
@@ -579,9 +579,22 @@ func validateParamIsUsed(y *limatype.LimaYAML) error {
579579
return nil
580580
}
581581

582+
func lookupIP(host string) error {
583+
if strings.HasSuffix(host, ".local") {
584+
// allow offline or slow mDNS
585+
return nil
586+
}
587+
ctx := context.Background()
588+
_, err := net.DefaultResolver.LookupIP(ctx, "ip", host)
589+
return err
590+
}
591+
582592
func validateHost(field, host string) error {
583-
if net.ParseIP(host) == nil {
584-
return fmt.Errorf("field `%s` must be IP", field)
593+
if net.ParseIP(host) != nil {
594+
return nil
595+
}
596+
if err := lookupIP(host); err != nil {
597+
return fmt.Errorf("field `%s` must be IP: %w", field, err)
585598
}
586599
return nil
587600
}

0 commit comments

Comments
 (0)