probe/pcap/pcap_test.go

28 lines
447 B
Go
Raw Normal View History

2018-08-12 10:24:23 +00:00
package pcap
import (
2018-08-12 11:08:31 +00:00
"log"
2018-08-12 10:24:23 +00:00
"testing"
2018-08-12 11:08:31 +00:00
"github.com/google/gopacket/pcap"
2018-08-12 10:24:23 +00:00
)
2018-08-12 11:08:31 +00:00
func TestFindIfaces(t *testing.T) {
devices, err := pcap.FindAllDevs()
if err != nil {
log.Fatal(err)
}
t.Log("Devices found:")
for _, d := range devices {
t.Log("\nName: ", d.Name)
t.Log("Description: ", d.Description)
for _, address := range d.Addresses {
t.Log("- IP address: ", address.IP)
t.Log("- Subnet mask: ", address.Netmask)
}
}
2018-08-12 10:24:23 +00:00
}