42 lines
810 B
Go
42 lines
810 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("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)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|