File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 4
4
package limayaml
5
5
6
6
import (
7
+ "context"
7
8
"errors"
8
9
"fmt"
9
10
"net"
@@ -16,6 +17,7 @@ import (
16
17
"strconv"
17
18
"strings"
18
19
"unicode"
20
+ "time"
19
21
20
22
"github.com/containerd/containerd/identifiers"
21
23
"github.com/coreos/go-semver/semver"
@@ -569,12 +571,26 @@ func ValidateParamIsUsed(y *LimaYAML) error {
569
571
return nil
570
572
}
571
573
574
+ func lookupIP (host string ) error {
575
+ var err error
576
+ if strings .HasSuffix (host , ".local" ) {
577
+ var r net.Resolver
578
+ const timeout = 500 * time .Millisecond // timeout for .local
579
+ ctx , cancel := context .WithTimeout (context .TODO (), timeout )
580
+ defer cancel ()
581
+ _ , err = r .LookupIP (ctx , "ip" , host )
582
+ } else {
583
+ _ , err = net .LookupIP (host )
584
+ }
585
+ return err
586
+ }
587
+
572
588
func validateHost (field , host string ) error {
573
589
if net .ParseIP (host ) != nil {
574
590
return nil
575
591
}
576
- if _ , err := net . LookupIP (host ); err != nil {
577
- return fmt .Errorf ("field `%s` must be IP" , field )
592
+ if err := lookupIP (host ); err != nil {
593
+ return fmt .Errorf ("field `%s` must be IP: %w " , field , err )
578
594
}
579
595
return nil
580
596
}
You can’t perform that action at this time.
0 commit comments