2018-08-23 04:21:46 +00:00
|
|
|
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)
|
2018-09-13 03:11:37 +00:00
|
|
|
t.Log("FriendlyName: ", iface.FriendlyName)
|
2018-08-23 04:21:46 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|