This commit is contained in:
crusader 2018-09-12 14:25:14 +09:00
parent 97184ea723
commit 831e7f5015

View File

@ -1,6 +1,7 @@
package nic package nic
import ( import (
"log"
"net" "net"
omm "git.loafle.net/overflow/model/meta" omm "git.loafle.net/overflow/model/meta"
@ -50,9 +51,19 @@ func DiscoverInterfaces() ([]*omn.Interface, error) {
continue continue
} }
var ip net.IP
switch v := netAddr.(type) {
case *net.IPNet:
ip = v.IP
case *net.IPAddr:
ip = v.IP
default:
log.Print("Addr is not *net.IPNet or *net.IPAddr", netAddr)
}
addr := &omn.InterfaceAddress{} addr := &omn.InterfaceAddress{}
iface.Addresses = append(iface.Addresses, addr) iface.Addresses = append(iface.Addresses, addr)
addr.Address = netAddr.String() addr.Address = ip.String()
addr.Netmask = ipNet.Mask.String() addr.Netmask = ipNet.Mask.String()
addr.Network = ipNet.Network().String() addr.Network = ipNet.Network().String()