probe/nic/nic_test.go
2018-09-13 12:11:37 +09:00

43 lines
856 B
Go

package nic
import (
"log"
"testing"
omm "git.loafle.net/overflow/model/meta"
)
func TestDiscoverGateway(t *testing.T) {
gwIP, gwIface, err := DiscoverGateway()
if err != nil {
log.Fatal(err)
}
t.Log("Gateway found")
t.Log("Iface: ", gwIface)
t.Log("IP: ", gwIP.String())
}
func TestDiscoverInterfaces(t *testing.T) {
ifaces, err := DiscoverInterfaces()
if err != nil {
log.Fatal(err)
}
t.Log("Interface found:")
for _, iface := range ifaces {
t.Log("Iface: ", iface.Iface)
t.Log("FriendlyName: ", iface.FriendlyName)
t.Log("Mac: ", iface.Mac)
for _, addr := range iface.Addresses {
t.Log("- IP version: ", omm.ToMetaIPTypeEnum(addr.MetaIPType).String())
t.Log("- IP address: ", addr.Address)
t.Log("- Netmask: ", addr.Netmask)
t.Log("- Network: ", addr.Network)
t.Log("- Gateway: ", addr.Gateway)
}
}
}