提交 f92015df 编写于 作者: S Sharif Elgamal

allow for prefix interace names for hyperv

上级 46a43774
......@@ -22,6 +22,7 @@ import (
"os/exec"
"reflect"
"regexp"
"strings"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
......@@ -134,7 +135,23 @@ func DriverIP(api libmachine.API, machineName string) (net.IP, error) {
// Based on code from http://stackoverflow.com/questions/23529663/how-to-get-all-addresses-and-masks-from-local-interfaces-in-go
func getIPForInterface(name string) (net.IP, error) {
i, _ := net.InterfaceByName(name)
ints, err := net.Interfaces()
if err != nil {
return nil, err
}
var i net.Interface
for _, in := range ints {
if strings.HasPrefix(in.Name, name) {
i = in
break
}
}
if i.Name == "" {
return nil, errors.Errorf("Could not find interface %s", name)
}
addrs, _ := i.Addrs()
for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册