mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fixed net.FindGateway if there's a VPN interface active
This commit is contained in:
parent
407fd392b9
commit
5041267be9
3 changed files with 18 additions and 56 deletions
|
@ -87,38 +87,6 @@ func TestFindInterfaceByName(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestMatchByAddress(t *testing.T) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(ifaces) <= 0 {
|
||||
t.Error("Unable to find any network interfaces to run test with.")
|
||||
}
|
||||
var exampleIface net.Interface
|
||||
// emulate libpcap's pcap_lookupdev function to find
|
||||
// default interface to test with ( maybe could use loopback ? )
|
||||
for _, iface := range ifaces {
|
||||
if iface.HardwareAddr != nil {
|
||||
exampleIface = iface
|
||||
break
|
||||
}
|
||||
}
|
||||
// check match by mac address
|
||||
if !matchByAddress(exampleIface, exampleIface.HardwareAddr.String()) {
|
||||
t.Error("unable to verify a match with a given interface and mac address")
|
||||
}
|
||||
addrs, err := exampleIface.Addrs()
|
||||
if err != nil || len(addrs) <= 0 {
|
||||
t.Error("Unable to find any ip addresses to run test with interface:", exampleIface.Name)
|
||||
|
||||
}
|
||||
// check match by ip address
|
||||
if !matchByAddress(exampleIface, addrs[0].String()) {
|
||||
t.Error("unable to verify a match with a given interface and ip address")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindInterface(t *testing.T) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue