File tree 1 file changed +18
-2
lines changed 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
package limayaml
2
2
3
3
import (
4
+ "context"
4
5
"errors"
5
6
"fmt"
6
7
"net"
@@ -10,6 +11,7 @@ import (
10
11
"regexp"
11
12
"runtime"
12
13
"strings"
14
+ "time"
13
15
14
16
"github.com/docker/go-units"
15
17
"github.com/lima-vm/lima/pkg/localpathutil"
@@ -436,12 +438,26 @@ func ValidateParamIsUsed(y *LimaYAML) error {
436
438
return nil
437
439
}
438
440
441
+ func lookupIP (host string ) error {
442
+ var err error
443
+ if strings .HasSuffix (host , ".local" ) {
444
+ var r net.Resolver
445
+ const timeout = 500 * time .Millisecond // timeout for .local
446
+ ctx , cancel := context .WithTimeout (context .TODO (), timeout )
447
+ defer cancel ()
448
+ _ , err = r .LookupIP (ctx , "ip" , host )
449
+ } else {
450
+ _ , err = net .LookupIP (host )
451
+ }
452
+ return err
453
+ }
454
+
439
455
func validateHost (field , host string ) error {
440
456
if net .ParseIP (host ) != nil {
441
457
return nil
442
458
}
443
- if _ , err := net . LookupIP (host ); err != nil {
444
- return fmt .Errorf ("field `%s` must be IP" , field )
459
+ if err := lookupIP (host ); err != nil {
460
+ return fmt .Errorf ("field `%s` must be IP: %w " , field , err )
445
461
}
446
462
return nil
447
463
}
You can’t perform that action at this time.
0 commit comments