mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
fix: trimming route line (fixes #357)
This commit is contained in:
parent
236a9940d9
commit
788c8d5994
1 changed files with 3 additions and 1 deletions
|
@ -6,6 +6,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/bettercap/bettercap/core"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
||||||
|
@ -21,7 +23,7 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
||||||
|
|
||||||
ifName := iface.Name()
|
ifName := iface.Name()
|
||||||
for _, line := range strings.Split(output, "\n") {
|
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)
|
m := IPv4RouteParser.FindStringSubmatch(line)
|
||||||
if len(m) == IPv4RouteTokens {
|
if len(m) == IPv4RouteTokens {
|
||||||
Debug("FindGateway(%s) line '%s' matched with %v", iface.Name(), line, m)
|
Debug("FindGateway(%s) line '%s' matched with %v", iface.Name(), line, m)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue