未验证 提交 522c746d 编写于 作者: M Medya Ghazizadeh 提交者: GitHub

Merge pull request #8106 from sharifelgamal/vbox

fix virtualbox IP address retrieval
...@@ -65,11 +65,13 @@ func HostIP(host *host.Host) (net.IP, error) { ...@@ -65,11 +65,13 @@ func HostIP(host *host.Host) (net.IP, error) {
} }
re := regexp.MustCompile(`hostonlyadapter2="(.*?)"`) re := regexp.MustCompile(`hostonlyadapter2="(.*?)"`)
iface := re.FindStringSubmatch(string(out))[1] iface := re.FindStringSubmatch(string(out))[1]
ip, err := getIPForInterface(iface) ipList, err := exec.Command(driver.VBoxManagePath(), "list", "hostonlyifs").Output()
if err != nil { if err != nil {
return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address") return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address")
} }
return ip, nil re = regexp.MustCompile(`(?s)Name:\s*` + iface + `.+IPAddress:\s*(\S+)`)
ip := re.FindStringSubmatch(string(ipList))[1]
return net.ParseIP(ip), nil
case driver.HyperKit: case driver.HyperKit:
return net.ParseIP("192.168.64.1"), nil return net.ParseIP("192.168.64.1"), nil
case driver.VMware: case driver.VMware:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册