File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import (
1818)
1919
2020const (
21- DefaultProtocol = iota
21+ Default = iota
2222 PreferIPv4
2323 PreferIPv6
2424)
@@ -58,7 +58,7 @@ func NewDriver(hostName, storePath string) *Driver {
5858 MemSize : defaultMemory ,
5959 CPU : defaultCPU ,
6060 DisableDynamicMemory : defaultDisableDynamicMemory ,
61- PreferredNetworkProtocol : DefaultProtocol ,
61+ PreferredNetworkProtocol : Default ,
6262 WaitTimeoutInSeconds : defaultWaitTimeoutInSeconds ,
6363 }
6464}
@@ -464,7 +464,7 @@ func (d *Driver) Kill() error {
464464}
465465
466466func isIPv4 (address string ) bool {
467- return strings .Count (address , ":" ) < 2
467+ return strings .Count (address , ":" ) < 1
468468}
469469
470470func (d * Driver ) GetIP () (string , error ) {
@@ -504,12 +504,23 @@ func (d *Driver) GetIP() (string, error) {
504504 }
505505
506506 default :
507+ var preferredIP string
507508 for _ , ipStr := range resp {
508509 ip := net .ParseIP (ipStr )
509510 if ip .IsGlobalUnicast () {
510- return ipStr , nil
511+ if preferredIP == "" {
512+ preferredIP = ipStr
513+ }
514+ if isIPv4 (ipStr ) && ip .To4 () != nil {
515+ preferredIP = ipStr
516+ break
517+ }
511518 }
512519 }
520+
521+ if preferredIP != "" {
522+ return preferredIP , nil
523+ }
513524 }
514525
515526 return "" , nil
You can’t perform that action at this time.
0 commit comments