fix: refactored routing logic (fixes #701)

This commit is contained in:
Simone Margaritelli 2021-04-10 21:55:00 +02:00
parent 88a83192ef
commit 43a93fd866
11 changed files with 202 additions and 80 deletions

View file

@ -11,23 +11,6 @@ import (
"github.com/bettercap/bettercap/core"
)
// only matches gateway lines
var IPv4RouteParser = regexp.MustCompile(`^(default|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\svia\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\sdev\s(\S+).*$`)
var IPv4RouteTokens = 4
var IPv4RouteCmd = "ip"
var IPv4RouteCmdOpts = []string{"route"}
func IPv4RouteIsGateway(ifname string, tokens []string, f func(gateway string) (*Endpoint, error)) (*Endpoint, error) {
ifname2 := tokens[3]
if ifname == ifname2 {
gateway := tokens[2]
return f(gateway)
}
return nil, nil
}
// see Windows version to understand why ....
func getInterfaceName(iface net.Interface) string {
return iface.Name