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"
@@ -9,6 +10,7 @@ import (
9
10
"path/filepath"
10
11
"runtime"
11
12
"strings"
13
+ "time"
12
14
13
15
"github.com/docker/go-units"
14
16
"github.com/lima-vm/lima/pkg/localpathutil"
@@ -451,12 +453,26 @@ func validateNetwork(y LimaYAML, warn bool) error {
451
453
return nil
452
454
}
453
455
456
+ func lookupIP (host string ) error {
457
+ var err error
458
+ if strings .HasSuffix (host , ".local" ) {
459
+ var r net.Resolver
460
+ const timeout = 500 * time .Millisecond // timeout for .local
461
+ ctx , cancel := context .WithTimeout (context .TODO (), timeout )
462
+ defer cancel ()
463
+ _ , err = r .LookupIP (ctx , "ip" , host )
464
+ } else {
465
+ _ , err = net .LookupIP (host )
466
+ }
467
+ return err
468
+ }
469
+
454
470
func validateHost (field , host string ) error {
455
471
if net .ParseIP (host ) != nil {
456
472
return nil
457
473
}
458
- if _ , err := net . LookupIP (host ); err != nil {
459
- return fmt .Errorf ("field `%s` must be IP" , field )
474
+ if err := lookupIP (host ); err != nil {
475
+ return fmt .Errorf ("field `%s` must be IP: %w " , field , err )
460
476
}
461
477
return nil
462
478
}
You can’t perform that action at this time.
0 commit comments