From 788c8d59943c63e38a2e1013e93d2979a378e7fd Mon Sep 17 00:00:00 2001 From: evilsocket Date: Sat, 13 Oct 2018 02:18:14 +0200 Subject: [PATCH] fix: trimming route line (fixes #357) --- network/net_gateway.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/network/net_gateway.go b/network/net_gateway.go index c3daa991..4b2cb268 100644 --- a/network/net_gateway.go +++ b/network/net_gateway.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/bettercap/bettercap/core" + + "github.com/evilsocket/islazy/str" ) func FindGateway(iface *Endpoint) (*Endpoint, error) { @@ -21,7 +23,7 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) { ifName := iface.Name() for _, line := range strings.Split(output, "\n") { - if strings.Contains(line, ifName) { + if line = str.Trim(line); strings.Contains(line, ifName) { m := IPv4RouteParser.FindStringSubmatch(line) if len(m) == IPv4RouteTokens { Debug("FindGateway(%s) line '%s' matched with %v", iface.Name(), line, m)