mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
start adding tests for lan related functions in network package
includes required imports and two helper functions to build reusable fresh-starts to be used in functions
This commit is contained in:
parent
d129bb65cc
commit
9c4a43062c
1 changed files with 27 additions and 0 deletions
27
network/lan_test.go
Normal file
27
network/lan_test.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package network
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func buildExampleLAN() *LAN {
|
||||||
|
iface, _ := FindInterface("")
|
||||||
|
gateway, _ := FindGateway(iface)
|
||||||
|
exNewCallback := func(e *Endpoint) {}
|
||||||
|
exLostCallback := func(e *Endpoint) {}
|
||||||
|
return NewLAN(iface, gateway, exNewCallback, exLostCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildExampleEndpoint() *Endpoint {
|
||||||
|
ifaces, _ := net.Interfaces()
|
||||||
|
var exampleIface net.Interface
|
||||||
|
for _, iface := range ifaces {
|
||||||
|
if iface.HardwareAddr != nil {
|
||||||
|
exampleIface = iface
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foundEndpoint, _ := FindInterface(exampleIface.Name)
|
||||||
|
return foundEndpoint
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue