29 lines
493 B
Go
29 lines
493 B
Go
package pcap
|
|
|
|
import (
|
|
"log"
|
|
"testing"
|
|
|
|
"github.com/google/gopacket/pcap"
|
|
)
|
|
|
|
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)
|
|
t.Log("Devices addresses: ", d.Description)
|
|
|
|
for _, address := range d.Addresses {
|
|
t.Log("- IP address: ", address.IP)
|
|
t.Log("- Subnet mask: ", address.Netmask)
|
|
}
|
|
}
|
|
|
|
}
|